-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPost.cs
163 lines (147 loc) · 5.69 KB
/
Post.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace Instagram
{
public partial class Post : Form
{
[DllImport("user32.dll")]
static extern bool HideCaret(IntPtr hWnd);
bool lightModeOn = true;
UIUtilities UI;
DBHandlingUtilities dbHandler;
public string postID, followingID, userID, userName;
public Main main;
public Post(string userID, string userName, bool lightModeOn)
{
InitializeComponent();
this.userID = userID;
this.userName = userName;
this.lightModeOn = lightModeOn;
UI = new UIUtilities(this.lightModeOn);
dbHandler = new DBHandlingUtilities();
Configure_Theme();
}
private void Configure_Theme()
{
Color backColor, textColor, barColor;
if (lightModeOn)
{
backColor = Color.FromArgb(242, 242, 242);
textColor = Color.FromArgb(0, 0, 0);
barColor = Color.FromArgb(209, 209, 209);
}
else
{
backColor = Color.FromArgb(43, 43, 43);
textColor = Color.FromArgb(255, 255, 255);
barColor = Color.FromArgb(31, 31, 31);
}
this.BackColor = backColor;
postDescriptionBox.BackColor = backColor;
userNameLabel.ForeColor = textColor;
postDescriptionBox.ForeColor = textColor;
timeLabel.ForeColor = textColor;
locationLabel.ForeColor = textColor;
likeLabel.ForeColor = textColor;
postDescriptionBox.Cursor = Cursors.Arrow;
menuBtn.Image = Image.FromFile(UI.Return_UI_Location() + "more.png");
likeBtn.Image = Image.FromFile(UI.Return_UI_Location() + "heart.png");
bookMarkedBtn.Image = Image.FromFile(UI.Return_UI_Location() + "bookmark.png");
topBar.BackColor = barColor;
bottomBar.BackColor = barColor;
}
private void likeBtn_MouseHover(object sender, EventArgs e)
{
//likeBtn.Image.Dispose();
//likeBtn.Image = Image.FromFile(Environment.CurrentDirectory + @"\Assets\Selected Mode\heart.png");
}
private void likeBtn_MouseLeave(object sender, EventArgs e)
{
//likeBtn.Image.Dispose();
//likeBtn.Image = Image.FromFile(UI.Return_UI_Location() + "heart.png");
}
private void likeBtn_Click(object sender, EventArgs e)
{
bool result = dbHandler.Add_Like(userID, userName, followingID, userNameLabel.Text, postID);
if(result)
{
Console.WriteLine("Reached here");
likeLabel.Text = (Int32.Parse(likeLabel.Text) + 1).ToString() + " Likes";
likeBtn.Image = Image.FromFile(Environment.CurrentDirectory + @"\Assets\Selected Mode\heart.png");
}
else
{
Console.WriteLine("Reached here");
likeLabel.Text = (Int32.Parse(likeLabel.Text) - 1).ToString() + " Likes";
likeBtn.Image = Image.FromFile(Environment.CurrentDirectory + @"\Assets\Selected Mode\heart.png");
}
}
private void bookMarkedBtn_MouseHover(object sender, EventArgs e)
{
//bookMarkedBtn.Image.Dispose();
//bookMarkedBtn.Image = Image.FromFile(Environment.CurrentDirectory + @"\Assets\Selected Mode\bookmark.png");
}
private void bookMarkedBtn_MouseLeave(object sender, EventArgs e)
{
//bookMarkedBtn.Image.Dispose();
//bookMarkedBtn.Image = Image.FromFile(UI.Return_UI_Location() + "bookmark.png");
}
private void menuBtn_MouseHover(object sender, EventArgs e)
{
if (userID == main?.userID)
{
menuBtn.Image.Dispose();
menuBtn.Image = Image.FromFile(Environment.CurrentDirectory + @"\Assets\Selected Mode\more.png");
}
else
{
this.menuBtn.Dispose();
}
}
private void menuBtn_MouseLeave(object sender, EventArgs e)
{
if(userID == main?.userID)
{
menuBtn.Image.Dispose();
menuBtn.Image = Image.FromFile(UI.Return_UI_Location() + "more.png");
}
else
{
this.menuBtn.Dispose();
}
}
private void menuBtn_Click(object sender, EventArgs e)
{
if(userID == main?.userID)
{
ConfirmationDialog dialog = new ConfirmationDialog(false, "delete this post?");
DialogResult result = dialog.ShowDialog();
if (result == DialogResult.OK)
{
// Remove post from db
// Refresh the main page
dbHandler.Remove_Post(userID, userName, postID);
this.main.form.Dispose();
this.main.form = new Home(main) { TopLevel = false, TopMost = true };
}
}
else
{
this.menuBtn.Dispose();
}
}
private void bookMarkedBtn_Click(object sender, EventArgs e)
{
bool result = dbHandler.Add_BookMark(userID, userName, followingID, userNameLabel.Text, postID);
}
private void userNameLabel_Click(object sender, EventArgs e)
{
}
private void postDescriptionBox_TextChanged(object sender, EventArgs e)
{
HideCaret(postDescriptionBox.Handle);
}
}
}