View difference between Paste ID: ArnqKAyr and jUuzNhSC
SHOW: | | - or go back to the newest paste.
1
Imports System.Drawing.Drawing2D, System.ComponentModel, System.Windows.Forms
2
3
''' <summary>
4
''' Flat UI Theme
5
''' Creator: iSynthesis (HF)
6
''' Version: 1.0.4
7
''' Date Created: 17/06/2013
8
''' Date Changed: 26/06/2013
9
''' UID: 374648
10
''' For any bugs / errors, PM me.
11
''' </summary>
12
''' <remarks></remarks>
13
14
Module Helpers
15
16
#Region " Variables"
17
    Friend G As Graphics, B As Bitmap
18
    Friend _FlatColor As Color = Color.FromArgb(35, 168, 109)
19
    Friend NearSF As New StringFormat() With {.Alignment = StringAlignment.Near, .LineAlignment = StringAlignment.Near}
20
    Friend CenterSF As New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center}
21
#End Region
22
23
#Region " Functions"
24
25
    Public Function RoundRec(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
26
        Dim P As GraphicsPath = New GraphicsPath()
27
        Dim ArcRectangleWidth As Integer = Curve * 2
28
        P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
29
        P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
30
        P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
31
        P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
32
        P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
33
        Return P
34
    End Function
35
36
    Public Function RoundRect(x!, y!, w!, h!, Optional r! = 0.3, Optional TL As Boolean = True, Optional TR As Boolean = True, Optional BR As Boolean = True, Optional BL As Boolean = True) As GraphicsPath
37
        Dim d! = Math.Min(w, h) * r, xw = x + w, yh = y + h
38
        RoundRect = New GraphicsPath
39
40
        With RoundRect
41
            If TL Then .AddArc(x, y, d, d, 180, 90) Else .AddLine(x, y, x, y)
42
            If TR Then .AddArc(xw - d, y, d, d, 270, 90) Else .AddLine(xw, y, xw, y)
43
            If BR Then .AddArc(xw - d, yh - d, d, d, 0, 90) Else .AddLine(xw, yh, xw, yh)
44
            If BL Then .AddArc(x, yh - d, d, d, 90, 90) Else .AddLine(x, yh, x, yh)
45
46
            .CloseFigure()
47
        End With
48
    End Function
49
50
    '-- Credit: AeonHack
51
    Public Function DrawArrow(x As Integer, y As Integer, flip As Boolean) As GraphicsPath
52
        Dim GP As New GraphicsPath()
53
54
        Dim W As Integer = 12
55
        Dim H As Integer = 6
56
57
        If flip Then
58
            GP.AddLine(x + 1, y, x + W + 1, y)
59
            GP.AddLine(x + W, y, x + H, y + H - 1)
60
        Else
61
            GP.AddLine(x, y + H, x + W, y + H)
62
            GP.AddLine(x + W, y + H, x + H, y)
63
        End If
64
65
        GP.CloseFigure()
66
        Return GP
67
    End Function
68
69
#End Region
70
71
End Module
72
73
#Region " Mouse States"
74
75
Enum MouseState As Byte
76
    None = 0
77
    Over = 1
78
    Down = 2
79
    Block = 3
80
End Enum
81
82
#End Region
83
84
Class FormSkin : Inherits ContainerControl
85
86
#Region " Variables"
87
88
    Private W, H As Integer
89
    Private Cap As Boolean = False
90
    Private _HeaderMaximize As Boolean = False
91
    Private MousePoint As New Point(0, 0)
92
    Private MoveHeight = 50
93
94
#End Region
95
96
#Region " Properties"
97
98
#Region " Colors"
99
100
    <Category("Colors")> _
101
    Public Property HeaderColor() As Color
102
        Get
103
            Return _HeaderColor
104
        End Get
105
        Set(value As Color)
106
            _HeaderColor = value
107
        End Set
108
    End Property
109
    <Category("Colors")> _
110
    Public Property BaseColor() As Color
111
        Get
112
            Return _BaseColor
113
        End Get
114
        Set(value As Color)
115
            _BaseColor = value
116
        End Set
117
    End Property
118
    <Category("Colors")> _
119
    Public Property BorderColor() As Color
120
        Get
121
            Return _BorderColor
122
        End Get
123
        Set(value As Color)
124
            _BorderColor = value
125
        End Set
126
    End Property
127
    <Category("Colors")> _
128
    Public Property FlatColor() As Color
129
        Get
130
            Return _FlatColor
131
        End Get
132
        Set(value As Color)
133
            _FlatColor = value
134
        End Set
135
    End Property
136
137
#End Region
138
139
#Region " Options"
140
141
    <Category("Options")> _
142
    Public Property HeaderMaximize As Boolean
143
        Get
144
            Return _HeaderMaximize
145
        End Get
146
        Set(value As Boolean)
147
            _HeaderMaximize = value
148
        End Set
149
    End Property
150
151
#End Region
152
153
    Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
154
        MyBase.OnMouseDown(e)
155
        If e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(0, 0, Width, MoveHeight).Contains(e.Location) Then
156
            Cap = True
157
            MousePoint = e.Location
158
        End If
159
    End Sub
160
161
    Private Sub FormSkin_MouseDoubleClick(sender As Object, e As MouseEventArgs) Handles Me.MouseDoubleClick
162
        If HeaderMaximize Then
163
            If e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(0, 0, Width, MoveHeight).Contains(e.Location) Then
164
                If FindForm.WindowState = FormWindowState.Normal Then
165
                    FindForm.WindowState = FormWindowState.Maximized : FindForm.Refresh()
166
                ElseIf FindForm.WindowState = FormWindowState.Maximized Then
167
                    FindForm.WindowState = FormWindowState.Normal : FindForm.Refresh()
168
                End If
169
            End If
170
        End If
171
    End Sub
172
173
    Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
174
        MyBase.OnMouseUp(e) : Cap = False
175
    End Sub
176
177
    Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
178
        MyBase.OnMouseMove(e)
179
        If Cap Then
180
            Parent.Location = MousePosition - MousePoint
181
        End If
182
    End Sub
183
184
    Protected Overrides Sub OnCreateControl()
185
        MyBase.OnCreateControl()
186
        ParentForm.FormBorderStyle = FormBorderStyle.None
187
        ParentForm.AllowTransparency = False
188
        ParentForm.TransparencyKey = Color.Fuchsia
189
        ParentForm.FindForm.StartPosition = FormStartPosition.CenterScreen
190
        Dock = DockStyle.Fill
191
        Invalidate()
192
    End Sub
193
194
#End Region
195
196
#Region " Colors"
197
198
#Region " Dark Colors"
199
200
    Private _HeaderColor As Color = Color.FromArgb(45, 47, 49)
201
    Private _BaseColor As Color = Color.FromArgb(60, 70, 73)
202
    Private _BorderColor As Color = Color.FromArgb(53, 58, 60)
203
    Private TextColor As Color = Color.FromArgb(234, 234, 234)
204
205
#End Region
206
207
#Region " Light Colors"
208
209
    Private _HeaderLight As Color = Color.FromArgb(171, 171, 172)
210
    Private _BaseLight As Color = Color.FromArgb(196, 199, 200)
211
    Public TextLight As Color = Color.FromArgb(45, 47, 49)
212
213
#End Region
214
215
#End Region
216
217
    Sub New()
218
        SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
219
                 ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
220
        DoubleBuffered = True
221
        BackColor = Color.White
222
        Font = New Font("Segoe UI", 12)
223
    End Sub
224
225
    Protected Overrides Sub OnPaint(e As PaintEventArgs)
226
        B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
227
        W = Width : H = Height
228
229
        Dim Base As New Rectangle(0, 0, W, H), Header As New Rectangle(0, 0, W, 50)
230
231
        With G
232
            .SmoothingMode = 2
233
            .PixelOffsetMode = 2
234
            .TextRenderingHint = 5
235
            .Clear(BackColor)
236
237
            '-- Base
238
            .FillRectangle(New SolidBrush(_BaseColor), Base)
239
240
            '-- Header
241
            .FillRectangle(New SolidBrush(_HeaderColor), Header)
242
243
            '-- Logo
244
            .FillRectangle(New SolidBrush(Color.FromArgb(243, 243, 243)), New Rectangle(8, 16, 4, 18))
245
            .FillRectangle(New SolidBrush(_FlatColor), 16, 16, 4, 18)
246
            .DrawString(Text, Font, New SolidBrush(TextColor), New Rectangle(26, 15, W, H), NearSF)
247
248
            '-- Border
249
            .DrawRectangle(New Pen(_BorderColor), Base)
250
        End With
251
252
        MyBase.OnPaint(e)
253
        G.Dispose()
254
        e.Graphics.InterpolationMode = 7
255
        e.Graphics.DrawImageUnscaled(B, 0, 0)
256
        B.Dispose()
257
    End Sub
258
End Class
259
260
Class FlatClose : Inherits Control
261
262
#Region " Variables"
263
264
    Private State As MouseState = MouseState.None
265
    Private x As Integer
266
267
#End Region
268
269
#Region " Properties"
270
271
#Region " Mouse States"
272
273
    Protected Overrides Sub OnMouseEnter(e As EventArgs)
274
        MyBase.OnMouseEnter(e)
275
        State = MouseState.Over : Invalidate()
276
    End Sub
277
    Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
278
        MyBase.OnMouseDown(e)
279
        State = MouseState.Down : Invalidate()
280
    End Sub
281
    Protected Overrides Sub OnMouseLeave(e As EventArgs)
282
        MyBase.OnMouseLeave(e)
283
        State = MouseState.None : Invalidate()
284
    End Sub
285
    Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
286
        MyBase.OnMouseUp(e)
287
        State = MouseState.Over : Invalidate()
288
    End Sub
289
    Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
290
        MyBase.OnMouseMove(e)
291
        x = e.X : Invalidate()
292
    End Sub
293
294
    Protected Overrides Sub OnClick(e As EventArgs)
295
        MyBase.OnClick(e)
296
        Environment.Exit(0)
297
    End Sub
298
299
#End Region
300
    
301
    Protected Overrides Sub OnResize(e As EventArgs)
302
        MyBase.OnResize(e)
303
        Size = New Size(18, 18)
304
    End Sub
305
306
#Region " Colors"
307
308
    <Category("Colors")> _
309
    Public Property BaseColor As Color
310
        Get
311
            Return _BaseColor
312
        End Get
313
        Set(value As Color)
314
            _BaseColor = value
315
        End Set
316
    End Property
317
318
    <Category("Colors")> _
319
    Public Property TextColor As Color
320
        Get
321
            Return _TextColor
322
        End Get
323
        Set(value As Color)
324
            _TextColor = value
325
        End Set
326
    End Property
327
328
#End Region
329
330
#End Region
331
332
#Region " Colors"
333
334
    Private _BaseColor As Color = Color.FromArgb(168, 35, 35)
335
    Private _TextColor As Color = Color.FromArgb(243, 243, 243)
336
337
#End Region
338
339
    Sub New()
340
        SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
341
                 ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
342
        DoubleBuffered = True
343
        BackColor = Color.White
344
        Size = New Size(18, 18)
345
        Anchor = AnchorStyles.Top Or AnchorStyles.Right
346
        Font = New Font("Marlett", 10)
347
    End Sub
348
349
    Protected Overrides Sub OnPaint(e As PaintEventArgs)
350
        Dim B As New Bitmap(Width, Height)
351
        Dim G As Graphics = Graphics.FromImage(B)
352
353
        Dim Base As New Rectangle(0, 0, Width, Height)
354
355
        With G
356
            .SmoothingMode = 2
357
            .PixelOffsetMode = 2
358
            .TextRenderingHint = 5
359
            .Clear(BackColor)
360
361
            '-- Base
362
            .FillRectangle(New SolidBrush(_BaseColor), Base)
363
364
            '-- X
365
            .DrawString("r", Font, New SolidBrush(TextColor), New Rectangle(0, 0, Width, Height), CenterSF)
366
367
            '-- Hover/down
368
            Select Case State
369
                Case MouseState.Over
370
                    .FillRectangle(New SolidBrush(Color.FromArgb(30, Color.White)), Base)
371
                Case MouseState.Down
372
                    .FillRectangle(New SolidBrush(Color.FromArgb(30, Color.Black)), Base)
373
            End Select
374
        End With
375
376
        MyBase.OnPaint(e)
377
        G.Dispose()
378
        e.Graphics.InterpolationMode = 7
379
        e.Graphics.DrawImageUnscaled(B, 0, 0)
380
        B.Dispose()
381
    End Sub
382
End Class
383
384
Class FlatMax : Inherits Control
385
386
#Region " Variables"
387
388
    Private State As MouseState = MouseState.None
389
    Private x As Integer
390
391
#End Region
392
393
#Region " Properties"
394
395
#Region " Mouse States"
396
397
    Protected Overrides Sub OnMouseEnter(e As EventArgs)
398
        MyBase.OnMouseEnter(e)
399
        State = MouseState.Over : Invalidate()
400
    End Sub
401
    Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
402
        MyBase.OnMouseDown(e)
403
        State = MouseState.Down : Invalidate()
404
    End Sub
405
    Protected Overrides Sub OnMouseLeave(e As EventArgs)
406
        MyBase.OnMouseLeave(e)
407
        State = MouseState.None : Invalidate()
408
    End Sub
409
    Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
410
        MyBase.OnMouseUp(e)
411
        State = MouseState.Over : Invalidate()
412
    End Sub
413
    Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
414
        MyBase.OnMouseMove(e)
415
        x = e.X : Invalidate()
416
    End Sub
417
418
    Protected Overrides Sub OnClick(e As EventArgs)
419
        MyBase.OnClick(e)
420
        Select Case FindForm.WindowState
421
            Case FormWindowState.Maximized
422
                FindForm.WindowState = FormWindowState.Normal
423
            Case FormWindowState.Normal
424
                FindForm.WindowState = FormWindowState.Maximized
425
        End Select
426
    End Sub
427
428
#End Region
429
430
#Region " Colors"
431
432
    <Category("Colors")> _
433
    Public Property BaseColor As Color
434
        Get
435
            Return _BaseColor
436
        End Get
437
        Set(value As Color)
438
            _BaseColor = value
439
        End Set
440
    End Property
441
442
    <Category("Colors")> _
443
    Public Property TextColor As Color
444
        Get
445
            Return _TextColor
446
        End Get
447
        Set(value As Color)
448
            _TextColor = value
449
        End Set
450
    End Property
451
452
#End Region
453
454
    Protected Overrides Sub OnResize(e As EventArgs)
455
        MyBase.OnResize(e)
456
        Size = New Size(18, 18)
457
    End Sub
458
459
#End Region
460
461
#Region " Colors"
462
463
    Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
464
    Private _TextColor As Color = Color.FromArgb(243, 243, 243)
465
466
#End Region
467
468
    Sub New()
469
        SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
470
                 ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
471
        DoubleBuffered = True
472
        BackColor = Color.White
473
        Size = New Size(18, 18)
474
        Anchor = AnchorStyles.Top Or AnchorStyles.Right
475
        Font = New Font("Marlett", 12)
476
    End Sub
477
478
    Protected Overrides Sub OnPaint(e As PaintEventArgs)
479
        Dim B As New Bitmap(Width, Height)
480
        Dim G As Graphics = Graphics.FromImage(B)
481
482
        Dim Base As New Rectangle(0, 0, Width, Height)
483
484
        With G
485
            .SmoothingMode = 2
486
            .PixelOffsetMode = 2
487
            .TextRenderingHint = 5
488
            .Clear(BackColor)
489
490
            '-- Base
491
            .FillRectangle(New SolidBrush(_BaseColor), Base)
492
493
            '-- Maximize
494
            If FindForm.WindowState = FormWindowState.Maximized Then
495
                .DrawString("1", Font, New SolidBrush(TextColor), New Rectangle(1, 1, Width, Height), CenterSF)
496
            ElseIf FindForm.WindowState = FormWindowState.Normal Then
497
                .DrawString("2", Font, New SolidBrush(TextColor), New Rectangle(1, 1, Width, Height), CenterSF)
498
            End If
499
500
            '-- Hover/down
501
            Select Case State
502
                Case MouseState.Over
503
                    .FillRectangle(New SolidBrush(Color.FromArgb(30, Color.White)), Base)
504
                Case MouseState.Down
505
                    .FillRectangle(New SolidBrush(Color.FromArgb(30, Color.Black)), Base)
506
            End Select
507
        End With
508
509
        MyBase.OnPaint(e)
510
        G.Dispose()
511
        e.Graphics.InterpolationMode = 7
512
        e.Graphics.DrawImageUnscaled(B, 0, 0)
513
        B.Dispose()
514
    End Sub
515
End Class
516
517
Class FlatMini : Inherits Control
518
519
#Region " Variables"
520
521
    Private State As MouseState = MouseState.None
522
    Private x As Integer
523
524
#End Region
525
526
#Region " Properties"
527
528
#Region " Mouse States"
529
530
    Protected Overrides Sub OnMouseEnter(e As EventArgs)
531
        MyBase.OnMouseEnter(e)
532
        State = MouseState.Over : Invalidate()
533
    End Sub
534
    Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
535
        MyBase.OnMouseDown(e)
536
        State = MouseState.Down : Invalidate()
537
    End Sub
538
    Protected Overrides Sub OnMouseLeave(e As EventArgs)
539
        MyBase.OnMouseLeave(e)
540
        State = MouseState.None : Invalidate()
541
    End Sub
542
    Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
543
        MyBase.OnMouseUp(e)
544
        State = MouseState.Over : Invalidate()
545
    End Sub
546
    Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
547
        MyBase.OnMouseMove(e)
548
        x = e.X : Invalidate()
549
    End Sub
550
551
    Protected Overrides Sub OnClick(e As EventArgs)
552
        MyBase.OnClick(e)
553
        Select Case FindForm.WindowState
554
            Case FormWindowState.Normal
555
                FindForm.WindowState = FormWindowState.Minimized
556
            Case FormWindowState.Maximized
557
                FindForm.WindowState = FormWindowState.Minimized
558
        End Select
559
    End Sub
560
561
#End Region
562
563
#Region " Colors"
564
565
    <Category("Colors")> _
566
    Public Property BaseColor As Color
567
        Get
568
            Return _BaseColor
569
        End Get
570
        Set(value As Color)
571
            _BaseColor = value
572
        End Set
573
    End Property
574
575
    <Category("Colors")> _
576
    Public Property TextColor As Color
577
        Get
578
            Return _TextColor
579
        End Get
580
        Set(value As Color)
581
            _TextColor = value
582
        End Set
583
    End Property
584
585
#End Region
586
587
    Protected Overrides Sub OnResize(e As EventArgs)
588
        MyBase.OnResize(e)
589
        Size = New Size(18, 18)
590
    End Sub
591
592
#End Region
593
594
#Region " Colors"
595
596
    Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
597
    Private _TextColor As Color = Color.FromArgb(243, 243, 243)
598
599
#End Region
600
601
    Sub New()
602
        SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
603
                 ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
604
        DoubleBuffered = True
605
        BackColor = Color.White
606
        Size = New Size(18, 18)
607
        Anchor = AnchorStyles.Top Or AnchorStyles.Right
608
        Font = New Font("Marlett", 12)
609
    End Sub
610
611
    Protected Overrides Sub OnPaint(e As PaintEventArgs)
612
        Dim B As New Bitmap(Width, Height)
613
        Dim G As Graphics = Graphics.FromImage(B)
614
615
        Dim Base As New Rectangle(0, 0, Width, Height)
616
617
        With G
618
            .SmoothingMode = 2
619
            .PixelOffsetMode = 2
620
            .TextRenderingHint = 5
621
            .Clear(BackColor)
622
623
            '-- Base
624
            .FillRectangle(New SolidBrush(_BaseColor), Base)
625
626
            '-- Minimize
627
            .DrawString("0", Font, New SolidBrush(TextColor), New Rectangle(2, 1, Width, Height), CenterSF)
628
629
            '-- Hover/down
630
            Select Case State
631
                Case MouseState.Over
632
                    .FillRectangle(New SolidBrush(Color.FromArgb(30, Color.White)), Base)
633
                Case MouseState.Down
634
                    .FillRectangle(New SolidBrush(Color.FromArgb(30, Color.Black)), Base)
635
            End Select
636
        End With
637
638
        MyBase.OnPaint(e)
639
        G.Dispose()
640
        e.Graphics.InterpolationMode = 7
641
        e.Graphics.DrawImageUnscaled(B, 0, 0)
642
        B.Dispose()
643
    End Sub
644
End Class
645
646
Class FlatColorPalette : Inherits Control
647
648
#Region " Variables"
649
650
    Private W, H As Integer
651
652
#End Region
653
654
#Region " Properties"
655
656
    Protected Overrides Sub OnResize(e As EventArgs)
657
        MyBase.OnResize(e)
658
        Width = 180
659
        Height = 80
660
    End Sub
661
662
#Region " Colors"
663
664
    <Category("Colors")> _
665
    Public Property Red As Color
666
        Get
667
            Return _Red
668
        End Get
669
        Set(value As Color)
670
            _Red = value
671
        End Set
672
    End Property
673
674
    <Category("Colors")> _
675
    Public Property Cyan As Color
676
        Get
677
            Return _Cyan
678
        End Get
679
        Set(value As Color)
680
            _Cyan = value
681
        End Set
682
    End Property
683
684
    <Category("Colors")> _
685
    Public Property Blue As Color
686
        Get
687
            Return _Blue
688
        End Get
689
        Set(value As Color)
690
            _Blue = value
691
        End Set
692
    End Property
693
694
    <Category("Colors")> _
695
    Public Property LimeGreen As Color
696
        Get
697
            Return _LimeGreen
698
        End Get
699
        Set(value As Color)
700
            _LimeGreen = value
701
        End Set
702
    End Property
703
704
    <Category("Colors")> _
705
    Public Property Orange As Color
706
        Get
707
            Return _Orange
708
        End Get
709
        Set(value As Color)
710
            _Orange = value
711
        End Set
712
    End Property
713
714
    <Category("Colors")> _
715
    Public Property Purple As Color
716
        Get
717
            Return _Purple
718
        End Get
719
        Set(value As Color)
720
            _Purple = value
721
        End Set
722
    End Property
723
724
    <Category("Colors")> _
725
    Public Property Black As Color
726
        Get
727
            Return _Black
728
        End Get
729
        Set(value As Color)
730
            _Black = value
731
        End Set
732
    End Property
733
734
    <Category("Colors")> _
735
    Public Property Gray As Color
736
        Get
737
            Return _Gray
738
        End Get
739
        Set(value As Color)
740
            _Gray = value
741
        End Set
742
    End Property
743
744
    <Category("Colors")> _
745
    Public Property White As Color
746
        Get
747
            Return _White
748
        End Get
749
        Set(value As Color)
750
            _White = value
751
        End Set
752
    End Property
753
754
#End Region
755
756
#End Region
757
758
#Region " Colors"
759
760
    Private _Red As Color = Color.FromArgb(220, 85, 96)
761
    Private _Cyan As Color = Color.FromArgb(10, 154, 157)
762
    Private _Blue As Color = Color.FromArgb(0, 128, 255)
763
    Private _LimeGreen As Color = Color.FromArgb(35, 168, 109)
764
    Private _Orange As Color = Color.FromArgb(253, 181, 63)
765
    Private _Purple As Color = Color.FromArgb(155, 88, 181)
766
    Private _Black As Color = Color.FromArgb(45, 47, 49)
767
    Private _Gray As Color = Color.FromArgb(63, 70, 73)
768
    Private _White As Color = Color.FromArgb(243, 243, 243)
769
770
#End Region
771
772
    Sub New()
773
        SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
774
                 ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
775
        DoubleBuffered = True
776
        BackColor = Color.FromArgb(60, 70, 73)
777
        Size = New Size(160, 80)
778
        Font = New Font("Segoe UI", 12)
779
    End Sub
780
781
    Protected Overrides Sub OnPaint(e As PaintEventArgs)
782
        B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
783
        W = Width - 1 : H = Height - 1
784
785
        With G
786
            .SmoothingMode = 2
787
            .PixelOffsetMode = 2
788
            .TextRenderingHint = 5
789
            .Clear(BackColor)
790
791
            '-- Colors 
792
            .FillRectangle(New SolidBrush(_Red), New Rectangle(0, 0, 20, 40))
793
            .FillRectangle(New SolidBrush(_Cyan), New Rectangle(20, 0, 20, 40))
794
            .FillRectangle(New SolidBrush(_Blue), New Rectangle(40, 0, 20, 40))
795
            .FillRectangle(New SolidBrush(_LimeGreen), New Rectangle(60, 0, 20, 40))
796
            .FillRectangle(New SolidBrush(_Orange), New Rectangle(80, 0, 20, 40))
797
            .FillRectangle(New SolidBrush(_Purple), New Rectangle(100, 0, 20, 40))
798
            .FillRectangle(New SolidBrush(_Black), New Rectangle(120, 0, 20, 40))
799
            .FillRectangle(New SolidBrush(_Gray), New Rectangle(140, 0, 20, 40))
800
            .FillRectangle(New SolidBrush(_White), New Rectangle(160, 0, 20, 40))
801
802
            '-- Text
803
            .DrawString("Color Palette", Font, New SolidBrush(_White), New Rectangle(0, 22, W, H), CenterSF)
804
        End With
805
806
        MyBase.OnPaint(e)
807
        G.Dispose()
808
        e.Graphics.InterpolationMode = 7
809
        e.Graphics.DrawImageUnscaled(B, 0, 0)
810
        B.Dispose()
811
    End Sub
812
End Class
813
814
Class FlatGroupBox : Inherits ContainerControl
815
816
#Region " Variables"
817
818
    Private W, H As Integer
819
    Private _ShowText As Boolean = True
820
821
#End Region
822
823
#Region " Properties"
824
825
    <Category("Colors")> _
826
    Public Property BaseColor As Color
827
        Get
828
            Return _BaseColor
829
        End Get
830
        Set(value As Color)
831
            _BaseColor = value
832
        End Set
833
    End Property
834
835
    Public Property ShowText As Boolean
836
        Get
837
            Return _ShowText
838
        End Get
839
        Set(value As Boolean)
840
            _ShowText = value
841
        End Set
842
    End Property
843
844
#End Region
845
846
#Region " Colors"
847
848
    Private _BaseColor As Color = Color.FromArgb(60, 70, 73)
849
850
#End Region
851
852
    Sub New()
853
        SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
854
                 ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or _
855
                 ControlStyles.SupportsTransparentBackColor, True)
856
        DoubleBuffered = True
857
        BackColor = Color.Transparent
858
        Size = New Size(240, 180)
859
        Font = New Font("Segoe ui", 10)
860
    End Sub
861
862
    Protected Overrides Sub OnPaint(e As PaintEventArgs)
863
        B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
864
        W = Width - 1 : H = Height - 1
865
866
        Dim GP, GP2, GP3 As New GraphicsPath
867
        Dim Base As New Rectangle(8, 8, W - 16, H - 16)
868
869
        With G
870
            .SmoothingMode = 2
871
            .PixelOffsetMode = 2
872
            .TextRenderingHint = 5
873
            .Clear(BackColor)
874
875
            '-- Base
876
            GP = Helpers.RoundRec(Base, 8)
877
            .FillPath(New SolidBrush(_BaseColor), GP)
878
879
            '-- Arrows
880
            GP2 = Helpers.DrawArrow(28, 2, False)
881
            .FillPath(New SolidBrush(_BaseColor), GP2)
882
            GP3 = Helpers.DrawArrow(28, 8, True)
883
            .FillPath(New SolidBrush(Color.FromArgb(60, 70, 73)), GP3)
884
885
            '-- if ShowText
886
            If ShowText Then
887
                .DrawString(Text, Font, New SolidBrush(_FlatColor), New Rectangle(16, 16, W, H), NearSF)
888
            End If
889
        End With
890
891
        MyBase.OnPaint(e)
892
        G.Dispose()
893
        e.Graphics.InterpolationMode = 7
894
        e.Graphics.DrawImageUnscaled(B, 0, 0)
895
        B.Dispose()
896
    End Sub
897
End Class
898
899
Class FlatButton : Inherits Control
900
901
#Region " Variables"
902
903
    Private W, H As Integer
904
    Private _Rounded As Boolean = False
905
    Private State As MouseState = MouseState.None
906
907
#End Region
908
909
#Region " Properties"
910
911
#Region " Colors"
912
913
    <Category("Colors")> _
914
    Public Property BaseColor As Color
915
        Get
916
            Return _BaseColor
917
        End Get
918
        Set(value As Color)
919
            _BaseColor = value
920
        End Set
921
    End Property
922
923
    <Category("Colors")> _
924
    Public Property TextColor As Color
925
        Get
926
            Return _TextColor
927
        End Get
928
        Set(value As Color)
929
            _TextColor = value
930
        End Set
931
    End Property
932
933
    <Category("Options")> _
934
    Public Property Rounded As Boolean
935
        Get
936
            Return _Rounded
937
        End Get
938
        Set(value As Boolean)
939
            _Rounded = value
940
        End Set
941
    End Property
942
943
#End Region
944
945
#Region " Mouse States"
946
947
    Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
948
        MyBase.OnMouseDown(e)
949
        State = MouseState.Down : Invalidate()
950
    End Sub
951
    Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
952
        MyBase.OnMouseUp(e)
953
        State = MouseState.Over : Invalidate()
954
    End Sub
955
    Protected Overrides Sub OnMouseEnter(e As EventArgs)
956
        MyBase.OnMouseEnter(e)
957
        State = MouseState.Over : Invalidate()
958
    End Sub
959
    Protected Overrides Sub OnMouseLeave(e As EventArgs)
960
        MyBase.OnMouseLeave(e)
961
        State = MouseState.None : Invalidate()
962
    End Sub
963
964
#End Region
965
966
#End Region
967
968
#Region " Colors"
969
970
    Private _BaseColor As Color = _FlatColor
971
    Private _TextColor As Color = Color.FromArgb(243, 243, 243)
972
973
#End Region
974
975
    Sub New()
976
        SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
977
                 ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or _
978
                 ControlStyles.SupportsTransparentBackColor, True)
979
        DoubleBuffered = True
980
        Size = New Size(106, 32)
981
        BackColor = Color.Transparent
982
        Font = New Font("Segoe UI", 12)
983
        Cursor = Cursors.Hand
984
    End Sub
985
986
    Protected Overrides Sub OnPaint(e As PaintEventArgs)
987
        B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
988
        W = Width - 1 : H = Height - 1
989
990
        Dim GP As New GraphicsPath
991
        Dim Base As New Rectangle(0, 0, W, H)
992
993
        With G
994
            .SmoothingMode = 2
995
            .PixelOffsetMode = 2
996
            .TextRenderingHint = 5
997
            .Clear(BackColor)
998
999
            Select Case State
1000
                Case MouseState.None
1001
                    If Rounded Then
1002
                        '-- Base
1003
                        GP = Helpers.RoundRec(Base, 6)
1004
                        .FillPath(New SolidBrush(_BaseColor), GP)
1005
1006
                        '-- Text
1007
                        .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
1008
                    Else
1009
                        '-- Base
1010
                        .FillRectangle(New SolidBrush(_BaseColor), Base)
1011
1012
                        '-- Text
1013
                        .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
1014
                    End If
1015
                Case MouseState.Over
1016
                    If Rounded Then
1017
                        '-- Base
1018
                        GP = Helpers.RoundRec(Base, 6)
1019
                        .FillPath(New SolidBrush(_BaseColor), GP)
1020
                        .FillPath(New SolidBrush(Color.FromArgb(20, Color.White)), GP)
1021
1022
                        '-- Text
1023
                        .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
1024
                    Else
1025
                        '-- Base
1026
                        .FillRectangle(New SolidBrush(_BaseColor), Base)
1027
                        .FillRectangle(New SolidBrush(Color.FromArgb(20, Color.White)), Base)
1028
1029
                        '-- Text
1030
                        .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
1031
                    End If
1032
                Case MouseState.Down
1033
                    If Rounded Then
1034
                        '-- Base
1035
                        GP = Helpers.RoundRec(Base, 6)
1036
                        .FillPath(New SolidBrush(_BaseColor), GP)
1037
                        .FillPath(New SolidBrush(Color.FromArgb(20, Color.Black)), GP)
1038
1039
                        '-- Text
1040
                        .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
1041
                    Else
1042
                        '-- Base
1043
                        .FillRectangle(New SolidBrush(_BaseColor), Base)
1044
                        .FillRectangle(New SolidBrush(Color.FromArgb(20, Color.Black)), Base)
1045
1046
                        '-- Text
1047
                        .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
1048
                    End If
1049
            End Select
1050
        End With
1051
1052
        MyBase.OnPaint(e)
1053
        G.Dispose()
1054
        e.Graphics.InterpolationMode = 7
1055
        e.Graphics.DrawImageUnscaled(B, 0, 0)
1056
        B.Dispose()
1057
    End Sub
1058
End Class
1059
1060
<DefaultEvent("CheckedChanged")> Class FlatToggle : Inherits Control
1061
1062
#Region " Variables"
1063
1064
    Private W, H As Integer
1065
    Private O As _Options
1066
    Private _Checked As Boolean = False
1067
    Private State As MouseState = MouseState.None
1068
1069
#End Region
1070
1071
#Region " Properties"
1072
    Public Event CheckedChanged(ByVal sender As Object)
1073
1074
    <Flags()> _
1075
    Enum _Options
1076
        Style1
1077
        Style2
1078
        Style3
1079
        Style4 '-- TODO: New Style
1080
        Style5 '-- TODO: New Style
1081
    End Enum
1082
1083
#Region " Options"
1084
1085
    <Category("Options")> _
1086
    Public Property Options As _Options
1087
        Get
1088
            Return O
1089
        End Get
1090
        Set(value As _Options)
1091
            O = value
1092
        End Set
1093
    End Property
1094
1095
    <Category("Options")> _
1096
    Public Property Checked As Boolean
1097
        Get
1098
            Return _Checked
1099
        End Get
1100
        Set(value As Boolean)
1101
            _Checked = value
1102
        End Set
1103
    End Property
1104
1105
#End Region
1106
1107
    Protected Overrides Sub OnTextChanged(e As EventArgs)
1108
        MyBase.OnTextChanged(e) : Invalidate()
1109
    End Sub
1110
1111
    Protected Overrides Sub OnResize(e As EventArgs)
1112
        MyBase.OnResize(e)
1113
        Width = 76
1114
        Height = 33
1115
    End Sub
1116
1117
#Region " Mouse States"
1118
1119
    Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
1120
        MyBase.OnMouseEnter(e)
1121
        State = MouseState.Over : Invalidate()
1122
    End Sub
1123
    Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
1124
        MyBase.OnMouseDown(e)
1125
        State = MouseState.Down : Invalidate()
1126
    End Sub
1127
    Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
1128
        MyBase.OnMouseLeave(e)
1129
        State = MouseState.None : Invalidate()
1130
    End Sub
1131
    Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
1132
        MyBase.OnMouseUp(e)
1133
        State = MouseState.Over : Invalidate()
1134
    End Sub
1135
    Protected Overrides Sub OnClick(e As EventArgs)
1136
        MyBase.OnClick(e)
1137
        _Checked = Not _Checked
1138
        RaiseEvent CheckedChanged(Me)
1139
    End Sub
1140
1141
#End Region
1142
1143
#End Region
1144
1145
#Region " Colors"
1146
1147
    Private BaseColor As Color = _FlatColor
1148
    Private BaseColorRed As Color = Color.FromArgb(220, 85, 96)
1149
    Private BGColor As Color = Color.FromArgb(84, 85, 86)
1150
    Private ToggleColor As Color = Color.FromArgb(45, 47, 49)
1151
    Private TextColor As Color = Color.FromArgb(243, 243, 243)
1152
1153
#End Region
1154
1155
    Sub New()
1156
        SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
1157
                 ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or _
1158
                 ControlStyles.SupportsTransparentBackColor, True)
1159
        DoubleBuffered = True
1160
        BackColor = Color.Transparent
1161
        Size = New Size(44, Height + 1)
1162
        Cursor = Cursors.Hand
1163
        Font = New Font("Segoe UI", 10)
1164
        Size = New Size(76, 33)
1165
    End Sub
1166
1167
    Protected Overrides Sub OnPaint(e As PaintEventArgs)
1168
        B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
1169
        W = Width - 1 : H = Height - 1
1170
1171
        Dim GP, GP2 As New GraphicsPath
1172
        Dim Base As New Rectangle(0, 0, W, H), Toggle As New Rectangle(CInt(W \ 2), 0, 38, H)
1173
1174
        With G
1175
            .SmoothingMode = 2
1176
            .PixelOffsetMode = 2
1177
            .TextRenderingHint = 5
1178
            .Clear(BackColor)
1179
1180
            Select Case O
1181
                Case _Options.Style1   '-- Style 1
1182
                    '-- Base
1183
                    GP = Helpers.RoundRec(Base, 6)
1184
                    GP2 = Helpers.RoundRec(Toggle, 6)
1185
                    .FillPath(New SolidBrush(BGColor), GP)
1186
                    .FillPath(New SolidBrush(ToggleColor), GP2)
1187
1188
                    '-- Text
1189
                    .DrawString("OFF", Font, New SolidBrush(BGColor), New Rectangle(19, 1, W, H), CenterSF)
1190
1191
                    If Checked Then
1192
                        '-- Base
1193
                        GP = Helpers.RoundRec(Base, 6)
1194
                        GP2 = Helpers.RoundRec(New Rectangle(CInt(W \ 2), 0, 38, H), 6)
1195
                        .FillPath(New SolidBrush(ToggleColor), GP)
1196
                        .FillPath(New SolidBrush(BaseColor), GP2)
1197
1198
                        '-- Text
1199
                        .DrawString("ON", Font, New SolidBrush(BaseColor), New Rectangle(8, 7, W, H), NearSF)
1200
                    End If
1201
                Case _Options.Style2   '-- Style 2
1202
                    '-- Base
1203
                    GP = Helpers.RoundRec(Base, 6)
1204
                    Toggle = New Rectangle(4, 4, 36, H - 8)
1205
                    GP2 = Helpers.RoundRec(Toggle, 4)
1206
                    .FillPath(New SolidBrush(BaseColorRed), GP)
1207
                    .FillPath(New SolidBrush(ToggleColor), GP2)
1208
1209
                    '-- Lines
1210
                    .DrawLine(New Pen(BGColor), 18, 20, 18, 12)
1211
                    .DrawLine(New Pen(BGColor), 22, 20, 22, 12)
1212
                    .DrawLine(New Pen(BGColor), 26, 20, 26, 12)
1213
1214
                    '-- Text
1215
                    .DrawString("r", New Font("Marlett", 8), New SolidBrush(TextColor), New Rectangle(19, 2, Width, Height), CenterSF)
1216
1217
                    If Checked Then
1218
                        GP = Helpers.RoundRec(Base, 6)
1219
                        Toggle = New Rectangle(CInt(W \ 2) - 2, 4, 36, H - 8)
1220
                        GP2 = Helpers.RoundRec(Toggle, 4)
1221
                        .FillPath(New SolidBrush(BaseColor), GP)
1222
                        .FillPath(New SolidBrush(ToggleColor), GP2)
1223
1224
                        '-- Lines
1225
                        .DrawLine(New Pen(BGColor), CInt(W \ 2) + 12, 20, CInt(W \ 2) + 12, 12)
1226
                        .DrawLine(New Pen(BGColor), CInt(W \ 2) + 16, 20, CInt(W \ 2) + 16, 12)
1227
                        .DrawLine(New Pen(BGColor), CInt(W \ 2) + 20, 20, CInt(W \ 2) + 20, 12)
1228
1229
                        '-- Text
1230
                        .DrawString("ü", New Font("Wingdings", 14), New SolidBrush(TextColor), New Rectangle(8, 7, Width, Height), NearSF)
1231
                    End If
1232
                Case _Options.Style3   '-- Style 3
1233
                    '-- Base
1234
                    GP = Helpers.RoundRec(Base, 16)
1235
                    Toggle = New Rectangle(W - 28, 4, 22, H - 8)
1236
                    GP2.AddEllipse(Toggle)
1237
                    .FillPath(New SolidBrush(ToggleColor), GP)
1238
                    .FillPath(New SolidBrush(BaseColorRed), GP2)
1239
1240
                    '-- Text
1241
                    .DrawString("OFF", Font, New SolidBrush(BaseColorRed), New Rectangle(-12, 2, W, H), CenterSF)
1242
1243
                    If Checked Then
1244
                        '-- Base
1245
                        GP = Helpers.RoundRec(Base, 16)
1246
                        Toggle = New Rectangle(6, 4, 22, H - 8)
1247
                        GP2.Reset()
1248
                        GP2.AddEllipse(Toggle)
1249
                        .FillPath(New SolidBrush(ToggleColor), GP)
1250
                        .FillPath(New SolidBrush(BaseColor), GP2)
1251
1252
                        '-- Text
1253
                        .DrawString("ON", Font, New SolidBrush(BaseColor), New Rectangle(12, 2, W, H), CenterSF)
1254
                    End If
1255
                Case _Options.Style4
1256
                    '-- TODO: New Styles
1257
                    If Checked Then
1258
                        '--
1259
                    End If
1260
                Case _Options.Style5
1261
                    '-- TODO: New Styles
1262
                    If Checked Then
1263
                        '--
1264
                    End If
1265
            End Select
1266
1267
        End With
1268
1269
        MyBase.OnPaint(e)
1270
        G.Dispose()
1271
        e.Graphics.InterpolationMode = 7
1272
        e.Graphics.DrawImageUnscaled(B, 0, 0)
1273
        B.Dispose()
1274
    End Sub
1275
End Class
1276
1277
<DefaultEvent("CheckedChanged")> Class RadioButton : Inherits Control
1278
1279
#Region " Variables"
1280
1281
    Private State As MouseState = MouseState.None
1282
    Private W, H As Integer
1283
    Private O As _Options
1284
    Private _Checked As Boolean
1285
1286
#End Region
1287
1288
#Region " Properties"
1289
    Property Checked() As Boolean
1290
        Get
1291
            Return _Checked
1292
        End Get
1293
        Set(value As Boolean)
1294
            _Checked = value
1295
            InvalidateControls()
1296
            RaiseEvent CheckedChanged(Me)
1297
            Invalidate()
1298
        End Set
1299
    End Property
1300
    Event CheckedChanged(ByVal sender As Object)
1301
    Protected Overrides Sub OnClick(e As EventArgs)
1302
        If Not _Checked Then Checked = True
1303
        MyBase.OnClick(e)
1304
    End Sub
1305
    Private Sub InvalidateControls()
1306
        If Not IsHandleCreated OrElse Not _Checked Then Return
1307
        For Each C As Control In Parent.Controls
1308
            If C IsNot Me AndAlso TypeOf C Is RadioButton Then
1309
                DirectCast(C, RadioButton).Checked = False
1310
                Invalidate()
1311
            End If
1312
        Next
1313
    End Sub
1314
    Protected Overrides Sub OnCreateControl()
1315
        MyBase.OnCreateControl()
1316
        InvalidateControls()
1317
    End Sub
1318
1319
    <Flags> _
1320
    Enum _Options
1321
        Style1
1322
        Style2
1323
    End Enum
1324
1325
    <Category("Options")> _
1326
    Public Property Options As _Options
1327
        Get
1328
            Return O
1329
        End Get
1330
        Set(value As _Options)
1331
            O = value
1332
        End Set
1333
    End Property
1334
1335
    Protected Overrides Sub OnResize(e As EventArgs)
1336
        MyBase.OnResize(e)
1337
        Height = 22
1338
    End Sub
1339
1340
#Region " Mouse States"
1341
1342
    Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
1343
        MyBase.OnMouseDown(e)
1344
        State = MouseState.Down : Invalidate()
1345
    End Sub
1346
    Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
1347
        MyBase.OnMouseUp(e)
1348
        State = MouseState.Over : Invalidate()
1349
    End Sub
1350
    Protected Overrides Sub OnMouseEnter(e As EventArgs)
1351
        MyBase.OnMouseEnter(e)
1352
        State = MouseState.Over : Invalidate()
1353
    End Sub
1354
    Protected Overrides Sub OnMouseLeave(e As EventArgs)
1355
        MyBase.OnMouseLeave(e)
1356
        State = MouseState.None : Invalidate()
1357
    End Sub
1358
1359
#End Region
1360
#End Region
1361
1362
#Region " Colors"
1363
1364
    Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
1365
    Private _BorderColor As Color = _FlatColor
1366
    Private _TextColor As Color = Color.FromArgb(243, 243, 243)
1367
1368
#End Region
1369
1370
    Sub New()
1371
        SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
1372
                   ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
1373
        DoubleBuffered = True
1374
        Cursor = Cursors.Hand
1375
        Size = New Size(100, 22)
1376
        BackColor = Color.FromArgb(60, 70, 73)
1377
        Font = New Font("Segoe UI", 10)
1378
    End Sub
1379
    Protected Overrides Sub OnPaint(e As PaintEventArgs)
1380
        B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
1381
        W = Width - 1 : H = Height - 1
1382
1383
        Dim Base As New Rectangle(0, 2, Height - 5, Height - 5), Dot As New Rectangle(4, 6, H - 12, H - 12)
1384
1385
        With G
1386
            .SmoothingMode = 2
1387
            .TextRenderingHint = 5
1388
            .Clear(BackColor)
1389
1390
            Select Case O
1391
                Case _Options.Style1
1392
                    '-- Base
1393
                    .FillEllipse(New SolidBrush(_BaseColor), Base)
1394
1395
                    Select Case State
1396
                        Case MouseState.Over
1397
                            .DrawEllipse(New Pen(_BorderColor), Base)
1398
                        Case MouseState.Down
1399
                            .DrawEllipse(New Pen(_BorderColor), Base)
1400
                    End Select
1401
1402
                    '-- If Checked 
1403
                    If Checked Then
1404
                        .FillEllipse(New SolidBrush(_BorderColor), Dot)
1405
                    End If
1406
                Case _Options.Style2
1407
                    '-- Base
1408
                    .FillEllipse(New SolidBrush(_BaseColor), Base)
1409
1410
                    Select Case State
1411
                        Case MouseState.Over
1412
                            '-- Base
1413
                            .DrawEllipse(New Pen(_BorderColor), Base)
1414
                            .FillEllipse(New SolidBrush(Color.FromArgb(118, 213, 170)), Base)
1415
                        Case MouseState.Down
1416
                            '-- Base
1417
                            .DrawEllipse(New Pen(_BorderColor), Base)
1418
                            .FillEllipse(New SolidBrush(Color.FromArgb(118, 213, 170)), Base)
1419
                    End Select
1420
1421
                    '-- If Checked
1422
                    If Checked Then
1423
                        '-- Base
1424
                        .FillEllipse(New SolidBrush(_BorderColor), Dot)
1425
                    End If
1426
            End Select
1427
1428
            .DrawString(Text, Font, New SolidBrush(_TextColor), New Rectangle(20, 2, W, H), NearSF)
1429
        End With
1430
1431
        MyBase.OnPaint(e)
1432
        G.Dispose()
1433
        e.Graphics.InterpolationMode = 7
1434
        e.Graphics.DrawImageUnscaled(B, 0, 0)
1435
        B.Dispose()
1436
    End Sub
1437
End Class
1438
1439
<DefaultEvent("CheckedChanged")> Class FlatCheckBox : Inherits Control
1440
1441
#Region " Variables"
1442
1443
    Private W, H As Integer
1444
    Private State As MouseState = MouseState.None
1445
    Private O As _Options
1446
    Private _Checked As Boolean
1447
1448
#End Region
1449
1450
#Region " Properties"
1451
    Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
1452
        MyBase.OnTextChanged(e)
1453
        Invalidate()
1454
    End Sub
1455
1456
    Property Checked() As Boolean
1457
        Get
1458
            Return _Checked
1459
        End Get
1460
        Set(ByVal value As Boolean)
1461
            _Checked = value
1462
            Invalidate()
1463
        End Set
1464
    End Property
1465
1466
    Event CheckedChanged(ByVal sender As Object)
1467
    Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
1468
        _Checked = Not _Checked
1469
        RaiseEvent CheckedChanged(Me)
1470
        MyBase.OnClick(e)
1471
    End Sub
1472
1473
    <Flags> _
1474
    Enum _Options
1475
        Style1
1476
        Style2
1477
    End Enum
1478
1479
    <Category("Options")> _
1480
    Public Property Options As _Options
1481
        Get
1482
            Return O
1483
        End Get
1484
        Set(value As _Options)
1485
            O = value
1486
        End Set
1487
    End Property
1488
1489
    Protected Overrides Sub OnResize(e As EventArgs)
1490
        MyBase.OnResize(e)
1491
        Height = 22
1492
    End Sub
1493
1494
#Region " Colors"
1495
1496
    <Category("Colors")> _
1497
    Public Property BaseColor As Color
1498
        Get
1499
            Return _BaseColor
1500
        End Get
1501
        Set(value As Color)
1502
            _BaseColor = value
1503
        End Set
1504
    End Property
1505
1506
    <Category("Colors")> _
1507
    Public Property BorderColor As Color
1508
        Get
1509
            Return _BorderColor
1510
        End Get
1511
        Set(value As Color)
1512
            _BorderColor = value
1513
        End Set
1514
    End Property
1515
1516
#End Region
1517
1518
#Region " Mouse States"
1519
1520
    Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
1521
        MyBase.OnMouseDown(e)
1522
        State = MouseState.Down : Invalidate()
1523
    End Sub
1524
    Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
1525
        MyBase.OnMouseUp(e)
1526
        State = MouseState.Over : Invalidate()
1527
    End Sub
1528
    Protected Overrides Sub OnMouseEnter(e As EventArgs)
1529
        MyBase.OnMouseEnter(e)
1530
        State = MouseState.Over : Invalidate()
1531
    End Sub
1532
    Protected Overrides Sub OnMouseLeave(e As EventArgs)
1533
        MyBase.OnMouseLeave(e)
1534
        State = MouseState.None : Invalidate()
1535
    End Sub
1536
1537
#End Region
1538
1539
#End Region
1540
1541
#Region " Colors"
1542
1543
    Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
1544
    Private _BorderColor As Color = _FlatColor
1545
    Private _TextColor As Color = Color.FromArgb(243, 243, 243)
1546
1547
#End Region
1548
1549
    Sub New()
1550
        SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
1551
                 ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
1552
        DoubleBuffered = True
1553
        BackColor = Color.FromArgb(60, 70, 73)
1554
        Cursor = Cursors.Hand
1555
        Font = New Font("Segoe UI", 10)
1556
        Size = New Size(112, 22)
1557
    End Sub
1558
1559
    Protected Overrides Sub OnPaint(e As PaintEventArgs)
1560
        B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
1561
        W = Width - 1 : H = Height - 1
1562
1563
        Dim Base As New Rectangle(0, 2, Height - 5, Height - 5)
1564
1565
        With G
1566
            .SmoothingMode = 2
1567
            .TextRenderingHint = 5
1568
            .Clear(BackColor)
1569
            Select Case O
1570
                Case _Options.Style1 '-- Style 1
1571
                    '-- Base
1572
                    .FillRectangle(New SolidBrush(_BaseColor), Base)
1573
1574
                    Select Case State
1575
                        Case MouseState.Over
1576
                            '-- Base
1577
                            .DrawRectangle(New Pen(_BorderColor), Base)
1578
                        Case MouseState.Down
1579
                            '-- Base
1580
                            .DrawRectangle(New Pen(_BorderColor), Base)
1581
                    End Select
1582
1583
                    '-- If Checked
1584
                    If Checked Then
1585
                        .DrawString("ü", New Font("Wingdings", 18), New SolidBrush(_BorderColor), New Rectangle(5, 7, H - 9, H - 9), CenterSF)
1586
                    End If
1587
1588
                    '-- If Enabled
1589
                    If Me.Enabled = False Then
1590
                        .FillRectangle(New SolidBrush(Color.FromArgb(54, 58, 61)), Base)
1591
                        .DrawString(Text, Font, New SolidBrush(Color.FromArgb(140, 142, 143)), New Rectangle(20, 2, W, H), NearSF)
1592
                    End If
1593
1594
                    '-- Text
1595
                    .DrawString(Text, Font, New SolidBrush(_TextColor), New Rectangle(20, 2, W, H), NearSF)
1596
                Case _Options.Style2 '-- Style 2
1597
                    '-- Base
1598
                    .FillRectangle(New SolidBrush(_BaseColor), Base)
1599
1600
                    Select Case State
1601
                        Case MouseState.Over
1602
                            '-- Base
1603
                            .DrawRectangle(New Pen(_BorderColor), Base)
1604
                            .FillRectangle(New SolidBrush(Color.FromArgb(118, 213, 170)), Base)
1605
                        Case MouseState.Down
1606
                            '-- Base
1607
                            .DrawRectangle(New Pen(_BorderColor), Base)
1608
                            .FillRectangle(New SolidBrush(Color.FromArgb(118, 213, 170)), Base)
1609
                    End Select
1610
1611
                    '-- If Checked
1612
                    If Checked Then
1613
                        .DrawString("ü", New Font("Wingdings", 18), New SolidBrush(_BorderColor), New Rectangle(5, 7, H - 9, H - 9), CenterSF)
1614
                    End If
1615
1616
                    '-- If Enabled
1617
                    If Me.Enabled = False Then
1618
                        .FillRectangle(New SolidBrush(Color.FromArgb(54, 58, 61)), Base)
1619
                        .DrawString(Text, Font, New SolidBrush(Color.FromArgb(48, 119, 91)), New Rectangle(20, 2, W, H), NearSF)
1620
                    End If
1621
1622
                    '-- Text
1623
                    .DrawString(Text, Font, New SolidBrush(_TextColor), New Rectangle(20, 2, W, H), NearSF)
1624
            End Select
1625
        End With
1626
1627
        MyBase.OnPaint(e)
1628
        G.Dispose()
1629
        e.Graphics.InterpolationMode = 7
1630
        e.Graphics.DrawImageUnscaled(B, 0, 0)
1631
        B.Dispose()
1632
    End Sub
1633
End Class
1634
1635
<DefaultEvent("TextChanged")> Class FlatTextBox : Inherits Control
1636
1637
#Region " Variables"
1638
1639
    Private W, H As Integer
1640
    Private State As MouseState = MouseState.None
1641
    Private WithEvents TB As Windows.Forms.TextBox
1642
1643
#End Region
1644
1645
#Region " Properties"
1646
1647
#Region " TextBox Properties"
1648
1649
    Private _TextAlign As HorizontalAlignment = HorizontalAlignment.Left
1650
    <Category("Options")> _
1651
    Property TextAlign() As HorizontalAlignment
1652
        Get
1653
            Return _TextAlign
1654
        End Get
1655
        Set(ByVal value As HorizontalAlignment)
1656
            _TextAlign = value
1657
            If TB IsNot Nothing Then
1658
                TB.TextAlign = value
1659
            End If
1660
        End Set
1661
    End Property
1662
    Private _MaxLength As Integer = 32767
1663
    <Category("Options")> _
1664
    Property MaxLength() As Integer
1665
        Get
1666
            Return _MaxLength
1667
        End Get
1668
        Set(ByVal value As Integer)
1669
            _MaxLength = value
1670
            If TB IsNot Nothing Then
1671
                TB.MaxLength = value
1672
            End If
1673
        End Set
1674
    End Property
1675
    Private _ReadOnly As Boolean
1676
    <Category("Options")> _
1677
    Property [ReadOnly]() As Boolean
1678
        Get
1679
            Return _ReadOnly
1680
        End Get
1681
        Set(ByVal value As Boolean)
1682
            _ReadOnly = value
1683
            If TB IsNot Nothing Then
1684
                TB.ReadOnly = value
1685
            End If
1686
        End Set
1687
    End Property
1688
    Private _UseSystemPasswordChar As Boolean
1689
    <Category("Options")> _
1690
    Property UseSystemPasswordChar() As Boolean
1691
        Get
1692
            Return _UseSystemPasswordChar
1693
        End Get
1694
        Set(ByVal value As Boolean)
1695
            _UseSystemPasswordChar = value
1696
            If TB IsNot Nothing Then
1697
                TB.UseSystemPasswordChar = value
1698
            End If
1699
        End Set
1700
    End Property
1701
    Private _Multiline As Boolean
1702
    <Category("Options")> _
1703
    Property Multiline() As Boolean
1704
        Get
1705
            Return _Multiline
1706
        End Get
1707
        Set(ByVal value As Boolean)
1708
            _Multiline = value
1709
            If TB IsNot Nothing Then
1710
                TB.Multiline = value
1711
1712
                If value Then
1713
                    TB.Height = Height - 11
1714
                Else
1715
                    Height = TB.Height + 11
1716
                End If
1717
1718
            End If
1719
        End Set
1720
    End Property
1721
    <Category("Options")> _
1722
    Overrides Property Text As String
1723
        Get
1724
            Return MyBase.Text
1725
        End Get
1726
        Set(ByVal value As String)
1727
            MyBase.Text = value
1728
            If TB IsNot Nothing Then
1729
                TB.Text = value
1730
            End If
1731
        End Set
1732
    End Property
1733
    <Category("Options")> _
1734
    Overrides Property Font As Font
1735
        Get
1736
            Return MyBase.Font
1737
        End Get
1738
        Set(ByVal value As Font)
1739
            MyBase.Font = value
1740
            If TB IsNot Nothing Then
1741
                TB.Font = value
1742
                TB.Location = New Point(3, 5)
1743
                TB.Width = Width - 6
1744
1745
                If Not _Multiline Then
1746
                    Height = TB.Height + 11
1747
                End If
1748
            End If
1749
        End Set
1750
    End Property
1751
1752
    Protected Overrides Sub OnCreateControl()
1753
        MyBase.OnCreateControl()
1754
        If Not Controls.Contains(TB) Then
1755
            Controls.Add(TB)
1756
        End If
1757
    End Sub
1758
    Private Sub OnBaseTextChanged(ByVal s As Object, ByVal e As EventArgs)
1759
        Text = TB.Text
1760
    End Sub
1761
    Private Sub OnBaseKeyDown(ByVal s As Object, ByVal e As KeyEventArgs)
1762
        If e.Control AndAlso e.KeyCode = Keys.A Then
1763
            TB.SelectAll()
1764
            e.SuppressKeyPress = True
1765
        End If
1766
        If e.Control AndAlso e.KeyCode = Keys.C Then
1767
            TB.Copy()
1768
            e.SuppressKeyPress = True
1769
        End If
1770
    End Sub
1771
    Protected Overrides Sub OnResize(ByVal e As EventArgs)
1772
        TB.Location = New Point(5, 5)
1773
        TB.Width = Width - 10
1774
1775
        If _Multiline Then
1776
            TB.Height = Height - 11
1777
        Else
1778
            Height = TB.Height + 11
1779
        End If
1780
1781
        MyBase.OnResize(e)
1782
    End Sub
1783
1784
#End Region
1785
1786
#Region " Colors"
1787
1788
    <Category("Colors")> _
1789
    Public Property TextColor As Color
1790
        Get
1791
            Return _TextColor
1792
        End Get
1793
        Set(value As Color)
1794
            _TextColor = value
1795
        End Set
1796
    End Property
1797
1798
    Public Overrides Property ForeColor() As Color
1799
        Get
1800
            Return _TextColor
1801
        End Get
1802
        Set(value As Color)
1803
            _TextColor = value
1804
        End Set
1805
    End Property
1806
1807
#End Region
1808
1809
#Region " Mouse States"
1810
1811
    Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
1812
        MyBase.OnMouseDown(e)
1813
        State = MouseState.Down : Invalidate()
1814
    End Sub
1815
    Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
1816
        MyBase.OnMouseUp(e)
1817
        State = MouseState.Over : TB.Focus() : Invalidate()
1818
    End Sub
1819
    Protected Overrides Sub OnMouseEnter(e As EventArgs)
1820
        MyBase.OnMouseEnter(e)
1821
        State = MouseState.Over : TB.Focus() : Invalidate()
1822
    End Sub
1823
    Protected Overrides Sub OnMouseLeave(e As EventArgs)
1824
        MyBase.OnMouseLeave(e)
1825
        State = MouseState.None : Invalidate()
1826
    End Sub
1827
1828
#End Region
1829
1830
#End Region
1831
1832
#Region " Colors"
1833
1834
    Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
1835
    Private _TextColor As Color = Color.FromArgb(192, 192, 192)
1836
    Private _BorderColor As Color = _FlatColor
1837
1838
#End Region
1839
1840
    Sub New()
1841
        SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
1842
                 ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or _
1843
                 ControlStyles.SupportsTransparentBackColor, True)
1844
        DoubleBuffered = True
1845
1846
        BackColor = Color.Transparent
1847
1848
        TB = New Windows.Forms.TextBox
1849
        TB.Font = New Font("Segoe UI", 10)
1850
        TB.Text = Text
1851
        TB.BackColor = _BaseColor
1852
        TB.ForeColor = _TextColor
1853
        TB.MaxLength = _MaxLength
1854
        TB.Multiline = _Multiline
1855
        TB.ReadOnly = _ReadOnly
1856
        TB.UseSystemPasswordChar = _UseSystemPasswordChar
1857
        TB.BorderStyle = BorderStyle.None
1858
        TB.Location = New Point(5, 5)
1859
        TB.Width = Width - 10
1860
1861
        TB.Cursor = Cursors.IBeam
1862
1863
        If _Multiline Then
1864
            TB.Height = Height - 11
1865
        Else
1866
            Height = TB.Height + 11
1867
        End If
1868
1869
        AddHandler TB.TextChanged, AddressOf OnBaseTextChanged
1870
        AddHandler TB.KeyDown, AddressOf OnBaseKeyDown
1871
    End Sub
1872
1873
    Protected Overrides Sub OnPaint(e As PaintEventArgs)
1874
        B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
1875
        W = Width - 1 : H = Height - 1
1876
1877
        Dim Base As New Rectangle(0, 0, W, H)
1878
1879
        With G
1880
            .SmoothingMode = 2
1881
            .PixelOffsetMode = 2
1882
            .TextRenderingHint = 5
1883
            .Clear(BackColor)
1884
1885
            '-- Colors
1886
            TB.BackColor = _BaseColor
1887
            TB.ForeColor = _TextColor
1888
1889
            '-- Base
1890
            .FillRectangle(New SolidBrush(_BaseColor), Base)
1891
        End With
1892
1893
        MyBase.OnPaint(e)
1894
        G.Dispose()
1895
        e.Graphics.InterpolationMode = 7
1896
        e.Graphics.DrawImageUnscaled(B, 0, 0)
1897
        B.Dispose()
1898
    End Sub
1899
1900
End Class
1901
1902
Class FlatTabControl : Inherits TabControl
1903
1904
#Region " Variables"
1905
1906
    Private W, H As Integer
1907
1908
#End Region
1909
1910
#Region " Properties"
1911
1912
    Protected Overrides Sub CreateHandle()
1913
        MyBase.CreateHandle()
1914
        Alignment = TabAlignment.Top
1915
    End Sub
1916
1917
#Region " Colors"
1918
1919
    <Category("Colors")> _
1920
    Public Property BaseColor As Color
1921
        Get
1922
            Return _BaseColor
1923
        End Get
1924
        Set(value As Color)
1925
            _BaseColor = value
1926
        End Set
1927
    End Property
1928
1929
    <Category("Colors")> _
1930
    Public Property ActiveColor As Color
1931
        Get
1932
            Return _ActiveColor
1933
        End Get
1934
        Set(value As Color)
1935
            _ActiveColor = value
1936
        End Set
1937
    End Property
1938
1939
#End Region
1940
    
1941
#End Region
1942
1943
#Region " Colors"
1944
1945
    Private BGColor As Color = Color.FromArgb(60, 70, 73)
1946
    Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
1947
    Private _ActiveColor As Color = _FlatColor
1948
1949
#End Region
1950
1951
    Sub New()
1952
        SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
1953
                 ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
1954
        DoubleBuffered = True
1955
        BackColor = Color.FromArgb(60, 70, 73)
1956
1957
        Font = New Font("Segoe UI", 10)
1958
        SizeMode = TabSizeMode.Fixed
1959
        ItemSize = New Size(120, 40)
1960
    End Sub
1961
1962
    Protected Overrides Sub OnPaint(e As PaintEventArgs)
1963
        B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
1964
        W = Width - 1 : H = Height - 1
1965
1966
        With G
1967
            .SmoothingMode = 2
1968
            .PixelOffsetMode = 2
1969
            .TextRenderingHint = 5
1970
            .Clear(_BaseColor)
1971
1972
            Try : SelectedTab.BackColor = BGColor : Catch : End Try
1973
1974
            For i = 0 To TabCount - 1
1975
                Dim Base As New Rectangle(New Point(GetTabRect(i).Location.X + 2, GetTabRect(i).Location.Y), New Size(GetTabRect(i).Width, GetTabRect(i).Height))
1976
                Dim BaseSize As New Rectangle(Base.Location, New Size(Base.Width, Base.Height))
1977
1978
                If i = SelectedIndex Then
1979
                    '-- Base
1980
                    .FillRectangle(New SolidBrush(_BaseColor), BaseSize)
1981
1982
                    '-- Gradiant
1983
                    '.fill
1984
                    .FillRectangle(New SolidBrush(_ActiveColor), BaseSize)
1985
1986
                    '-- ImageList
1987
                    If ImageList IsNot Nothing Then
1988
                        Try
1989
                            If ImageList.Images(TabPages(i).ImageIndex) IsNot Nothing Then
1990
                                '-- Image
1991
                                .DrawImage(ImageList.Images(TabPages(i).ImageIndex), New Point(BaseSize.Location.X + 8, BaseSize.Location.Y + 6))
1992
                                '-- Text
1993
                                .DrawString("      " & TabPages(i).Text, Font, Brushes.White, BaseSize, CenterSF)
1994
                            Else
1995
                                '-- Text
1996
                                .DrawString(TabPages(i).Text, Font, Brushes.White, BaseSize, CenterSF)
1997
                            End If
1998
                        Catch ex As Exception
1999
                            Throw New Exception(ex.Message)
2000
                        End Try
2001
                    Else
2002
                        '-- Text
2003
                        .DrawString(TabPages(i).Text, Font, Brushes.White, BaseSize, CenterSF)
2004
                    End If
2005
                Else
2006
                    '-- Base
2007
                    .FillRectangle(New SolidBrush(_BaseColor), BaseSize)
2008
2009
                    '-- ImageList
2010
                    If ImageList IsNot Nothing Then
2011
                        Try
2012
                            If ImageList.Images(TabPages(i).ImageIndex) IsNot Nothing Then
2013
                                '-- Image
2014
                                .DrawImage(ImageList.Images(TabPages(i).ImageIndex), New Point(BaseSize.Location.X + 8, BaseSize.Location.Y + 6))
2015
                                '-- Text
2016
                                .DrawString("      " & TabPages(i).Text, Font, New SolidBrush(Color.White), BaseSize, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
2017
                            Else
2018
                                '-- Text
2019
                                .DrawString(TabPages(i).Text, Font, New SolidBrush(Color.White), BaseSize, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
2020
                            End If
2021
                        Catch ex As Exception
2022
                            Throw New Exception(ex.Message)
2023
                        End Try
2024
                    Else
2025
                        '-- Text
2026
                        .DrawString(TabPages(i).Text, Font, New SolidBrush(Color.White), BaseSize, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
2027
                    End If
2028
                End If
2029
            Next
2030
        End With
2031
2032
        MyBase.OnPaint(e)
2033
        G.Dispose()
2034
        e.Graphics.InterpolationMode = 7
2035
        e.Graphics.DrawImageUnscaled(B, 0, 0)
2036
        B.Dispose()
2037
    End Sub
2038
End Class
2039
2040
Class FlatAlertBox : Inherits Control
2041
2042
    ''' <summary>
2043
    ''' How to use: FlatAlertBox.ShowControl(Kind, String, Interval)
2044
    ''' </summary>
2045
    ''' <remarks></remarks>
2046
2047
#Region " Variables"
2048
2049
    Private W, H As Integer
2050
    Private K As _Kind
2051
    Private _Text As String
2052
    Private State As MouseState = MouseState.None
2053
    Private X As Integer
2054
    Private WithEvents T As Timer
2055
2056
#End Region
2057
2058
#Region " Properties"
2059
2060
    <Flags()> _
2061
    Enum _Kind
2062
        [Success]
2063
        [Error]
2064
        [Info]
2065
    End Enum
2066
2067
#Region " Options"
2068
2069
    <Category("Options")> _
2070
    Public Property kind As _Kind
2071
        Get
2072
            Return K
2073
        End Get
2074
        Set(value As _Kind)
2075
            K = value
2076
        End Set
2077
    End Property
2078
2079
    <Category("Options")> _
2080
    Overrides Property Text As String
2081
        Get
2082
            Return MyBase.Text
2083
        End Get
2084
        Set(ByVal value As String)
2085
            MyBase.Text = value
2086
            If _Text IsNot Nothing Then
2087
                _Text = value
2088
            End If
2089
        End Set
2090
    End Property
2091
2092
    <Category("Options")> _
2093
    Shadows Property Visible As Boolean
2094
        Get
2095
            Return MyBase.Visible = False
2096
        End Get
2097
        Set(value As Boolean)
2098
            MyBase.Visible = value
2099
        End Set
2100
    End Property
2101
2102
#End Region
2103
2104
    Protected Overrides Sub OnTextChanged(e As EventArgs)
2105
        MyBase.OnTextChanged(e) : Invalidate()
2106
    End Sub
2107
2108
    Protected Overrides Sub OnResize(e As EventArgs)
2109
        MyBase.OnResize(e)
2110
        Height = 42
2111
    End Sub
2112
2113
    Public Sub ShowControl(Kind As _Kind, Str As String, Interval As Integer)
2114
        K = Kind
2115
        Text = Str
2116
        Me.Visible = True
2117
        T = New Timer
2118
        T.Interval = Interval
2119
        T.Enabled = True
2120
    End Sub
2121
2122
    Private Sub T_Tick(sender As Object, e As EventArgs) Handles T.Tick
2123
        Me.Visible = False
2124
        T.Enabled = False
2125
        T.Dispose()
2126
    End Sub
2127
2128
#Region " Mouse States"
2129
2130
    Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
2131
        MyBase.OnMouseDown(e)
2132
        State = MouseState.Down : Invalidate()
2133
    End Sub
2134
    Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
2135
        MyBase.OnMouseUp(e)
2136
        State = MouseState.Over : Invalidate()
2137
    End Sub
2138
    Protected Overrides Sub OnMouseEnter(e As EventArgs)
2139
        MyBase.OnMouseEnter(e)
2140
        State = MouseState.Over : Invalidate()
2141
    End Sub
2142
    Protected Overrides Sub OnMouseLeave(e As EventArgs)
2143
        MyBase.OnMouseLeave(e)
2144
        State = MouseState.None : Invalidate()
2145
    End Sub
2146
2147
    Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
2148
        MyBase.OnMouseMove(e)
2149
        X = e.X : Invalidate()
2150
    End Sub
2151
2152
    Protected Overrides Sub OnClick(e As EventArgs)
2153
        MyBase.OnClick(e)
2154
        Me.Visible = False
2155
    End Sub
2156
2157
#End Region
2158
2159
#End Region
2160
2161
#Region " Colors"
2162
2163
    Private SuccessColor As Color = Color.FromArgb(60, 85, 79)
2164
    Private SuccessText As Color = Color.FromArgb(35, 169, 110)
2165
    Private ErrorColor As Color = Color.FromArgb(87, 71, 71)
2166
    Private ErrorText As Color = Color.FromArgb(254, 142, 122)
2167
    Private InfoColor As Color = Color.FromArgb(70, 91, 94)
2168
    Private InfoText As Color = Color.FromArgb(97, 185, 186)
2169
2170
#End Region
2171
2172
    Sub New()
2173
        SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
2174
                 ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
2175
        DoubleBuffered = True
2176
        BackColor = Color.FromArgb(60, 70, 73)
2177
        Size = New Size(576, 42)
2178
        Location = New Point(10, 61)
2179
        Font = New Font("Segoe UI", 10)
2180
        Cursor = Cursors.Hand
2181
    End Sub
2182
2183
    Protected Overrides Sub OnPaint(e As PaintEventArgs)
2184
        B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
2185
        W = Width - 1 : H = Height - 1
2186
2187
        Dim Base As New Rectangle(0, 0, W, H)
2188
2189
        With G
2190
            .SmoothingMode = 2
2191
            .TextRenderingHint = 5
2192
            .Clear(BackColor)
2193
2194
            Select Case K
2195
                Case _Kind.Success
2196
                    '-- Base
2197
                    .FillRectangle(New SolidBrush(SuccessColor), Base)
2198
2199
                    '-- Ellipse
2200
                    .FillEllipse(New SolidBrush(SuccessText), New Rectangle(8, 9, 24, 24))
2201
                    .FillEllipse(New SolidBrush(SuccessColor), New Rectangle(10, 11, 20, 20))
2202
2203
                    '-- Checked Sign
2204
                    .DrawString("ü", New Font("Wingdings", 22), New SolidBrush(SuccessText), New Rectangle(7, 7, W, H), NearSF)
2205
                    .DrawString(Text, Font, New SolidBrush(SuccessText), New Rectangle(48, 12, W, H), NearSF)
2206
2207
                    '-- X button
2208
                    .FillEllipse(New SolidBrush(Color.FromArgb(35, Color.Black)), New Rectangle(W - 30, H - 29, 17, 17))
2209
                    .DrawString("r", New Font("Marlett", 8), New SolidBrush(SuccessColor), New Rectangle(W - 28, 16, W, H), NearSF)
2210
2211
                    Select Case State ' -- Mouse Over
2212
                        Case MouseState.Over
2213
                            .DrawString("r", New Font("Marlett", 8), New SolidBrush(Color.FromArgb(25, Color.White)), New Rectangle(W - 28, 16, W, H), NearSF)
2214
                    End Select
2215
2216
                Case _Kind.Error
2217
                    '-- Base
2218
                    .FillRectangle(New SolidBrush(ErrorColor), Base)
2219
2220
                    '-- Ellipse
2221
                    .FillEllipse(New SolidBrush(ErrorText), New Rectangle(8, 9, 24, 24))
2222
                    .FillEllipse(New SolidBrush(ErrorColor), New Rectangle(10, 11, 20, 20))
2223
2224
                    '-- X Sign
2225
                    .DrawString("r", New Font("Marlett", 16), New SolidBrush(ErrorText), New Rectangle(6, 11, W, H), NearSF)
2226
                    .DrawString(Text, Font, New SolidBrush(ErrorText), New Rectangle(48, 12, W, H), NearSF)
2227
2228
                    '-- X button
2229
                    .FillEllipse(New SolidBrush(Color.FromArgb(35, Color.Black)), New Rectangle(W - 32, H - 29, 17, 17))
2230
                    .DrawString("r", New Font("Marlett", 8), New SolidBrush(ErrorColor), New Rectangle(W - 30, 17, W, H), NearSF)
2231
2232
                    Select Case State
2233
                        Case MouseState.Over ' -- Mouse Over
2234
                            .DrawString("r", New Font("Marlett", 8), New SolidBrush(Color.FromArgb(25, Color.White)), New Rectangle(W - 30, 15, W, H), NearSF)
2235
                    End Select
2236
2237
                Case _Kind.Info
2238
                    '-- Base
2239
                    .FillRectangle(New SolidBrush(InfoColor), Base)
2240
2241
                    '-- Ellipse
2242
                    .FillEllipse(New SolidBrush(InfoText), New Rectangle(8, 9, 24, 24))
2243
                    .FillEllipse(New SolidBrush(InfoColor), New Rectangle(10, 11, 20, 20))
2244
2245
                    '-- Info Sign
2246
                    .DrawString("¡", New Font("Segoe UI", 20, FontStyle.Bold), New SolidBrush(InfoText), New Rectangle(12, -4, W, H), NearSF)
2247
                    .DrawString(Text, Font, New SolidBrush(InfoText), New Rectangle(48, 12, W, H), NearSF)
2248
2249
                    '-- X button
2250
                    .FillEllipse(New SolidBrush(Color.FromArgb(35, Color.Black)), New Rectangle(W - 32, H - 29, 17, 17))
2251
                    .DrawString("r", New Font("Marlett", 8), New SolidBrush(InfoColor), New Rectangle(W - 30, 17, W, H), NearSF)
2252
2253
                    Select Case State
2254
                        Case MouseState.Over ' -- Mouse Over
2255
                            .DrawString("r", New Font("Marlett", 8), New SolidBrush(Color.FromArgb(25, Color.White)), New Rectangle(W - 30, 17, W, H), NearSF)
2256
                    End Select
2257
            End Select
2258
2259
        End With
2260
2261
        MyBase.OnPaint(e)
2262
        G.Dispose()
2263
        e.Graphics.InterpolationMode = 7
2264
        e.Graphics.DrawImageUnscaled(B, 0, 0)
2265
        B.Dispose()
2266
    End Sub
2267
2268
End Class
2269
2270
Class FlatProgressBar : Inherits Control
2271
2272
#Region " Variables"
2273
2274
    Private W, H As Integer
2275
    Private _Value As Integer = 0
2276
    Private _Maximum As Integer = 100
2277
2278
#End Region
2279
2280
#Region " Properties"
2281
2282
#Region " Control"
2283
2284
    <Category("Control")>
2285
    Public Property Maximum() As Integer
2286
        Get
2287
            Return _Maximum
2288
        End Get
2289
        Set(V As Integer)
2290
            Select Case V
2291
                Case Is < _Value
2292
                    _Value = V
2293
            End Select
2294
            _Maximum = V
2295
            Invalidate()
2296
        End Set
2297
    End Property
2298
2299
    <Category("Control")>
2300
    Public Property Value() As Integer
2301
        Get
2302
            Select Case _Value
2303
                Case 0
2304
                    Return 0
2305
                    Invalidate()
2306
                Case Else
2307
                    Return _Value
2308
                    Invalidate()
2309
            End Select
2310
        End Get
2311
        Set(V As Integer)
2312
            Select Case V
2313
                Case Is > _Maximum
2314
                    V = _Maximum
2315
                    Invalidate()
2316
            End Select
2317
            _Value = V
2318
            Invalidate()
2319
        End Set
2320
    End Property
2321
2322
#End Region
2323
2324
#Region " Colors"
2325
2326
    <Category("Colors")>
2327
    Public Property ProgressColor As Color
2328
        Get
2329
            Return _ProgressColor
2330
        End Get
2331
        Set(value As Color)
2332
            _ProgressColor = value
2333
        End Set
2334
    End Property
2335
2336
    <Category("Colors")>
2337
    Public Property DarkerProgress As Color
2338
        Get
2339
            Return _DarkerProgress
2340
        End Get
2341
        Set(value As Color)
2342
            _DarkerProgress = value
2343
        End Set
2344
    End Property
2345
2346
#End Region
2347
2348
    Protected Overrides Sub OnResize(e As EventArgs)
2349
        MyBase.OnResize(e)
2350
        Height = 42
2351
    End Sub
2352
2353
    Protected Overrides Sub CreateHandle()
2354
        MyBase.CreateHandle()
2355
        Height = 42
2356
    End Sub
2357
2358
    Public Sub Increment(ByVal Amount As Integer)
2359
        Value += Amount
2360
    End Sub
2361
2362
#End Region
2363
2364
#Region " Colors"
2365
2366
    Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
2367
    Private _ProgressColor As Color = _FlatColor
2368
    Private _DarkerProgress As Color = Color.FromArgb(23, 148, 92)
2369
2370
#End Region
2371
2372
    Sub New()
2373
        SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
2374
                 ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
2375
        DoubleBuffered = True
2376
        BackColor = Color.FromArgb(60, 70, 73)
2377
        Height = 42
2378
    End Sub
2379
2380
    Protected Overrides Sub OnPaint(e As PaintEventArgs)
2381
        B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
2382
        W = Width - 1 : H = Height - 1
2383
2384
        Dim Base As New Rectangle(0, 24, W, H)
2385
        Dim GP, GP2, GP3 As New GraphicsPath
2386
2387
        With G
2388
            .SmoothingMode = 2
2389
            .PixelOffsetMode = 2
2390
            .TextRenderingHint = 5
2391
            .Clear(BackColor)
2392
2393
            '-- Progress Value
2394
            Dim iValue As Integer = CInt(_Value / _Maximum * Width)
2395
2396
            Select Case Value
2397
                Case 0
2398
                    '-- Base
2399
                    .FillRectangle(New SolidBrush(_BaseColor), Base)
2400
                    '--Progress
2401
                    .FillRectangle(New SolidBrush(_ProgressColor), New Rectangle(0, 24, iValue - 1, H - 1))
2402
                Case 100
2403
                    '-- Base
2404
                    .FillRectangle(New SolidBrush(_BaseColor), Base)
2405
                    '--Progress
2406
                    .FillRectangle(New SolidBrush(_ProgressColor), New Rectangle(0, 24, iValue - 1, H - 1))
2407
                Case Else
2408
                    '-- Base
2409
                    .FillRectangle(New SolidBrush(_BaseColor), Base)
2410
2411
                    '--Progress
2412
                    GP.AddRectangle(New Rectangle(0, 24, iValue - 1, H - 1))
2413
                    .FillPath(New SolidBrush(_ProgressColor), GP)
2414
2415
                    '-- Hatch Brush
2416
                    Dim HB As New HatchBrush(HatchStyle.Plaid, _DarkerProgress, _ProgressColor)
2417
                    .FillRectangle(HB, New Rectangle(0, 24, iValue - 1, H - 1))
2418
2419
                    '-- Balloon
2420
                    Dim Balloon As New Rectangle(iValue - 18, 0, 34, 16)
2421
                    GP2 = Helpers.RoundRec(Balloon, 4)
2422
                    .FillPath(New SolidBrush(_BaseColor), GP2)
2423
2424
                    '-- Arrow
2425
                    GP3 = Helpers.DrawArrow(iValue - 9, 16, True)
2426
                    .FillPath(New SolidBrush(_BaseColor), GP3)
2427
2428
                    '-- Value > You can add "%" > value & "%"
2429
                    .DrawString(Value, New Font("Segoe UI", 10), New SolidBrush(_ProgressColor), New Rectangle(iValue - 11, -2, W, H), NearSF)
2430
            End Select
2431
        End With
2432
2433
        MyBase.OnPaint(e)
2434
        G.Dispose()
2435
        e.Graphics.InterpolationMode = 7
2436
        e.Graphics.DrawImageUnscaled(B, 0, 0)
2437
        B.Dispose()
2438
    End Sub
2439
2440
End Class
2441
2442
Class FlatComboBox : Inherits Windows.Forms.ComboBox
2443
2444
#Region " Variables"
2445
2446
    Private W, H As Integer
2447
    Private _StartIndex As Integer = 0
2448
    Private x, y As Integer
2449
2450
#End Region
2451
2452
#Region " Properties"
2453
2454
#Region " Mouse States"
2455
2456
    Private State As MouseState = MouseState.None
2457
    Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
2458
        MyBase.OnMouseDown(e)
2459
        State = MouseState.Down : Invalidate()
2460
    End Sub
2461
    Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
2462
        MyBase.OnMouseUp(e)
2463
        State = MouseState.Over : Invalidate()
2464
    End Sub
2465
    Protected Overrides Sub OnMouseEnter(e As EventArgs)
2466
        MyBase.OnMouseEnter(e)
2467
        State = MouseState.Over : Invalidate()
2468
    End Sub
2469
    Protected Overrides Sub OnMouseLeave(e As EventArgs)
2470
        MyBase.OnMouseLeave(e)
2471
        State = MouseState.None : Invalidate()
2472
    End Sub
2473
2474
    Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
2475
        MyBase.OnMouseMove(e)
2476
        x = e.Location.X
2477
        y = e.Location.Y
2478
        Invalidate()
2479
        If e.X < Width - 41 Then Cursor = Cursors.IBeam Else Cursor = Cursors.Hand
2480
    End Sub
2481
2482
    Protected Overrides Sub OnDrawItem(e As DrawItemEventArgs)
2483
        MyBase.OnDrawItem(e) : Invalidate()
2484
        If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
2485
            Invalidate()
2486
        End If
2487
    End Sub
2488
2489
    Protected Overrides Sub OnClick(e As EventArgs)
2490
        MyBase.OnClick(e) : Invalidate()
2491
    End Sub
2492
2493
#End Region
2494
2495
#Region " Colors"
2496
2497
    <Category("Colors")> _
2498
    Public Property HoverColor As Color
2499
        Get
2500
            Return _HoverColor
2501
        End Get
2502
        Set(value As Color)
2503
            _HoverColor = value
2504
        End Set
2505
    End Property
2506
2507
#End Region
2508
2509
    Private Property StartIndex As Integer
2510
        Get
2511
            Return _StartIndex
2512
        End Get
2513
        Set(ByVal value As Integer)
2514
            _StartIndex = value
2515
            Try
2516
                MyBase.SelectedIndex = value
2517
            Catch
2518
            End Try
2519
            Invalidate()
2520
        End Set
2521
    End Property
2522
2523
    Sub DrawItem_(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles Me.DrawItem
2524
        If e.Index < 0 Then Exit Sub
2525
        e.DrawBackground()
2526
        e.DrawFocusRectangle()
2527
2528
        e.Graphics.SmoothingMode = 2
2529
        e.Graphics.PixelOffsetMode = 2
2530
        e.Graphics.TextRenderingHint = 5
2531
        e.Graphics.InterpolationMode = 7
2532
2533
        If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
2534
            '-- Selected item
2535
            e.Graphics.FillRectangle(New SolidBrush(_HoverColor), e.Bounds)
2536
        Else
2537
            '-- Not Selected
2538
            e.Graphics.FillRectangle(New SolidBrush(_BaseColor), e.Bounds)
2539
        End If
2540
2541
        '-- Text
2542
        e.Graphics.DrawString(MyBase.GetItemText(MyBase.Items(e.Index)), New Font("Segoe UI", 8), _
2543
                     Brushes.White, New Rectangle(e.Bounds.X + 2, e.Bounds.Y + 2, e.Bounds.Width, e.Bounds.Height))
2544
2545
2546
        e.Graphics.Dispose()
2547
    End Sub
2548
2549
    Protected Overrides Sub OnResize(e As EventArgs)
2550
        MyBase.OnResize(e)
2551
        Height = 18
2552
    End Sub
2553
2554
#End Region
2555
2556
#Region " Colors"
2557
2558
    Private _BaseColor As Color = Color.FromArgb(25, 27, 29)
2559
    Private _BGColor As Color = Color.FromArgb(45, 47, 49)
2560
    Private _HoverColor As Color = Color.FromArgb(35, 168, 109)
2561
2562
#End Region
2563
2564
    Sub New()
2565
        SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
2566
                 ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
2567
        DoubleBuffered = True
2568
2569
        DrawMode = DrawMode.OwnerDrawFixed
2570
        BackColor = Color.FromArgb(45, 45, 48)
2571
        ForeColor = Color.White
2572
        DropDownStyle = ComboBoxStyle.DropDownList
2573
        Cursor = Cursors.Hand
2574
        StartIndex = 0
2575
        ItemHeight = 18
2576
        Font = New Font("Segoe UI", 8, FontStyle.Regular)
2577
    End Sub
2578
2579
    Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
2580
        B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
2581
        W = Width : H = Height
2582
2583
        Dim Base As New Rectangle(0, 0, W, H)
2584
        Dim Button As New Rectangle(CInt(W - 40), 0, W, H)
2585
        Dim GP, GP2 As New GraphicsPath
2586
2587
        With G
2588
            .Clear(Color.FromArgb(45, 45, 48))
2589
            .SmoothingMode = 2
2590
            .PixelOffsetMode = 2
2591
            .TextRenderingHint = 5
2592
2593
            '-- Base
2594
            .FillRectangle(New SolidBrush(_BGColor), Base)
2595
2596
            '-- Button
2597
            GP.Reset()
2598
            GP.AddRectangle(Button)
2599
            .SetClip(GP)
2600
            .FillRectangle(New SolidBrush(_BaseColor), Button)
2601
            .ResetClip()
2602
2603
            '-- Lines
2604
            .DrawLine(Pens.White, W - 10, 6, W - 30, 6)
2605
            .DrawLine(Pens.White, W - 10, 12, W - 30, 12)
2606
            .DrawLine(Pens.White, W - 10, 18, W - 30, 18)
2607
2608
            '-- Text
2609
            .DrawString(Text, Font, Brushes.White, New Point(4, 6), NearSF)
2610
        End With
2611
2612
        G.Dispose()
2613
        e.Graphics.InterpolationMode = 7
2614
        e.Graphics.DrawImageUnscaled(B, 0, 0)
2615
        B.Dispose()
2616
    End Sub
2617
End Class
2618
2619
Class FlatStickyButton : Inherits Control
2620
2621
#Region " Variables"
2622
2623
    Private W, H As Integer
2624
    Private State As MouseState = MouseState.None
2625
    Private _Rounded As Boolean = False
2626
2627
#End Region
2628
2629
#Region " Properties"
2630
2631
#Region " MouseStates"
2632
2633
    Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
2634
        MyBase.OnMouseDown(e)
2635
        State = MouseState.Down : Invalidate()
2636
    End Sub
2637
    Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
2638
        MyBase.OnMouseUp(e)
2639
        State = MouseState.Over : Invalidate()
2640
    End Sub
2641
    Protected Overrides Sub OnMouseEnter(e As EventArgs)
2642
        MyBase.OnMouseEnter(e)
2643
        State = MouseState.Over : Invalidate()
2644
    End Sub
2645
    Protected Overrides Sub OnMouseLeave(e As EventArgs)
2646
        MyBase.OnMouseLeave(e)
2647
        State = MouseState.None : Invalidate()
2648
    End Sub
2649
2650
#End Region
2651
2652
#Region " Function"
2653
2654
    Private Function GetConnectedSides() As Boolean()
2655
        Dim Bool = New Boolean(3) {False, False, False, False}
2656
2657
        For Each B As Control In Parent.Controls
2658
            If TypeOf B Is FlatStickyButton Then
2659
                If B Is Me Or Not Rect.IntersectsWith(Rect) Then Continue For
2660
                Dim A = Math.Atan2(Left() - B.Left, Top - B.Top) * 2 / Math.PI
2661
                If A \ 1 = A Then Bool(A + 1) = True
2662
            End If
2663
        Next
2664
2665
        Return Bool
2666
    End Function
2667
2668
    Private ReadOnly Property Rect() As Rectangle
2669
        Get
2670
            Return New Rectangle(Left, Top, Width, Height)
2671
        End Get
2672
    End Property
2673
2674
#End Region
2675
2676
#Region " Colors"
2677
2678
    <Category("Colors")> _
2679
    Public Property BaseColor As Color
2680
        Get
2681
            Return _BaseColor
2682
        End Get
2683
        Set(value As Color)
2684
            _BaseColor = value
2685
        End Set
2686
    End Property
2687
2688
    <Category("Colors")> _
2689
    Public Property TextColor As Color
2690
        Get
2691
            Return _TextColor
2692
        End Get
2693
        Set(value As Color)
2694
            _TextColor = value
2695
        End Set
2696
    End Property
2697
2698
    <Category("Options")> _
2699
    Public Property Rounded As Boolean
2700
        Get
2701
            Return _Rounded
2702
        End Get
2703
        Set(value As Boolean)
2704
            _Rounded = value
2705
        End Set
2706
    End Property
2707
2708
#End Region
2709
2710
    Protected Overrides Sub OnResize(e As EventArgs)
2711
        MyBase.OnResize(e)
2712
        'Height = 32
2713
    End Sub
2714
2715
    Protected Overrides Sub OnCreateControl()
2716
        MyBase.OnCreateControl()
2717
        'Size = New Size(112, 32)
2718
    End Sub
2719
2720
#End Region
2721
2722
#Region " Colors"
2723
2724
    Private _BaseColor As Color = _FlatColor
2725
    Private _TextColor As Color = Color.FromArgb(243, 243, 243)
2726
2727
#End Region
2728
2729
    Sub New()
2730
        SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
2731
        ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or _
2732
        ControlStyles.SupportsTransparentBackColor, True)
2733
        DoubleBuffered = True
2734
        Size = New Size(106, 32)
2735
        BackColor = Color.Transparent
2736
        Font = New Font("Segoe UI", 12)
2737
        Cursor = Cursors.Hand
2738
    End Sub
2739
2740
    Protected Overrides Sub OnPaint(e As PaintEventArgs)
2741
        B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
2742
        W = Width : H = Height
2743
2744
        Dim GP As New GraphicsPath
2745
2746
        Dim GCS = GetConnectedSides()
2747
        Dim RoundedBase = Helpers.RoundRect(0, 0, W, H, , Not (GCS(2) Or GCS(1)), Not (GCS(1) Or GCS(0)), Not (GCS(3) Or GCS(0)), Not (GCS(3) Or GCS(2)))
2748
        Dim Base As New Rectangle(0, 0, W, H)
2749
2750
        With G
2751
            .SmoothingMode = 2
2752
            .PixelOffsetMode = 2
2753
            .TextRenderingHint = 5
2754
            .Clear(BackColor)
2755
2756
            Select Case State
2757
                Case MouseState.None
2758
                    If Rounded Then
2759
                        '-- Base
2760
                        GP = RoundedBase
2761
                        .FillPath(New SolidBrush(_BaseColor), GP)
2762
2763
                        '-- Text
2764
                        .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
2765
                    Else
2766
                        '-- Base
2767
                        .FillRectangle(New SolidBrush(_BaseColor), Base)
2768
2769
                        '-- Text
2770
                        .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
2771
                    End If
2772
                Case MouseState.Over
2773
                    If Rounded Then
2774
                        '-- Base
2775
                        GP = RoundedBase
2776
                        .FillPath(New SolidBrush(_BaseColor), GP)
2777
                        .FillPath(New SolidBrush(Color.FromArgb(20, Color.White)), GP)
2778
2779
                        '-- Text
2780
                        .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
2781
                    Else
2782
                        '-- Base
2783
                        .FillRectangle(New SolidBrush(_BaseColor), Base)
2784
                        .FillRectangle(New SolidBrush(Color.FromArgb(20, Color.White)), Base)
2785
2786
                        '-- Text
2787
                        .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
2788
                    End If
2789
                Case MouseState.Down
2790
                    If Rounded Then
2791
                        '-- Base
2792
                        GP = RoundedBase
2793
                        .FillPath(New SolidBrush(_BaseColor), GP)
2794
                        .FillPath(New SolidBrush(Color.FromArgb(20, Color.Black)), GP)
2795
2796
                        '-- Text
2797
                        .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
2798
                    Else
2799
                        '-- Base
2800
                        .FillRectangle(New SolidBrush(_BaseColor), Base)
2801
                        .FillRectangle(New SolidBrush(Color.FromArgb(20, Color.Black)), Base)
2802
2803
                        '-- Text
2804
                        .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
2805
                    End If
2806
            End Select
2807
2808
        End With
2809
2810
        MyBase.OnPaint(e)
2811
        G.Dispose()
2812
        e.Graphics.InterpolationMode = 7
2813
        e.Graphics.DrawImageUnscaled(B, 0, 0)
2814
        B.Dispose()
2815
    End Sub
2816
2817
End Class
2818
2819
Class FlatNumeric : Inherits Control
2820
2821
#Region " Variables"
2822
2823
    Private W, H As Integer
2824
    Private State As MouseState = MouseState.None
2825
    Private x, y As Integer
2826
    Private _Value, _Min, _Max As Long
2827
    Private Bool As Boolean
2828
2829
#End Region
2830
2831
#Region " Properties"
2832
2833
    Public Property Value As Long
2834
        Get
2835
            Return _Value
2836
        End Get
2837
        Set(value As Long)
2838
            If value <= _Max And value >= _Min Then _Value = value
2839
            Invalidate()
2840
        End Set
2841
    End Property
2842
2843
    Public Property Maximum As Long
2844
        Get
2845
            Return _Max
2846
        End Get
2847
        Set(value As Long)
2848
            If value > _Min Then _Max = value
2849
            If _Value > _Max Then _Value = _Max
2850
            Invalidate()
2851
        End Set
2852
    End Property
2853
2854
    Public Property Minimum As Long
2855
        Get
2856
            Return _Min
2857
        End Get
2858
        Set(value As Long)
2859
            If value < _Max Then _Min = value
2860
            If _Value < _Min Then _Value = Minimum
2861
            Invalidate()
2862
        End Set
2863
    End Property
2864
2865
    Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
2866
        MyBase.OnMouseMove(e)
2867
        x = e.Location.X
2868
        y = e.Location.Y
2869
        Invalidate()
2870
        If e.X < Width - 23 Then Cursor = Cursors.IBeam Else Cursor = Cursors.Hand
2871
    End Sub
2872
2873
    Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
2874
        MyBase.OnMouseDown(e)
2875
        If x > Width - 21 AndAlso x < Width - 3 Then
2876
            If y < 15 Then
2877
                If (Value + 1) <= _Max Then _Value += 1
2878
            Else
2879
                If (Value - 1) >= _Min Then _Value -= 1
2880
            End If
2881
        Else
2882
            Bool = Not Bool
2883
            Focus()
2884
        End If
2885
        Invalidate()
2886
    End Sub
2887
2888
    Protected Overrides Sub OnKeyPress(e As KeyPressEventArgs)
2889
        MyBase.OnKeyPress(e)
2890
        Try
2891
            If Bool Then _Value = CStr(CStr(_Value) & e.KeyChar.ToString())
2892
            If _Value > _Max Then _Value = _Max
2893
            Invalidate()
2894
        Catch : End Try
2895
    End Sub
2896
2897
    Protected Overrides Sub OnKeyDown(e As KeyEventArgs)
2898
        MyBase.OnKeyDown(e)
2899
        If e.KeyCode = Keys.Back Then
2900
            Value = 0
2901
        End If
2902
    End Sub
2903
2904
    Protected Overrides Sub OnResize(e As EventArgs)
2905
        MyBase.OnResize(e)
2906
        Height = 30
2907
    End Sub
2908
2909
#Region " Colors"
2910
2911
    <Category("Colors")> _
2912
    Public Property BaseColor As Color
2913
        Get
2914
            Return _BaseColor
2915
        End Get
2916
        Set(value As Color)
2917
            _BaseColor = value
2918
        End Set
2919
    End Property
2920
2921
    <Category("Colors")> _
2922
    Public Property ButtonColor As Color
2923
        Get
2924
            Return _ButtonColor
2925
        End Get
2926
        Set(value As Color)
2927
            _ButtonColor = value
2928
        End Set
2929
    End Property
2930
2931
#End Region
2932
2933
#End Region
2934
2935
#Region " Colors"
2936
2937
    Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
2938
    Private _ButtonColor As Color = _FlatColor
2939
2940
#End Region
2941
2942
    Sub New()
2943
        SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
2944
        ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or _
2945
        ControlStyles.SupportsTransparentBackColor, True)
2946
        DoubleBuffered = True
2947
        Font = New Font("Segoe UI", 10)
2948
        BackColor = Color.FromArgb(60, 70, 73)
2949
        ForeColor = Color.White
2950
        _Min = 0
2951
        _Max = 9999999
2952
    End Sub
2953
2954
2955
    Protected Overrides Sub OnPaint(e As PaintEventArgs)
2956
        B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
2957
        W = Width : H = Height
2958
2959
        Dim Base As New Rectangle(0, 0, W, H)
2960
2961
        With G
2962
            .SmoothingMode = 2
2963
            .PixelOffsetMode = 2
2964
            .TextRenderingHint = 5
2965
            .Clear(BackColor)
2966
2967
            '-- Base
2968
            .FillRectangle(New SolidBrush(_BaseColor), Base)
2969
            .FillRectangle(New SolidBrush(_ButtonColor), New Rectangle(Width - 24, 0, 24, H))
2970
2971
            '-- Add
2972
            .DrawString("+", New Font("Segoe UI", 12), Brushes.White, New Point(Width - 12, 8), CenterSF)
2973
            '-- Subtract
2974
            .DrawString("-", New Font("Segoe UI", 10, FontStyle.Bold), Brushes.White, New Point(Width - 12, 22), CenterSF)
2975
2976
            '-- Text
2977
            .DrawString(Value, Font, Brushes.White, New Rectangle(5, 1, W, H), New StringFormat() With {.LineAlignment = StringAlignment.Center})
2978
        End With
2979
2980
        MyBase.OnPaint(e)
2981
        G.Dispose()
2982
        e.Graphics.InterpolationMode = 7
2983
        e.Graphics.DrawImageUnscaled(B, 0, 0)
2984
        B.Dispose()
2985
    End Sub
2986
2987
End Class
2988
2989
Class FlatListBox : Inherits Control
2990
2991
#Region " Variables"
2992
2993
    Private WithEvents ListBx As New ListBox
2994
    Private _items As String() = {""}
2995
2996
#End Region
2997
2998
#Region " Poperties"
2999
3000
    <Category("Options")> _
3001
    Public Property items As String()
3002
        Get
3003
            Return _items
3004
        End Get
3005
        Set(value As String())
3006
            _items = value
3007
            ListBx.Items.Clear()
3008
            ListBx.Items.AddRange(value)
3009
            Invalidate()
3010
        End Set
3011
    End Property
3012
3013
    <Category("Colors")> _
3014
    Public Property SelectedColor As Color
3015
        Get
3016
            Return _SelectedColor
3017
        End Get
3018
        Set(value As Color)
3019
            _SelectedColor = value
3020
        End Set
3021
    End Property
3022
3023
    Public ReadOnly Property SelectedItem() As String
3024
        Get
3025
            Return ListBx.SelectedItem
3026
        End Get
3027
    End Property
3028
3029
    Public ReadOnly Property SelectedIndex() As Integer
3030
        Get
3031
            Return ListBx.SelectedIndex
3032
            If ListBx.SelectedIndex < 0 Then Exit Property
3033
        End Get
3034
    End Property
3035
3036
    Public Sub Clear()
3037
        ListBx.Items.Clear()
3038
    End Sub
3039
3040
    Public Sub ClearSelected()
3041
        For i As Integer = (ListBx.SelectedItems.Count - 1) To 0 Step -1
3042
            ListBx.Items.Remove(ListBx.SelectedItems(i))
3043
        Next
3044
    End Sub
3045
3046
    Sub Drawitem(ByVal sender As Object, ByVal e As DrawItemEventArgs) Handles ListBx.DrawItem
3047
        If e.Index < 0 Then Exit Sub
3048
        e.DrawBackground()
3049
        e.DrawFocusRectangle()
3050
3051
        e.Graphics.SmoothingMode = 2
3052
        e.Graphics.PixelOffsetMode = 2
3053
        e.Graphics.InterpolationMode = 7
3054
        e.Graphics.TextRenderingHint = 5
3055
3056
        If InStr(e.State.ToString, "Selected,") > 0 Then '-- if selected
3057
            '-- Base
3058
            e.Graphics.FillRectangle(New SolidBrush(_SelectedColor), New Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height))
3059
3060
            '-- Text
3061
            e.Graphics.DrawString(" " & ListBx.Items(e.Index).ToString(), New Font("Segoe UI", 8), Brushes.White, e.Bounds.X, e.Bounds.Y + 2)
3062
        Else
3063
            '-- Base
3064
            e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(51, 53, 55)), New Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height))
3065
3066
            '-- Text 
3067
            e.Graphics.DrawString(" " & ListBx.Items(e.Index).ToString(), New Font("Segoe UI", 8), Brushes.White, e.Bounds.X, e.Bounds.Y + 2)
3068
        End If
3069
3070
        e.Graphics.Dispose()
3071
    End Sub
3072
3073
    Protected Overrides Sub OnCreateControl()
3074
        MyBase.OnCreateControl()
3075
        If Not Controls.Contains(ListBx) Then
3076
            Controls.Add(ListBx)
3077
        End If
3078
    End Sub
3079
3080
    Sub AddRange(ByVal items As Object())
3081
        ListBx.Items.Remove("")
3082
        ListBx.Items.AddRange(items)
3083
    End Sub
3084
3085
    Sub AddItem(ByVal item As Object)
3086
        ListBx.Items.Remove("")
3087
        ListBx.Items.Add(item)
3088
    End Sub
3089
3090
#End Region
3091
3092
#Region " Colors"
3093
3094
    Private BaseColor As Color = Color.FromArgb(45, 47, 49)
3095
    Private _SelectedColor As Color = _FlatColor
3096
3097
#End Region
3098
3099
    Sub New()
3100
        SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
3101
            ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
3102
        DoubleBuffered = True
3103
3104
        ListBx.DrawMode = Windows.Forms.DrawMode.OwnerDrawFixed
3105
        ListBx.ScrollAlwaysVisible = False
3106
        ListBx.HorizontalScrollbar = False
3107
        ListBx.BorderStyle = BorderStyle.None
3108
        ListBx.BackColor = BaseColor
3109
        ListBx.ForeColor = Color.White
3110
        ListBx.Location = New Point(3, 3)
3111
        ListBx.Font = New Font("Segoe UI", 8)
3112
        ListBx.ItemHeight = 20
3113
        ListBx.Items.Clear()
3114
        ListBx.IntegralHeight = False
3115
3116
        Size = New Size(131, 101)
3117
        BackColor = BaseColor
3118
    End Sub
3119
3120
    Protected Overrides Sub OnPaint(e As PaintEventArgs)
3121
        B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
3122
3123
        Dim Base As New Rectangle(0, 0, Width, Height)
3124
3125
        With G
3126
            .SmoothingMode = 2
3127
            .PixelOffsetMode = 2
3128
            .TextRenderingHint = 5
3129
            .Clear(BackColor)
3130
3131
            '-- Size
3132
            ListBx.Size = New Size(Width - 6, Height - 2)
3133
3134
            '-- Base
3135
            .FillRectangle(New SolidBrush(BaseColor), Base)
3136
        End With
3137
3138
        MyBase.OnPaint(e)
3139
        G.Dispose()
3140
        e.Graphics.InterpolationMode = 7
3141
        e.Graphics.DrawImageUnscaled(B, 0, 0)
3142
        B.Dispose()
3143
    End Sub
3144
3145
End Class
3146
3147
Class FlatContextMenuStrip : Inherits ContextMenuStrip
3148
3149
    Protected Overrides Sub OnTextChanged(e As EventArgs)
3150
        MyBase.OnTextChanged(e) : Invalidate()
3151
    End Sub
3152
3153
    Sub New()
3154
        MyBase.New()
3155
        Renderer = New ToolStripProfessionalRenderer(New TColorTable())
3156
        ShowImageMargin = False
3157
        ForeColor = Color.White
3158
        Font = New Font("Segoe UI", 8)
3159
    End Sub
3160
3161
    Protected Overrides Sub OnPaint(e As PaintEventArgs)
3162
        MyBase.OnPaint(e)
3163
        e.Graphics.TextRenderingHint = 5
3164
    End Sub
3165
3166
    Class TColorTable : Inherits ProfessionalColorTable
3167
3168
#Region " Properties"
3169
3170
#Region " Colors"
3171
3172
        <Category("Colors")> _
3173
        Public Property _BackColor As Color
3174
            Get
3175
                Return BackColor
3176
            End Get
3177
            Set(value As Color)
3178
                BackColor = value
3179
            End Set
3180
        End Property
3181
3182
        <Category("Colors")> _
3183
        Public Property _CheckedColor As Color
3184
            Get
3185
                Return CheckedColor
3186
            End Get
3187
            Set(value As Color)
3188
                CheckedColor = value
3189
            End Set
3190
        End Property
3191
3192
        <Category("Colors")> _
3193
        Public Property _BorderColor As Color
3194
            Get
3195
                Return BorderColor
3196
            End Get
3197
            Set(value As Color)
3198
                BorderColor = value
3199
            End Set
3200
        End Property
3201
3202
#End Region
3203
3204
#End Region
3205
3206
#Region " Colors"
3207
3208
        Private BackColor As Color = Color.FromArgb(45, 47, 49)
3209
        Private CheckedColor As Color = _FlatColor
3210
        Private BorderColor As Color = Color.FromArgb(53, 58, 60)
3211
3212
#End Region
3213
3214
#Region " Overrides"
3215
3216
        Public Overrides ReadOnly Property ButtonSelectedBorder As Color
3217
            Get
3218
                Return BackColor
3219
            End Get
3220
        End Property
3221
        Public Overrides ReadOnly Property CheckBackground() As Color
3222
            Get
3223
                Return CheckedColor
3224
            End Get
3225
        End Property
3226
        Public Overrides ReadOnly Property CheckPressedBackground() As Color
3227
            Get
3228
                Return CheckedColor
3229
            End Get
3230
        End Property
3231
        Public Overrides ReadOnly Property CheckSelectedBackground() As Color
3232
            Get
3233
                Return CheckedColor
3234
            End Get
3235
        End Property
3236
        Public Overrides ReadOnly Property ImageMarginGradientBegin() As Color
3237
            Get
3238
                Return CheckedColor
3239
            End Get
3240
        End Property
3241
        Public Overrides ReadOnly Property ImageMarginGradientEnd() As Color
3242
            Get
3243
                Return CheckedColor
3244
            End Get
3245
        End Property
3246
        Public Overrides ReadOnly Property ImageMarginGradientMiddle() As Color
3247
            Get
3248
                Return CheckedColor
3249
            End Get
3250
        End Property
3251
        Public Overrides ReadOnly Property MenuBorder() As Color
3252
            Get
3253
                Return BorderColor
3254
            End Get
3255
        End Property
3256
        Public Overrides ReadOnly Property MenuItemBorder() As Color
3257
            Get
3258
                Return BorderColor
3259
            End Get
3260
        End Property
3261
        Public Overrides ReadOnly Property MenuItemSelected() As Color
3262
            Get
3263
                Return CheckedColor
3264
            End Get
3265
        End Property
3266
        Public Overrides ReadOnly Property SeparatorDark() As Color
3267
            Get
3268
                Return BorderColor
3269
            End Get
3270
        End Property
3271
        Public Overrides ReadOnly Property ToolStripDropDownBackground() As Color
3272
            Get
3273
                Return BackColor
3274
            End Get
3275
        End Property
3276
3277
#End Region
3278
3279
    End Class
3280
3281
End Class
3282
3283
<DefaultEvent("Scroll")> Class FlatTrackBar : Inherits Control
3284
3285
#Region " Variables"
3286
3287
    Private W, H As Integer
3288
    Private Val As Integer
3289
    Private Bool As Boolean
3290
    Private Track As Rectangle
3291
    Private Knob As Rectangle
3292
    Private Style_ As _Style
3293
3294
#End Region
3295
3296
#Region " Properties"
3297
3298
#Region " Mouse States"
3299
3300
    Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
3301
        MyBase.OnMouseDown(e)
3302
        If e.Button = Windows.Forms.MouseButtons.Left Then
3303
            Val = CInt((_Value - _Minimum) / (_Maximum - _Minimum) * (Width - 11))
3304
            Track = New Rectangle(Val, 0, 10, 20)
3305
3306
            Bool = Track.Contains(e.Location)
3307
        End If
3308
    End Sub
3309
3310
    Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
3311
        MyBase.OnMouseMove(e)
3312
        If Bool AndAlso e.X > -1 AndAlso e.X < (Width + 1) Then
3313
            Value = _Minimum + CInt((_Maximum - _Minimum) * (e.X / Width))
3314
        End If
3315
    End Sub
3316
3317
    Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
3318
        MyBase.OnMouseUp(e) : Bool = False
3319
    End Sub
3320
3321
#End Region
3322
3323
#Region " Styles"
3324
3325
    <Flags> _
3326
    Enum _Style
3327
        Slider
3328
        Knob
3329
    End Enum
3330
3331
    Public Property Style As _Style
3332
        Get
3333
            Return Style_
3334
        End Get
3335
        Set(value As _Style)
3336
            Style_ = value
3337
        End Set
3338
    End Property
3339
3340
#End Region
3341
3342
#Region " Colors"
3343
3344
    <Category("Colors")> _
3345
    Public Property TrackColor As Color
3346
        Get
3347
            Return _TrackColor
3348
        End Get
3349
        Set(value As Color)
3350
            _TrackColor = value
3351
        End Set
3352
    End Property
3353
3354
    <Category("Colors")> _
3355
    Public Property HatchColor As Color
3356
        Get
3357
            Return _HatchColor
3358
        End Get
3359
        Set(value As Color)
3360
            _HatchColor = value
3361
        End Set
3362
    End Property
3363
3364
#End Region
3365
3366
    Event Scroll(ByVal sender As Object)
3367
    Private _Minimum As Integer
3368
    Public Property Minimum As Integer
3369
        Get
3370
            Return Minimum
3371
        End Get
3372
        Set(value As Integer)
3373
            If value < 0 Then
3374
            End If
3375
3376
            _Minimum = value
3377
3378
            If value > _Value Then _Value = value
3379
            If value > _Maximum Then _Maximum = value
3380
            Invalidate()
3381
        End Set
3382
    End Property
3383
    Private _Maximum As Integer = 10
3384
    Public Property Maximum As Integer
3385
        Get
3386
            Return _Maximum
3387
        End Get
3388
        Set(value As Integer)
3389
            If value < 0 Then
3390
            End If
3391
3392
            _Maximum = value
3393
            If value < _Value Then _Value = value
3394
            If value < _Minimum Then _Minimum = value
3395
            Invalidate()
3396
        End Set
3397
    End Property
3398
    Private _Value As Integer
3399
    Public Property Value As Integer
3400
        Get
3401
            Return _Value
3402
        End Get
3403
        Set(value As Integer)
3404
            If value = _Value Then Return
3405
3406
            If value > _Maximum OrElse value < _Minimum Then
3407
            End If
3408
3409
            _Value = value
3410
            Invalidate()
3411
            RaiseEvent Scroll(Me)
3412
        End Set
3413
    End Property
3414
    Private _ShowValue As Boolean = False
3415
    Public Property ShowValue As Boolean
3416
        Get
3417
            Return _ShowValue
3418
        End Get
3419
        Set(value As Boolean)
3420
            _ShowValue = value
3421
        End Set
3422
    End Property
3423
3424
    Protected Overrides Sub OnKeyDown(e As KeyEventArgs)
3425
        MyBase.OnKeyDown(e)
3426
        If e.KeyCode = Keys.Subtract Then
3427
            If Value = 0 Then Exit Sub
3428
            Value -= 1
3429
        ElseIf e.KeyCode = Keys.Add Then
3430
            If Value = _Maximum Then Exit Sub
3431
            Value += 1
3432
        End If
3433
    End Sub
3434
3435
    Protected Overrides Sub OnTextChanged(e As EventArgs)
3436
        MyBase.OnTextChanged(e) : Invalidate()
3437
    End Sub
3438
3439
    Protected Overrides Sub OnResize(e As EventArgs)
3440
        MyBase.OnResize(e)
3441
        Height = 23
3442
    End Sub
3443
3444
#End Region
3445
3446
#Region " Colors"
3447
3448
    Private BaseColor As Color = Color.FromArgb(45, 47, 49)
3449
    Private _TrackColor As Color = _FlatColor
3450
    Private SliderColor As Color = Color.FromArgb(25, 27, 29)
3451
    Private _HatchColor As Color = Color.FromArgb(23, 148, 92)
3452
3453
#End Region
3454
3455
    Sub New()
3456
        SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
3457
                 ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
3458
        DoubleBuffered = True
3459
        Height = 18
3460
3461
        BackColor = Color.FromArgb(60, 70, 73)
3462
    End Sub
3463
3464
    Protected Overrides Sub OnPaint(e As PaintEventArgs)
3465
        B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
3466
        W = Width - 1 : H = Height - 1
3467
3468
        Dim Base As New Rectangle(1, 6, W - 2, 8)
3469
        Dim GP, GP2 As New GraphicsPath
3470
3471
        With G
3472
            .SmoothingMode = 2
3473
            .PixelOffsetMode = 2
3474
            .TextRenderingHint = 5
3475
            .Clear(BackColor)
3476
3477
            '-- Value
3478
            Val = CInt((_Value - _Minimum) / (_Maximum - _Minimum) * (W - 10))
3479
            Track = New Rectangle(Val, 0, 10, 20)
3480
            Knob = New Rectangle(Val, 4, 11, 14)
3481
3482
            '-- Base
3483
            GP.AddRectangle(Base)
3484
            .SetClip(GP)
3485
            .FillRectangle(New SolidBrush(BaseColor), New Rectangle(0, 7, W, 8))
3486
            .FillRectangle(New SolidBrush(_TrackColor), New Rectangle(0, 7, Track.X + Track.Width, 8))
3487
            .ResetClip()
3488
3489
            '-- Hatch Brush
3490
            Dim HB As New HatchBrush(HatchStyle.Plaid, HatchColor, _TrackColor)
3491
            .FillRectangle(HB, New Rectangle(-10, 7, Track.X + Track.Width, 8))
3492
3493
            '-- Slider/Knob
3494
            Select Case Style
3495
                Case _Style.Slider
3496
                    GP2.AddRectangle(Track)
3497
                    .FillPath(New SolidBrush(SliderColor), GP2)
3498
                Case _Style.Knob
3499
                    GP2.AddEllipse(Knob)
3500
                    .FillPath(New SolidBrush(SliderColor), GP2)
3501
            End Select
3502
3503
            '-- Show the value 
3504
            If ShowValue Then
3505
                .DrawString(Value, New Font("Segoe UI", 8), Brushes.White, New Rectangle(1, 6, W, H), New StringFormat() _
3506
                            With {.Alignment = StringAlignment.Far, .LineAlignment = StringAlignment.Far})
3507
            End If
3508
        End With
3509
3510
        MyBase.OnPaint(e)
3511
        G.Dispose()
3512
        e.Graphics.InterpolationMode = 7
3513
        e.Graphics.DrawImageUnscaled(B, 0, 0)
3514
        B.Dispose()
3515
    End Sub
3516
End Class
3517
3518
Class FlatStatusBar : Inherits Control
3519
3520
#Region " Variables"
3521
3522
    Private W, H As Integer
3523
    Private _ShowTimeDate As Boolean = False
3524
3525
#End Region
3526
3527
#Region " Properties"
3528
3529
    Protected Overrides Sub CreateHandle()
3530
        MyBase.CreateHandle()
3531
        Dock = DockStyle.Bottom
3532
    End Sub
3533
3534
    Protected Overrides Sub OnTextChanged(e As EventArgs)
3535
        MyBase.OnTextChanged(e) : Invalidate()
3536
    End Sub
3537
3538
#Region " Colors"
3539
3540
    <Category("Colors")> _
3541
    Public Property BaseColor As Color
3542
        Get
3543
            Return _BaseColor
3544
        End Get
3545
        Set(value As Color)
3546
            _BaseColor = value
3547
        End Set
3548
    End Property
3549
3550
    <Category("Colors")> _
3551
    Public Property TextColor As Color
3552
        Get
3553
            Return _TextColor
3554
        End Get
3555
        Set(value As Color)
3556
            _TextColor = value
3557
        End Set
3558
    End Property
3559
3560
    <Category("Colors")> _
3561
    Public Property RectColor As Color
3562
        Get
3563
            Return _RectColor
3564
        End Get
3565
        Set(value As Color)
3566
            _RectColor = value
3567
        End Set
3568
    End Property
3569
3570
#End Region
3571
3572
    Public Property ShowTimeDate As Boolean
3573
        Get
3574
            Return _ShowTimeDate
3575
        End Get
3576
        Set(value As Boolean)
3577
            _ShowTimeDate = value
3578
        End Set
3579
    End Property
3580
3581
    Function GetTimeDate() As String
3582
        Return DateTime.Now.Date & " " & DateTime.Now.Hour & ":" & DateTime.Now.Minute
3583
    End Function
3584
3585
#End Region
3586
3587
#Region " Colors"
3588
3589
    Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
3590
    Private _TextColor As Color = Color.White
3591
    Private _RectColor As Color = _FlatColor
3592
3593
#End Region
3594
3595
    Sub New()
3596
        SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
3597
                 ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
3598
        DoubleBuffered = True
3599
        Font = New Font("Segoe UI", 8)
3600
        ForeColor = Color.White
3601
        Size = New Size(Width, 20)
3602
    End Sub
3603
3604
    Protected Overrides Sub OnPaint(e As PaintEventArgs)
3605
        B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
3606
        W = Width : H = Height
3607
3608
        Dim Base As New Rectangle(0, 0, W, H)
3609
3610
        With G
3611
            .SmoothingMode = 2
3612
            .PixelOffsetMode = 2
3613
            .TextRenderingHint = 5
3614
            .Clear(BaseColor)
3615
3616
            '-- Base
3617
            .FillRectangle(New SolidBrush(BaseColor), Base)
3618
3619
            '-- Text
3620
            .DrawString(Text, Font, Brushes.White, New Rectangle(10, 4, W, H), NearSF)
3621
3622
            '-- Rectangle
3623
            .FillRectangle(New SolidBrush(_RectColor), New Rectangle(4, 4, 4, 14))
3624
3625
            '-- TimeDate
3626
            If ShowTimeDate Then
3627
                .DrawString(GetTimeDate, Font, New SolidBrush(_TextColor), New Rectangle(-4, 2, W, H), New StringFormat() _
3628
                            With {.Alignment = StringAlignment.Far, .LineAlignment = StringAlignment.Center})
3629
            End If
3630
        End With
3631
3632
        MyBase.OnPaint(e)
3633
        G.Dispose()
3634
        e.Graphics.InterpolationMode = 7
3635
        e.Graphics.DrawImageUnscaled(B, 0, 0)
3636
        B.Dispose()
3637
    End Sub
3638
End Class
3639
3640
Class FlatLabel : Inherits Label
3641
3642
    Protected Overrides Sub OnTextChanged(e As EventArgs)
3643
        MyBase.OnTextChanged(e) : Invalidate()
3644
    End Sub
3645
3646
    Sub New()
3647
        SetStyle(ControlStyles.SupportsTransparentBackColor, True)
3648
        Font = New Font("Segoe UI", 8)
3649
        ForeColor = Color.White
3650
        BackColor = Color.Transparent
3651
        Text = Text
3652
    End Sub
3653
3654
End Class
3655
3656
Class FlatTreeView : Inherits TreeView
3657
3658
#Region " Variables"
3659
3660
    Private State As TreeNodeStates
3661
3662
#End Region
3663
3664
#Region " Properties"
3665
3666
    Protected Overrides Sub OnDrawNode(e As DrawTreeNodeEventArgs)
3667
        Try
3668
            Dim Bounds As New Rectangle(e.Bounds.Location.X, e.Bounds.Location.Y, e.Bounds.Width, e.Bounds.Height)
3669
            'e.Node.Nodes.Item.
3670
            Select Case State
3671
                Case TreeNodeStates.Default
3672
                    e.Graphics.FillRectangle(Brushes.Red, Bounds)
3673
                    e.Graphics.DrawString(e.Node.Text, New Font("Segoe UI", 8), Brushes.LimeGreen, New Rectangle(Bounds.X + 2, Bounds.Y + 2, Bounds.Width, Bounds.Height), NearSF)
3674
                    Invalidate()
3675
                Case TreeNodeStates.Checked
3676
                    e.Graphics.FillRectangle(Brushes.Green, Bounds)
3677
                    e.Graphics.DrawString(e.Node.Text, New Font("Segoe UI", 8), Brushes.Black, New Rectangle(Bounds.X + 2, Bounds.Y + 2, Bounds.Width, Bounds.Height), NearSF)
3678
                    Invalidate()
3679
                Case TreeNodeStates.Selected
3680
                    e.Graphics.FillRectangle(Brushes.Green, Bounds)
3681
                    e.Graphics.DrawString(e.Node.Text, New Font("Segoe UI", 8), Brushes.Black, New Rectangle(Bounds.X + 2, Bounds.Y + 2, Bounds.Width, Bounds.Height), NearSF)
3682
                    Invalidate()
3683
            End Select
3684
3685
        Catch ex As Exception
3686
            MsgBox(ex.Message)
3687
        End Try
3688
3689
        MyBase.OnDrawNode(e)
3690
    End Sub
3691
3692
#End Region
3693
3694
#Region " Colors"
3695
3696
    Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
3697
    Private _LineColor As Color = Color.FromArgb(25, 27, 29)
3698
3699
#End Region
3700
    Sub New()
3701
3702
        SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
3703
                 ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
3704
        DoubleBuffered = True
3705
3706
        BackColor = _BaseColor
3707
        ForeColor = Color.White
3708
        LineColor = _LineColor
3709
        DrawMode = TreeViewDrawMode.OwnerDrawAll
3710
    End Sub
3711
3712
    Protected Overrides Sub OnPaint(e As PaintEventArgs)
3713
        B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
3714
3715
        Dim Base As New Rectangle(0, 0, Width, Height)
3716
3717
        With G
3718
            .SmoothingMode = 2
3719
            .PixelOffsetMode = 2
3720
            .TextRenderingHint = 5
3721
            .Clear(BackColor)
3722
3723
            .FillRectangle(New SolidBrush(_BaseColor), Base)
3724
            .DrawString(Text, New Font("Segoe UI", 8), Brushes.Black, New Rectangle(Bounds.X + 2, Bounds.Y + 2, Bounds.Width, Bounds.Height), NearSF)
3725
3726
        End With
3727
3728
        MyBase.OnPaint(e)
3729
        G.Dispose()
3730
        e.Graphics.InterpolationMode = 7
3731
        e.Graphics.DrawImageUnscaled(B, 0, 0)
3732
        B.Dispose()
3733
    End Sub
3734
3735
End Class