-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUpload.cs
104 lines (89 loc) · 3.44 KB
/
Upload.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*============================================================================*
* Title : Artsy (Social Application w/ Art Auction)
* Description : "Artsy" is a social application idea that would provide artists
a place to showcase their artworks and offer them the chance
to make a profit from it.
* Filename : Upload.cs
* Version : v1.0
* Author : Gensaya, Carl Jerwin F.
* Yr&Sec&Uni : BSCS 3-3 PUP Main
* Subject : Advance Programming
*============================================================================*/
using System;
using System.IO;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Drawing.Imaging;
using System.Threading;
using System.Windows.Forms;
namespace Artsy {
public class UploadTemp : Form {
public static void Main(String[] args) {
Application.Run(new UploadTemp());
}
public UploadTemp() {
DisplayUpload();
}
/*============================================================================*
* Function : DisplayUpload
* Params : None
* Returns : Void
* Description: Test cs file for image uploading.
*=============================================================================*/
void DisplayUpload() {
Size = new Size(900, 600); StartPosition = FormStartPosition.CenterScreen;
BackColor = Color.White; AutoScroll = true;
Button Btn = new Button() {
Size = new Size(150, 150),
Location = new Point(10, 10),
Text = "!!!"
};
Btn.Click += new EventHandler(TestClick);
this.Controls.Add(Btn);
Button Save = new Button() {
Size = new Size(150, 150),
Location = new Point(10, 200),
Text = "SAVE"
};
Save.Click += new EventHandler(TestClick);
this.Controls.Add(Save);
Pbx = new PictureBox() {
Size = new Size(300, 300),
SizeMode = PictureBoxSizeMode.StretchImage,
Location = new Point(170, 10)
};
this.Controls.Add(Pbx);
}
void TestClick(object source, EventArgs ca) {
var sender = source as Button;
if(sender.Text == "SAVE"){
if(pic != null){
Artwork upload = new Artwork();
string CurrentPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\DB\";
pic.Save(CurrentPath + upload.AddArtwork(30,".png"), ImageFormat.Png);
MessageBox.Show("Image successfully uploaded");
}
} else {
OpenFileDialog _OFDialog = new OpenFileDialog() {
InitialDirectory = @"C:\",
Title = "Locate your artwork",
CheckFileExists = true,
CheckPathExists = true,
Filter = "All Pictures (*.jpg, *.png, *.jpeg, *.bmp)|*.jpg; *.png; *.jpeg; *.bmp",
RestoreDirectory = true,
ReadOnlyChecked = true,
ShowReadOnly = true,
};
if (_OFDialog.ShowDialog() == DialogResult.OK) {
pic = new Bitmap(_OFDialog.FileName);
Pbx.Size = pic.Size;
Pbx.Image = new Bitmap(_OFDialog.FileName);
}
}
}
/*==============================INITIALIZATION==============================*/
PictureBox Pbx;
Bitmap pic;
}
}