SHOW:
|
|
- or go back to the newest paste.
1 | Imports System | |
2 | Imports System.Windows.Forms | |
3 | Imports System.Drawing | |
4 | Imports System.Drawing.Drawing2D | |
5 | Imports System.Drawing.Text | |
6 | Imports System.ComponentModel | |
7 | Imports System.Collections.Generic | |
8 | Imports System.Text | |
9 | ||
10 | 'IMPORTANT: | |
11 | 'Please leave these comments in place as they help protect intellectual rights and allow | |
12 | 'developers to determine the version of the theme they are using. | |
13 | ||
14 | 'Name: Net Seal Theme | |
15 | 'Created: 4/15/2013 | |
16 | 'Version: 1.0.0.0 Beta | |
17 | 'Site: http://nimoru.com/ | |
18 | ||
19 | 'This work is licensed under a Creative Commons Attribution 3.0 Unported License. | |
20 | 'To view a copy of this license, please visit http://creativecommons.org/licenses/by/3.0/ | |
21 | ||
22 | 'Copyright © 2013 Nimoru Software | |
23 | ||
24 | Module ThemeModule | |
25 | ||
26 | Friend G As Graphics | |
27 | ||
28 | Sub New() | |
29 | TextBitmap = New Bitmap(1, 1) | |
30 | TextGraphics = Graphics.FromImage(TextBitmap) | |
31 | End Sub | |
32 | ||
33 | Private TextBitmap As Bitmap | |
34 | Private TextGraphics As Graphics | |
35 | ||
36 | Friend Function MeasureString(text As String, font As Font) As SizeF | |
37 | Return TextGraphics.MeasureString(text, font) | |
38 | End Function | |
39 | ||
40 | Friend Function MeasureString(text As String, font As Font, width As Integer) As SizeF | |
41 | Return TextGraphics.MeasureString(text, font, width, StringFormat.GenericTypographic) | |
42 | End Function | |
43 | ||
44 | Private CreateRoundPath As GraphicsPath | |
45 | Private CreateRoundRectangle As Rectangle | |
46 | ||
47 | Friend Function CreateRound(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal slope As Integer) As GraphicsPath | |
48 | CreateRoundRectangle = New Rectangle(x, y, width, height) | |
49 | Return CreateRound(CreateRoundRectangle, slope) | |
50 | End Function | |
51 | ||
52 | Friend Function CreateRound(ByVal r As Rectangle, ByVal slope As Integer) As GraphicsPath | |
53 | CreateRoundPath = New GraphicsPath(FillMode.Winding) | |
54 | CreateRoundPath.AddArc(r.X, r.Y, slope, slope, 180.0F, 90.0F) | |
55 | CreateRoundPath.AddArc(r.Right - slope, r.Y, slope, slope, 270.0F, 90.0F) | |
56 | CreateRoundPath.AddArc(r.Right - slope, r.Bottom - slope, slope, slope, 0.0F, 90.0F) | |
57 | CreateRoundPath.AddArc(r.X, r.Bottom - slope, slope, slope, 90.0F, 90.0F) | |
58 | CreateRoundPath.CloseFigure() | |
59 | Return CreateRoundPath | |
60 | End Function | |
61 | ||
62 | End Module | |
63 | ||
64 | Class NSTheme | |
65 | Inherits ThemeContainer154 | |
66 | ||
67 | Private _AccentOffset As Integer = 42 | |
68 | Public Property AccentOffset() As Integer | |
69 | Get | |
70 | Return _AccentOffset | |
71 | End Get | |
72 | Set(ByVal value As Integer) | |
73 | _AccentOffset = value | |
74 | Invalidate() | |
75 | End Set | |
76 | End Property | |
77 | ||
78 | Sub New() | |
79 | Header = 30 | |
80 | BackColor = Color.FromArgb(50, 50, 50) | |
81 | ||
82 | P1 = New Pen(Color.FromArgb(35, 35, 35)) | |
83 | P2 = New Pen(Color.FromArgb(60, 60, 60)) | |
84 | ||
85 | B1 = New SolidBrush(Color.FromArgb(50, 50, 50)) | |
86 | End Sub | |
87 | ||
88 | Protected Overrides Sub ColorHook() | |
89 | ||
90 | End Sub | |
91 | ||
92 | Private R1 As Rectangle | |
93 | ||
94 | Private P1, P2 As Pen | |
95 | Private B1 As SolidBrush | |
96 | ||
97 | Private Pad As Integer | |
98 | ||
99 | Protected Overrides Sub PaintHook() | |
100 | G.Clear(BackColor) | |
101 | DrawBorders(P2, 1) | |
102 | ||
103 | G.DrawLine(P1, 0, 26, Width, 26) | |
104 | G.DrawLine(P2, 0, 25, Width, 25) | |
105 | ||
106 | Pad = Math.Max(Measure().Width + 20, 80) | |
107 | R1 = New Rectangle(Pad, 17, Width - (Pad * 2) + _AccentOffset, 8) | |
108 | ||
109 | G.DrawRectangle(P2, R1) | |
110 | G.DrawRectangle(P1, R1.X + 1, R1.Y + 1, R1.Width - 2, R1.Height) | |
111 | ||
112 | G.DrawLine(P1, 0, 29, Width, 29) | |
113 | G.DrawLine(P2, 0, 30, Width, 30) | |
114 | ||
115 | DrawText(Brushes.Black, HorizontalAlignment.Left, 8, 1) | |
116 | DrawText(Brushes.White, HorizontalAlignment.Left, 7, 0) | |
117 | ||
118 | G.FillRectangle(B1, 0, 27, Width, 2) | |
119 | DrawBorders(Pens.Black) | |
120 | End Sub | |
121 | ||
122 | End Class | |
123 | ||
124 | Class NSButton | |
125 | Inherits Control | |
126 | ||
127 | Sub New() | |
128 | SetStyle(DirectCast(139286, ControlStyles), True) | |
129 | SetStyle(ControlStyles.Selectable, False) | |
130 | ||
131 | P1 = New Pen(Color.FromArgb(35, 35, 35)) | |
132 | P2 = New Pen(Color.FromArgb(65, 65, 65)) | |
133 | End Sub | |
134 | ||
135 | Private IsMouseDown As Boolean | |
136 | ||
137 | Private GP1, GP2 As GraphicsPath | |
138 | ||
139 | Private SZ1 As SizeF | |
140 | Private PT1 As PointF | |
141 | ||
142 | Private P1, P2 As Pen | |
143 | ||
144 | Private PB1 As PathGradientBrush | |
145 | Private GB1 As LinearGradientBrush | |
146 | ||
147 | Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs) | |
148 | G = e.Graphics | |
149 | G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit | |
150 | ||
151 | G.Clear(BackColor) | |
152 | G.SmoothingMode = SmoothingMode.AntiAlias | |
153 | ||
154 | GP1 = CreateRound(0, 0, Width - 1, Height - 1, 7) | |
155 | GP2 = CreateRound(1, 1, Width - 3, Height - 3, 7) | |
156 | ||
157 | If IsMouseDown Then | |
158 | PB1 = New PathGradientBrush(GP1) | |
159 | PB1.CenterColor = Color.FromArgb(60, 60, 60) | |
160 | PB1.SurroundColors = {Color.FromArgb(55, 55, 55)} | |
161 | PB1.FocusScales = New PointF(0.8F, 0.5F) | |
162 | ||
163 | G.FillPath(PB1, GP1) | |
164 | Else | |
165 | GB1 = New LinearGradientBrush(ClientRectangle, Color.FromArgb(60, 60, 60), Color.FromArgb(55, 55, 55), 90.0F) | |
166 | G.FillPath(GB1, GP1) | |
167 | End If | |
168 | ||
169 | G.DrawPath(P1, GP1) | |
170 | G.DrawPath(P2, GP2) | |
171 | ||
172 | SZ1 = G.MeasureString(Text, Font) | |
173 | PT1 = New PointF(5, Height \ 2 - SZ1.Height / 2) | |
174 | ||
175 | If IsMouseDown Then | |
176 | PT1.X += 1.0F | |
177 | PT1.Y += 1.0F | |
178 | End If | |
179 | ||
180 | G.DrawString(Text, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1) | |
181 | G.DrawString(Text, Font, Brushes.White, PT1) | |
182 | End Sub | |
183 | ||
184 | Protected Overrides Sub OnMouseDown(e As MouseEventArgs) | |
185 | IsMouseDown = True | |
186 | Invalidate() | |
187 | End Sub | |
188 | ||
189 | Protected Overrides Sub OnMouseUp(e As MouseEventArgs) | |
190 | IsMouseDown = False | |
191 | Invalidate() | |
192 | End Sub | |
193 | ||
194 | End Class | |
195 | ||
196 | Class NSProgressBar | |
197 | Inherits Control | |
198 | ||
199 | Private _Minimum As Integer | |
200 | Property Minimum() As Integer | |
201 | Get | |
202 | Return _Minimum | |
203 | End Get | |
204 | Set(ByVal value As Integer) | |
205 | If value < 0 Then | |
206 | Throw New Exception("Property value is not valid.") | |
207 | End If | |
208 | ||
209 | _Minimum = value | |
210 | If value > _Value Then _Value = value | |
211 | If value > _Maximum Then _Maximum = value | |
212 | Invalidate() | |
213 | End Set | |
214 | End Property | |
215 | ||
216 | Private _Maximum As Integer = 100 | |
217 | Property Maximum() As Integer | |
218 | Get | |
219 | Return _Maximum | |
220 | End Get | |
221 | Set(ByVal value As Integer) | |
222 | If value < 0 Then | |
223 | Throw New Exception("Property value is not valid.") | |
224 | End If | |
225 | ||
226 | _Maximum = value | |
227 | If value < _Value Then _Value = value | |
228 | If value < _Minimum Then _Minimum = value | |
229 | Invalidate() | |
230 | End Set | |
231 | End Property | |
232 | ||
233 | Private _Value As Integer | |
234 | Property Value() As Integer | |
235 | Get | |
236 | Return _Value | |
237 | End Get | |
238 | Set(ByVal value As Integer) | |
239 | If value > _Maximum OrElse value < _Minimum Then | |
240 | Throw New Exception("Property value is not valid.") | |
241 | End If | |
242 | ||
243 | _Value = value | |
244 | Invalidate() | |
245 | End Set | |
246 | End Property | |
247 | ||
248 | Private Sub Increment(ByVal amount As Integer) | |
249 | Value += amount | |
250 | End Sub | |
251 | ||
252 | Sub New() | |
253 | SetStyle(DirectCast(139286, ControlStyles), True) | |
254 | SetStyle(ControlStyles.Selectable, False) | |
255 | ||
256 | P1 = New Pen(Color.FromArgb(35, 35, 35)) | |
257 | P2 = New Pen(Color.FromArgb(55, 55, 55)) | |
258 | B1 = New SolidBrush(Color.FromArgb(200, 160, 0)) | |
259 | End Sub | |
260 | ||
261 | Private GP1, GP2, GP3 As GraphicsPath | |
262 | ||
263 | Private R1, R2 As Rectangle | |
264 | ||
265 | Private P1, P2 As Pen | |
266 | Private B1 As SolidBrush | |
267 | Private GB1, GB2 As LinearGradientBrush | |
268 | ||
269 | Private I1 As Integer | |
270 | ||
271 | Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs) | |
272 | G = e.Graphics | |
273 | ||
274 | G.Clear(BackColor) | |
275 | G.SmoothingMode = SmoothingMode.AntiAlias | |
276 | ||
277 | GP1 = CreateRound(0, 0, Width - 1, Height - 1, 7) | |
278 | GP2 = CreateRound(1, 1, Width - 3, Height - 3, 7) | |
279 | ||
280 | R1 = New Rectangle(0, 2, Width - 1, Height - 1) | |
281 | GB1 = New LinearGradientBrush(R1, Color.FromArgb(45, 45, 45), Color.FromArgb(50, 50, 50), 90.0F) | |
282 | ||
283 | G.SetClip(GP1) | |
284 | G.FillRectangle(GB1, R1) | |
285 | ||
286 | I1 = CInt((_Value - _Minimum) / (_Maximum - _Minimum) * (Width - 3)) | |
287 | ||
288 | If I1 > 1 Then | |
289 | GP3 = CreateRound(1, 1, I1, Height - 3, 7) | |
290 | ||
291 | R2 = New Rectangle(1, 1, I1, Height - 3) | |
292 | GB2 = New LinearGradientBrush(R2, Color.FromArgb(205, 150, 0), Color.FromArgb(150, 110, 0), 90.0F) | |
293 | ||
294 | G.FillPath(GB2, GP3) | |
295 | G.DrawPath(P1, GP3) | |
296 | ||
297 | G.SetClip(GP3) | |
298 | G.SmoothingMode = SmoothingMode.None | |
299 | ||
300 | G.FillRectangle(B1, R2.X, R2.Y + 1, R2.Width, R2.Height \ 2) | |
301 | ||
302 | G.SmoothingMode = SmoothingMode.AntiAlias | |
303 | G.ResetClip() | |
304 | End If | |
305 | ||
306 | G.DrawPath(P2, GP1) | |
307 | G.DrawPath(P1, GP2) | |
308 | End Sub | |
309 | ||
310 | End Class | |
311 | ||
312 | Class NSLabel | |
313 | Inherits Control | |
314 | ||
315 | Sub New() | |
316 | SetStyle(DirectCast(139286, ControlStyles), True) | |
317 | SetStyle(ControlStyles.Selectable, False) | |
318 | ||
319 | Font = New Font("Segoe UI", 11.25F, FontStyle.Bold) | |
320 | ||
321 | B1 = New SolidBrush(Color.FromArgb(205, 150, 0)) | |
322 | End Sub | |
323 | ||
324 | Private _Value1 As String = "NET" | |
325 | Public Property Value1() As String | |
326 | Get | |
327 | Return _Value1 | |
328 | End Get | |
329 | Set(ByVal value As String) | |
330 | _Value1 = value | |
331 | Invalidate() | |
332 | End Set | |
333 | End Property | |
334 | ||
335 | Private _Value2 As String = "SEAL" | |
336 | Public Property Value2() As String | |
337 | Get | |
338 | Return _Value2 | |
339 | End Get | |
340 | Set(ByVal value As String) | |
341 | _Value2 = value | |
342 | Invalidate() | |
343 | End Set | |
344 | End Property | |
345 | ||
346 | Private B1 As SolidBrush | |
347 | ||
348 | Private PT1, PT2 As PointF | |
349 | Private SZ1, SZ2 As SizeF | |
350 | ||
351 | Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs) | |
352 | G = e.Graphics | |
353 | G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit | |
354 | ||
355 | G.Clear(BackColor) | |
356 | ||
357 | SZ1 = G.MeasureString(Value1, Font, Width, StringFormat.GenericTypographic) | |
358 | SZ2 = G.MeasureString(Value2, Font, Width, StringFormat.GenericTypographic) | |
359 | ||
360 | PT1 = New PointF(0, Height \ 2 - SZ1.Height / 2) | |
361 | PT2 = New PointF(SZ1.Width + 1, Height \ 2 - SZ1.Height / 2) | |
362 | ||
363 | G.DrawString(Value1, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1) | |
364 | G.DrawString(Value1, Font, Brushes.White, PT1) | |
365 | ||
366 | G.DrawString(Value2, Font, Brushes.Black, PT2.X + 1, PT2.Y + 1) | |
367 | G.DrawString(Value2, Font, B1, PT2) | |
368 | End Sub | |
369 | ||
370 | End Class | |
371 | ||
372 | <DefaultEvent("TextChanged")> _ | |
373 | Class NSTextBox | |
374 | Inherits Control | |
375 | ||
376 | Private _TextAlign As HorizontalAlignment = HorizontalAlignment.Left | |
377 | Property TextAlign() As HorizontalAlignment | |
378 | Get | |
379 | Return _TextAlign | |
380 | End Get | |
381 | Set(ByVal value As HorizontalAlignment) | |
382 | _TextAlign = value | |
383 | If Base IsNot Nothing Then | |
384 | Base.TextAlign = value | |
385 | End If | |
386 | End Set | |
387 | End Property | |
388 | ||
389 | Private _MaxLength As Integer = 32767 | |
390 | Property MaxLength() As Integer | |
391 | Get | |
392 | Return _MaxLength | |
393 | End Get | |
394 | Set(ByVal value As Integer) | |
395 | _MaxLength = value | |
396 | If Base IsNot Nothing Then | |
397 | Base.MaxLength = value | |
398 | End If | |
399 | End Set | |
400 | End Property | |
401 | ||
402 | Private _ReadOnly As Boolean | |
403 | Property [ReadOnly]() As Boolean | |
404 | Get | |
405 | Return _ReadOnly | |
406 | End Get | |
407 | Set(ByVal value As Boolean) | |
408 | _ReadOnly = value | |
409 | If Base IsNot Nothing Then | |
410 | Base.ReadOnly = value | |
411 | End If | |
412 | End Set | |
413 | End Property | |
414 | ||
415 | Private _UseSystemPasswordChar As Boolean | |
416 | Property UseSystemPasswordChar() As Boolean | |
417 | Get | |
418 | Return _UseSystemPasswordChar | |
419 | End Get | |
420 | Set(ByVal value As Boolean) | |
421 | _UseSystemPasswordChar = value | |
422 | If Base IsNot Nothing Then | |
423 | Base.UseSystemPasswordChar = value | |
424 | End If | |
425 | End Set | |
426 | End Property | |
427 | ||
428 | Private _Multiline As Boolean | |
429 | Property Multiline() As Boolean | |
430 | Get | |
431 | Return _Multiline | |
432 | End Get | |
433 | Set(ByVal value As Boolean) | |
434 | _Multiline = value | |
435 | If Base IsNot Nothing Then | |
436 | Base.Multiline = value | |
437 | ||
438 | If value Then | |
439 | Base.Height = Height - 11 | |
440 | Else | |
441 | Height = Base.Height + 11 | |
442 | End If | |
443 | End If | |
444 | End Set | |
445 | End Property | |
446 | ||
447 | Overrides Property Text As String | |
448 | Get | |
449 | Return MyBase.Text | |
450 | End Get | |
451 | Set(ByVal value As String) | |
452 | MyBase.Text = value | |
453 | If Base IsNot Nothing Then | |
454 | Base.Text = value | |
455 | End If | |
456 | End Set | |
457 | End Property | |
458 | ||
459 | Overrides Property Font As Font | |
460 | Get | |
461 | Return MyBase.Font | |
462 | End Get | |
463 | Set(ByVal value As Font) | |
464 | MyBase.Font = value | |
465 | If Base IsNot Nothing Then | |
466 | Base.Font = value | |
467 | Base.Location = New Point(5, 5) | |
468 | Base.Width = Width - 8 | |
469 | ||
470 | If Not _Multiline Then | |
471 | Height = Base.Height + 11 | |
472 | End If | |
473 | End If | |
474 | End Set | |
475 | End Property | |
476 | ||
477 | Protected Overrides Sub OnHandleCreated(e As EventArgs) | |
478 | If Not Controls.Contains(Base) Then | |
479 | Controls.Add(Base) | |
480 | End If | |
481 | ||
482 | MyBase.OnHandleCreated(e) | |
483 | End Sub | |
484 | ||
485 | Private Base As TextBox | |
486 | Sub New() | |
487 | SetStyle(DirectCast(139286, ControlStyles), True) | |
488 | SetStyle(ControlStyles.Selectable, True) | |
489 | ||
490 | Cursor = Cursors.IBeam | |
491 | ||
492 | Base = New TextBox | |
493 | Base.Font = Font | |
494 | Base.Text = Text | |
495 | Base.MaxLength = _MaxLength | |
496 | Base.Multiline = _Multiline | |
497 | Base.ReadOnly = _ReadOnly | |
498 | Base.UseSystemPasswordChar = _UseSystemPasswordChar | |
499 | ||
500 | Base.ForeColor = Color.White | |
501 | Base.BackColor = Color.FromArgb(50, 50, 50) | |
502 | ||
503 | Base.BorderStyle = BorderStyle.None | |
504 | ||
505 | Base.Location = New Point(5, 5) | |
506 | Base.Width = Width - 14 | |
507 | ||
508 | If _Multiline Then | |
509 | Base.Height = Height - 11 | |
510 | Else | |
511 | Height = Base.Height + 11 | |
512 | End If | |
513 | ||
514 | AddHandler Base.TextChanged, AddressOf OnBaseTextChanged | |
515 | AddHandler Base.KeyDown, AddressOf OnBaseKeyDown | |
516 | ||
517 | P1 = New Pen(Color.FromArgb(35, 35, 35)) | |
518 | P2 = New Pen(Color.FromArgb(55, 55, 55)) | |
519 | End Sub | |
520 | ||
521 | Private GP1, GP2 As GraphicsPath | |
522 | ||
523 | Private P1, P2 As Pen | |
524 | Private PB1 As PathGradientBrush | |
525 | ||
526 | Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs) | |
527 | G = e.Graphics | |
528 | ||
529 | G.Clear(BackColor) | |
530 | G.SmoothingMode = SmoothingMode.AntiAlias | |
531 | ||
532 | GP1 = CreateRound(0, 0, Width - 1, Height - 1, 7) | |
533 | GP2 = CreateRound(1, 1, Width - 3, Height - 3, 7) | |
534 | ||
535 | PB1 = New PathGradientBrush(GP1) | |
536 | PB1.CenterColor = Color.FromArgb(50, 50, 50) | |
537 | PB1.SurroundColors = {Color.FromArgb(45, 45, 45)} | |
538 | PB1.FocusScales = New PointF(0.9F, 0.5F) | |
539 | ||
540 | G.FillPath(PB1, GP1) | |
541 | ||
542 | G.DrawPath(P2, GP1) | |
543 | G.DrawPath(P1, GP2) | |
544 | End Sub | |
545 | ||
546 | Private Sub OnBaseTextChanged(ByVal s As Object, ByVal e As EventArgs) | |
547 | Text = Base.Text | |
548 | End Sub | |
549 | ||
550 | Private Sub OnBaseKeyDown(ByVal s As Object, ByVal e As KeyEventArgs) | |
551 | If e.Control AndAlso e.KeyCode = Keys.A Then | |
552 | Base.SelectAll() | |
553 | e.SuppressKeyPress = True | |
554 | End If | |
555 | End Sub | |
556 | ||
557 | Protected Overrides Sub OnResize(ByVal e As EventArgs) | |
558 | Base.Location = New Point(5, 5) | |
559 | ||
560 | Base.Width = Width - 10 | |
561 | Base.Height = Height - 11 | |
562 | ||
563 | MyBase.OnResize(e) | |
564 | End Sub | |
565 | ||
566 | Protected Overrides Sub OnMouseDown(e As MouseEventArgs) | |
567 | Base.Focus() | |
568 | MyBase.OnMouseDown(e) | |
569 | End Sub | |
570 | ||
571 | Protected Overrides Sub OnEnter(e As EventArgs) | |
572 | Base.Focus() | |
573 | Invalidate() | |
574 | MyBase.OnEnter(e) | |
575 | End Sub | |
576 | ||
577 | Protected Overrides Sub OnLeave(e As EventArgs) | |
578 | Invalidate() | |
579 | MyBase.OnLeave(e) | |
580 | End Sub | |
581 | ||
582 | End Class | |
583 | ||
584 | <DefaultEvent("CheckedChanged")> _ | |
585 | Class NSCheckBox | |
586 | Inherits Control | |
587 | ||
588 | Event CheckedChanged(sender As Object) | |
589 | ||
590 | Sub New() | |
591 | SetStyle(DirectCast(139286, ControlStyles), True) | |
592 | SetStyle(ControlStyles.Selectable, False) | |
593 | ||
594 | P11 = New Pen(Color.FromArgb(55, 55, 55)) | |
595 | P22 = New Pen(Color.FromArgb(35, 35, 35)) | |
596 | P3 = New Pen(Color.Black, 2.0F) | |
597 | P4 = New Pen(Color.White, 2.0F) | |
598 | End Sub | |
599 | ||
600 | Private _Checked As Boolean | |
601 | Public Property Checked() As Boolean | |
602 | Get | |
603 | Return _Checked | |
604 | End Get | |
605 | Set(ByVal value As Boolean) | |
606 | _Checked = value | |
607 | RaiseEvent CheckedChanged(Me) | |
608 | ||
609 | Invalidate() | |
610 | End Set | |
611 | End Property | |
612 | ||
613 | Private GP1, GP2 As GraphicsPath | |
614 | ||
615 | Private SZ1 As SizeF | |
616 | Private PT1 As PointF | |
617 | ||
618 | Private P11, P22, P3, P4 As Pen | |
619 | ||
620 | Private PB1 As PathGradientBrush | |
621 | ||
622 | Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs) | |
623 | G = e.Graphics | |
624 | G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit | |
625 | ||
626 | G.Clear(BackColor) | |
627 | G.SmoothingMode = SmoothingMode.AntiAlias | |
628 | ||
629 | GP1 = CreateRound(0, 2, Height - 5, Height - 5, 5) | |
630 | GP2 = CreateRound(1, 3, Height - 7, Height - 7, 5) | |
631 | ||
632 | PB1 = New PathGradientBrush(GP1) | |
633 | PB1.CenterColor = Color.FromArgb(50, 50, 50) | |
634 | PB1.SurroundColors = {Color.FromArgb(45, 45, 45)} | |
635 | PB1.FocusScales = New PointF(0.3F, 0.3F) | |
636 | ||
637 | G.FillPath(PB1, GP1) | |
638 | G.DrawPath(P11, GP1) | |
639 | G.DrawPath(P22, GP2) | |
640 | ||
641 | If _Checked Then | |
642 | G.DrawLine(P3, 5, Height - 9, 8, Height - 7) | |
643 | G.DrawLine(P3, 7, Height - 7, Height - 8, 7) | |
644 | ||
645 | G.DrawLine(P4, 4, Height - 10, 7, Height - 8) | |
646 | G.DrawLine(P4, 6, Height - 8, Height - 9, 6) | |
647 | End If | |
648 | ||
649 | SZ1 = G.MeasureString(Text, Font) | |
650 | PT1 = New PointF(Height - 3, Height \ 2 - SZ1.Height / 2) | |
651 | ||
652 | G.DrawString(Text, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1) | |
653 | G.DrawString(Text, Font, Brushes.White, PT1) | |
654 | End Sub | |
655 | ||
656 | Protected Overrides Sub OnMouseDown(e As MouseEventArgs) | |
657 | Checked = Not Checked | |
658 | End Sub | |
659 | ||
660 | End Class | |
661 | ||
662 | <DefaultEvent("CheckedChanged")> _ | |
663 | Class NSRadioButton | |
664 | Inherits Control | |
665 | ||
666 | Event CheckedChanged(sender As Object) | |
667 | ||
668 | Sub New() | |
669 | SetStyle(DirectCast(139286, ControlStyles), True) | |
670 | SetStyle(ControlStyles.Selectable, False) | |
671 | ||
672 | P1 = New Pen(Color.FromArgb(55, 55, 55)) | |
673 | P2 = New Pen(Color.FromArgb(35, 35, 35)) | |
674 | End Sub | |
675 | ||
676 | Private _Checked As Boolean | |
677 | Public Property Checked() As Boolean | |
678 | Get | |
679 | Return _Checked | |
680 | End Get | |
681 | Set(ByVal value As Boolean) | |
682 | _Checked = value | |
683 | ||
684 | If _Checked Then | |
685 | InvalidateParent() | |
686 | End If | |
687 | ||
688 | RaiseEvent CheckedChanged(Me) | |
689 | Invalidate() | |
690 | End Set | |
691 | End Property | |
692 | ||
693 | Private Sub InvalidateParent() | |
694 | If Parent Is Nothing Then Return | |
695 | ||
696 | For Each C As Control In Parent.Controls | |
697 | If Not (C Is Me) AndAlso (TypeOf C Is NSRadioButton) Then | |
698 | DirectCast(C, NSRadioButton).Checked = False | |
699 | End If | |
700 | Next | |
701 | End Sub | |
702 | ||
703 | Private GP1 As GraphicsPath | |
704 | ||
705 | Private SZ1 As SizeF | |
706 | Private PT1 As PointF | |
707 | ||
708 | Private P1, P2 As Pen | |
709 | ||
710 | Private PB1 As PathGradientBrush | |
711 | ||
712 | Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs) | |
713 | G = e.Graphics | |
714 | G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit | |
715 | ||
716 | G.Clear(BackColor) | |
717 | G.SmoothingMode = SmoothingMode.AntiAlias | |
718 | ||
719 | GP1 = New GraphicsPath | |
720 | GP1.AddEllipse(0, 2, Height - 5, Height - 5) | |
721 | ||
722 | PB1 = New PathGradientBrush(GP1) | |
723 | PB1.CenterColor = Color.FromArgb(50, 50, 50) | |
724 | PB1.SurroundColors = {Color.FromArgb(45, 45, 45)} | |
725 | PB1.FocusScales = New PointF(0.3F, 0.3F) | |
726 | ||
727 | G.FillPath(PB1, GP1) | |
728 | ||
729 | G.DrawEllipse(P1, 0, 2, Height - 5, Height - 5) | |
730 | G.DrawEllipse(P2, 1, 3, Height - 7, Height - 7) | |
731 | ||
732 | If _Checked Then | |
733 | G.FillEllipse(Brushes.Black, 6, 8, Height - 15, Height - 15) | |
734 | G.FillEllipse(Brushes.White, 5, 7, Height - 15, Height - 15) | |
735 | End If | |
736 | ||
737 | SZ1 = G.MeasureString(Text, Font) | |
738 | PT1 = New PointF(Height - 3, Height \ 2 - SZ1.Height / 2) | |
739 | ||
740 | G.DrawString(Text, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1) | |
741 | G.DrawString(Text, Font, Brushes.White, PT1) | |
742 | End Sub | |
743 | ||
744 | Protected Overrides Sub OnMouseDown(e As MouseEventArgs) | |
745 | Checked = True | |
746 | MyBase.OnMouseDown(e) | |
747 | End Sub | |
748 | ||
749 | End Class | |
750 | ||
751 | Class NSComboBox | |
752 | Inherits ComboBox | |
753 | ||
754 | Sub New() | |
755 | SetStyle(DirectCast(139286, ControlStyles), True) | |
756 | SetStyle(ControlStyles.Selectable, False) | |
757 | ||
758 | DrawMode = Windows.Forms.DrawMode.OwnerDrawFixed | |
759 | DropDownStyle = ComboBoxStyle.DropDownList | |
760 | ||
761 | BackColor = Color.FromArgb(50, 50, 50) | |
762 | ForeColor = Color.White | |
763 | ||
764 | P1 = New Pen(Color.FromArgb(35, 35, 35)) | |
765 | P2 = New Pen(Color.White, 2.0F) | |
766 | P3 = New Pen(Brushes.Black, 2.0F) | |
767 | P4 = New Pen(Color.FromArgb(65, 65, 65)) | |
768 | ||
769 | B1 = New SolidBrush(Color.FromArgb(65, 65, 65)) | |
770 | B2 = New SolidBrush(Color.FromArgb(55, 55, 55)) | |
771 | End Sub | |
772 | ||
773 | Private GP1, GP2 As GraphicsPath | |
774 | ||
775 | Private SZ1 As SizeF | |
776 | Private PT1 As PointF | |
777 | ||
778 | Private P1, P2, P3, P4 As Pen | |
779 | Private B1, B2 As SolidBrush | |
780 | ||
781 | Private GB1 As LinearGradientBrush | |
782 | ||
783 | Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs) | |
784 | G = e.Graphics | |
785 | G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit | |
786 | ||
787 | G.Clear(BackColor) | |
788 | G.SmoothingMode = SmoothingMode.AntiAlias | |
789 | ||
790 | GP1 = CreateRound(0, 0, Width - 1, Height - 1, 7) | |
791 | GP2 = CreateRound(1, 1, Width - 3, Height - 3, 7) | |
792 | ||
793 | GB1 = New LinearGradientBrush(ClientRectangle, Color.FromArgb(60, 60, 60), Color.FromArgb(55, 55, 55), 90.0F) | |
794 | G.SetClip(GP1) | |
795 | G.FillRectangle(GB1, ClientRectangle) | |
796 | G.ResetClip() | |
797 | ||
798 | G.DrawPath(P1, GP1) | |
799 | G.DrawPath(P4, GP2) | |
800 | ||
801 | SZ1 = G.MeasureString(Text, Font) | |
802 | PT1 = New PointF(5, Height \ 2 - SZ1.Height / 2) | |
803 | ||
804 | G.DrawString(Text, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1) | |
805 | G.DrawString(Text, Font, Brushes.White, PT1) | |
806 | ||
807 | G.DrawLine(P3, Width - 15, 10, Width - 11, 13) | |
808 | G.DrawLine(P3, Width - 7, 10, Width - 11, 13) | |
809 | G.DrawLine(Pens.Black, Width - 11, 13, Width - 11, 14) | |
810 | ||
811 | G.DrawLine(P2, Width - 16, 9, Width - 12, 12) | |
812 | G.DrawLine(P2, Width - 8, 9, Width - 12, 12) | |
813 | G.DrawLine(Pens.White, Width - 12, 12, Width - 12, 13) | |
814 | ||
815 | G.DrawLine(P1, Width - 22, 0, Width - 22, Height) | |
816 | G.DrawLine(P4, Width - 23, 1, Width - 23, Height - 2) | |
817 | G.DrawLine(P4, Width - 21, 1, Width - 21, Height - 2) | |
818 | End Sub | |
819 | ||
820 | Protected Overrides Sub OnDrawItem(e As DrawItemEventArgs) | |
821 | e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit | |
822 | ||
823 | If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then | |
824 | e.Graphics.FillRectangle(B1, e.Bounds) | |
825 | Else | |
826 | e.Graphics.FillRectangle(B2, e.Bounds) | |
827 | End If | |
828 | ||
829 | If Not e.Index = -1 Then | |
830 | e.Graphics.DrawString(GetItemText(Items(e.Index)), e.Font, Brushes.White, e.Bounds) | |
831 | End If | |
832 | End Sub | |
833 | ||
834 | End Class | |
835 | ||
836 | Class NSTabControl | |
837 | Inherits TabControl | |
838 | ||
839 | Sub New() | |
840 | SetStyle(DirectCast(139286, ControlStyles), True) | |
841 | SetStyle(ControlStyles.Selectable, False) | |
842 | ||
843 | SizeMode = TabSizeMode.Fixed | |
844 | Alignment = TabAlignment.Left | |
845 | ItemSize = New Size(28, 115) | |
846 | ||
847 | DrawMode = TabDrawMode.OwnerDrawFixed | |
848 | ||
849 | P1 = New Pen(Color.FromArgb(55, 55, 55)) | |
850 | P2 = New Pen(Color.FromArgb(35, 35, 35)) | |
851 | P3 = New Pen(Color.FromArgb(45, 45, 45), 2) | |
852 | ||
853 | B1 = New SolidBrush(Color.FromArgb(50, 50, 50)) | |
854 | B2 = New SolidBrush(Color.FromArgb(35, 35, 35)) | |
855 | B3 = New SolidBrush(Color.FromArgb(205, 150, 0)) | |
856 | B4 = New SolidBrush(Color.FromArgb(65, 65, 65)) | |
857 | ||
858 | SF1 = New StringFormat() | |
859 | SF1.LineAlignment = StringAlignment.Center | |
860 | End Sub | |
861 | ||
862 | Protected Overrides Sub OnControlAdded(e As ControlEventArgs) | |
863 | If TypeOf e.Control Is TabPage Then | |
864 | e.Control.BackColor = Color.FromArgb(50, 50, 50) | |
865 | End If | |
866 | ||
867 | MyBase.OnControlAdded(e) | |
868 | End Sub | |
869 | ||
870 | Private GP1, GP2, GP3, GP4 As GraphicsPath | |
871 | ||
872 | Private R1, R2 As Rectangle | |
873 | ||
874 | Private P1, P2, P3 As Pen | |
875 | Private B1, B2, B3, B4 As SolidBrush | |
876 | ||
877 | Private PB1 As PathGradientBrush | |
878 | ||
879 | Private TP1 As TabPage | |
880 | Private SF1 As StringFormat | |
881 | ||
882 | Private Offset As Integer | |
883 | Private ItemHeight As Integer | |
884 | ||
885 | Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs) | |
886 | G = e.Graphics | |
887 | G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit | |
888 | ||
889 | G.Clear(Color.FromArgb(50, 50, 50)) | |
890 | G.SmoothingMode = SmoothingMode.AntiAlias | |
891 | ||
892 | ItemHeight = ItemSize.Height + 2 | |
893 | ||
894 | GP1 = CreateRound(0, 0, ItemHeight + 3, Height - 1, 7) | |
895 | GP2 = CreateRound(1, 1, ItemHeight + 3, Height - 3, 7) | |
896 | ||
897 | PB1 = New PathGradientBrush(GP1) | |
898 | PB1.CenterColor = Color.FromArgb(50, 50, 50) | |
899 | PB1.SurroundColors = {Color.FromArgb(45, 45, 45)} | |
900 | PB1.FocusScales = New PointF(0.8F, 0.95F) | |
901 | ||
902 | G.FillPath(PB1, GP1) | |
903 | ||
904 | G.DrawPath(P1, GP1) | |
905 | G.DrawPath(P2, GP2) | |
906 | ||
907 | For I As Integer = 0 To TabCount - 1 | |
908 | R1 = GetTabRect(I) | |
909 | R1.Y += 2 | |
910 | R1.Height -= 3 | |
911 | R1.Width += 1 | |
912 | R1.X -= 1 | |
913 | ||
914 | TP1 = TabPages(I) | |
915 | Offset = 0 | |
916 | ||
917 | If SelectedIndex = I Then | |
918 | G.FillRectangle(B1, R1) | |
919 | ||
920 | For J As Integer = 0 To 1 | |
921 | G.FillRectangle(B2, R1.X + 5 + (J * 5), R1.Y + 6, 2, R1.Height - 9) | |
922 | ||
923 | G.SmoothingMode = SmoothingMode.None | |
924 | G.FillRectangle(B3, R1.X + 5 + (J * 5), R1.Y + 5, 2, R1.Height - 9) | |
925 | G.SmoothingMode = SmoothingMode.AntiAlias | |
926 | ||
927 | Offset += 5 | |
928 | Next | |
929 | ||
930 | G.DrawRectangle(P3, R1.X + 1, R1.Y - 1, R1.Width, R1.Height + 2) | |
931 | G.DrawRectangle(P1, R1.X + 1, R1.Y + 1, R1.Width - 2, R1.Height - 2) | |
932 | G.DrawRectangle(P2, R1) | |
933 | Else | |
934 | For J As Integer = 0 To 1 | |
935 | G.FillRectangle(B2, R1.X + 5 + (J * 5), R1.Y + 6, 2, R1.Height - 9) | |
936 | ||
937 | G.SmoothingMode = SmoothingMode.None | |
938 | G.FillRectangle(B4, R1.X + 5 + (J * 5), R1.Y + 5, 2, R1.Height - 9) | |
939 | G.SmoothingMode = SmoothingMode.AntiAlias | |
940 | ||
941 | Offset += 5 | |
942 | Next | |
943 | End If | |
944 | ||
945 | R1.X += 5 + Offset | |
946 | ||
947 | R2 = R1 | |
948 | R2.Y += 1 | |
949 | R2.X += 1 | |
950 | ||
951 | G.DrawString(TP1.Text, Font, Brushes.Black, R2, SF1) | |
952 | G.DrawString(TP1.Text, Font, Brushes.White, R1, SF1) | |
953 | Next | |
954 | ||
955 | GP3 = CreateRound(ItemHeight, 0, Width - ItemHeight - 1, Height - 1, 7) | |
956 | GP4 = CreateRound(ItemHeight + 1, 1, Width - ItemHeight - 3, Height - 3, 7) | |
957 | ||
958 | G.DrawPath(P2, GP3) | |
959 | G.DrawPath(P1, GP4) | |
960 | End Sub | |
961 | ||
962 | End Class | |
963 | ||
964 | <DefaultEvent("CheckedChanged")> _ | |
965 | Class NSOnOffBox | |
966 | Inherits Control | |
967 | ||
968 | Event CheckedChanged(sender As Object) | |
969 | ||
970 | Sub New() | |
971 | SetStyle(DirectCast(139286, ControlStyles), True) | |
972 | SetStyle(ControlStyles.Selectable, False) | |
973 | ||
974 | P1 = New Pen(Color.FromArgb(55, 55, 55)) | |
975 | P2 = New Pen(Color.FromArgb(35, 35, 35)) | |
976 | P3 = New Pen(Color.FromArgb(65, 65, 65)) | |
977 | ||
978 | B1 = New SolidBrush(Color.FromArgb(35, 35, 35)) | |
979 | B2 = New SolidBrush(Color.FromArgb(85, 85, 85)) | |
980 | B3 = New SolidBrush(Color.FromArgb(65, 65, 65)) | |
981 | B4 = New SolidBrush(Color.FromArgb(205, 150, 0)) | |
982 | B5 = New SolidBrush(Color.FromArgb(40, 40, 40)) | |
983 | ||
984 | SF1 = New StringFormat() | |
985 | SF1.LineAlignment = StringAlignment.Center | |
986 | SF1.Alignment = StringAlignment.Near | |
987 | ||
988 | SF2 = New StringFormat() | |
989 | SF2.LineAlignment = StringAlignment.Center | |
990 | SF2.Alignment = StringAlignment.Far | |
991 | End Sub | |
992 | ||
993 | Private _Checked As Boolean | |
994 | Public Property Checked() As Boolean | |
995 | Get | |
996 | Return _Checked | |
997 | End Get | |
998 | Set(ByVal value As Boolean) | |
999 | _Checked = value | |
1000 | RaiseEvent CheckedChanged(Me) | |
1001 | ||
1002 | Invalidate() | |
1003 | End Set | |
1004 | End Property | |
1005 | ||
1006 | Private GP1, GP2, GP3, GP4 As GraphicsPath | |
1007 | ||
1008 | Private P1, P2, P3 As Pen | |
1009 | Private B1, B2, B3, B4, B5 As SolidBrush | |
1010 | ||
1011 | Private PB1 As PathGradientBrush | |
1012 | Private GB1 As LinearGradientBrush | |
1013 | ||
1014 | Private R1, R2, R3 As Rectangle | |
1015 | Private SF1, SF2 As StringFormat | |
1016 | ||
1017 | Private Offset As Integer | |
1018 | ||
1019 | Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs) | |
1020 | G = e.Graphics | |
1021 | G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit | |
1022 | ||
1023 | G.Clear(BackColor) | |
1024 | G.SmoothingMode = SmoothingMode.AntiAlias | |
1025 | ||
1026 | GP1 = CreateRound(0, 0, Width - 1, Height - 1, 7) | |
1027 | GP2 = CreateRound(1, 1, Width - 3, Height - 3, 7) | |
1028 | ||
1029 | PB1 = New PathGradientBrush(GP1) | |
1030 | PB1.CenterColor = Color.FromArgb(50, 50, 50) | |
1031 | PB1.SurroundColors = {Color.FromArgb(45, 45, 45)} | |
1032 | PB1.FocusScales = New PointF(0.3F, 0.3F) | |
1033 | ||
1034 | G.FillPath(PB1, GP1) | |
1035 | G.DrawPath(P1, GP1) | |
1036 | G.DrawPath(P2, GP2) | |
1037 | ||
1038 | R1 = New Rectangle(5, 0, Width - 10, Height + 2) | |
1039 | R2 = New Rectangle(6, 1, Width - 10, Height + 2) | |
1040 | ||
1041 | R3 = New Rectangle(1, 1, (Width \ 2) - 1, Height - 3) | |
1042 | ||
1043 | If _Checked Then | |
1044 | G.DrawString("On", Font, Brushes.Black, R2, SF1) | |
1045 | G.DrawString("On", Font, Brushes.White, R1, SF1) | |
1046 | ||
1047 | R3.X += (Width \ 2) - 1 | |
1048 | Else | |
1049 | G.DrawString("Off", Font, B1, R2, SF2) | |
1050 | G.DrawString("Off", Font, B2, R1, SF2) | |
1051 | End If | |
1052 | ||
1053 | GP3 = CreateRound(R3, 7) | |
1054 | GP4 = CreateRound(R3.X + 1, R3.Y + 1, R3.Width - 2, R3.Height - 2, 7) | |
1055 | ||
1056 | GB1 = New LinearGradientBrush(ClientRectangle, Color.FromArgb(60, 60, 60), Color.FromArgb(55, 55, 55), 90.0F) | |
1057 | ||
1058 | G.FillPath(GB1, GP3) | |
1059 | G.DrawPath(P2, GP3) | |
1060 | G.DrawPath(P3, GP4) | |
1061 | ||
1062 | Offset = R3.X + (R3.Width \ 2) - 3 | |
1063 | ||
1064 | For I As Integer = 0 To 1 | |
1065 | If _Checked Then | |
1066 | G.FillRectangle(B1, Offset + (I * 5), 7, 2, Height - 14) | |
1067 | Else | |
1068 | G.FillRectangle(B3, Offset + (I * 5), 7, 2, Height - 14) | |
1069 | End If | |
1070 | ||
1071 | G.SmoothingMode = SmoothingMode.None | |
1072 | ||
1073 | If _Checked Then | |
1074 | G.FillRectangle(B4, Offset + (I * 5), 7, 2, Height - 14) | |
1075 | Else | |
1076 | G.FillRectangle(B5, Offset + (I * 5), 7, 2, Height - 14) | |
1077 | End If | |
1078 | ||
1079 | G.SmoothingMode = SmoothingMode.AntiAlias | |
1080 | Next | |
1081 | End Sub | |
1082 | ||
1083 | Protected Overrides Sub OnMouseDown(e As MouseEventArgs) | |
1084 | Checked = Not Checked | |
1085 | MyBase.OnMouseDown(e) | |
1086 | End Sub | |
1087 | ||
1088 | End Class | |
1089 | ||
1090 | Class NSControlButton | |
1091 | Inherits Control | |
1092 | ||
1093 | Enum Button As Byte | |
1094 | None = 0 | |
1095 | Minimize = 1 | |
1096 | MaximizeRestore = 2 | |
1097 | Close = 3 | |
1098 | End Enum | |
1099 | ||
1100 | Private _ControlButton As Button = Button.Close | |
1101 | Public Property ControlButton() As Button | |
1102 | Get | |
1103 | Return _ControlButton | |
1104 | End Get | |
1105 | Set(ByVal value As Button) | |
1106 | _ControlButton = value | |
1107 | Invalidate() | |
1108 | End Set | |
1109 | End Property | |
1110 | ||
1111 | Sub New() | |
1112 | SetStyle(DirectCast(139286, ControlStyles), True) | |
1113 | SetStyle(ControlStyles.Selectable, False) | |
1114 | ||
1115 | Anchor = AnchorStyles.Top Or AnchorStyles.Right | |
1116 | ||
1117 | Width = 18 | |
1118 | Height = 20 | |
1119 | ||
1120 | MinimumSize = Size | |
1121 | MaximumSize = Size | |
1122 | ||
1123 | Margin = New Padding(0) | |
1124 | End Sub | |
1125 | ||
1126 | Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs) | |
1127 | G = e.Graphics | |
1128 | G.Clear(BackColor) | |
1129 | ||
1130 | Select Case _ControlButton | |
1131 | Case Button.Minimize | |
1132 | DrawMinimize(3, 10) | |
1133 | Case Button.MaximizeRestore | |
1134 | If FindForm().WindowState = FormWindowState.Normal Then | |
1135 | DrawMaximize(3, 5) | |
1136 | Else | |
1137 | DrawRestore(3, 4) | |
1138 | End If | |
1139 | Case Button.Close | |
1140 | DrawClose(4, 5) | |
1141 | End Select | |
1142 | End Sub | |
1143 | ||
1144 | Private Sub DrawMinimize(ByVal x As Integer, ByVal y As Integer) | |
1145 | G.FillRectangle(Brushes.White, x, y, 12, 5) | |
1146 | G.DrawRectangle(Pens.Black, x, y, 11, 4) | |
1147 | End Sub | |
1148 | ||
1149 | Private Sub DrawMaximize(ByVal x As Integer, ByVal y As Integer) | |
1150 | G.DrawRectangle(New Pen(Color.White, 2), x + 2, y + 2, 8, 6) | |
1151 | G.DrawRectangle(Pens.Black, x, y, 11, 9) | |
1152 | G.DrawRectangle(Pens.Black, x + 3, y + 3, 5, 3) | |
1153 | End Sub | |
1154 | ||
1155 | Private Sub DrawRestore(ByVal x As Integer, ByVal y As Integer) | |
1156 | G.FillRectangle(Brushes.White, x + 3, y + 1, 8, 4) | |
1157 | G.FillRectangle(Brushes.White, x + 7, y + 5, 4, 4) | |
1158 | G.DrawRectangle(Pens.Black, x + 2, y + 0, 9, 9) | |
1159 | ||
1160 | G.FillRectangle(Brushes.White, x + 1, y + 3, 2, 6) | |
1161 | G.FillRectangle(Brushes.White, x + 1, y + 9, 8, 2) | |
1162 | G.DrawRectangle(Pens.Black, x, y + 2, 9, 9) | |
1163 | G.DrawRectangle(Pens.Black, x + 3, y + 5, 3, 3) | |
1164 | End Sub | |
1165 | ||
1166 | Private ClosePath As GraphicsPath | |
1167 | Private Sub DrawClose(ByVal x As Integer, ByVal y As Integer) | |
1168 | If ClosePath Is Nothing Then | |
1169 | ClosePath = New GraphicsPath | |
1170 | ClosePath.AddLine(x + 1, y, x + 3, y) | |
1171 | ClosePath.AddLine(x + 5, y + 2, x + 7, y) | |
1172 | ClosePath.AddLine(x + 9, y, x + 10, y + 1) | |
1173 | ClosePath.AddLine(x + 7, y + 4, x + 7, y + 5) | |
1174 | ClosePath.AddLine(x + 10, y + 8, x + 9, y + 9) | |
1175 | ClosePath.AddLine(x + 7, y + 9, x + 5, y + 7) | |
1176 | ClosePath.AddLine(x + 3, y + 9, x + 1, y + 9) | |
1177 | ClosePath.AddLine(x + 0, y + 8, x + 3, y + 5) | |
1178 | ClosePath.AddLine(x + 3, y + 4, x + 0, y + 1) | |
1179 | End If | |
1180 | ||
1181 | G.FillPath(Brushes.White, ClosePath) | |
1182 | G.DrawPath(Pens.Black, ClosePath) | |
1183 | End Sub | |
1184 | ||
1185 | Protected Overrides Sub OnMouseClick(ByVal e As MouseEventArgs) | |
1186 | If e.Button = Windows.Forms.MouseButtons.Left Then | |
1187 | ||
1188 | Dim F As Form = FindForm() | |
1189 | ||
1190 | Select Case _ControlButton | |
1191 | Case Button.Minimize | |
1192 | F.WindowState = FormWindowState.Minimized | |
1193 | Case Button.MaximizeRestore | |
1194 | If F.WindowState = FormWindowState.Normal Then | |
1195 | F.WindowState = FormWindowState.Maximized | |
1196 | Else | |
1197 | F.WindowState = FormWindowState.Normal | |
1198 | End If | |
1199 | Case Button.Close | |
1200 | F.Close() | |
1201 | End Select | |
1202 | ||
1203 | End If | |
1204 | ||
1205 | Invalidate() | |
1206 | MyBase.OnMouseClick(e) | |
1207 | End Sub | |
1208 | ||
1209 | End Class | |
1210 | ||
1211 | Class NSGroupBox | |
1212 | Inherits ContainerControl | |
1213 | ||
1214 | Private _DrawSeperator As Boolean | |
1215 | Public Property DrawSeperator() As Boolean | |
1216 | Get | |
1217 | Return _DrawSeperator | |
1218 | End Get | |
1219 | Set(ByVal value As Boolean) | |
1220 | _DrawSeperator = value | |
1221 | Invalidate() | |
1222 | End Set | |
1223 | End Property | |
1224 | ||
1225 | Private _Title As String = "GroupBox" | |
1226 | Public Property Title() As String | |
1227 | Get | |
1228 | Return _Title | |
1229 | End Get | |
1230 | Set(ByVal value As String) | |
1231 | _Title = value | |
1232 | Invalidate() | |
1233 | End Set | |
1234 | End Property | |
1235 | ||
1236 | Private _SubTitle As String = "Details" | |
1237 | Public Property SubTitle() As String | |
1238 | Get | |
1239 | Return _SubTitle | |
1240 | End Get | |
1241 | Set(ByVal value As String) | |
1242 | _SubTitle = value | |
1243 | Invalidate() | |
1244 | End Set | |
1245 | End Property | |
1246 | ||
1247 | Private _TitleFont As Font | |
1248 | Private _SubTitleFont As Font | |
1249 | ||
1250 | Sub New() | |
1251 | SetStyle(DirectCast(139286, ControlStyles), True) | |
1252 | SetStyle(ControlStyles.Selectable, False) | |
1253 | ||
1254 | _TitleFont = New Font("Verdana", 10.0F) | |
1255 | _SubTitleFont = New Font("Verdana", 6.5F) | |
1256 | ||
1257 | P1 = New Pen(Color.FromArgb(35, 35, 35)) | |
1258 | P2 = New Pen(Color.FromArgb(55, 55, 55)) | |
1259 | ||
1260 | B1 = New SolidBrush(Color.FromArgb(205, 150, 0)) | |
1261 | End Sub | |
1262 | ||
1263 | Private GP1, GP2 As GraphicsPath | |
1264 | ||
1265 | Private PT1 As PointF | |
1266 | Private SZ1, SZ2 As SizeF | |
1267 | ||
1268 | Private P1, P2 As Pen | |
1269 | Private B1 As SolidBrush | |
1270 | ||
1271 | Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs) | |
1272 | G = e.Graphics | |
1273 | G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit | |
1274 | ||
1275 | G.Clear(BackColor) | |
1276 | G.SmoothingMode = SmoothingMode.AntiAlias | |
1277 | ||
1278 | GP1 = CreateRound(0, 0, Width - 1, Height - 1, 7) | |
1279 | GP2 = CreateRound(1, 1, Width - 3, Height - 3, 7) | |
1280 | ||
1281 | G.DrawPath(P1, GP1) | |
1282 | G.DrawPath(P2, GP2) | |
1283 | ||
1284 | SZ1 = G.MeasureString(_Title, _TitleFont, Width, StringFormat.GenericTypographic) | |
1285 | SZ2 = G.MeasureString(_SubTitle, _SubTitleFont, Width, StringFormat.GenericTypographic) | |
1286 | ||
1287 | G.DrawString(_Title, _TitleFont, Brushes.Black, 6, 6) | |
1288 | G.DrawString(_Title, _TitleFont, B1, 5, 5) | |
1289 | ||
1290 | PT1 = New PointF(6.0F, SZ1.Height + 4.0F) | |
1291 | ||
1292 | G.DrawString(_SubTitle, _SubTitleFont, Brushes.Black, PT1.X + 1, PT1.Y + 1) | |
1293 | G.DrawString(_SubTitle, _SubTitleFont, Brushes.White, PT1.X, PT1.Y) | |
1294 | ||
1295 | If _DrawSeperator Then | |
1296 | Dim Y As Integer = CInt(PT1.Y + SZ2.Height) + 8 | |
1297 | ||
1298 | G.DrawLine(P1, 4, Y, Width - 5, Y) | |
1299 | G.DrawLine(P2, 4, Y + 1, Width - 5, Y + 1) | |
1300 | End If | |
1301 | End Sub | |
1302 | ||
1303 | End Class | |
1304 | ||
1305 | Class NSSeperator | |
1306 | Inherits Control | |
1307 | ||
1308 | Sub New() | |
1309 | SetStyle(DirectCast(139286, ControlStyles), True) | |
1310 | SetStyle(ControlStyles.Selectable, False) | |
1311 | ||
1312 | Height = 10 | |
1313 | ||
1314 | P1 = New Pen(Color.FromArgb(35, 35, 35)) | |
1315 | P2 = New Pen(Color.FromArgb(55, 55, 55)) | |
1316 | End Sub | |
1317 | ||
1318 | Private P1, P2 As Pen | |
1319 | ||
1320 | Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs) | |
1321 | G = e.Graphics | |
1322 | G.Clear(BackColor) | |
1323 | ||
1324 | G.DrawLine(P1, 0, 5, Width, 5) | |
1325 | G.DrawLine(P2, 0, 6, Width, 6) | |
1326 | End Sub | |
1327 | ||
1328 | End Class | |
1329 | ||
1330 | <DefaultEvent("Scroll")> _ | |
1331 | Class NSTrackBar | |
1332 | Inherits Control | |
1333 | ||
1334 | Event Scroll(ByVal sender As Object) | |
1335 | ||
1336 | Private _Minimum As Integer | |
1337 | Property Minimum() As Integer | |
1338 | Get | |
1339 | Return _Minimum | |
1340 | End Get | |
1341 | Set(ByVal value As Integer) | |
1342 | If value < 0 Then | |
1343 | Throw New Exception("Property value is not valid.") | |
1344 | End If | |
1345 | ||
1346 | _Minimum = value | |
1347 | If value > _Value Then _Value = value | |
1348 | If value > _Maximum Then _Maximum = value | |
1349 | Invalidate() | |
1350 | End Set | |
1351 | End Property | |
1352 | ||
1353 | Private _Maximum As Integer = 10 | |
1354 | Property Maximum() As Integer | |
1355 | Get | |
1356 | Return _Maximum | |
1357 | End Get | |
1358 | Set(ByVal value As Integer) | |
1359 | If value < 0 Then | |
1360 | Throw New Exception("Property value is not valid.") | |
1361 | End If | |
1362 | ||
1363 | _Maximum = value | |
1364 | If value < _Value Then _Value = value | |
1365 | If value < _Minimum Then _Minimum = value | |
1366 | Invalidate() | |
1367 | End Set | |
1368 | End Property | |
1369 | ||
1370 | Private _Value As Integer | |
1371 | Property Value() As Integer | |
1372 | Get | |
1373 | Return _Value | |
1374 | End Get | |
1375 | Set(ByVal value As Integer) | |
1376 | If value = _Value Then Return | |
1377 | ||
1378 | If value > _Maximum OrElse value < _Minimum Then | |
1379 | Throw New Exception("Property value is not valid.") | |
1380 | End If | |
1381 | ||
1382 | _Value = value | |
1383 | Invalidate() | |
1384 | ||
1385 | RaiseEvent Scroll(Me) | |
1386 | End Set | |
1387 | End Property | |
1388 | ||
1389 | Sub New() | |
1390 | SetStyle(DirectCast(139286, ControlStyles), True) | |
1391 | SetStyle(ControlStyles.Selectable, False) | |
1392 | ||
1393 | Height = 17 | |
1394 | ||
1395 | P1 = New Pen(Color.FromArgb(150, 110, 0), 2) | |
1396 | P2 = New Pen(Color.FromArgb(55, 55, 55)) | |
1397 | P3 = New Pen(Color.FromArgb(35, 35, 35)) | |
1398 | P4 = New Pen(Color.FromArgb(65, 65, 65)) | |
1399 | End Sub | |
1400 | ||
1401 | Private GP1, GP2, GP3, GP4 As GraphicsPath | |
1402 | ||
1403 | Private R1, R2, R3 As Rectangle | |
1404 | Private I1 As Integer | |
1405 | ||
1406 | Private P1, P2, P3, P4 As Pen | |
1407 | ||
1408 | Private GB1, GB2, GB3 As LinearGradientBrush | |
1409 | ||
1410 | Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs) | |
1411 | G = e.Graphics | |
1412 | ||
1413 | G.Clear(BackColor) | |
1414 | G.SmoothingMode = SmoothingMode.AntiAlias | |
1415 | ||
1416 | GP1 = CreateRound(0, 5, Width - 1, 10, 5) | |
1417 | GP2 = CreateRound(1, 6, Width - 3, 8, 5) | |
1418 | ||
1419 | R1 = New Rectangle(0, 7, Width - 1, 5) | |
1420 | GB1 = New LinearGradientBrush(R1, Color.FromArgb(45, 45, 45), Color.FromArgb(50, 50, 50), 90.0F) | |
1421 | ||
1422 | I1 = CInt((_Value - _Minimum) / (_Maximum - _Minimum) * (Width - 11)) | |
1423 | R2 = New Rectangle(I1, 0, 10, 20) | |
1424 | ||
1425 | G.SetClip(GP2) | |
1426 | G.FillRectangle(GB1, R1) | |
1427 | ||
1428 | R3 = New Rectangle(1, 7, R2.X + R2.Width - 2, 8) | |
1429 | GB2 = New LinearGradientBrush(R3, Color.FromArgb(205, 150, 0), Color.FromArgb(150, 110, 0), 90.0F) | |
1430 | ||
1431 | G.SmoothingMode = SmoothingMode.None | |
1432 | G.FillRectangle(GB2, R3) | |
1433 | G.SmoothingMode = SmoothingMode.AntiAlias | |
1434 | ||
1435 | For I As Integer = 0 To R3.Width - 15 Step 5 | |
1436 | G.DrawLine(P1, I, 0, I + 15, Height) | |
1437 | Next | |
1438 | ||
1439 | G.ResetClip() | |
1440 | ||
1441 | G.DrawPath(P2, GP1) | |
1442 | G.DrawPath(P3, GP2) | |
1443 | ||
1444 | GP3 = CreateRound(R2, 5) | |
1445 | GP4 = CreateRound(R2.X + 1, R2.Y + 1, R2.Width - 2, R2.Height - 2, 5) | |
1446 | GB3 = New LinearGradientBrush(ClientRectangle, Color.FromArgb(60, 60, 60), Color.FromArgb(55, 55, 55), 90.0F) | |
1447 | ||
1448 | G.FillPath(GB3, GP3) | |
1449 | G.DrawPath(P3, GP3) | |
1450 | G.DrawPath(P4, GP4) | |
1451 | End Sub | |
1452 | ||
1453 | Private TrackDown As Boolean | |
1454 | Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs) | |
1455 | If e.Button = Windows.Forms.MouseButtons.Left Then | |
1456 | I1 = CInt((_Value - _Minimum) / (_Maximum - _Minimum) * (Width - 11)) | |
1457 | R2 = New Rectangle(I1, 0, 10, 20) | |
1458 | ||
1459 | TrackDown = R2.Contains(e.Location) | |
1460 | End If | |
1461 | ||
1462 | MyBase.OnMouseDown(e) | |
1463 | End Sub | |
1464 | ||
1465 | Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs) | |
1466 | If TrackDown AndAlso e.X > -1 AndAlso e.X < (Width + 1) Then | |
1467 | Value = _Minimum + CInt((_Maximum - _Minimum) * (e.X / Width)) | |
1468 | End If | |
1469 | ||
1470 | MyBase.OnMouseMove(e) | |
1471 | End Sub | |
1472 | ||
1473 | Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs) | |
1474 | TrackDown = False | |
1475 | MyBase.OnMouseUp(e) | |
1476 | End Sub | |
1477 | ||
1478 | End Class | |
1479 | ||
1480 | <DefaultEvent("ValueChanged")> _ | |
1481 | Class NSRandomPool | |
1482 | Inherits Control | |
1483 | ||
1484 | Event ValueChanged(ByVal sender As Object) | |
1485 | ||
1486 | Private _Value As New StringBuilder | |
1487 | ReadOnly Property Value() As String | |
1488 | Get | |
1489 | Return _Value.ToString() | |
1490 | End Get | |
1491 | End Property | |
1492 | ||
1493 | Private _FullValue As String | |
1494 | ReadOnly Property FullValue() As String | |
1495 | Get | |
1496 | Return BitConverter.ToString(Table).Replace("-", "") | |
1497 | End Get | |
1498 | End Property | |
1499 | ||
1500 | Private RNG As New Random() | |
1501 | ||
1502 | Private ItemSize As Integer = 9 | |
1503 | Private DrawSize As Integer = 8 | |
1504 | ||
1505 | Private WA As Rectangle | |
1506 | ||
1507 | Private RowSize As Integer | |
1508 | Private ColumnSize As Integer | |
1509 | ||
1510 | Sub New() | |
1511 | SetStyle(DirectCast(139286, ControlStyles), True) | |
1512 | SetStyle(ControlStyles.Selectable, False) | |
1513 | ||
1514 | P1 = New Pen(Color.FromArgb(55, 55, 55)) | |
1515 | P2 = New Pen(Color.FromArgb(35, 35, 35)) | |
1516 | ||
1517 | B1 = New SolidBrush(Color.FromArgb(30, 30, 30)) | |
1518 | End Sub | |
1519 | ||
1520 | Protected Overrides Sub OnHandleCreated(e As EventArgs) | |
1521 | UpdateTable() | |
1522 | MyBase.OnHandleCreated(e) | |
1523 | End Sub | |
1524 | ||
1525 | Private Table As Byte() | |
1526 | Private Sub UpdateTable() | |
1527 | WA = New Rectangle(5, 5, Width - 10, Height - 10) | |
1528 | ||
1529 | RowSize = WA.Width \ ItemSize | |
1530 | ColumnSize = WA.Height \ ItemSize | |
1531 | ||
1532 | WA.Width = RowSize * ItemSize | |
1533 | WA.Height = ColumnSize * ItemSize | |
1534 | ||
1535 | WA.X = (Width \ 2) - (WA.Width \ 2) | |
1536 | WA.Y = (Height \ 2) - (WA.Height \ 2) | |
1537 | ||
1538 | Table = New Byte((RowSize * ColumnSize) - 1) {} | |
1539 | ||
1540 | For I As Integer = 0 To Table.Length - 1 | |
1541 | Table(I) = CByte(RNG.Next(100)) | |
1542 | Next | |
1543 | ||
1544 | Invalidate() | |
1545 | End Sub | |
1546 | ||
1547 | Protected Overrides Sub OnSizeChanged(e As EventArgs) | |
1548 | UpdateTable() | |
1549 | End Sub | |
1550 | ||
1551 | Private Index1 As Integer = -1 | |
1552 | Private Index2 As Integer | |
1553 | ||
1554 | Private InvertColors As Boolean | |
1555 | ||
1556 | Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs) | |
1557 | HandleDraw(e) | |
1558 | End Sub | |
1559 | ||
1560 | Protected Overrides Sub OnMouseDown(e As MouseEventArgs) | |
1561 | HandleDraw(e) | |
1562 | MyBase.OnMouseDown(e) | |
1563 | End Sub | |
1564 | ||
1565 | Private Sub HandleDraw(e As MouseEventArgs) | |
1566 | If e.Button = Windows.Forms.MouseButtons.Left OrElse e.Button = Windows.Forms.MouseButtons.Right Then | |
1567 | If Not WA.Contains(e.Location) Then Return | |
1568 | ||
1569 | InvertColors = (e.Button = Windows.Forms.MouseButtons.Right) | |
1570 | ||
1571 | Index1 = GetIndex(e.X, e.Y) | |
1572 | If Index1 = Index2 Then Return | |
1573 | ||
1574 | Dim L As Boolean = Not (Index1 Mod RowSize = 0) | |
1575 | Dim R As Boolean = Not (Index1 Mod RowSize = (RowSize - 1)) | |
1576 | ||
1577 | Randomize(Index1 - RowSize) | |
1578 | If L Then Randomize(Index1 - 1) | |
1579 | Randomize(Index1) | |
1580 | If R Then Randomize(Index1 + 1) | |
1581 | Randomize(Index1 + RowSize) | |
1582 | ||
1583 | _Value.Append(Table(Index1).ToString("X")) | |
1584 | If _Value.Length > 32 Then _Value.Remove(0, 2) | |
1585 | ||
1586 | RaiseEvent ValueChanged(Me) | |
1587 | ||
1588 | Index2 = Index1 | |
1589 | Invalidate() | |
1590 | End If | |
1591 | End Sub | |
1592 | ||
1593 | Private GP1, GP2 As GraphicsPath | |
1594 | ||
1595 | Private P1, P2 As Pen | |
1596 | Private B1, B2 As SolidBrush | |
1597 | ||
1598 | Private PB1 As PathGradientBrush | |
1599 | ||
1600 | Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs) | |
1601 | G = e.Graphics | |
1602 | ||
1603 | G.Clear(BackColor) | |
1604 | G.SmoothingMode = SmoothingMode.AntiAlias | |
1605 | ||
1606 | GP1 = CreateRound(0, 0, Width - 1, Height - 1, 7) | |
1607 | GP2 = CreateRound(1, 1, Width - 3, Height - 3, 7) | |
1608 | ||
1609 | PB1 = New PathGradientBrush(GP1) | |
1610 | PB1.CenterColor = Color.FromArgb(50, 50, 50) | |
1611 | PB1.SurroundColors = {Color.FromArgb(45, 45, 45)} | |
1612 | PB1.FocusScales = New PointF(0.9F, 0.5F) | |
1613 | ||
1614 | G.FillPath(PB1, GP1) | |
1615 | ||
1616 | G.DrawPath(P1, GP1) | |
1617 | G.DrawPath(P2, GP2) | |
1618 | ||
1619 | G.SmoothingMode = SmoothingMode.None | |
1620 | ||
1621 | For I As Integer = 0 To Table.Length - 1 | |
1622 | Dim C As Integer = Math.Max(Table(I), 75) | |
1623 | ||
1624 | Dim X As Integer = ((I Mod RowSize) * ItemSize) + WA.X | |
1625 | Dim Y As Integer = ((I \ RowSize) * ItemSize) + WA.Y | |
1626 | ||
1627 | B2 = New SolidBrush(Color.FromArgb(C, C, C)) | |
1628 | ||
1629 | G.FillRectangle(B1, X + 1, Y + 1, DrawSize, DrawSize) | |
1630 | G.FillRectangle(B2, X, Y, DrawSize, DrawSize) | |
1631 | ||
1632 | B2.Dispose() | |
1633 | Next | |
1634 | ||
1635 | End Sub | |
1636 | ||
1637 | Private Function GetIndex(ByVal x As Integer, ByVal y As Integer) As Integer | |
1638 | Return (((y - WA.Y) \ ItemSize) * RowSize) + ((x - WA.X) \ ItemSize) | |
1639 | End Function | |
1640 | ||
1641 | Private Sub Randomize(ByVal index As Integer) | |
1642 | If index > -1 AndAlso index < Table.Length Then | |
1643 | If InvertColors Then | |
1644 | Table(index) = CByte(RNG.Next(100)) | |
1645 | Else | |
1646 | Table(index) = CByte(RNG.Next(100, 256)) | |
1647 | End If | |
1648 | End If | |
1649 | End Sub | |
1650 | ||
1651 | End Class | |
1652 | ||
1653 | Class NSKeyboard | |
1654 | Inherits Control | |
1655 | ||
1656 | Private TextBitmap As Bitmap | |
1657 | Private TextGraphics As Graphics | |
1658 | ||
1659 | Const LowerKeys As String = "1234567890-=qwertyuiop[]asdfghjkl\;'zxcvbnm,./`" | |
1660 | Const UpperKeys As String = "!@#$%^&*()_+QWERTYUIOP{}ASDFGHJKL|:""ZXCVBNM<>?~" | |
1661 | ||
1662 | Sub New() | |
1663 | SetStyle(DirectCast(139286, ControlStyles), True) | |
1664 | SetStyle(ControlStyles.Selectable, False) | |
1665 | ||
1666 | Font = New Font("Verdana", 8.25F) | |
1667 | ||
1668 | TextBitmap = New Bitmap(1, 1) | |
1669 | TextGraphics = Graphics.FromImage(TextBitmap) | |
1670 | ||
1671 | MinimumSize = New Size(386, 162) | |
1672 | MaximumSize = New Size(386, 162) | |
1673 | ||
1674 | Lower = LowerKeys.ToCharArray() | |
1675 | Upper = UpperKeys.ToCharArray() | |
1676 | ||
1677 | PrepareCache() | |
1678 | ||
1679 | P1 = New Pen(Color.FromArgb(45, 45, 45)) | |
1680 | P2 = New Pen(Color.FromArgb(65, 65, 65)) | |
1681 | P3 = New Pen(Color.FromArgb(35, 35, 35)) | |
1682 | ||
1683 | B1 = New SolidBrush(Color.FromArgb(100, 100, 100)) | |
1684 | End Sub | |
1685 | ||
1686 | Private _Target As Control | |
1687 | Public Property Target() As Control | |
1688 | Get | |
1689 | Return _Target | |
1690 | End Get | |
1691 | Set(ByVal value As Control) | |
1692 | _Target = value | |
1693 | End Set | |
1694 | End Property | |
1695 | ||
1696 | Private Shift As Boolean | |
1697 | ||
1698 | Private Pressed As Integer = -1 | |
1699 | Private Buttons As Rectangle() | |
1700 | ||
1701 | Private Lower As Char() | |
1702 | Private Upper As Char() | |
1703 | Private Other As String() = {"Shift", "Space", "Back"} | |
1704 | ||
1705 | Private UpperCache As PointF() | |
1706 | Private LowerCache As PointF() | |
1707 | ||
1708 | Private Sub PrepareCache() | |
1709 | Buttons = New Rectangle(50) {} | |
1710 | UpperCache = New PointF(Upper.Length - 1) {} | |
1711 | LowerCache = New PointF(Lower.Length - 1) {} | |
1712 | ||
1713 | Dim I As Integer | |
1714 | ||
1715 | Dim S As SizeF | |
1716 | Dim R As Rectangle | |
1717 | ||
1718 | For Y As Integer = 0 To 3 | |
1719 | For X As Integer = 0 To 11 | |
1720 | I = (Y * 12) + X | |
1721 | R = New Rectangle(X * 32, Y * 32, 32, 32) | |
1722 | ||
1723 | Buttons(I) = R | |
1724 | ||
1725 | If Not I = 47 AndAlso Not Char.IsLetter(Upper(I)) Then | |
1726 | S = TextGraphics.MeasureString(Upper(I), Font) | |
1727 | UpperCache(I) = New PointF(R.X + (R.Width \ 2 - S.Width / 2), R.Y + R.Height - S.Height - 2) | |
1728 | ||
1729 | S = TextGraphics.MeasureString(Lower(I), Font) | |
1730 | LowerCache(I) = New PointF(R.X + (R.Width \ 2 - S.Width / 2), R.Y + R.Height - S.Height - 2) | |
1731 | End If | |
1732 | Next | |
1733 | Next | |
1734 | ||
1735 | Buttons(48) = New Rectangle(0, 4 * 32, 2 * 32, 32) | |
1736 | Buttons(49) = New Rectangle(Buttons(48).Right, 4 * 32, 8 * 32, 32) | |
1737 | Buttons(50) = New Rectangle(Buttons(49).Right, 4 * 32, 2 * 32, 32) | |
1738 | End Sub | |
1739 | ||
1740 | Private GP1 As GraphicsPath | |
1741 | ||
1742 | Private SZ1 As SizeF | |
1743 | Private PT1 As PointF | |
1744 | ||
1745 | Private P1, P2, P3 As Pen | |
1746 | Private B1 As SolidBrush | |
1747 | ||
1748 | Private PB1 As PathGradientBrush | |
1749 | Private GB1 As LinearGradientBrush | |
1750 | ||
1751 | Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs) | |
1752 | G = e.Graphics | |
1753 | G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit | |
1754 | ||
1755 | G.Clear(BackColor) | |
1756 | ||
1757 | Dim R As Rectangle | |
1758 | ||
1759 | Dim Offset As Integer | |
1760 | G.DrawRectangle(P1, 0, 0, (12 * 32) + 1, (5 * 32) + 1) | |
1761 | ||
1762 | For I As Integer = 0 To Buttons.Length - 1 | |
1763 | R = Buttons(I) | |
1764 | ||
1765 | Offset = 0 | |
1766 | If I = Pressed Then | |
1767 | Offset = 1 | |
1768 | ||
1769 | GP1 = New GraphicsPath() | |
1770 | GP1.AddRectangle(R) | |
1771 | ||
1772 | PB1 = New PathGradientBrush(GP1) | |
1773 | PB1.CenterColor = Color.FromArgb(60, 60, 60) | |
1774 | PB1.SurroundColors = {Color.FromArgb(55, 55, 55)} | |
1775 | PB1.FocusScales = New PointF(0.8F, 0.5F) | |
1776 | ||
1777 | G.FillPath(PB1, GP1) | |
1778 | Else | |
1779 | GB1 = New LinearGradientBrush(R, Color.FromArgb(60, 60, 60), Color.FromArgb(55, 55, 55), 90.0F) | |
1780 | G.FillRectangle(GB1, R) | |
1781 | End If | |
1782 | ||
1783 | Select Case I | |
1784 | Case 48, 49, 50 | |
1785 | SZ1 = G.MeasureString(Other(I - 48), Font) | |
1786 | G.DrawString(Other(I - 48), Font, Brushes.Black, R.X + (R.Width \ 2 - SZ1.Width / 2) + Offset + 1, R.Y + (R.Height \ 2 - SZ1.Height / 2) + Offset + 1) | |
1787 | G.DrawString(Other(I - 48), Font, Brushes.White, R.X + (R.Width \ 2 - SZ1.Width / 2) + Offset, R.Y + (R.Height \ 2 - SZ1.Height / 2) + Offset) | |
1788 | Case 47 | |
1789 | DrawArrow(Color.Black, R.X + Offset + 1, R.Y + Offset + 1) | |
1790 | DrawArrow(Color.White, R.X + Offset, R.Y + Offset) | |
1791 | Case Else | |
1792 | If Shift Then | |
1793 | G.DrawString(Upper(I), Font, Brushes.Black, R.X + 3 + Offset + 1, R.Y + 2 + Offset + 1) | |
1794 | G.DrawString(Upper(I), Font, Brushes.White, R.X + 3 + Offset, R.Y + 2 + Offset) | |
1795 | ||
1796 | If Not Char.IsLetter(Lower(I)) Then | |
1797 | PT1 = LowerCache(I) | |
1798 | G.DrawString(Lower(I), Font, B1, PT1.X + Offset, PT1.Y + Offset) | |
1799 | End If | |
1800 | Else | |
1801 | G.DrawString(Lower(I), Font, Brushes.Black, R.X + 3 + Offset + 1, R.Y + 2 + Offset + 1) | |
1802 | G.DrawString(Lower(I), Font, Brushes.White, R.X + 3 + Offset, R.Y + 2 + Offset) | |
1803 | ||
1804 | If Not Char.IsLetter(Upper(I)) Then | |
1805 | PT1 = UpperCache(I) | |
1806 | G.DrawString(Upper(I), Font, B1, PT1.X + Offset, PT1.Y + Offset) | |
1807 | End If | |
1808 | End If | |
1809 | End Select | |
1810 | ||
1811 | G.DrawRectangle(P2, R.X + 1 + Offset, R.Y + 1 + Offset, R.Width - 2, R.Height - 2) | |
1812 | G.DrawRectangle(P3, R.X + Offset, R.Y + Offset, R.Width, R.Height) | |
1813 | ||
1814 | If I = Pressed Then | |
1815 | G.DrawLine(P1, R.X, R.Y, R.Right, R.Y) | |
1816 | G.DrawLine(P1, R.X, R.Y, R.X, R.Bottom) | |
1817 | End If | |
1818 | Next | |
1819 | End Sub | |
1820 | ||
1821 | Private Sub DrawArrow(color As Color, rx As Integer, ry As Integer) | |
1822 | Dim R As New Rectangle(rx + 8, ry + 8, 16, 16) | |
1823 | G.SmoothingMode = SmoothingMode.AntiAlias | |
1824 | ||
1825 | Dim P As New Pen(color, 1) | |
1826 | Dim C As New AdjustableArrowCap(3, 2) | |
1827 | P.CustomEndCap = C | |
1828 | ||
1829 | G.DrawArc(P, R, 0.0F, 290.0F) | |
1830 | ||
1831 | P.Dispose() | |
1832 | C.Dispose() | |
1833 | G.SmoothingMode = SmoothingMode.None | |
1834 | End Sub | |
1835 | ||
1836 | Protected Overrides Sub OnMouseDown(e As MouseEventArgs) | |
1837 | Dim Index As Integer = ((e.Y \ 32) * 12) + (e.X \ 32) | |
1838 | ||
1839 | If Index > 47 Then | |
1840 | For I As Integer = 48 To Buttons.Length - 1 | |
1841 | If Buttons(I).Contains(e.X, e.Y) Then | |
1842 | Pressed = I | |
1843 | Exit For | |
1844 | End If | |
1845 | Next | |
1846 | Else | |
1847 | Pressed = Index | |
1848 | End If | |
1849 | ||
1850 | HandleKey() | |
1851 | Invalidate() | |
1852 | End Sub | |
1853 | ||
1854 | Protected Overrides Sub OnMouseUp(e As MouseEventArgs) | |
1855 | Pressed = -1 | |
1856 | Invalidate() | |
1857 | End Sub | |
1858 | ||
1859 | Private Sub HandleKey() | |
1860 | If _Target Is Nothing Then Return | |
1861 | If Pressed = -1 Then Return | |
1862 | ||
1863 | Select Case Pressed | |
1864 | Case 47 | |
1865 | _Target.Text = String.Empty | |
1866 | Case 48 | |
1867 | Shift = Not Shift | |
1868 | Case 49 | |
1869 | _Target.Text &= " " | |
1870 | Case 50 | |
1871 | If Not _Target.Text.Length = 0 Then | |
1872 | _Target.Text = _Target.Text.Remove(_Target.Text.Length - 1) | |
1873 | End If | |
1874 | Case Else | |
1875 | If Shift Then | |
1876 | _Target.Text &= Upper(Pressed) | |
1877 | Else | |
1878 | _Target.Text &= Lower(Pressed) | |
1879 | End If | |
1880 | End Select | |
1881 | End Sub | |
1882 | ||
1883 | End Class | |
1884 | ||
1885 | <DefaultEvent("SelectedIndexChanged")> _ | |
1886 | Class NSPaginator | |
1887 | Inherits Control | |
1888 | ||
1889 | Public Event SelectedIndexChanged(sender As Object, e As EventArgs) | |
1890 | ||
1891 | Private TextBitmap As Bitmap | |
1892 | Private TextGraphics As Graphics | |
1893 | ||
1894 | Sub New() | |
1895 | SetStyle(DirectCast(139286, ControlStyles), True) | |
1896 | SetStyle(ControlStyles.Selectable, False) | |
1897 | ||
1898 | Size = New Size(202, 26) | |
1899 | ||
1900 | TextBitmap = New Bitmap(1, 1) | |
1901 | TextGraphics = Graphics.FromImage(TextBitmap) | |
1902 | ||
1903 | InvalidateItems() | |
1904 | ||
1905 | B1 = New SolidBrush(Color.FromArgb(50, 50, 50)) | |
1906 | B2 = New SolidBrush(Color.FromArgb(55, 55, 55)) | |
1907 | ||
1908 | P1 = New Pen(Color.FromArgb(35, 35, 35)) | |
1909 | P2 = New Pen(Color.FromArgb(55, 55, 55)) | |
1910 | P3 = New Pen(Color.FromArgb(65, 65, 65)) | |
1911 | End Sub | |
1912 | ||
1913 | Private _SelectedIndex As Integer | |
1914 | Public Property SelectedIndex() As Integer | |
1915 | Get | |
1916 | Return _SelectedIndex | |
1917 | End Get | |
1918 | Set(ByVal value As Integer) | |
1919 | _SelectedIndex = Math.Max(Math.Min(value, MaximumIndex), 0) | |
1920 | Invalidate() | |
1921 | End Set | |
1922 | End Property | |
1923 | ||
1924 | Private _NumberOfPages As Integer | |
1925 | Public Property NumberOfPages() As Integer | |
1926 | Get | |
1927 | Return _NumberOfPages | |
1928 | End Get | |
1929 | Set(ByVal value As Integer) | |
1930 | _NumberOfPages = value | |
1931 | _SelectedIndex = Math.Max(Math.Min(_SelectedIndex, MaximumIndex), 0) | |
1932 | Invalidate() | |
1933 | End Set | |
1934 | End Property | |
1935 | ||
1936 | Public ReadOnly Property MaximumIndex As Integer | |
1937 | Get | |
1938 | Return NumberOfPages - 1 | |
1939 | End Get | |
1940 | End Property | |
1941 | ||
1942 | Private ItemWidth As Integer | |
1943 | ||
1944 | Public Overrides Property Font As Font | |
1945 | Get | |
1946 | Return MyBase.Font | |
1947 | End Get | |
1948 | Set(value As Font) | |
1949 | MyBase.Font = value | |
1950 | ||
1951 | InvalidateItems() | |
1952 | Invalidate() | |
1953 | End Set | |
1954 | End Property | |
1955 | ||
1956 | Private Sub InvalidateItems() | |
1957 | Dim S As Size = TextGraphics.MeasureString("000 ..", Font).ToSize() | |
1958 | ItemWidth = S.Width + 10 | |
1959 | End Sub | |
1960 | ||
1961 | Private GP1, GP2 As GraphicsPath | |
1962 | ||
1963 | Private R1 As Rectangle | |
1964 | ||
1965 | Private SZ1 As Size | |
1966 | Private PT1 As Point | |
1967 | ||
1968 | Private P1, P2, P3 As Pen | |
1969 | Private B1, B2 As SolidBrush | |
1970 | ||
1971 | Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs) | |
1972 | G = e.Graphics | |
1973 | G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit | |
1974 | ||
1975 | G.Clear(BackColor) | |
1976 | G.SmoothingMode = SmoothingMode.AntiAlias | |
1977 | ||
1978 | Dim LeftEllipse, RightEllipse As Boolean | |
1979 | ||
1980 | If _SelectedIndex < 4 Then | |
1981 | For I As Integer = 0 To Math.Min(MaximumIndex, 4) | |
1982 | RightEllipse = (I = 4) AndAlso (MaximumIndex > 4) | |
1983 | DrawBox(I * ItemWidth, I, False, RightEllipse) | |
1984 | Next | |
1985 | ElseIf _SelectedIndex > 3 AndAlso _SelectedIndex < (MaximumIndex - 3) Then | |
1986 | For I As Integer = 0 To 4 | |
1987 | LeftEllipse = (I = 0) | |
1988 | RightEllipse = (I = 4) | |
1989 | DrawBox(I * ItemWidth, _SelectedIndex + I - 2, LeftEllipse, RightEllipse) | |
1990 | Next | |
1991 | Else | |
1992 | For I As Integer = 0 To 4 | |
1993 | LeftEllipse = (I = 0) AndAlso (MaximumIndex > 4) | |
1994 | DrawBox(I * ItemWidth, MaximumIndex - (4 - I), LeftEllipse, False) | |
1995 | Next | |
1996 | End If | |
1997 | End Sub | |
1998 | ||
1999 | Private Sub DrawBox(x As Integer, index As Integer, leftEllipse As Boolean, rightEllipse As Boolean) | |
2000 | R1 = New Rectangle(x, 0, ItemWidth - 4, Height - 1) | |
2001 | ||
2002 | GP1 = CreateRound(R1, 7) | |
2003 | GP2 = CreateRound(R1.X + 1, R1.Y + 1, R1.Width - 2, R1.Height - 2, 7) | |
2004 | ||
2005 | Dim T As String = CStr(index + 1) | |
2006 | ||
2007 | If leftEllipse Then T = ".. " & T | |
2008 | If rightEllipse Then T = T & " .." | |
2009 | ||
2010 | SZ1 = G.MeasureString(T, Font).ToSize() | |
2011 | PT1 = New Point(R1.X + (R1.Width \ 2 - SZ1.Width \ 2), R1.Y + (R1.Height \ 2 - SZ1.Height \ 2)) | |
2012 | ||
2013 | If index = _SelectedIndex Then | |
2014 | G.FillPath(B1, GP1) | |
2015 | ||
2016 | Dim F As New Font(Font, FontStyle.Underline) | |
2017 | G.DrawString(T, F, Brushes.Black, PT1.X + 1, PT1.Y + 1) | |
2018 | G.DrawString(T, F, Brushes.White, PT1) | |
2019 | F.Dispose() | |
2020 | ||
2021 | G.DrawPath(P1, GP2) | |
2022 | G.DrawPath(P2, GP1) | |
2023 | Else | |
2024 | G.FillPath(B2, GP1) | |
2025 | ||
2026 | G.DrawString(T, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1) | |
2027 | G.DrawString(T, Font, Brushes.White, PT1) | |
2028 | ||
2029 | G.DrawPath(P3, GP2) | |
2030 | G.DrawPath(P1, GP1) | |
2031 | End If | |
2032 | End Sub | |
2033 | ||
2034 | Protected Overrides Sub OnMouseDown(e As MouseEventArgs) | |
2035 | If e.Button = Windows.Forms.MouseButtons.Left Then | |
2036 | Dim NewIndex As Integer | |
2037 | Dim OldIndex As Integer = _SelectedIndex | |
2038 | ||
2039 | If _SelectedIndex < 4 Then | |
2040 | NewIndex = (e.X \ ItemWidth) | |
2041 | ElseIf _SelectedIndex > 3 AndAlso _SelectedIndex < (MaximumIndex - 3) Then | |
2042 | NewIndex = (e.X \ ItemWidth) | |
2043 | ||
2044 | Select Case NewIndex | |
2045 | Case 2 | |
2046 | NewIndex = OldIndex | |
2047 | Case Is < 2 | |
2048 | NewIndex = OldIndex - (2 - NewIndex) | |
2049 | Case Is > 2 | |
2050 | NewIndex = OldIndex + (NewIndex - 2) | |
2051 | End Select | |
2052 | Else | |
2053 | NewIndex = MaximumIndex - (4 - (e.X \ ItemWidth)) | |
2054 | End If | |
2055 | ||
2056 | If (NewIndex < _NumberOfPages) AndAlso (Not NewIndex = OldIndex) Then | |
2057 | SelectedIndex = NewIndex | |
2058 | RaiseEvent SelectedIndexChanged(Me, Nothing) | |
2059 | End If | |
2060 | End If | |
2061 | ||
2062 | MyBase.OnMouseDown(e) | |
2063 | End Sub | |
2064 | ||
2065 | End Class | |
2066 | ||
2067 | <DefaultEvent("Scroll")> _ | |
2068 | Class NSVScrollBar | |
2069 | Inherits Control | |
2070 | ||
2071 | Event Scroll(ByVal sender As Object) | |
2072 | ||
2073 | Private _Minimum As Integer | |
2074 | Property Minimum() As Integer | |
2075 | Get | |
2076 | Return _Minimum | |
2077 | End Get | |
2078 | Set(ByVal value As Integer) | |
2079 | If value < 0 Then | |
2080 | Throw New Exception("Property value is not valid.") | |
2081 | End If | |
2082 | ||
2083 | _Minimum = value | |
2084 | If value > _Value Then _Value = value | |
2085 | If value > _Maximum Then _Maximum = value | |
2086 | ||
2087 | InvalidateLayout() | |
2088 | End Set | |
2089 | End Property | |
2090 | ||
2091 | Private _Maximum As Integer = 100 | |
2092 | Property Maximum() As Integer | |
2093 | Get | |
2094 | Return _Maximum | |
2095 | End Get | |
2096 | Set(ByVal value As Integer) | |
2097 | If value < 0 Then | |
2098 | Throw New Exception("Property value is not valid.") | |
2099 | End If | |
2100 | ||
2101 | _Maximum = value | |
2102 | If value < _Value Then _Value = value | |
2103 | If value < _Minimum Then _Minimum = value | |
2104 | ||
2105 | InvalidateLayout() | |
2106 | End Set | |
2107 | End Property | |
2108 | ||
2109 | Private _Value As Integer | |
2110 | Property Value() As Integer | |
2111 | Get | |
2112 | If Not ShowThumb Then Return _Minimum | |
2113 | Return _Value | |
2114 | End Get | |
2115 | Set(ByVal value As Integer) | |
2116 | If value = _Value Then Return | |
2117 | ||
2118 | If value > _Maximum OrElse value < _Minimum Then | |
2119 | Throw New Exception("Property value is not valid.") | |
2120 | End If | |
2121 | ||
2122 | _Value = value | |
2123 | InvalidatePosition() | |
2124 | ||
2125 | RaiseEvent Scroll(Me) | |
2126 | End Set | |
2127 | End Property | |
2128 | ||
2129 | Private _SmallChange As Integer = 1 | |
2130 | Public Property SmallChange() As Integer | |
2131 | Get | |
2132 | Return _SmallChange | |
2133 | End Get | |
2134 | Set(ByVal value As Integer) | |
2135 | If value < 1 Then | |
2136 | Throw New Exception("Property value is not valid.") | |
2137 | End If | |
2138 | ||
2139 | _SmallChange = value | |
2140 | End Set | |
2141 | End Property | |
2142 | ||
2143 | Private _LargeChange As Integer = 10 | |
2144 | Public Property LargeChange() As Integer | |
2145 | Get | |
2146 | Return _LargeChange | |
2147 | End Get | |
2148 | Set(ByVal value As Integer) | |
2149 | If value < 1 Then | |
2150 | Throw New Exception("Property value is not valid.") | |
2151 | End If | |
2152 | ||
2153 | _LargeChange = value | |
2154 | End Set | |
2155 | End Property | |
2156 | ||
2157 | Private ButtonSize As Integer = 16 | |
2158 | Private ThumbSize As Integer = 24 ' 14 minimum | |
2159 | ||
2160 | Private TSA As Rectangle | |
2161 | Private BSA As Rectangle | |
2162 | Private Shaft As Rectangle | |
2163 | Private Thumb As Rectangle | |
2164 | ||
2165 | Private ShowThumb As Boolean | |
2166 | Private ThumbDown As Boolean | |
2167 | ||
2168 | Sub New() | |
2169 | SetStyle(DirectCast(139286, ControlStyles), True) | |
2170 | SetStyle(ControlStyles.Selectable, False) | |
2171 | ||
2172 | Width = 18 | |
2173 | ||
2174 | B1 = New SolidBrush(Color.FromArgb(55, 55, 55)) | |
2175 | B2 = New SolidBrush(Color.FromArgb(35, 35, 35)) | |
2176 | ||
2177 | P1 = New Pen(Color.FromArgb(35, 35, 35)) | |
2178 | P2 = New Pen(Color.FromArgb(65, 65, 65)) | |
2179 | P3 = New Pen(Color.FromArgb(55, 55, 55)) | |
2180 | P4 = New Pen(Color.FromArgb(40, 40, 40)) | |
2181 | End Sub | |
2182 | ||
2183 | Private GP1, GP2, GP3, GP4 As GraphicsPath | |
2184 | ||
2185 | Private P1, P2, P3, P4 As Pen | |
2186 | Private B1, B2 As SolidBrush | |
2187 | ||
2188 | Dim I1 As Integer | |
2189 | ||
2190 | Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs) | |
2191 | G = e.Graphics | |
2192 | G.Clear(BackColor) | |
2193 | ||
2194 | GP1 = DrawArrow(4, 6, False) | |
2195 | GP2 = DrawArrow(5, 7, False) | |
2196 | ||
2197 | G.FillPath(B1, GP2) | |
2198 | G.FillPath(B2, GP1) | |
2199 | ||
2200 | GP3 = DrawArrow(4, Height - 11, True) | |
2201 | GP4 = DrawArrow(5, Height - 10, True) | |
2202 | ||
2203 | G.FillPath(B1, GP4) | |
2204 | G.FillPath(B2, GP3) | |
2205 | ||
2206 | If ShowThumb Then | |
2207 | G.FillRectangle(B1, Thumb) | |
2208 | G.DrawRectangle(P1, Thumb) | |
2209 | G.DrawRectangle(P2, Thumb.X + 1, Thumb.Y + 1, Thumb.Width - 2, Thumb.Height - 2) | |
2210 | ||
2211 | Dim Y As Integer | |
2212 | Dim LY As Integer = Thumb.Y + (Thumb.Height \ 2) - 3 | |
2213 | ||
2214 | For I As Integer = 0 To 2 | |
2215 | Y = LY + (I * 3) | |
2216 | ||
2217 | G.DrawLine(P1, Thumb.X + 5, Y, Thumb.Right - 5, Y) | |
2218 | G.DrawLine(P2, Thumb.X + 5, Y + 1, Thumb.Right - 5, Y + 1) | |
2219 | Next | |
2220 | End If | |
2221 | ||
2222 | G.DrawRectangle(P3, 0, 0, Width - 1, Height - 1) | |
2223 | G.DrawRectangle(P4, 1, 1, Width - 3, Height - 3) | |
2224 | End Sub | |
2225 | ||
2226 | Private Function DrawArrow(x As Integer, y As Integer, flip As Boolean) As GraphicsPath | |
2227 | Dim GP As New GraphicsPath() | |
2228 | ||
2229 | Dim W As Integer = 9 | |
2230 | Dim H As Integer = 5 | |
2231 | ||
2232 | If flip Then | |
2233 | GP.AddLine(x + 1, y, x + W + 1, y) | |
2234 | GP.AddLine(x + W, y, x + H, y + H - 1) | |
2235 | Else | |
2236 | GP.AddLine(x, y + H, x + W, y + H) | |
2237 | GP.AddLine(x + W, y + H, x + H, y) | |
2238 | End If | |
2239 | ||
2240 | GP.CloseFigure() | |
2241 | Return GP | |
2242 | End Function | |
2243 | ||
2244 | Protected Overrides Sub OnSizeChanged(e As EventArgs) | |
2245 | InvalidateLayout() | |
2246 | End Sub | |
2247 | ||
2248 | Private Sub InvalidateLayout() | |
2249 | TSA = New Rectangle(0, 0, Width, ButtonSize) | |
2250 | BSA = New Rectangle(0, Height - ButtonSize, Width, ButtonSize) | |
2251 | Shaft = New Rectangle(0, TSA.Bottom + 1, Width, Height - (ButtonSize * 2) - 1) | |
2252 | ||
2253 | ShowThumb = ((_Maximum - _Minimum) > Shaft.Height) | |
2254 | ||
2255 | If ShowThumb Then | |
2256 | 'ThumbSize = Math.Max(0, 14) 'TODO: Implement this. | |
2257 | Thumb = New Rectangle(1, 0, Width - 3, ThumbSize) | |
2258 | End If | |
2259 | ||
2260 | RaiseEvent Scroll(Me) | |
2261 | InvalidatePosition() | |
2262 | End Sub | |
2263 | ||
2264 | Private Sub InvalidatePosition() | |
2265 | Thumb.Y = CInt(GetProgress() * (Shaft.Height - ThumbSize)) + TSA.Height | |
2266 | Invalidate() | |
2267 | End Sub | |
2268 | ||
2269 | Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs) | |
2270 | If e.Button = Windows.Forms.MouseButtons.Left AndAlso ShowThumb Then | |
2271 | If TSA.Contains(e.Location) Then | |
2272 | I1 = _Value - _SmallChange | |
2273 | ElseIf BSA.Contains(e.Location) Then | |
2274 | I1 = _Value + _SmallChange | |
2275 | Else | |
2276 | If Thumb.Contains(e.Location) Then | |
2277 | ThumbDown = True | |
2278 | Return | |
2279 | Else | |
2280 | If e.Y < Thumb.Y Then | |
2281 | I1 = _Value - _LargeChange | |
2282 | Else | |
2283 | I1 = _Value + _LargeChange | |
2284 | End If | |
2285 | End If | |
2286 | End If | |
2287 | ||
2288 | Value = Math.Min(Math.Max(I1, _Minimum), _Maximum) | |
2289 | InvalidatePosition() | |
2290 | End If | |
2291 | End Sub | |
2292 | ||
2293 | Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs) | |
2294 | If ThumbDown AndAlso ShowThumb Then | |
2295 | Dim ThumbPosition As Integer = e.Y - TSA.Height - (ThumbSize \ 2) | |
2296 | Dim ThumbBounds As Integer = Shaft.Height - ThumbSize | |
2297 | ||
2298 | I1 = CInt((ThumbPosition / ThumbBounds) * (_Maximum - _Minimum)) + _Minimum | |
2299 | ||
2300 | Value = Math.Min(Math.Max(I1, _Minimum), _Maximum) | |
2301 | InvalidatePosition() | |
2302 | End If | |
2303 | End Sub | |
2304 | ||
2305 | Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs) | |
2306 | ThumbDown = False | |
2307 | End Sub | |
2308 | ||
2309 | Private Function GetProgress() As Double | |
2310 | Return (_Value - _Minimum) / (_Maximum - _Minimum) | |
2311 | End Function | |
2312 | ||
2313 | End Class | |
2314 | ||
2315 | <DefaultEvent("Scroll")> _ | |
2316 | Class NSHScrollBar | |
2317 | Inherits Control | |
2318 | ||
2319 | Event Scroll(ByVal sender As Object) | |
2320 | ||
2321 | Private _Minimum As Integer | |
2322 | Property Minimum() As Integer | |
2323 | Get | |
2324 | Return _Minimum | |
2325 | End Get | |
2326 | Set(ByVal value As Integer) | |
2327 | If value < 0 Then | |
2328 | Throw New Exception("Property value is not valid.") | |
2329 | End If | |
2330 | ||
2331 | _Minimum = value | |
2332 | If value > _Value Then _Value = value | |
2333 | If value > _Maximum Then _Maximum = value | |
2334 | ||
2335 | InvalidateLayout() | |
2336 | End Set | |
2337 | End Property | |
2338 | ||
2339 | Private _Maximum As Integer = 100 | |
2340 | Property Maximum() As Integer | |
2341 | Get | |
2342 | Return _Maximum | |
2343 | End Get | |
2344 | Set(ByVal value As Integer) | |
2345 | If value < 0 Then | |
2346 | Throw New Exception("Property value is not valid.") | |
2347 | End If | |
2348 | ||
2349 | _Maximum = value | |
2350 | If value < _Value Then _Value = value | |
2351 | If value < _Minimum Then _Minimum = value | |
2352 | ||
2353 | InvalidateLayout() | |
2354 | End Set | |
2355 | End Property | |
2356 | ||
2357 | Private _Value As Integer | |
2358 | Property Value() As Integer | |
2359 | Get | |
2360 | If Not ShowThumb Then Return _Minimum | |
2361 | Return _Value | |
2362 | End Get | |
2363 | Set(ByVal value As Integer) | |
2364 | If value = _Value Then Return | |
2365 | ||
2366 | If value > _Maximum OrElse value < _Minimum Then | |
2367 | Throw New Exception("Property value is not valid.") | |
2368 | End If | |
2369 | ||
2370 | _Value = value | |
2371 | InvalidatePosition() | |
2372 | ||
2373 | RaiseEvent Scroll(Me) | |
2374 | End Set | |
2375 | End Property | |
2376 | ||
2377 | Private _SmallChange As Integer = 1 | |
2378 | Public Property SmallChange() As Integer | |
2379 | Get | |
2380 | Return _SmallChange | |
2381 | End Get | |
2382 | Set(ByVal value As Integer) | |
2383 | If value < 1 Then | |
2384 | Throw New Exception("Property value is not valid.") | |
2385 | End If | |
2386 | ||
2387 | _SmallChange = value | |
2388 | End Set | |
2389 | End Property | |
2390 | ||
2391 | Private _LargeChange As Integer = 10 | |
2392 | Public Property LargeChange() As Integer | |
2393 | Get | |
2394 | Return _LargeChange | |
2395 | End Get | |
2396 | Set(ByVal value As Integer) | |
2397 | If value < 1 Then | |
2398 | Throw New Exception("Property value is not valid.") | |
2399 | End If | |
2400 | ||
2401 | _LargeChange = value | |
2402 | End Set | |
2403 | End Property | |
2404 | ||
2405 | Private ButtonSize As Integer = 16 | |
2406 | Private ThumbSize As Integer = 24 ' 14 minimum | |
2407 | ||
2408 | Private LSA As Rectangle | |
2409 | Private RSA As Rectangle | |
2410 | Private Shaft As Rectangle | |
2411 | Private Thumb As Rectangle | |
2412 | ||
2413 | Private ShowThumb As Boolean | |
2414 | Private ThumbDown As Boolean | |
2415 | ||
2416 | Sub New() | |
2417 | SetStyle(DirectCast(139286, ControlStyles), True) | |
2418 | SetStyle(ControlStyles.Selectable, False) | |
2419 | ||
2420 | Height = 18 | |
2421 | ||
2422 | B1 = New SolidBrush(Color.FromArgb(55, 55, 55)) | |
2423 | B2 = New SolidBrush(Color.FromArgb(35, 35, 35)) | |
2424 | ||
2425 | P1 = New Pen(Color.FromArgb(35, 35, 35)) | |
2426 | P2 = New Pen(Color.FromArgb(65, 65, 65)) | |
2427 | P3 = New Pen(Color.FromArgb(55, 55, 55)) | |
2428 | P4 = New Pen(Color.FromArgb(40, 40, 40)) | |
2429 | End Sub | |
2430 | ||
2431 | Private GP1, GP2, GP3, GP4 As GraphicsPath | |
2432 | ||
2433 | Private P1, P2, P3, P4 As Pen | |
2434 | Private B1, B2 As SolidBrush | |
2435 | ||
2436 | Dim I1 As Integer | |
2437 | ||
2438 | Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs) | |
2439 | G = e.Graphics | |
2440 | G.Clear(BackColor) | |
2441 | ||
2442 | GP1 = DrawArrow(6, 4, False) | |
2443 | GP2 = DrawArrow(7, 5, False) | |
2444 | ||
2445 | G.FillPath(B1, GP2) | |
2446 | G.FillPath(B2, GP1) | |
2447 | ||
2448 | GP3 = DrawArrow(Width - 11, 4, True) | |
2449 | GP4 = DrawArrow(Width - 10, 5, True) | |
2450 | ||
2451 | G.FillPath(B1, GP4) | |
2452 | G.FillPath(B2, GP3) | |
2453 | ||
2454 | If ShowThumb Then | |
2455 | G.FillRectangle(B1, Thumb) | |
2456 | G.DrawRectangle(P1, Thumb) | |
2457 | G.DrawRectangle(P2, Thumb.X + 1, Thumb.Y + 1, Thumb.Width - 2, Thumb.Height - 2) | |
2458 | ||
2459 | Dim X As Integer | |
2460 | Dim LX As Integer = Thumb.X + (Thumb.Width \ 2) - 3 | |
2461 | ||
2462 | For I As Integer = 0 To 2 | |
2463 | X = LX + (I * 3) | |
2464 | ||
2465 | G.DrawLine(P1, X, Thumb.Y + 5, X, Thumb.Bottom - 5) | |
2466 | G.DrawLine(P2, X + 1, Thumb.Y + 5, X + 1, Thumb.Bottom - 5) | |
2467 | Next | |
2468 | End If | |
2469 | ||
2470 | G.DrawRectangle(P3, 0, 0, Width - 1, Height - 1) | |
2471 | G.DrawRectangle(P4, 1, 1, Width - 3, Height - 3) | |
2472 | End Sub | |
2473 | ||
2474 | Private Function DrawArrow(x As Integer, y As Integer, flip As Boolean) As GraphicsPath | |
2475 | Dim GP As New GraphicsPath() | |
2476 | ||
2477 | Dim W As Integer = 5 | |
2478 | Dim H As Integer = 9 | |
2479 | ||
2480 | If flip Then | |
2481 | GP.AddLine(x, y + 1, x, y + H + 1) | |
2482 | GP.AddLine(x, y + H, x + W - 1, y + W) | |
2483 | Else | |
2484 | GP.AddLine(x + W, y, x + W, y + H) | |
2485 | GP.AddLine(x + W, y + H, x + 1, y + W) | |
2486 | End If | |
2487 | ||
2488 | GP.CloseFigure() | |
2489 | Return GP | |
2490 | End Function | |
2491 | ||
2492 | Protected Overrides Sub OnSizeChanged(e As EventArgs) | |
2493 | InvalidateLayout() | |
2494 | End Sub | |
2495 | ||
2496 | Private Sub InvalidateLayout() | |
2497 | LSA = New Rectangle(0, 0, ButtonSize, Height) | |
2498 | RSA = New Rectangle(Width - ButtonSize, 0, ButtonSize, Height) | |
2499 | Shaft = New Rectangle(LSA.Right + 1, 0, Width - (ButtonSize * 2) - 1, Height) | |
2500 | ||
2501 | ShowThumb = ((_Maximum - _Minimum) > Shaft.Width) | |
2502 | ||
2503 | If ShowThumb Then | |
2504 | 'ThumbSize = Math.Max(0, 14) 'TODO: Implement this. | |
2505 | Thumb = New Rectangle(0, 1, ThumbSize, Height - 3) | |
2506 | End If | |
2507 | ||
2508 | RaiseEvent Scroll(Me) | |
2509 | InvalidatePosition() | |
2510 | End Sub | |
2511 | ||
2512 | Private Sub InvalidatePosition() | |
2513 | Thumb.X = CInt(GetProgress() * (Shaft.Width - ThumbSize)) + LSA.Width | |
2514 | Invalidate() | |
2515 | End Sub | |
2516 | ||
2517 | Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs) | |
2518 | If e.Button = Windows.Forms.MouseButtons.Left AndAlso ShowThumb Then | |
2519 | If LSA.Contains(e.Location) Then | |
2520 | I1 = _Value - _SmallChange | |
2521 | ElseIf RSA.Contains(e.Location) Then | |
2522 | I1 = _Value + _SmallChange | |
2523 | Else | |
2524 | If Thumb.Contains(e.Location) Then | |
2525 | ThumbDown = True | |
2526 | Return | |
2527 | Else | |
2528 | If e.X < Thumb.X Then | |
2529 | I1 = _Value - _LargeChange | |
2530 | Else | |
2531 | I1 = _Value + _LargeChange | |
2532 | End If | |
2533 | End If | |
2534 | End If | |
2535 | ||
2536 | Value = Math.Min(Math.Max(I1, _Minimum), _Maximum) | |
2537 | InvalidatePosition() | |
2538 | End If | |
2539 | End Sub | |
2540 | ||
2541 | Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs) | |
2542 | If ThumbDown AndAlso ShowThumb Then | |
2543 | Dim ThumbPosition As Integer = e.X - LSA.Width - (ThumbSize \ 2) | |
2544 | Dim ThumbBounds As Integer = Shaft.Width - ThumbSize | |
2545 | ||
2546 | I1 = CInt((ThumbPosition / ThumbBounds) * (_Maximum - _Minimum)) + _Minimum | |
2547 | ||
2548 | Value = Math.Min(Math.Max(I1, _Minimum), _Maximum) | |
2549 | InvalidatePosition() | |
2550 | End If | |
2551 | End Sub | |
2552 | ||
2553 | Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs) | |
2554 | ThumbDown = False | |
2555 | End Sub | |
2556 | ||
2557 | Private Function GetProgress() As Double | |
2558 | Return (_Value - _Minimum) / (_Maximum - _Minimum) | |
2559 | End Function | |
2560 | ||
2561 | End Class | |
2562 | ||
2563 | Class NSContextMenu | |
2564 | Inherits ContextMenuStrip | |
2565 | ||
2566 | Sub New() | |
2567 | Renderer = New ToolStripProfessionalRenderer(New NSColorTable()) | |
2568 | ForeColor = Color.White | |
2569 | End Sub | |
2570 | ||
2571 | Protected Overrides Sub OnPaint(e As PaintEventArgs) | |
2572 | e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit | |
2573 | MyBase.OnPaint(e) | |
2574 | End Sub | |
2575 | ||
2576 | End Class | |
2577 | ||
2578 | Class NSColorTable | |
2579 | Inherits ProfessionalColorTable | |
2580 | ||
2581 | Private BackColor As Color = Color.FromArgb(55, 55, 55) | |
2582 | ||
2583 | Public Overrides ReadOnly Property ButtonSelectedBorder() As Color | |
2584 | Get | |
2585 | Return BackColor | |
2586 | End Get | |
2587 | End Property | |
2588 | ||
2589 | Public Overrides ReadOnly Property CheckBackground() As Color | |
2590 | Get | |
2591 | Return BackColor | |
2592 | End Get | |
2593 | End Property | |
2594 | ||
2595 | Public Overrides ReadOnly Property CheckPressedBackground() As Color | |
2596 | Get | |
2597 | Return BackColor | |
2598 | End Get | |
2599 | End Property | |
2600 | ||
2601 | Public Overrides ReadOnly Property CheckSelectedBackground() As Color | |
2602 | Get | |
2603 | Return BackColor | |
2604 | End Get | |
2605 | End Property | |
2606 | ||
2607 | Public Overrides ReadOnly Property ImageMarginGradientBegin() As Color | |
2608 | Get | |
2609 | Return BackColor | |
2610 | End Get | |
2611 | End Property | |
2612 | ||
2613 | Public Overrides ReadOnly Property ImageMarginGradientEnd() As Color | |
2614 | Get | |
2615 | Return BackColor | |
2616 | End Get | |
2617 | End Property | |
2618 | ||
2619 | Public Overrides ReadOnly Property ImageMarginGradientMiddle() As Color | |
2620 | Get | |
2621 | Return BackColor | |
2622 | End Get | |
2623 | End Property | |
2624 | ||
2625 | Public Overrides ReadOnly Property MenuBorder() As Color | |
2626 | Get | |
2627 | Return Color.FromArgb(25, 25, 25) | |
2628 | End Get | |
2629 | End Property | |
2630 | ||
2631 | Public Overrides ReadOnly Property MenuItemBorder() As Color | |
2632 | Get | |
2633 | Return BackColor | |
2634 | End Get | |
2635 | End Property | |
2636 | ||
2637 | Public Overrides ReadOnly Property MenuItemSelected() As Color | |
2638 | Get | |
2639 | Return Color.FromArgb(65, 65, 65) | |
2640 | End Get | |
2641 | End Property | |
2642 | ||
2643 | Public Overrides ReadOnly Property SeparatorDark() As Color | |
2644 | Get | |
2645 | Return Color.FromArgb(35, 35, 35) | |
2646 | End Get | |
2647 | End Property | |
2648 | ||
2649 | Public Overrides ReadOnly Property ToolStripDropDownBackground() As Color | |
2650 | Get | |
2651 | Return BackColor | |
2652 | End Get | |
2653 | End Property | |
2654 | ||
2655 | End Class |