-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAddPost.cs
94 lines (88 loc) · 3.23 KB
/
AddPost.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
using System;
using System.Drawing;
using System.Windows.Forms;
namespace Instagram
{
public partial class AddPost : Form
{
bool lightModeOn = true;
UIUtilities UI;
DBHandlingUtilities dbHandler;
string userName, userID;
public AddPost(string userID, string userName, bool lightModeOn)
{
InitializeComponent();
this.userName = userName;
this.userID = userID;
UI = new UIUtilities(lightModeOn);
dbHandler = new DBHandlingUtilities();
this.lightModeOn = lightModeOn;
Configure_Page();
Configure_Theme();
}
private void Configure_Theme()
{
Color backColor, textColor;
if (lightModeOn)
{
backColor = Color.FromArgb(209, 209, 209);
textColor = Color.FromArgb(0, 0, 0);
}
else
{
backColor = Color.FromArgb(31, 31, 31);
textColor = Color.FromArgb(255, 255, 255);
}
this.BackColor = backColor;
postDescritpionLabel.BackColor = backColor;
locationLabel.BackColor = backColor;
locationBox.BackColor = backColor;
userNameLabel.BackColor = backColor;
postDescritpionBox.BackColor = backColor;
userNameLabel.ForeColor = textColor;
postDescritpionLabel.ForeColor = textColor;
locationLabel.ForeColor = textColor;
postDescritpionBox.ForeColor = textColor;
locationBox.ForeColor = textColor;
postPictureBox.BackColor = backColor;
nextBtn.Image = Image.FromFile(UI.Return_UI_Location() + "next.png");
}
private void Configure_Page()
{
userNameLabel.Text = userName;
profilePictureBox.Bitmap = (Bitmap)dbHandler.Retrieve_Profile_Picture_Using_SQL(Int32.Parse(userID));
}
private void pictureBox1_MouseHover(object sender, EventArgs e)
{
nextBtn.Image.Dispose();
nextBtn.Image = Image.FromFile(Environment.CurrentDirectory + @"\Assets\Selected Mode\next.png");
}
private void nextBtn_Click(object sender, EventArgs e)
{
if (postPictureBox.Image != null)
{
dbHandler.Add_Post(userID, userName, postDescritpionBox.Text, locationBox.Text);
this.Dispose();
}
else
MessageBox.Show("Image not Uploaded!", "Post Upload Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
private void uploadPictureBtn_Click(object sender, EventArgs e)
{
try
{
dbHandler.Get_Picture();
postPictureBox.Image = Image.FromFile(dbHandler.fileDirectory);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "Post Upload Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void nextBtn_MouseLeave(object sender, EventArgs e)
{
nextBtn.Image.Dispose();
nextBtn.Image = Image.FromFile(UI.Return_UI_Location() + "next.png");
}
}
}