-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.cs
259 lines (237 loc) · 9.04 KB
/
Main.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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
using System;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
using System.Runtime.InteropServices;
namespace Instagram
{
public partial class Main : Form
{
UIUtilities UI;
Panel addStoryPostButtonPanel = null;
public bool lightModeOn = false;
public Form form;
int time = 0;
public string userName = "Eqan", userID = "3";
public Main()
{
InitializeComponent();
using (var stream = File.OpenRead(Environment.CurrentDirectory + @"\Assets\Logo.ico"))
{
this.Icon = new Icon(stream);
}
formVirtualizer.Visible = false;
formVirtualizer.SendToBack();
axMoviePlayer1.BringToFront();
}
public void Configure_Theme()
{
if (lightModeOn)
this.BackColor = Color.FromArgb(242, 242, 242);
else
this.BackColor = Color.FromArgb(43, 43, 43);
UI.Dispose_UI_Components();
UI = new UIUtilities(this, lightModeOn);
Initialize_GUI_Components();
Initialize_Top_Left_Buttons();
}
private void Initialize_GUI_Components()
{
// Form virtualizer
Initialize_Form_Virtualizer_Settings();
// Side Panel
this.Controls.Add(UI.Get_Panel());
}
private void Initialize_Top_Left_Buttons()
{
// Top Left Buttons
this.Controls.Add(UI.Get_CloseBtn());
this.Controls.Add(UI.Get_MaximizeBtn());
this.Controls.Add(UI.Get_MinimizeBtn());
}
public void Initialize_Form_Virtualizer_Settings()
{
Color backColor;
if (lightModeOn)
backColor = Color.FromArgb(242, 242, 242);
else
backColor = Color.FromArgb(43, 43, 43);
formVirtualizer.Width = this.Width - UI.sidePanel.Width;
formVirtualizer.Height = this.Height;
formVirtualizer.Location = new System.Drawing.Point(UI.sidePanel.Width, 20);
formVirtualizer.BackColor = backColor;
}
public void Initialize_Form_Virtualizer_For_SignUP()
{
Initialize_Top_Left_Buttons();
Color backColor;
if (lightModeOn)
backColor = Color.FromArgb(209, 209, 209);
else
backColor = Color.FromArgb(31, 31, 31);
this.CenterToScreen();
formVirtualizer.Width = this.Width;
formVirtualizer.Height = this.Height - 30;
formVirtualizer.Location = new System.Drawing.Point(0, 30);
formVirtualizer.BackColor = backColor;
this.BackColor = backColor;
}
private void Intro_Load(object sender, EventArgs e)
{
Create_Rounded_Corners();
Start_Intro();
}
void Start_Intro()
{
string vidLocation;
if (!lightModeOn)
{
vidLocation = Environment.CurrentDirectory + @"\Assets\Dark Mode\Intro.mp4";
this.BackColor = Color.Black;
}
else
{
vidLocation = Environment.CurrentDirectory + @"\Assets\Light Mode\Intro.mp4";
this.BackColor = Color.White;
}
axMoviePlayer1.FileName = vidLocation;
axMoviePlayer1.Play();
timer1.Interval = 900;
timer1.Start();
}
// ? Count The Duration Of The Intro And Proceeds TO The Next Form After The Designated Time
private void timer1_Tick(object sender, EventArgs e)
{
if (time == (int)axMoviePlayer1.Duration)
{
axMoviePlayer1.Stop();
Initiate_Login();
}
time++;
}
public void Initiate_Main_Form_Window(string userID, string userName)
{
this.userID = userID;
this.userName = userName;
if (lightModeOn)
this.BackColor = Color.FromArgb(242, 242, 242);
else
this.BackColor = Color.FromArgb(43, 43, 43);
form = new Home(this) { TopLevel = false, TopMost = true };
Initialize_GUI_Components();
}
private void Initiate_Login()
{
Dispose_Intro_Screen();
this.Size = new Size(800, 450);
UI = new UIUtilities(this, lightModeOn);
UI.Create_Rounded_Corners();
Initialize_Form_Virtualizer_For_SignUP();
form = new Login(this) { TopLevel = false, TopMost = true };
}
private void Dispose_Intro_Screen()
{
timer1.Stop();
time = 0;
axMoviePlayer1.Dispose();
formVirtualizer.BringToFront();
formVirtualizer.Visible = true;
}
private void Main_MouseDown(object sender, MouseEventArgs e)
{
IntPtr handle = this.Handle;
UI.MouseDown(handle, sender, e);
}
private void Check_Form_Disposed()
{
form?.Dispose();
addStoryPostButtonPanel?.Dispose();
}
public void Initialize_Form(int option)
{
Color backColor;
if (lightModeOn)
backColor = Color.FromArgb(242, 242, 242);
else
backColor = Color.FromArgb(43, 43, 43);
Check_Form_Disposed();
bool executes = true;
switch (option)
{
case 0:
Check_Form_Disposed();
form = new Home(this) { TopLevel = false, TopMost = true };
break;
case 1:
Check_Form_Disposed();
form = new Chat() { TopLevel = false, TopMost = true };
break;
case 2:
Check_Form_Disposed();
form = new Search(this) { TopLevel = false, TopMost = true };
break;
case 3:
{
Check_Form_Disposed();
AddButton addBtn = new AddButton(this) { TopLevel = false, TopMost = true };
addStoryPostButtonPanel = UI.Create_Panel(new int[] { addBtn.Width, addBtn.Height }, new int[] { this.Height / 2 - 160, (int)Math.Round(45 * 4.5, MidpointRounding.AwayFromZero) }, Color.Transparent);
addBtn.Add_Panel_Reference(addStoryPostButtonPanel);
this.Controls.Add(addStoryPostButtonPanel);
addStoryPostButtonPanel.Controls.Add(addBtn);
addBtn.Show();
addStoryPostButtonPanel.BringToFront();
form = new Home(this) { TopLevel = false, TopMost = true };
break;
}
case 4:
Check_Form_Disposed();
form = new Activity(this) { TopLevel = false, TopMost = true };
break;
case 5:
if (form != null)
form.Dispose();
form = new Profile(this) { TopLevel = false, TopMost = true };
break;
default:
executes = false;
break;
}
if (executes)
this.formVirtualizer.Paint += new System.Windows.Forms.PaintEventHandler(this.formVirtualizer_Paint);
}
private void formVirtualizer_Paint(object sender, PaintEventArgs e)
{
try
{
formVirtualizer.Controls.Add(form);
form.Show();
}
catch(Exception error)
{
form = new Home(this) { TopLevel = false, TopMost = true };
formVirtualizer.Controls.Add(form);
form.Show();
Console.Write(error.ToString());
}
}
private void axMoviePlayer1_MouseDownEvent(object sender, AxMOVIEPLAYERLib._DMoviePlayerEvents_MouseDownEvent e)
{
this.axMoviePlayer1.MouseDownEvent += new AxMOVIEPLAYERLib._DMoviePlayerEvents_MouseDownEventHandler(this.axMoviePlayer1_MouseDownEvent);
}
[DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn")]
private static extern IntPtr CreateRoundRectRgn
(
int nLeftRect, // x-coordinate of upper-left corner
int nTopRect, // y-coordinate of upper-left corner
int nRightRect, // x-coordinate of lower-right corner
int nBottomRect, // y-coordinate of lower-right corner
int nWidthEllipse, // height of ellipse
int nHeightEllipse // width of ellipse
);
public void Create_Rounded_Corners()
{
this.FormBorderStyle = FormBorderStyle.None;
this.Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, this.Width, this.Height, 20, 20));
}
}
}