-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNormal.vb
More file actions
345 lines (272 loc) · 12.5 KB
/
Normal.vb
File metadata and controls
345 lines (272 loc) · 12.5 KB
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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
Imports System.Runtime.InteropServices
Imports System.Windows.Forms
Imports Microsoft.Win32
Public Class Normal
Dim a, b
Dim op As String
Public MoveForm As Boolean
Public MoveForm_MousePosition As Point
Dim m
Public Sub New()
InitializeComponent()
Me.DoubleBuffered = True
Me.SetStyle(ControlStyles.ResizeRedraw, True)
End Sub
Private Const cGrip As Integer = 16
Private Const cCaption As Integer = 32
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
End Sub
Protected Overrides Sub WndProc(ByRef m As Message)
If m.Msg = &H84 Then
Dim pos As Point = New Point(m.LParam.ToInt32())
pos = Me.PointToClient(pos)
If pos.Y < cCaption Then
m.Result = CType(2, IntPtr)
Return
End If
If pos.X >= Me.ClientSize.Width - cGrip AndAlso pos.Y >= Me.ClientSize.Height - cGrip Then
m.Result = CType(17, IntPtr)
Return
End If
End If
MyBase.WndProc(m)
End Sub
<DllImport("user32.dll")>
Public Shared Function SystemParametersInfo(ByVal uAction As Integer, ByVal uParam As Integer, ByRef lpvParam As Integer, ByVal fuWinIni As Integer) As Integer
End Function
Public Sub MoveForm_MouseDown(sender As Object, e As MouseEventArgs) Handles _
MyBase.MouseDown ' Add more handles here (Example: PictureBox1.MouseDown)
If e.Button = MouseButtons.Left Then
MoveForm = True
Me.Cursor = Cursors.NoMove2D
MoveForm_MousePosition = e.Location
End If
End Sub
Public Sub MoveForm_MouseMove(sender As Object, e As MouseEventArgs) Handles _
MyBase.MouseMove ' Add more handles here (Example: PictureBox1.MouseMove)
If MoveForm Then
Me.Location = Me.Location + (e.Location - MoveForm_MousePosition)
End If
End Sub
Public Sub MoveForm_MouseUp(sender As Object, e As MouseEventArgs) Handles _
MyBase.MouseUp ' Add more handles here (Example: PictureBox1.MouseUp)
If e.Button = MouseButtons.Left Then
MoveForm = False
Me.Cursor = Cursors.Default
End If
End Sub
Private Const SPI_GETNONCLIENTMETRICS As Integer = 41
Private Const SPI_SETNONCLIENTMETRICS As Integer = 42
Private Const SPIF_UPDATEINIFILE As Integer = &H1
Sub SwitchMode()
If SystemInformation.HighContrast = True Then
Me.BackColor = Color.DarkGray
Me.ForeColor = Color.White
Else
Me.BackColor = Color.White
Me.ForeColor = Color.Black
End If
End Sub
Private Sub Normal_Load(sender As Object, e As EventArgs) Handles MyBase.Load
If FastMenu.Visible Then
FastMenuToolStripMenuItem.Text = "Fast Menu (Close)"
Else
FastMenuToolStripMenuItem.Text = "Fast Menu"
End If
Me.AutoScaleMode = AutoScaleMode.Dpi
Me.MaximumSize = Screen.FromRectangle(Me.Bounds).WorkingArea.Size
ApplyMenuColors(MenuStrip1)
' Carica le impostazioni
My.Settings.Reload()
' Imposta la lingua iniziale
Dim linguaSelezionata As String = System.Configuration.ConfigurationManager.AppSettings("Lingua")
Dim choosenStartup As String = System.Configuration.ConfigurationManager.AppSettings("Startup")
If choosenStartup = "Normal" Then
Me.WindowState = FormWindowState.Normal
ElseIf choosenStartup = "Maximized" Then
Me.WindowState = FormWindowState.Maximized
End If
If linguaSelezionata = "English" Then
Button1.Text = "Clear"
CalculatorToolStripMenuItem.Text = "Calculator"
If FastMenu.Visible = True Then
FastMenuToolStripMenuItem.Text = "Fast Menu (Close)"
Else
FastMenuToolStripMenuItem.Text = "Fast Menu"
End If
AboutToolStripMenuItem.Text = "About"
SettingsToolStripMenuItem.Text = "Settings"
Label1.Text = "Standard Calculator"
ElseIf linguaSelezionata = "Italian" Then
Button1.Text = "C"
CalculatorToolStripMenuItem.Text = "Calcolatrici"
FastMenuToolStripMenuItem.Text = "Menu Veloce"
AboutToolStripMenuItem.Text = "Informazioni su"
SettingsToolStripMenuItem.Text = "Impostazioni"
Label1.Text = "Calcolatrice Standard"
End If
' Applica i colori salvati alle altre parti del form
Me.ForeColor = My.Settings.TextColor
Me.BackColor = My.Settings.BackgroundColor
TextBox1.ForeColor = My.Settings.TextColor
End Sub
Private Sub ApplyMenuColors(menu As MenuStrip)
' Applica i colori di sfondo e del testo del menu
menu.BackColor = My.Settings.BackgroundColor
menu.ForeColor = My.Settings.TextColor
' Itera attraverso tutti gli elementi del menu
For Each item As ToolStripItem In menu.Items
' Controlla se l'elemento è un ToolStripMenuItem
If TypeOf item Is ToolStripMenuItem Then
' Applica i colori di sfondo e del testo al ToolStripMenuItem
Dim menuItem As ToolStripMenuItem = CType(item, ToolStripMenuItem)
menuItem.BackColor = My.Settings.BackgroundColor
menuItem.ForeColor = My.Settings.TextColor
' Applica ricorsivamente i colori agli elementi figlio del ToolStripMenuItem
ApplyMenuColorsToItems(menuItem)
ElseIf TypeOf item Is ToolStripTextBox Then
' Se l'elemento è un ToolStripTextBox, applica i colori appropriati
Dim toolStripTextBox As ToolStripTextBox = CType(item, ToolStripTextBox)
toolStripTextBox.BackColor = My.Settings.BackgroundColor
toolStripTextBox.ForeColor = My.Settings.TextColor
End If
Next
End Sub
Private Sub ApplyMenuColorsToItems(menuItem As ToolStripMenuItem)
' Itera attraverso gli elementi figlio del ToolStripMenuItem
For Each subItem As ToolStripItem In menuItem.DropDownItems
' Controlla se l'elemento figlio è un ToolStripMenuItem
If TypeOf subItem Is ToolStripMenuItem Then
' Applica i colori di sfondo e del testo al ToolStripMenuItem figlio
Dim subMenuItem As ToolStripMenuItem = CType(subItem, ToolStripMenuItem)
subMenuItem.BackColor = My.Settings.BackgroundColor
subMenuItem.ForeColor = My.Settings.TextColor
' Applica ricorsivamente i colori agli elementi figlio del ToolStripMenuItem figlio
ApplyMenuColorsToItems(subMenuItem)
ElseIf TypeOf subItem Is ToolStripTextBox Then
' Se l'elemento figlio è un ToolStripTextBox, applica i colori appropriati
Dim toolStripTextBox As ToolStripTextBox = CType(subItem, ToolStripTextBox)
toolStripTextBox.BackColor = My.Settings.BackgroundColor
toolStripTextBox.ForeColor = My.Settings.TextColor
End If
Next
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Butt1.Click
TextBox1.Text = TextBox1.Text & “1”
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Butt2.Click
TextBox1.Text = TextBox1.Text & “2”
End Sub
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Butt3.Click
TextBox1.Text = TextBox1.Text & “3”
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Butt4.Click
TextBox1.Text = TextBox1.Text & “4”
End Sub
Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Butt5.Click
TextBox1.Text = TextBox1.Text & “5”
End Sub
Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Butt6.Click
TextBox1.Text = TextBox1.Text & “6”
End Sub
Private Sub Button13_Click(sender As Object, e As EventArgs) Handles Butt7.Click
TextBox1.Text = TextBox1.Text & “7”
End Sub
Private Sub Button12_Click(sender As Object, e As EventArgs) Handles Butt8.Click
TextBox1.Text = TextBox1.Text & “8”
End Sub
Private Sub Button16_Click(sender As Object, e As EventArgs) Handles Butt9.Click
TextBox1.Text = TextBox1.Text & “9”
End Sub
Private Sub Button17_Click(sender As Object, e As EventArgs) Handles Butt0.Click
TextBox1.Text = TextBox1.Text & “0”
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Plus.Click
a = CDbl(TextBox1.Text)
op = “+”
TextBox1.Text = “”
End Sub
Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Molt.Click
a = CDbl(TextBox1.Text)
op = “*”
TextBox1.Text = “”
End Sub
Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Div.Click
a = CDbl(TextBox1.Text)
op = “/”
TextBox1.Text = “”
End Sub
Private Sub Button14_Click(sender As Object, e As EventArgs) Handles Button14.Click
b = CDbl(TextBox1.Text)
Select Case op
Case “/”
TextBox1.Text = a / b
Case “*”
TextBox1.Text = a * b
Case “+”
TextBox1.Text = a + b
Case “-”
TextBox1.Text = a - b
End Select
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
TextBox1.Text = “”
End Sub
Private Sub ScOpen_Click(sender As Object, e As EventArgs)
Scientific.Show()
Me.Hide()
End Sub
Private Sub NormalToolStripMenuItem_Click(sender As Object, e As EventArgs)
End Sub
Private Sub ScientificToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ScientificToolStripMenuItem.Click
TextBox1.Text = “”
Me.Hide()
Scientific.Show()
End Sub
Private Sub AboutToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles AboutToolStripMenuItem.Click
About.Show()
End Sub
Private Sub Button15_Click_1(sender As Object, e As EventArgs) Handles minx.Click
TextBox1.Text = "-"
End Sub
Private Sub Copy_Click(sender As Object, e As EventArgs)
End Sub
Private Sub Closea_Click(sender As Object, e As EventArgs) Handles Closea.Click
Application.Exit()
End Sub
Private Sub Minimizea_Click(sender As Object, e As EventArgs) Handles Minimizea.Click
Me.WindowState = FormWindowState.Minimized
End Sub
Private Sub ThemeSettingsToolStripMenuItem_Click(sender As Object, e As EventArgs)
End Sub
Private Sub ProgrammerToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ProgrammerToolStripMenuItem.Click
Me.Hide()
Programmer.Show()
End Sub
Private Sub ButtonBackspace_Click(sender As Object, e As EventArgs) Handles ButtonBackspace.Click
If TextBox1.Text < " " Then
TextBox1.Text = Mid(TextBox1.Text, 1, Len(TextBox1.Text) - 1 + 1)
Else
TextBox1.Text = Mid(TextBox1.Text, 1, Len(TextBox1.Text) - 1)
End If
End Sub
Private Sub BinaryAdditionToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles BinaryAdditionToolStripMenuItem.Click
Me.Hide()
BinaryOp.Show()
End Sub
Private Sub FastMenuToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles FastMenuToolStripMenuItem.Click
FastMenu.Show()
End Sub
Private Sub FastMenuToolStripMenuItem_MouseUp(sender As Object, e As MouseEventArgs) Handles FastMenuToolStripMenuItem.DoubleClick
End Sub
Private Sub SettingsToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SettingsToolStripMenuItem.Click
Settingsc.Show()
End Sub
Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Minus.Click
a = CDbl(TextBox1.Text)
op = “-”
TextBox1.Text = “”
End Sub
End Class