-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm1.cs
236 lines (205 loc) · 7.21 KB
/
Form1.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
// This file is part of Mukavemet.
// Mukavemet is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Mukavemet is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Mukavemet. If not, see <https://www.gnu.org/licenses/>.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using S7.Net;
using mukavemet.Properties;
using System.Data.SQLite;
using Excel = Microsoft.Office.Interop.Excel;
using System.IO;
using System.Drawing.Imaging;
using System.Configuration;
namespace mukavemet
{
public partial class MainScreen : Form
{
private Color unselButtonBgColor = Color.FromArgb(0, 97, 193);
private Color unselButtonTxtColor = Color.White;
private Color selButtonBgColor = Color.White;
private Color selButtonTxtColor = Color.FromArgb(237, 28, 36);
private Form formMeasure;
private Form formData;
private Form formAbout;
private FormSettings formSettings;
private Form activeForm = null;
private Bitmap bmpMeasure;
private Bitmap bmpData;
private Bitmap bmpSettings;
private Bitmap bmpMeasureSel;
private Bitmap bmpDataSel;
private Bitmap bmpSettingsSel;
public MainScreen()
{
InitializeComponent();
bmpMeasure = new Bitmap(btMenuMeasure.Image);
bmpData = new Bitmap(btMenuData.Image);
bmpSettings = new Bitmap(btMenuSettings.Image);
bmpMeasureSel = MakeSelBitmap(btMenuMeasure);
bmpDataSel = MakeSelBitmap(btMenuData);
bmpSettingsSel = MakeSelBitmap(btMenuSettings);
CustomizeDesign();
formMeasure = new FormMeasure();
formData = new FormData();
formSettings = new FormSettings();
}
private void MainScreen_Load(object sender, EventArgs e)
{
btMenuMeasure.PerformClick();
}
////////// BURADAN SONRA UI TASARIMI //////////
private void CustomizeDesign()
{
pnSubMenuHelp.Visible = false;
ButtonColorUnsel(btMenuMeasure);
ButtonColorUnsel(btMenuData);
ButtonColorUnsel(btMenuSettings);
}
private void HideSubMenu()
{
if (pnSubMenuHelp.Visible == true)
pnSubMenuHelp.Visible = false;
}
private void ShowSubMenu(Panel subMenu)
{
if (subMenu.Visible == false)
{
HideSubMenu();
subMenu.Visible = true;
}
else
subMenu.Visible = false;
}
private void ButtonColorUnsel(Button button)
{
if (button.BackColor == selButtonBgColor)
{
button.BackColor = unselButtonBgColor;
button.ForeColor = unselButtonTxtColor;
switch (button.Text)
{
case " Ölçüm":
button.Image = bmpMeasure;
break;
case " Kayıt":
button.Image = bmpData;
break;
case " Ayarlar":
button.Image = bmpSettings;
break;
}
}
}
private void ButtonColorSel(Button button)
{
CustomizeDesign();
if (button.BackColor == unselButtonBgColor)
{
button.BackColor = selButtonBgColor;
button.ForeColor = selButtonTxtColor;
switch (button.Text)
{
case " Ölçüm":
button.Image = bmpMeasureSel;
break;
case " Kayıt":
button.Image = bmpDataSel;
break;
case " Ayarlar":
button.Image = bmpSettingsSel;
break;
}
}
}
private Bitmap MakeSelBitmap(Button button)
{
Bitmap bmp = new Bitmap(button.Image);
for (int x = 0; x < bmp.Width; x++)
{
for (int y = 0; y < bmp.Height; y++)
{
Color oldColor = bmp.GetPixel(x, y);
Color newColor = Color.FromArgb(oldColor.A, selButtonTxtColor.R, selButtonTxtColor.G, selButtonTxtColor.B);
bmp.SetPixel(x, y, newColor);
}
}
return bmp;
}
private void btMenuHelp_Click(object sender, EventArgs e)
{
ShowSubMenu(pnSubMenuHelp);
}
private void btMenuMeasure_Click(object sender, EventArgs e)
{
ButtonColorSel((Button)sender);
openChildForm(formMeasure);
}
private void btMenuData_Click(object sender, EventArgs e)
{
ButtonColorSel((Button)sender);
openChildForm(formData);
}
private void btMenuSettings_Click(object sender, EventArgs e)
{
string promptValue = Prompt.ShowDialog("Parola:", "Yetkilendirme");
if (promptValue == Settings.Default.Auth)
{
ButtonColorSel((Button)sender);
openChildForm(formSettings);
formSettings.ReloadMainScreen += RefreshFormMeasure;
formSettings.ReturnMainScreen += ReturnFormMeasure;
}
}
private void btMenuAbout_Click(object sender, EventArgs e)
{
if (formAbout == null || formAbout.IsDisposed)
{
formAbout = new FormAbout();
formAbout.Show();
}
else
{
formAbout.Focus();
}
}
public void openChildForm(Form childForm)
{
childForm.TopLevel = false;
childForm.FormBorderStyle = FormBorderStyle.None;
childForm.Dock = DockStyle.Fill;
if(!pnChildForm.Controls.Contains(childForm))
pnChildForm.Controls.Add(childForm);
pnChildForm.Tag = childForm;
childForm.BringToFront();
childForm.Show();
if (activeForm != null && activeForm != childForm)
activeForm.Hide();
activeForm = childForm;
}
private void RefreshFormMeasure()
{
if (formMeasure != null)
formMeasure.Close();
formMeasure = new FormMeasure();
}
private void ReturnFormMeasure()
{
btMenuMeasure.PerformClick();
}
}
}