View difference between Paste ID: fMMbk7AR and kyn8edfB
SHOW: | | - or go back to the newest paste.
1
Imports System, System.IO, System.Collections.Generic
2
Imports System.Drawing, System.Drawing.Drawing2D
3
Imports System.ComponentModel, System.Windows.Forms
4
Imports System.Runtime.InteropServices
5
Imports System.Drawing.Imaging
6
7
'------------------
8
'ThemeBase Creator: aeonhack
9
'Theme Creator: TWIXXZOR
10-
'Site: elitevs.net
10+
'Site: fivestargamerz.com
11-
'Version: 1.5.3
11+
12
MustInherit Class ThemeContainer153
13
    Inherits ContainerControl
14
15
#Region " Initialization "
16
17
    Protected G As Graphics, B As Bitmap
18
19
    Sub New()
20
        SetStyle(DirectCast(139270, ControlStyles), True)
21
22
        _ImageSize = Size.Empty
23
        Font = New Font("Verdana", 8S)
24
25
        MeasureBitmap = New Bitmap(1, 1)
26
        MeasureGraphics = Graphics.FromImage(MeasureBitmap)
27
28
        DrawRadialPath = New GraphicsPath
29
30
        InvalidateCustimization() 'Remove?
31
    End Sub
32
33
    Protected NotOverridable Overrides Sub OnHandleCreated(ByVal e As EventArgs)
34
        InvalidateCustimization()
35
        ColorHook()
36
37
        If Not _LockWidth = 0 Then Width = _LockWidth
38
        If Not _LockHeight = 0 Then Height = _LockHeight
39
        If Not _ControlMode Then MyBase.Dock = DockStyle.Fill
40
41
        Transparent = _Transparent
42
        If _Transparent AndAlso _BackColor Then BackColor = Color.Transparent
43
44
        MyBase.OnHandleCreated(e)
45
    End Sub
46
47
    Protected NotOverridable Overrides Sub OnParentChanged(ByVal e As EventArgs)
48
        MyBase.OnParentChanged(e)
49
50
        If Parent Is Nothing Then Return
51
        _IsParentForm = TypeOf Parent Is Form
52
53
        If Not _ControlMode Then
54
            InitializeMessages()
55
56
            If _IsParentForm Then
57
                ParentForm.FormBorderStyle = _BorderStyle
58
                ParentForm.TransparencyKey = _TransparencyKey
59
            End If
60
61
            Parent.BackColor = BackColor
62
        End If
63
64
        OnCreation()
65
    End Sub
66
67
#End Region
68
69
70
    Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
71
        If Width = 0 OrElse Height = 0 Then Return
72
73
        If _Transparent AndAlso _ControlMode Then
74
            PaintHook()
75
            e.Graphics.DrawImage(B, 0, 0)
76
        Else
77
            G = e.Graphics
78
            PaintHook()
79
        End If
80
    End Sub
81
82
83
#Region " Size Handling "
84
85
    Private Frame As Rectangle
86
    Protected NotOverridable Overrides Sub OnSizeChanged(ByVal e As EventArgs)
87
        If _Movable AndAlso Not _ControlMode Then
88
            Frame = New Rectangle(7, 7, Width - 14, _Header - 7)
89
        End If
90
91
        InvalidateBitmap()
92
        Invalidate()
93
94
        MyBase.OnSizeChanged(e)
95
    End Sub
96
97
    Protected Overrides Sub SetBoundsCore(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal specified As BoundsSpecified)
98
        If Not _LockWidth = 0 Then width = _LockWidth
99
        If Not _LockHeight = 0 Then height = _LockHeight
100
        MyBase.SetBoundsCore(x, y, width, height, specified)
101
    End Sub
102
103
#End Region
104
105
#Region " State Handling "
106
107
    Protected State As MouseState
108
    Private Sub SetState(ByVal current As MouseState)
109
        State = current
110
        Invalidate()
111
    End Sub
112
113
    Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
114
        If Not (_IsParentForm AndAlso ParentForm.WindowState = FormWindowState.Maximized) Then
115
            If _Sizable AndAlso Not _ControlMode Then InvalidateMouse()
116
        End If
117
118
        MyBase.OnMouseMove(e)
119
    End Sub
120
121
    Protected Overrides Sub OnEnabledChanged(ByVal e As EventArgs)
122
        If Enabled Then SetState(MouseState.None) Else SetState(MouseState.Block)
123
        MyBase.OnEnabledChanged(e)
124
    End Sub
125
126
    Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
127
        SetState(MouseState.Over)
128
        MyBase.OnMouseEnter(e)
129
    End Sub
130
131
    Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
132
        SetState(MouseState.Over)
133
        MyBase.OnMouseUp(e)
134
    End Sub
135
136
    Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
137
        SetState(MouseState.None)
138
139
        If GetChildAtPoint(PointToClient(MousePosition)) IsNot Nothing Then
140
            If _Sizable AndAlso Not _ControlMode Then
141
                Cursor = Cursors.Default
142
                Previous = 0
143
            End If
144
        End If
145
146
        MyBase.OnMouseLeave(e)
147
    End Sub
148
149
    Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
150
        If e.Button = Windows.Forms.MouseButtons.Left Then SetState(MouseState.Down)
151
152
        If Not (_IsParentForm AndAlso ParentForm.WindowState = FormWindowState.Maximized OrElse _ControlMode) Then
153
            If _Movable AndAlso Frame.Contains(e.Location) Then
154
                Capture = False
155
                WM_LMBUTTONDOWN = True
156
                DefWndProc(Messages(0))
157
            ElseIf _Sizable AndAlso Not Previous = 0 Then
158
                Capture = False
159
                WM_LMBUTTONDOWN = True
160
                DefWndProc(Messages(Previous))
161
            End If
162
        End If
163
164
        MyBase.OnMouseDown(e)
165
    End Sub
166
167
    Private WM_LMBUTTONDOWN As Boolean
168
    Protected Overrides Sub WndProc(ByRef m As Message)
169
        MyBase.WndProc(m)
170
171
        If WM_LMBUTTONDOWN AndAlso m.Msg = 513 Then
172
            WM_LMBUTTONDOWN = False
173
174
            SetState(MouseState.Over)
175
            If Not _SmartBounds Then Return
176
177
            If IsParentMdi Then
178
                CorrectBounds(New Rectangle(Point.Empty, Parent.Parent.Size))
179
            Else
180
                CorrectBounds(Screen.FromControl(Parent).WorkingArea)
181
            End If
182
        End If
183
    End Sub
184
185
    Private GetIndexPoint As Point
186
    Private B1, B2, B3, B4 As Boolean
187
    Private Function GetIndex() As Integer
188
        GetIndexPoint = PointToClient(MousePosition)
189
        B1 = GetIndexPoint.X < 7
190
        B2 = GetIndexPoint.X > Width - 7
191
        B3 = GetIndexPoint.Y < 7
192
        B4 = GetIndexPoint.Y > Height - 7
193
194
        If B1 AndAlso B3 Then Return 4
195
        If B1 AndAlso B4 Then Return 7
196
        If B2 AndAlso B3 Then Return 5
197
        If B2 AndAlso B4 Then Return 8
198
        If B1 Then Return 1
199
        If B2 Then Return 2
200
        If B3 Then Return 3
201
        If B4 Then Return 6
202
        Return 0
203
    End Function
204
205
    Private Current, Previous As Integer
206
    Private Sub InvalidateMouse()
207
        Current = GetIndex()
208
        If Current = Previous Then Return
209
210
        Previous = Current
211
        Select Case Previous
212
            Case 0
213
                Cursor = Cursors.Default
214
            Case 1, 2
215
                Cursor = Cursors.SizeWE
216
            Case 3, 6
217
                Cursor = Cursors.SizeNS
218
            Case 4, 8
219
                Cursor = Cursors.SizeNWSE
220
            Case 5, 7
221
                Cursor = Cursors.SizeNESW
222
        End Select
223
    End Sub
224
225
    Private Messages(8) As Message
226
    Private Sub InitializeMessages()
227
        Messages(0) = Message.Create(Parent.Handle, 161, New IntPtr(2), IntPtr.Zero)
228
        For I As Integer = 1 To 8
229
            Messages(I) = Message.Create(Parent.Handle, 161, New IntPtr(I + 9), IntPtr.Zero)
230
        Next
231
    End Sub
232
233
    Private Sub CorrectBounds(ByVal bounds As Rectangle)
234
        If Parent.Width > bounds.Width Then Parent.Width = bounds.Width
235
        If Parent.Height > bounds.Height Then Parent.Height = bounds.Height
236
237
        Dim X As Integer = Parent.Location.X
238
        Dim Y As Integer = Parent.Location.Y
239
240
        If X < bounds.X Then X = bounds.X
241
        If Y < bounds.Y Then Y = bounds.Y
242
243
        Dim Width As Integer = bounds.X + bounds.Width
244
        Dim Height As Integer = bounds.Y + bounds.Height
245
246
        If X + Parent.Width > Width Then X = Width - Parent.Width
247
        If Y + Parent.Height > Height Then Y = Height - Parent.Height
248
249
        Parent.Location = New Point(X, Y)
250
    End Sub
251
252
#End Region
253
254
255
#Region " Base Properties "
256
257
    Overrides Property Dock As DockStyle
258
        Get
259
            Return MyBase.Dock
260
        End Get
261
        Set(ByVal value As DockStyle)
262
            If Not _ControlMode Then Return
263
            MyBase.Dock = value
264
        End Set
265
    End Property
266
267
    Private _BackColor As Boolean
268
    <Category("Misc")> _
269
    Overrides Property BackColor() As Color
270
        Get
271
            Return MyBase.BackColor
272
        End Get
273
        Set(ByVal value As Color)
274
            If value = MyBase.BackColor Then Return
275
276
            If Not IsHandleCreated AndAlso _ControlMode AndAlso value = Color.Transparent Then
277
                _BackColor = True
278
                Return
279
            End If
280
281
            MyBase.BackColor = value
282
            If Parent IsNot Nothing Then
283
                If Not _ControlMode Then Parent.BackColor = value
284
                ColorHook()
285
            End If
286
        End Set
287
    End Property
288
289
    Overrides Property MinimumSize As Size
290
        Get
291
            Return MyBase.MinimumSize
292
        End Get
293
        Set(ByVal value As Size)
294
            MyBase.MinimumSize = value
295
            If Parent IsNot Nothing Then Parent.MinimumSize = value
296
        End Set
297
    End Property
298
299
    Overrides Property MaximumSize As Size
300
        Get
301
            Return MyBase.MaximumSize
302
        End Get
303
        Set(ByVal value As Size)
304
            MyBase.MaximumSize = value
305
            If Parent IsNot Nothing Then Parent.MaximumSize = value
306
        End Set
307
    End Property
308
309
    Overrides Property Text() As String
310
        Get
311
            Return MyBase.Text
312
        End Get
313
        Set(ByVal value As String)
314
            MyBase.Text = value
315
            Invalidate()
316
        End Set
317
    End Property
318
319
    Overrides Property Font() As Font
320
        Get
321
            Return MyBase.Font
322
        End Get
323
        Set(ByVal value As Font)
324
            MyBase.Font = value
325
            Invalidate()
326
        End Set
327
    End Property
328
329
    <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
330
    Overrides Property ForeColor() As Color
331
        Get
332
            Return Color.Empty
333
        End Get
334
        Set(ByVal value As Color)
335
        End Set
336
    End Property
337
    <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
338
    Overrides Property BackgroundImage() As Image
339
        Get
340
            Return Nothing
341
        End Get
342
        Set(ByVal value As Image)
343
        End Set
344
    End Property
345
    <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
346
    Overrides Property BackgroundImageLayout() As ImageLayout
347
        Get
348
            Return ImageLayout.None
349
        End Get
350
        Set(ByVal value As ImageLayout)
351
        End Set
352
    End Property
353
354
#End Region
355
356
#Region " Public Properties "
357
358
    Private _SmartBounds As Boolean = True
359
    Property SmartBounds() As Boolean
360
        Get
361
            Return _SmartBounds
362
        End Get
363
        Set(ByVal value As Boolean)
364
            _SmartBounds = value
365
        End Set
366
    End Property
367
368
    Private _Movable As Boolean = True
369
    Property Movable() As Boolean
370
        Get
371
            Return _Movable
372
        End Get
373
        Set(ByVal value As Boolean)
374
            _Movable = value
375
        End Set
376
    End Property
377
378
    Private _Sizable As Boolean = True
379
    Property Sizable() As Boolean
380
        Get
381
            Return _Sizable
382
        End Get
383
        Set(ByVal value As Boolean)
384
            _Sizable = value
385
        End Set
386
    End Property
387
388
    Private _TransparencyKey As Color
389
    Property TransparencyKey() As Color
390
        Get
391
            If _IsParentForm AndAlso Not _ControlMode Then Return ParentForm.TransparencyKey Else Return _TransparencyKey
392
        End Get
393
        Set(ByVal value As Color)
394
            If value = _TransparencyKey Then Return
395
            _TransparencyKey = value
396
397
            If _IsParentForm AndAlso Not _ControlMode Then
398
                ParentForm.TransparencyKey = value
399
                ColorHook()
400
            End If
401
        End Set
402
    End Property
403
404
    Private _BorderStyle As FormBorderStyle
405
    Property BorderStyle() As FormBorderStyle
406
        Get
407
            If _IsParentForm AndAlso Not _ControlMode Then Return ParentForm.FormBorderStyle Else Return _BorderStyle
408
        End Get
409
        Set(ByVal value As FormBorderStyle)
410
            _BorderStyle = value
411
412
            If _IsParentForm AndAlso Not _ControlMode Then
413
                ParentForm.FormBorderStyle = value
414
415
                If Not value = FormBorderStyle.None Then
416
                    Movable = False
417
                    Sizable = False
418
                End If
419
            End If
420
        End Set
421
    End Property
422
423
    Private _NoRounding As Boolean
424
    Property NoRounding() As Boolean
425
        Get
426
            Return _NoRounding
427
        End Get
428
        Set(ByVal v As Boolean)
429
            _NoRounding = v
430
            Invalidate()
431
        End Set
432
    End Property
433
434
    Private _Image As Image
435
    Property Image() As Image
436
        Get
437
            Return _Image
438
        End Get
439
        Set(ByVal value As Image)
440
            If value Is Nothing Then _ImageSize = Size.Empty Else _ImageSize = value.Size
441
442
            _Image = value
443
            Invalidate()
444
        End Set
445
    End Property
446
447
    Private Items As New Dictionary(Of String, Color)
448
    Property Colors() As Bloom()
449
        Get
450
            Dim T As New List(Of Bloom)
451
            Dim E As Dictionary(Of String, Color).Enumerator = Items.GetEnumerator
452
453
            While E.MoveNext
454
                T.Add(New Bloom(E.Current.Key, E.Current.Value))
455
            End While
456
457
            Return T.ToArray
458
        End Get
459
        Set(ByVal value As Bloom())
460
            For Each B As Bloom In value
461
                If Items.ContainsKey(B.Name) Then Items(B.Name) = B.Value
462
            Next
463
464
            InvalidateCustimization()
465
            ColorHook()
466
            Invalidate()
467
        End Set
468
    End Property
469
470
    Private _Customization As String
471
    Property Customization() As String
472
        Get
473
            Return _Customization
474
        End Get
475
        Set(ByVal value As String)
476
            If value = _Customization Then Return
477
478
            Dim Data As Byte()
479
            Dim Items As Bloom() = Colors
480
481
            Try
482
                Data = Convert.FromBase64String(value)
483
                For I As Integer = 0 To Items.Length - 1
484
                    Items(I).Value = Color.FromArgb(BitConverter.ToInt32(Data, I * 4))
485
                Next
486
            Catch
487
                Return
488
            End Try
489
490
            _Customization = value
491
492
            Colors = Items
493
            ColorHook()
494
            Invalidate()
495
        End Set
496
    End Property
497
498
    Private _Transparent As Boolean
499
    Property Transparent() As Boolean
500
        Get
501
            Return _Transparent
502
        End Get
503
        Set(ByVal value As Boolean)
504
            _Transparent = value
505
            If Not (IsHandleCreated OrElse _ControlMode) Then Return
506
507
            If Not value AndAlso Not BackColor.A = 255 Then
508
                Throw New Exception("Unable to change value to false while a transparent BackColor is in use.")
509
            End If
510
511
            SetStyle(ControlStyles.Opaque, Not value)
512
            SetStyle(ControlStyles.SupportsTransparentBackColor, value)
513
514
            InvalidateBitmap()
515
            Invalidate()
516
        End Set
517
    End Property
518
519
#End Region
520
521
#Region " Private Properties "
522
523
    Private _ImageSize As Size
524
    Protected ReadOnly Property ImageSize() As Size
525
        Get
526
            Return _ImageSize
527
        End Get
528
    End Property
529
530
    Private _IsParentForm As Boolean
531
    Protected ReadOnly Property IsParentForm As Boolean
532
        Get
533
            Return _IsParentForm
534
        End Get
535
    End Property
536
537
    Protected ReadOnly Property IsParentMdi As Boolean
538
        Get
539
            If Parent Is Nothing Then Return False
540
            Return Parent.Parent IsNot Nothing
541
        End Get
542
    End Property
543
544
    Private _LockWidth As Integer
545
    Protected Property LockWidth() As Integer
546
        Get
547
            Return _LockWidth
548
        End Get
549
        Set(ByVal value As Integer)
550
            _LockWidth = value
551
            If Not LockWidth = 0 AndAlso IsHandleCreated Then Width = LockWidth
552
        End Set
553
    End Property
554
555
    Private _LockHeight As Integer
556
    Protected Property LockHeight() As Integer
557
        Get
558
            Return _LockHeight
559
        End Get
560
        Set(ByVal value As Integer)
561
            _LockHeight = value
562
            If Not LockHeight = 0 AndAlso IsHandleCreated Then Height = LockHeight
563
        End Set
564
    End Property
565
566
    Private _Header As Integer = 24
567
    Protected Property Header() As Integer
568
        Get
569
            Return _Header
570
        End Get
571
        Set(ByVal v As Integer)
572
            _Header = v
573
574
            If Not _ControlMode Then
575
                Frame = New Rectangle(7, 7, Width - 14, v - 7)
576
                Invalidate()
577
            End If
578
        End Set
579
    End Property
580
581
    Private _ControlMode As Boolean
582
    Protected Property ControlMode() As Boolean
583
        Get
584
            Return _ControlMode
585
        End Get
586
        Set(ByVal v As Boolean)
587
            _ControlMode = v
588
589
            Transparent = _Transparent
590
            If _Transparent AndAlso _BackColor Then BackColor = Color.Transparent
591
592
            InvalidateBitmap()
593
            Invalidate()
594
        End Set
595
    End Property
596
597
#End Region
598
599
600
#Region " Property Helpers "
601
602
    Protected Function GetPen(ByVal name As String) As Pen
603
        Return New Pen(Items(name))
604
    End Function
605
    Protected Function GetPen(ByVal name As String, ByVal width As Single) As Pen
606
        Return New Pen(Items(name), width)
607
    End Function
608
609
    Protected Function GetBrush(ByVal name As String) As SolidBrush
610
        Return New SolidBrush(Items(name))
611
    End Function
612
613
    Protected Function GetColor(ByVal name As String) As Color
614
        Return Items(name)
615
    End Function
616
617
    Protected Sub SetColor(ByVal name As String, ByVal value As Color)
618
        If Items.ContainsKey(name) Then Items(name) = value Else Items.Add(name, value)
619
    End Sub
620
    Protected Sub SetColor(ByVal name As String, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
621
        SetColor(name, Color.FromArgb(r, g, b))
622
    End Sub
623
    Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
624
        SetColor(name, Color.FromArgb(a, r, g, b))
625
    End Sub
626
    Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal value As Color)
627
        SetColor(name, Color.FromArgb(a, value))
628
    End Sub
629
630
    Private Sub InvalidateBitmap()
631
        If _Transparent AndAlso _ControlMode Then
632
            If Width = 0 OrElse Height = 0 Then Return
633
            B = New Bitmap(Width, Height, PixelFormat.Format32bppPArgb)
634
            G = Graphics.FromImage(B)
635
        Else
636
            G = Nothing
637
            B = Nothing
638
        End If
639
    End Sub
640
641
    Private Sub InvalidateCustimization()
642
        Dim M As New MemoryStream(Items.Count * 4)
643
644
        For Each B As Bloom In Colors
645
            M.Write(BitConverter.GetBytes(B.Value.ToArgb), 0, 4)
646
        Next
647
648
        M.Close()
649
        _Customization = Convert.ToBase64String(M.ToArray)
650
    End Sub
651
652
#End Region
653
654
655
#Region " User Hooks "
656
657
    Protected MustOverride Sub ColorHook()
658
    Protected MustOverride Sub PaintHook()
659
660
    Protected Overridable Sub OnCreation()
661
    End Sub
662
663
#End Region
664
665
666
#Region " Offset "
667
668
    Private OffsetReturnRectangle As Rectangle
669
    Protected Function Offset(ByVal r As Rectangle, ByVal amount As Integer) As Rectangle
670
        OffsetReturnRectangle = New Rectangle(r.X + amount, r.Y + amount, r.Width - (amount * 2), r.Height - (amount * 2))
671
        Return OffsetReturnRectangle
672
    End Function
673
674
    Private OffsetReturnSize As Size
675
    Protected Function Offset(ByVal s As Size, ByVal amount As Integer) As Size
676
        OffsetReturnSize = New Size(s.Width + amount, s.Height + amount)
677
        Return OffsetReturnSize
678
    End Function
679
680
    Private OffsetReturnPoint As Point
681
    Protected Function Offset(ByVal p As Point, ByVal amount As Integer) As Point
682
        OffsetReturnPoint = New Point(p.X + amount, p.Y + amount)
683
        Return OffsetReturnPoint
684
    End Function
685
686
#End Region
687
688
#Region " Center "
689
690
    Private CenterReturn As Point
691
692
    Protected Function Center(ByVal p As Rectangle, ByVal c As Rectangle) As Point
693
        CenterReturn = New Point((p.Width \ 2 - c.Width \ 2) + p.X + c.X, (p.Height \ 2 - c.Height \ 2) + p.Y + c.Y)
694
        Return CenterReturn
695
    End Function
696
    Protected Function Center(ByVal p As Rectangle, ByVal c As Size) As Point
697
        CenterReturn = New Point((p.Width \ 2 - c.Width \ 2) + p.X, (p.Height \ 2 - c.Height \ 2) + p.Y)
698
        Return CenterReturn
699
    End Function
700
701
    Protected Function Center(ByVal child As Rectangle) As Point
702
        Return Center(Width, Height, child.Width, child.Height)
703
    End Function
704
    Protected Function Center(ByVal child As Size) As Point
705
        Return Center(Width, Height, child.Width, child.Height)
706
    End Function
707
    Protected Function Center(ByVal childWidth As Integer, ByVal childHeight As Integer) As Point
708
        Return Center(Width, Height, childWidth, childHeight)
709
    End Function
710
711
    Protected Function Center(ByVal p As Size, ByVal c As Size) As Point
712
        Return Center(p.Width, p.Height, c.Width, c.Height)
713
    End Function
714
715
    Protected Function Center(ByVal pWidth As Integer, ByVal pHeight As Integer, ByVal cWidth As Integer, ByVal cHeight As Integer) As Point
716
        CenterReturn = New Point(pWidth \ 2 - cWidth \ 2, pHeight \ 2 - cHeight \ 2)
717
        Return CenterReturn
718
    End Function
719
720
#End Region
721
722
#Region " Measure "
723
724
    Private MeasureBitmap As Bitmap
725
    Private MeasureGraphics As Graphics 'TODO: Potential issues during multi-threading.
726
727
    Protected Function Measure() As Size
728
        Return MeasureGraphics.MeasureString(Text, Font, Width).ToSize
729
    End Function
730
    Protected Function Measure(ByVal text As String) As Size
731
        Return MeasureGraphics.MeasureString(text, Font, Width).ToSize
732
    End Function
733
734
#End Region
735
736
737
#Region " DrawPixel "
738
739
    Private DrawPixelBrush As SolidBrush
740
741
    Protected Sub DrawPixel(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer)
742
        If _Transparent Then
743
            B.SetPixel(x, y, c1)
744
        Else
745
            DrawPixelBrush = New SolidBrush(c1)
746
            G.FillRectangle(DrawPixelBrush, x, y, 1, 1)
747
        End If
748
    End Sub
749
750
#End Region
751
752
#Region " DrawCorners "
753
754
    Private DrawCornersBrush As SolidBrush
755
756
    Protected Sub DrawCorners(ByVal c1 As Color, ByVal offset As Integer)
757
        DrawCorners(c1, 0, 0, Width, Height, offset)
758
    End Sub
759
    Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle, ByVal offset As Integer)
760
        DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height, offset)
761
    End Sub
762
    Protected Sub DrawCorners(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal offset As Integer)
763
        DrawCorners(c1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
764
    End Sub
765
766
    Protected Sub DrawCorners(ByVal c1 As Color)
767
        DrawCorners(c1, 0, 0, Width, Height)
768
    End Sub
769
    Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle)
770
        DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height)
771
    End Sub
772
    Protected Sub DrawCorners(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
773
        If _NoRounding Then Return
774
775
        If _Transparent Then
776
            B.SetPixel(x, y, c1)
777
            B.SetPixel(x + (width - 1), y, c1)
778
            B.SetPixel(x, y + (height - 1), c1)
779
            B.SetPixel(x + (width - 1), y + (height - 1), c1)
780
        Else
781
            DrawCornersBrush = New SolidBrush(c1)
782
            G.FillRectangle(DrawCornersBrush, x, y, 1, 1)
783
            G.FillRectangle(DrawCornersBrush, x + (width - 1), y, 1, 1)
784
            G.FillRectangle(DrawCornersBrush, x, y + (height - 1), 1, 1)
785
            G.FillRectangle(DrawCornersBrush, x + (width - 1), y + (height - 1), 1, 1)
786
        End If
787
    End Sub
788
789
#End Region
790
791
#Region " DrawBorders "
792
793
    Protected Sub DrawBorders(ByVal p1 As Pen, ByVal offset As Integer)
794
        DrawBorders(p1, 0, 0, Width, Height, offset)
795
    End Sub
796
    Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle, ByVal offset As Integer)
797
        DrawBorders(p1, r.X, r.Y, r.Width, r.Height, offset)
798
    End Sub
799
    Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal offset As Integer)
800
        DrawBorders(p1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
801
    End Sub
802
803
    Protected Sub DrawBorders(ByVal p1 As Pen)
804
        DrawBorders(p1, 0, 0, Width, Height)
805
    End Sub
806
    Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle)
807
        DrawBorders(p1, r.X, r.Y, r.Width, r.Height)
808
    End Sub
809
    Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
810
        G.DrawRectangle(p1, x, y, width - 1, height - 1)
811
    End Sub
812
813
#End Region
814
815
#Region " DrawText "
816
817
    Private DrawTextPoint As Point
818
    Private DrawTextSize As Size
819
820
    Protected Sub DrawText(ByVal b1 As Brush, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
821
        DrawText(b1, Text, a, x, y)
822
    End Sub
823
    Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
824
        If text.Length = 0 Then Return
825
826
        DrawTextSize = Measure(text)
827
        DrawTextPoint = New Point(Width \ 2 - DrawTextSize.Width \ 2, Header \ 2 - DrawTextSize.Height \ 2)
828
829
        Select Case a
830
            Case HorizontalAlignment.Left
831
                G.DrawString(text, Font, b1, x, DrawTextPoint.Y + y)
832
            Case HorizontalAlignment.Center
833
                G.DrawString(text, Font, b1, DrawTextPoint.X + x, DrawTextPoint.Y + y)
834
            Case HorizontalAlignment.Right
835
                G.DrawString(text, Font, b1, Width - DrawTextSize.Width - x, DrawTextPoint.Y + y)
836
        End Select
837
    End Sub
838
839
    Protected Sub DrawText(ByVal b1 As Brush, ByVal p1 As Point)
840
        If Text.Length = 0 Then Return
841
        G.DrawString(Text, Font, b1, p1)
842
    End Sub
843
    Protected Sub DrawText(ByVal b1 As Brush, ByVal x As Integer, ByVal y As Integer)
844
        If Text.Length = 0 Then Return
845
        G.DrawString(Text, Font, b1, x, y)
846
    End Sub
847
848
#End Region
849
850
#Region " DrawImage "
851
852
    Private DrawImagePoint As Point
853
854
    Protected Sub DrawImage(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
855
        DrawImage(_Image, a, x, y)
856
    End Sub
857
    Protected Sub DrawImage(ByVal image As Image, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
858
        If image Is Nothing Then Return
859
        DrawImagePoint = New Point(Width \ 2 - image.Width \ 2, Header \ 2 - image.Height \ 2)
860
861
        Select Case a
862
            Case HorizontalAlignment.Left
863
                G.DrawImage(image, x, DrawImagePoint.Y + y, image.Width, image.Height)
864
            Case HorizontalAlignment.Center
865
                G.DrawImage(image, DrawImagePoint.X + x, DrawImagePoint.Y + y, image.Width, image.Height)
866
            Case HorizontalAlignment.Right
867
                G.DrawImage(image, Width - image.Width - x, DrawImagePoint.Y + y, image.Width, image.Height)
868
        End Select
869
    End Sub
870
871
    Protected Sub DrawImage(ByVal p1 As Point)
872
        DrawImage(_Image, p1.X, p1.Y)
873
    End Sub
874
    Protected Sub DrawImage(ByVal x As Integer, ByVal y As Integer)
875
        DrawImage(_Image, x, y)
876
    End Sub
877
878
    Protected Sub DrawImage(ByVal image As Image, ByVal p1 As Point)
879
        DrawImage(image, p1.X, p1.Y)
880
    End Sub
881
    Protected Sub DrawImage(ByVal image As Image, ByVal x As Integer, ByVal y As Integer)
882
        If image Is Nothing Then Return
883
        G.DrawImage(image, x, y, image.Width, image.Height)
884
    End Sub
885
886
#End Region
887
888
#Region " DrawGradient "
889
890
    Private DrawGradientBrush As LinearGradientBrush
891
    Private DrawGradientRectangle As Rectangle
892
893
    Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
894
        DrawGradientRectangle = New Rectangle(x, y, width, height)
895
        DrawGradient(blend, DrawGradientRectangle)
896
    End Sub
897
    Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single)
898
        DrawGradientRectangle = New Rectangle(x, y, width, height)
899
        DrawGradient(blend, DrawGradientRectangle, angle)
900
    End Sub
901
902
    Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle)
903
        DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, 90.0F)
904
        DrawGradientBrush.InterpolationColors = blend
905
        G.FillRectangle(DrawGradientBrush, r)
906
    End Sub
907
    Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal angle As Single)
908
        DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, angle)
909
        DrawGradientBrush.InterpolationColors = blend
910
        G.FillRectangle(DrawGradientBrush, r)
911
    End Sub
912
913
914
    Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
915
        DrawGradientRectangle = New Rectangle(x, y, width, height)
916
        DrawGradient(c1, c2, DrawGradientRectangle)
917
    End Sub
918
    Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single)
919
        DrawGradientRectangle = New Rectangle(x, y, width, height)
920
        DrawGradient(c1, c2, DrawGradientRectangle, angle)
921
    End Sub
922
923
    Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
924
        DrawGradientBrush = New LinearGradientBrush(r, c1, c2, 90.0F)
925
        G.FillRectangle(DrawGradientBrush, r)
926
    End Sub
927
    Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
928
        DrawGradientBrush = New LinearGradientBrush(r, c1, c2, angle)
929
        G.FillRectangle(DrawGradientBrush, r)
930
    End Sub
931
932
#End Region
933
934
#Region " DrawRadial "
935
936
    Private DrawRadialPath As GraphicsPath
937
    Private DrawRadialBrush1 As PathGradientBrush
938
    Private DrawRadialBrush2 As LinearGradientBrush
939
    Private DrawRadialRectangle As Rectangle
940
941
    Sub DrawRadial(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
942
        DrawRadialRectangle = New Rectangle(x, y, width, height)
943
        DrawRadial(blend, DrawRadialRectangle, width \ 2, height \ 2)
944
    End Sub
945
    Sub DrawRadial(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal center As Point)
946
        DrawRadialRectangle = New Rectangle(x, y, width, height)
947
        DrawRadial(blend, DrawRadialRectangle, center.X, center.Y)
948
    End Sub
949
    Sub DrawRadial(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal cx As Integer, ByVal cy As Integer)
950
        DrawRadialRectangle = New Rectangle(x, y, width, height)
951
        DrawRadial(blend, DrawRadialRectangle, cx, cy)
952
    End Sub
953
954
    Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle)
955
        DrawRadial(blend, r, r.Width \ 2, r.Height \ 2)
956
    End Sub
957
    Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal center As Point)
958
        DrawRadial(blend, r, center.X, center.Y)
959
    End Sub
960
    Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal cx As Integer, ByVal cy As Integer)
961
        DrawRadialPath.Reset()
962
        DrawRadialPath.AddEllipse(r.X, r.Y, r.Width - 1, r.Height - 1)
963
964
        DrawRadialBrush1 = New PathGradientBrush(DrawRadialPath)
965
        DrawRadialBrush1.CenterPoint = New Point(r.X + cx, r.Y + cy)
966
        DrawRadialBrush1.InterpolationColors = blend
967
968
        If G.SmoothingMode = SmoothingMode.AntiAlias Then
969
            G.FillEllipse(DrawRadialBrush1, r.X + 1, r.Y + 1, r.Width - 3, r.Height - 3)
970
        Else
971
            G.FillEllipse(DrawRadialBrush1, r)
972
        End If
973
    End Sub
974
975
976
    Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
977
        DrawRadialRectangle = New Rectangle(x, y, width, height)
978
        DrawRadial(c1, c2, DrawGradientRectangle)
979
    End Sub
980
    Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single)
981
        DrawRadialRectangle = New Rectangle(x, y, width, height)
982
        DrawRadial(c1, c2, DrawGradientRectangle, angle)
983
    End Sub
984
985
    Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
986
        DrawRadialBrush2 = New LinearGradientBrush(r, c1, c2, 90.0F)
987
        G.FillRectangle(DrawGradientBrush, r)
988
    End Sub
989
    Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
990
        DrawRadialBrush2 = New LinearGradientBrush(r, c1, c2, angle)
991
        G.FillEllipse(DrawGradientBrush, r)
992
    End Sub
993
994
#End Region
995
996
End Class
997
998
MustInherit Class ThemeControl153
999
    Inherits Control
1000
1001
1002
#Region " Initialization "
1003
1004
    Protected G As Graphics, B As Bitmap
1005
1006
    Sub New()
1007
        SetStyle(DirectCast(139270, ControlStyles), True)
1008
1009
        _ImageSize = Size.Empty
1010
        Font = New Font("Verdana", 8S)
1011
1012
        MeasureBitmap = New Bitmap(1, 1)
1013
        MeasureGraphics = Graphics.FromImage(MeasureBitmap)
1014
1015
        DrawRadialPath = New GraphicsPath
1016
1017
        InvalidateCustimization() 'Remove?
1018
    End Sub
1019
1020
    Protected NotOverridable Overrides Sub OnHandleCreated(ByVal e As EventArgs)
1021
        InvalidateCustimization()
1022
        ColorHook()
1023
1024
        If Not _LockWidth = 0 Then Width = _LockWidth
1025
        If Not _LockHeight = 0 Then Height = _LockHeight
1026
1027
        Transparent = _Transparent
1028
        If _Transparent AndAlso _BackColor Then BackColor = Color.Transparent
1029
1030
        MyBase.OnHandleCreated(e)
1031
    End Sub
1032
1033
    Protected NotOverridable Overrides Sub OnParentChanged(ByVal e As EventArgs)
1034
        If Parent IsNot Nothing Then OnCreation()
1035
        MyBase.OnParentChanged(e)
1036
    End Sub
1037
1038
#End Region
1039
1040
1041
    Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
1042
        If Width = 0 OrElse Height = 0 Then Return
1043
1044
        If _Transparent Then
1045
            PaintHook()
1046
            e.Graphics.DrawImage(B, 0, 0)
1047
        Else
1048
            G = e.Graphics
1049
            PaintHook()
1050
        End If
1051
    End Sub
1052
1053
1054
#Region " Size Handling "
1055
1056
    Protected NotOverridable Overrides Sub OnSizeChanged(ByVal e As EventArgs)
1057
        If _Transparent Then
1058
            InvalidateBitmap()
1059
        End If
1060
1061
        Invalidate()
1062
        MyBase.OnSizeChanged(e)
1063
    End Sub
1064
1065
    Protected Overrides Sub SetBoundsCore(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal specified As BoundsSpecified)
1066
        If Not _LockWidth = 0 Then width = _LockWidth
1067
        If Not _LockHeight = 0 Then height = _LockHeight
1068
        MyBase.SetBoundsCore(x, y, width, height, specified)
1069
    End Sub
1070
1071
#End Region
1072
1073
#Region " State Handling "
1074
1075
    Private InPosition As Boolean
1076
    Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
1077
        InPosition = True
1078
        SetState(MouseState.Over)
1079
        MyBase.OnMouseEnter(e)
1080
    End Sub
1081
1082
    Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
1083
        If InPosition Then SetState(MouseState.Over)
1084
        MyBase.OnMouseUp(e)
1085
    End Sub
1086
1087
    Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
1088
        If e.Button = Windows.Forms.MouseButtons.Left Then SetState(MouseState.Down)
1089
        MyBase.OnMouseDown(e)
1090
    End Sub
1091
1092
    Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
1093
        InPosition = False
1094
        SetState(MouseState.None)
1095
        MyBase.OnMouseLeave(e)
1096
    End Sub
1097
1098
    Protected Overrides Sub OnEnabledChanged(ByVal e As EventArgs)
1099
        If Enabled Then SetState(MouseState.None) Else SetState(MouseState.Block)
1100
        MyBase.OnEnabledChanged(e)
1101
    End Sub
1102
1103
    Protected State As MouseState
1104
    Private Sub SetState(ByVal current As MouseState)
1105
        State = current
1106
        Invalidate()
1107
    End Sub
1108
1109
#End Region
1110
1111
1112
#Region " Base Properties "
1113
1114
    <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
1115
    Overrides Property ForeColor() As Color
1116
        Get
1117
            Return Color.Empty
1118
        End Get
1119
        Set(ByVal value As Color)
1120
        End Set
1121
    End Property
1122
    <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
1123
    Overrides Property BackgroundImage() As Image
1124
        Get
1125
            Return Nothing
1126
        End Get
1127
        Set(ByVal value As Image)
1128
        End Set
1129
    End Property
1130
    <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
1131
    Overrides Property BackgroundImageLayout() As ImageLayout
1132
        Get
1133
            Return ImageLayout.None
1134
        End Get
1135
        Set(ByVal value As ImageLayout)
1136
        End Set
1137
    End Property
1138
1139
    Overrides Property Text() As String
1140
        Get
1141
            Return MyBase.Text
1142
        End Get
1143
        Set(ByVal value As String)
1144
            MyBase.Text = value
1145
            Invalidate()
1146
        End Set
1147
    End Property
1148
    Overrides Property Font() As Font
1149
        Get
1150
            Return MyBase.Font
1151
        End Get
1152
        Set(ByVal value As Font)
1153
            MyBase.Font = value
1154
            Invalidate()
1155
        End Set
1156
    End Property
1157
1158
    Private _BackColor As Boolean
1159
    <Category("Misc")> _
1160
    Overrides Property BackColor() As Color
1161
        Get
1162
            Return MyBase.BackColor
1163
        End Get
1164
        Set(ByVal value As Color)
1165
            If Not IsHandleCreated AndAlso value = Color.Transparent Then
1166
                _BackColor = True
1167
                Return
1168
            End If
1169
1170
            MyBase.BackColor = value
1171
            If Parent IsNot Nothing Then ColorHook()
1172
        End Set
1173
    End Property
1174
1175
#End Region
1176
1177
#Region " Public Properties "
1178
1179
    Private _NoRounding As Boolean
1180
    Property NoRounding() As Boolean
1181
        Get
1182
            Return _NoRounding
1183
        End Get
1184
        Set(ByVal v As Boolean)
1185
            _NoRounding = v
1186
            Invalidate()
1187
        End Set
1188
    End Property
1189
1190
    Private _Image As Image
1191
    Property Image() As Image
1192
        Get
1193
            Return _Image
1194
        End Get
1195
        Set(ByVal value As Image)
1196
            If value Is Nothing Then
1197
                _ImageSize = Size.Empty
1198
            Else
1199
                _ImageSize = value.Size
1200
            End If
1201
1202
            _Image = value
1203
            Invalidate()
1204
        End Set
1205
    End Property
1206
1207
    Private _Transparent As Boolean
1208
    Property Transparent() As Boolean
1209
        Get
1210
            Return _Transparent
1211
        End Get
1212
        Set(ByVal value As Boolean)
1213
            _Transparent = value
1214
            If Not IsHandleCreated Then Return
1215
1216
            If Not value AndAlso Not BackColor.A = 255 Then
1217
                Throw New Exception("Unable to change value to false while a transparent BackColor is in use.")
1218
            End If
1219
1220
            SetStyle(ControlStyles.Opaque, Not value)
1221
            SetStyle(ControlStyles.SupportsTransparentBackColor, value)
1222
1223
            If value Then InvalidateBitmap() Else B = Nothing
1224
            Invalidate()
1225
        End Set
1226
    End Property
1227
1228
    Private Items As New Dictionary(Of String, Color)
1229
    Property Colors() As Bloom()
1230
        Get
1231
            Dim T As New List(Of Bloom)
1232
            Dim E As Dictionary(Of String, Color).Enumerator = Items.GetEnumerator
1233
1234
            While E.MoveNext
1235
                T.Add(New Bloom(E.Current.Key, E.Current.Value))
1236
            End While
1237
1238
            Return T.ToArray
1239
        End Get
1240
        Set(ByVal value As Bloom())
1241
            For Each B As Bloom In value
1242
                If Items.ContainsKey(B.Name) Then Items(B.Name) = B.Value
1243
            Next
1244
1245
            InvalidateCustimization()
1246
            ColorHook()
1247
            Invalidate()
1248
        End Set
1249
    End Property
1250
1251
    Private _Customization As String
1252
    Property Customization() As String
1253
        Get
1254
            Return _Customization
1255
        End Get
1256
        Set(ByVal value As String)
1257
            If value = _Customization Then Return
1258
1259
            Dim Data As Byte()
1260
            Dim Items As Bloom() = Colors
1261
1262
            Try
1263
                Data = Convert.FromBase64String(value)
1264
                For I As Integer = 0 To Items.Length - 1
1265
                    Items(I).Value = Color.FromArgb(BitConverter.ToInt32(Data, I * 4))
1266
                Next
1267
            Catch
1268
                Return
1269
            End Try
1270
1271
            _Customization = value
1272
1273
            Colors = Items
1274
            ColorHook()
1275
            Invalidate()
1276
        End Set
1277
    End Property
1278
1279
#End Region
1280
1281
#Region " Private Properties "
1282
1283
    Private _ImageSize As Size
1284
    Protected ReadOnly Property ImageSize() As Size
1285
        Get
1286
            Return _ImageSize
1287
        End Get
1288
    End Property
1289
1290
    Private _LockWidth As Integer
1291
    Protected Property LockWidth() As Integer
1292
        Get
1293
            Return _LockWidth
1294
        End Get
1295
        Set(ByVal value As Integer)
1296
            _LockWidth = value
1297
            If Not LockWidth = 0 AndAlso IsHandleCreated Then Width = LockWidth
1298
        End Set
1299
    End Property
1300
1301
    Private _LockHeight As Integer
1302
    Protected Property LockHeight() As Integer
1303
        Get
1304
            Return _LockHeight
1305
        End Get
1306
        Set(ByVal value As Integer)
1307
            _LockHeight = value
1308
            If Not LockHeight = 0 AndAlso IsHandleCreated Then Height = LockHeight
1309
        End Set
1310
    End Property
1311
1312
#End Region
1313
1314
1315
#Region " Property Helpers "
1316
1317
    Protected Function GetPen(ByVal name As String) As Pen
1318
        Return New Pen(Items(name))
1319
    End Function
1320
    Protected Function GetPen(ByVal name As String, ByVal width As Single) As Pen
1321
        Return New Pen(Items(name), width)
1322
    End Function
1323
1324
    Protected Function GetBrush(ByVal name As String) As SolidBrush
1325
        Return New SolidBrush(Items(name))
1326
    End Function
1327
1328
    Protected Function GetColor(ByVal name As String) As Color
1329
        Return Items(name)
1330
    End Function
1331
1332
    Protected Sub SetColor(ByVal name As String, ByVal value As Color)
1333
        If Items.ContainsKey(name) Then Items(name) = value Else Items.Add(name, value)
1334
    End Sub
1335
    Protected Sub SetColor(ByVal name As String, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
1336
        SetColor(name, Color.FromArgb(r, g, b))
1337
    End Sub
1338
    Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
1339
        SetColor(name, Color.FromArgb(a, r, g, b))
1340
    End Sub
1341
    Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal value As Color)
1342
        SetColor(name, Color.FromArgb(a, value))
1343
    End Sub
1344
1345
    Private Sub InvalidateBitmap()
1346
        If Width = 0 OrElse Height = 0 Then Return
1347
        B = New Bitmap(Width, Height, PixelFormat.Format32bppPArgb)
1348
        G = Graphics.FromImage(B)
1349
    End Sub
1350
1351
    Private Sub InvalidateCustimization()
1352
        Dim M As New MemoryStream(Items.Count * 4)
1353
1354
        For Each B As Bloom In Colors
1355
            M.Write(BitConverter.GetBytes(B.Value.ToArgb), 0, 4)
1356
        Next
1357
1358
        M.Close()
1359
        _Customization = Convert.ToBase64String(M.ToArray)
1360
    End Sub
1361
1362
#End Region
1363
1364
1365
#Region " User Hooks "
1366
1367
    Protected MustOverride Sub ColorHook()
1368
    Protected MustOverride Sub PaintHook()
1369
1370
    Protected Overridable Sub OnCreation()
1371
    End Sub
1372
1373
#End Region
1374
1375
1376
#Region " Offset "
1377
1378
    Private OffsetReturnRectangle As Rectangle
1379
    Protected Function Offset(ByVal r As Rectangle, ByVal amount As Integer) As Rectangle
1380
        OffsetReturnRectangle = New Rectangle(r.X + amount, r.Y + amount, r.Width - (amount * 2), r.Height - (amount * 2))
1381
        Return OffsetReturnRectangle
1382
    End Function
1383
1384
    Private OffsetReturnSize As Size
1385
    Protected Function Offset(ByVal s As Size, ByVal amount As Integer) As Size
1386
        OffsetReturnSize = New Size(s.Width + amount, s.Height + amount)
1387
        Return OffsetReturnSize
1388
    End Function
1389
1390
    Private OffsetReturnPoint As Point
1391
    Protected Function Offset(ByVal p As Point, ByVal amount As Integer) As Point
1392
        OffsetReturnPoint = New Point(p.X + amount, p.Y + amount)
1393
        Return OffsetReturnPoint
1394
    End Function
1395
1396
#End Region
1397
1398
#Region " Center "
1399
1400
    Private CenterReturn As Point
1401
1402
    Protected Function Center(ByVal p As Rectangle, ByVal c As Rectangle) As Point
1403
        CenterReturn = New Point((p.Width \ 2 - c.Width \ 2) + p.X + c.X, (p.Height \ 2 - c.Height \ 2) + p.Y + c.Y)
1404
        Return CenterReturn
1405
    End Function
1406
    Protected Function Center(ByVal p As Rectangle, ByVal c As Size) As Point
1407
        CenterReturn = New Point((p.Width \ 2 - c.Width \ 2) + p.X, (p.Height \ 2 - c.Height \ 2) + p.Y)
1408
        Return CenterReturn
1409
    End Function
1410
1411
    Protected Function Center(ByVal child As Rectangle) As Point
1412
        Return Center(Width, Height, child.Width, child.Height)
1413
    End Function
1414
    Protected Function Center(ByVal child As Size) As Point
1415
        Return Center(Width, Height, child.Width, child.Height)
1416
    End Function
1417
    Protected Function Center(ByVal childWidth As Integer, ByVal childHeight As Integer) As Point
1418
        Return Center(Width, Height, childWidth, childHeight)
1419
    End Function
1420
1421
    Protected Function Center(ByVal p As Size, ByVal c As Size) As Point
1422
        Return Center(p.Width, p.Height, c.Width, c.Height)
1423
    End Function
1424
1425
    Protected Function Center(ByVal pWidth As Integer, ByVal pHeight As Integer, ByVal cWidth As Integer, ByVal cHeight As Integer) As Point
1426
        CenterReturn = New Point(pWidth \ 2 - cWidth \ 2, pHeight \ 2 - cHeight \ 2)
1427
        Return CenterReturn
1428
    End Function
1429
1430
#End Region
1431
1432
#Region " Measure "
1433
1434
    Private MeasureBitmap As Bitmap
1435
    Private MeasureGraphics As Graphics 'TODO: Potential issues during multi-threading.
1436
1437
    Protected Function Measure() As Size
1438
        Return MeasureGraphics.MeasureString(Text, Font, Width).ToSize
1439
    End Function
1440
    Protected Function Measure(ByVal text As String) As Size
1441
        Return MeasureGraphics.MeasureString(text, Font, Width).ToSize
1442
    End Function
1443
1444
#End Region
1445
1446
1447
#Region " DrawPixel "
1448
1449
    Private DrawPixelBrush As SolidBrush
1450
1451
    Protected Sub DrawPixel(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer)
1452
        If _Transparent Then
1453
            B.SetPixel(x, y, c1)
1454
        Else
1455
            DrawPixelBrush = New SolidBrush(c1)
1456
            G.FillRectangle(DrawPixelBrush, x, y, 1, 1)
1457
        End If
1458
    End Sub
1459
1460
#End Region
1461
1462
#Region " DrawCorners "
1463
1464
    Private DrawCornersBrush As SolidBrush
1465
1466
    Protected Sub DrawCorners(ByVal c1 As Color, ByVal offset As Integer)
1467
        DrawCorners(c1, 0, 0, Width, Height, offset)
1468
    End Sub
1469
    Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle, ByVal offset As Integer)
1470
        DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height, offset)
1471
    End Sub
1472
    Protected Sub DrawCorners(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal offset As Integer)
1473
        DrawCorners(c1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
1474
    End Sub
1475
1476
    Protected Sub DrawCorners(ByVal c1 As Color)
1477
        DrawCorners(c1, 0, 0, Width, Height)
1478
    End Sub
1479
    Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle)
1480
        DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height)
1481
    End Sub
1482
    Protected Sub DrawCorners(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
1483
        If _NoRounding Then Return
1484
1485
        If _Transparent Then
1486
            B.SetPixel(x, y, c1)
1487
            B.SetPixel(x + (width - 1), y, c1)
1488
            B.SetPixel(x, y + (height - 1), c1)
1489
            B.SetPixel(x + (width - 1), y + (height - 1), c1)
1490
        Else
1491
            DrawCornersBrush = New SolidBrush(c1)
1492
            G.FillRectangle(DrawCornersBrush, x, y, 1, 1)
1493
            G.FillRectangle(DrawCornersBrush, x + (width - 1), y, 1, 1)
1494
            G.FillRectangle(DrawCornersBrush, x, y + (height - 1), 1, 1)
1495
            G.FillRectangle(DrawCornersBrush, x + (width - 1), y + (height - 1), 1, 1)
1496
        End If
1497
    End Sub
1498
1499
#End Region
1500
1501
#Region " DrawBorders "
1502
1503
    Protected Sub DrawBorders(ByVal p1 As Pen, ByVal offset As Integer)
1504
        DrawBorders(p1, 0, 0, Width, Height, offset)
1505
    End Sub
1506
    Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle, ByVal offset As Integer)
1507
        DrawBorders(p1, r.X, r.Y, r.Width, r.Height, offset)
1508
    End Sub
1509
    Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal offset As Integer)
1510
        DrawBorders(p1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
1511
    End Sub
1512
1513
    Protected Sub DrawBorders(ByVal p1 As Pen)
1514
        DrawBorders(p1, 0, 0, Width, Height)
1515
    End Sub
1516
    Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle)
1517
        DrawBorders(p1, r.X, r.Y, r.Width, r.Height)
1518
    End Sub
1519
    Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
1520
        G.DrawRectangle(p1, x, y, width - 1, height - 1)
1521
    End Sub
1522
1523
#End Region
1524
1525
#Region " DrawText "
1526
1527
    Private DrawTextPoint As Point
1528
    Private DrawTextSize As Size
1529
1530
    Protected Sub DrawText(ByVal b1 As Brush, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
1531
        DrawText(b1, Text, a, x, y)
1532
    End Sub
1533
    Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
1534
        If text.Length = 0 Then Return
1535
1536
        DrawTextSize = Measure(text)
1537
        DrawTextPoint = Center(DrawTextSize)
1538
1539
        Select Case a
1540
            Case HorizontalAlignment.Left
1541
                G.DrawString(text, Font, b1, x, DrawTextPoint.Y + y)
1542
            Case HorizontalAlignment.Center
1543
                G.DrawString(text, Font, b1, DrawTextPoint.X + x, DrawTextPoint.Y + y)
1544
            Case HorizontalAlignment.Right
1545
                G.DrawString(text, Font, b1, Width - DrawTextSize.Width - x, DrawTextPoint.Y + y)
1546
        End Select
1547
    End Sub
1548
1549
    Protected Sub DrawText(ByVal b1 As Brush, ByVal p1 As Point)
1550
        If Text.Length = 0 Then Return
1551
        G.DrawString(Text, Font, b1, p1)
1552
    End Sub
1553
    Protected Sub DrawText(ByVal b1 As Brush, ByVal x As Integer, ByVal y As Integer)
1554
        If Text.Length = 0 Then Return
1555
        G.DrawString(Text, Font, b1, x, y)
1556
    End Sub
1557
1558
#End Region
1559
1560
#Region " DrawImage "
1561
1562
    Private DrawImagePoint As Point
1563
1564
    Protected Sub DrawImage(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
1565
        DrawImage(_Image, a, x, y)
1566
    End Sub
1567
    Protected Sub DrawImage(ByVal image As Image, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
1568
        If image Is Nothing Then Return
1569
        DrawImagePoint = Center(image.Size)
1570
1571
        Select Case a
1572
            Case HorizontalAlignment.Left
1573
                G.DrawImage(image, x, DrawImagePoint.Y + y, image.Width, image.Height)
1574
            Case HorizontalAlignment.Center
1575
                G.DrawImage(image, DrawImagePoint.X + x, DrawImagePoint.Y + y, image.Width, image.Height)
1576
            Case HorizontalAlignment.Right
1577
                G.DrawImage(image, Width - image.Width - x, DrawImagePoint.Y + y, image.Width, image.Height)
1578
        End Select
1579
    End Sub
1580
1581
    Protected Sub DrawImage(ByVal p1 As Point)
1582
        DrawImage(_Image, p1.X, p1.Y)
1583
    End Sub
1584
    Protected Sub DrawImage(ByVal x As Integer, ByVal y As Integer)
1585
        DrawImage(_Image, x, y)
1586
    End Sub
1587
1588
    Protected Sub DrawImage(ByVal image As Image, ByVal p1 As Point)
1589
        DrawImage(image, p1.X, p1.Y)
1590
    End Sub
1591
    Protected Sub DrawImage(ByVal image As Image, ByVal x As Integer, ByVal y As Integer)
1592
        If image Is Nothing Then Return
1593
        G.DrawImage(image, x, y, image.Width, image.Height)
1594
    End Sub
1595
1596
#End Region
1597
1598
#Region " DrawGradient "
1599
1600
    Private DrawGradientBrush As LinearGradientBrush
1601
    Private DrawGradientRectangle As Rectangle
1602
1603
    Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
1604
        DrawGradientRectangle = New Rectangle(x, y, width, height)
1605
        DrawGradient(blend, DrawGradientRectangle)
1606
    End Sub
1607
    Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single)
1608
        DrawGradientRectangle = New Rectangle(x, y, width, height)
1609
        DrawGradient(blend, DrawGradientRectangle, angle)
1610
    End Sub
1611
1612
    Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle)
1613
        DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, 90.0F)
1614
        DrawGradientBrush.InterpolationColors = blend
1615
        G.FillRectangle(DrawGradientBrush, r)
1616
    End Sub
1617
    Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal angle As Single)
1618
        DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, angle)
1619
        DrawGradientBrush.InterpolationColors = blend
1620
        G.FillRectangle(DrawGradientBrush, r)
1621
    End Sub
1622
1623
1624
    Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
1625
        DrawGradientRectangle = New Rectangle(x, y, width, height)
1626
        DrawGradient(c1, c2, DrawGradientRectangle)
1627
    End Sub
1628
    Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single)
1629
        DrawGradientRectangle = New Rectangle(x, y, width, height)
1630
        DrawGradient(c1, c2, DrawGradientRectangle, angle)
1631
    End Sub
1632
1633
    Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
1634
        DrawGradientBrush = New LinearGradientBrush(r, c1, c2, 90.0F)
1635
        G.FillRectangle(DrawGradientBrush, r)
1636
    End Sub
1637
    Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
1638
        DrawGradientBrush = New LinearGradientBrush(r, c1, c2, angle)
1639
        G.FillRectangle(DrawGradientBrush, r)
1640
    End Sub
1641
1642
#End Region
1643
1644
#Region " DrawRadial "
1645
1646
    Private DrawRadialPath As GraphicsPath
1647
    Private DrawRadialBrush1 As PathGradientBrush
1648
    Private DrawRadialBrush2 As LinearGradientBrush
1649
    Private DrawRadialRectangle As Rectangle
1650
1651
    Sub DrawRadial(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
1652
        DrawRadialRectangle = New Rectangle(x, y, width, height)
1653
        DrawRadial(blend, DrawRadialRectangle, width \ 2, height \ 2)
1654
    End Sub
1655
    Sub DrawRadial(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal center As Point)
1656
        DrawRadialRectangle = New Rectangle(x, y, width, height)
1657
        DrawRadial(blend, DrawRadialRectangle, center.X, center.Y)
1658
    End Sub
1659
    Sub DrawRadial(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal cx As Integer, ByVal cy As Integer)
1660
        DrawRadialRectangle = New Rectangle(x, y, width, height)
1661
        DrawRadial(blend, DrawRadialRectangle, cx, cy)
1662
    End Sub
1663
1664
    Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle)
1665
        DrawRadial(blend, r, r.Width \ 2, r.Height \ 2)
1666
    End Sub
1667
    Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal center As Point)
1668
        DrawRadial(blend, r, center.X, center.Y)
1669
    End Sub
1670
    Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal cx As Integer, ByVal cy As Integer)
1671
        DrawRadialPath.Reset()
1672
        DrawRadialPath.AddEllipse(r.X, r.Y, r.Width - 1, r.Height - 1)
1673
1674
        DrawRadialBrush1 = New PathGradientBrush(DrawRadialPath)
1675
        DrawRadialBrush1.CenterPoint = New Point(r.X + cx, r.Y + cy)
1676
        DrawRadialBrush1.InterpolationColors = blend
1677
1678
        If G.SmoothingMode = SmoothingMode.AntiAlias Then
1679
            G.FillEllipse(DrawRadialBrush1, r.X + 1, r.Y + 1, r.Width - 3, r.Height - 3)
1680
        Else
1681
            G.FillEllipse(DrawRadialBrush1, r)
1682
        End If
1683
    End Sub
1684
1685
1686
    Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
1687
        DrawRadialRectangle = New Rectangle(x, y, width, height)
1688
        DrawRadial(c1, c2, DrawRadialRectangle)
1689
    End Sub
1690
    Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single)
1691
        DrawRadialRectangle = New Rectangle(x, y, width, height)
1692
        DrawRadial(c1, c2, DrawRadialRectangle, angle)
1693
    End Sub
1694
1695
    Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
1696
        DrawRadialBrush2 = New LinearGradientBrush(r, c1, c2, 90.0F)
1697
        G.FillEllipse(DrawRadialBrush2, r)
1698
    End Sub
1699
    Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
1700
        DrawRadialBrush2 = New LinearGradientBrush(r, c1, c2, angle)
1701
        G.FillEllipse(DrawRadialBrush2, r)
1702
    End Sub
1703
1704
#End Region
1705
1706
End Class
1707
1708
Enum MouseState As Byte
1709
    None = 0
1710
    Over = 1
1711
    Down = 2
1712
    Block = 3
1713
End Enum
1714
1715
Structure Bloom
1716
1717
    Public _Name As String
1718
    ReadOnly Property Name() As String
1719
        Get
1720
            Return _Name
1721
        End Get
1722
    End Property
1723
1724
    Private _Value As Color
1725
    Property Value() As Color
1726
        Get
1727
            Return _Value
1728
        End Get
1729
        Set(ByVal value As Color)
1730
            _Value = value
1731
        End Set
1732
    End Property
1733
1734
    Sub New(ByVal name As String, ByVal value As Color)
1735
        _Name = name
1736
        _Value = value
1737
    End Sub
1738
End Structure
1739
1740
Class Theme
1741
    Inherits ThemeContainer153
1742
    Sub New()
1743
        SetColor("tW", 204, 204, 204)
1744
        SetColor("tLB", 0, 213, 238)
1745
        SetColor("tDB", 0, 102, 176)
1746
    End Sub
1747
    Dim W, LB, DB As Color
1748
    Protected Overrides Sub ColorHook()
1749
        TransparencyKey = Color.Bisque
1750
        Header = 20
1751
        W = GetColor("tW")
1752
        LB = GetColor("tLB")
1753
        DB = GetColor("tDB")
1754
    End Sub
1755
1756
    Protected Overrides Sub PaintHook()
1757
        DrawBorders(Pens.Gray)
1758
        DrawGradient(Color.White, W, 0, 0, Width, Height)
1759
        G.DrawLine(Pens.Black, 11, 0, 11, Height)
1760
        DrawGradient(LB, DB, 0, 0, 11, Height)
1761
        G.DrawLine(Pens.Black, Width - 12, 0, Width - 12, Height)
1762
        DrawGradient(LB, DB, 12, Height - 12, Width - 24, 12)
1763
        G.DrawLine(Pens.Black, 11, Height - 12, Width - 12, Height - 12)
1764
        DrawGradient(LB, DB, Width - 11, 0, 11, Height)
1765
        DrawGradient(LB, DB, 11, 3, Width - 12, 3)
1766
        DrawGradient(LB, DB, 0, 0, Width, 20)
1767
        DrawBorders(Pens.DeepSkyBlue, 0, 0, Width, 21)
1768
        DrawBorders(Pens.Black, 0, 0, Width, 22)
1769
        DrawBorders(Pens.Black)
1770
        DrawText(Brushes.White, HorizontalAlignment.Center, 0, 0)
1771
    End Sub
1772
End Class
1773
1774
Class Button
1775
    Inherits ThemeControl153
1776
    Sub New()
1777
        SetColor("tLB", 0, 213, 238)
1778
        SetColor("tDB", 0, 102, 176)
1779
        SetColor("tLLB", 0, 223, 248)
1780
        SetColor("tLDB", 0, 112, 186)
1781
        SetColor("tDLB", 0, 203, 218)
1782
        SetColor("tDDB", 0, 92, 166)
1783
    End Sub
1784
    Dim LB, DB, LLB, LDB, DLB, DDB As Color
1785
    Protected Overrides Sub ColorHook()
1786
        LB = GetColor("tLB")
1787
        DB = GetColor("tDB")
1788
        LLB = GetColor("tLLB")
1789
        LDB = GetColor("tLDB")
1790
        DLB = GetColor("tDLB")
1791
        DDB = GetColor("tDDB")
1792
    End Sub
1793
1794
    Protected Overrides Sub PaintHook()
1795
        G.Clear(Color.DodgerBlue)
1796
1797
        If State = MouseState.None Then
1798
            DrawGradient(LB, DB, 0, 0, Width, Height, 90S)
1799
        ElseIf State = MouseState.Over Then
1800
            DrawGradient(LLB, LDB, 0, 0, Width, Height, 90S)
1801
        ElseIf State = MouseState.Down Then
1802
            DrawGradient(DLB, DDB, 0, 0, Width, Height, 90S)
1803
        End If
1804
        DrawBorders(Pens.Black, 0)
1805
        DrawBorders(Pens.DeepSkyBlue, 1)
1806
        DrawText(Brushes.White, HorizontalAlignment.Center, 0, 0)
1807
    End Sub
1808
End Class
1809
1810
Class ProgressBar
1811
    Inherits ThemeControl153
1812
    Sub New()
1813
1814
        SetColor("tW", 204, 204, 204)
1815
        SetColor("tLB", 0, 213, 238)
1816
        SetColor("tDB", 0, 102, 176)
1817
    End Sub
1818
1819
    Private _Maximum As Integer
1820
    Public Property Maximum() As Integer
1821
        Get
1822
            Select Case _Maximum
1823
                Case 0
1824
                    Return 100
1825
                Case Else
1826
                    Return _Maximum
1827
            End Select
1828
        End Get
1829
        Set(ByVal v As Integer)
1830
            Select Case v
1831
                Case Is < _Value
1832
                    _Value = v
1833
            End Select
1834
            _Maximum = v
1835
            Invalidate()
1836
        End Set
1837
    End Property
1838
    Private _Value As Integer
1839
    Public Property Value() As Integer
1840
        Get
1841
            Select Case _Value
1842
                Case 0
1843
                    Return 1
1844
                Case Else
1845
                    Return _Value
1846
            End Select
1847
        End Get
1848
        Set(ByVal v As Integer)
1849
            Select Case v
1850
                Case Is > _Maximum
1851
                    v = _Maximum
1852
            End Select
1853
            _Value = v
1854
            Invalidate()
1855
        End Set
1856
    End Property
1857
1858
    Dim LB, DB, W As Color
1859
    Private Progress As Integer
1860
    Dim Blend As New ColorBlend
1861
    Protected Overrides Sub ColorHook()
1862
        LB = GetColor("tLB")
1863
        DB = GetColor("tDB")
1864
        W = GetColor("tW")
1865
    End Sub
1866
1867
    Protected Overrides Sub PaintHook()
1868
        DrawGradient(Color.White, W, ClientRectangle)
1869
        DrawBorders(Pens.Black)
1870
        Dim a As New ColorBlend
1871
        a.Colors = {LB, DB}
1872
        a.Positions = {0.0F, 1.0F}
1873
        G.FillRectangle(Brushes.DimGray, 3, 3, Width - 6, Height - 6)
1874
        DrawGradient(a, 3, 3, CInt(_Value / _Maximum * Width) - 5, Height - 6, 90S)
1875
        DrawBorders(Pens.DeepSkyBlue, 4, 4, CInt(_Value / _Maximum * Width) - 5, Height - 8)
1876
            Dim T As New HatchBrush(HatchStyle.DarkDownwardDiagonal, Color.DeepSkyBlue, Color.Empty)
1877
            G.FillRectangle(T, New Rectangle(5, 5, CInt((_Value / _Maximum) * Width - 8), Height - 10))
1878
        DrawBorders(Pens.Black, 3)
1879
    End Sub
1880
End Class
1881
1882
Class TopButton
1883
    Inherits ThemeControl153
1884
    Sub New()
1885
        SetColor("tLB", 0, 223, 248)
1886
        SetColor("tDB", 0, 112, 186)
1887
        SetColor("tLLB", 0, 233, 255)
1888
        SetColor("tLDB", 0, 122, 196)
1889
        SetColor("tDLB", 0, 203, 218)
1890
        SetColor("tDDB", 0, 92, 166)
1891
        Size = New Size(20, 14)
1892
    End Sub
1893
    Dim LB, DB, LLB, LDB, DLB, DDB As Color
1894
    Protected Overrides Sub ColorHook()
1895
        LB = GetColor("tLB")
1896
        DB = GetColor("tDB")
1897
        LLB = GetColor("tLLB")
1898
        LDB = GetColor("tLDB")
1899
        DLB = GetColor("tDLB")
1900
        DDB = GetColor("tDDB")
1901
    End Sub
1902
1903
    Protected Overrides Sub PaintHook()
1904
        If State = MouseState.None Then
1905
            DrawGradient(LB, DB, ClientRectangle)
1906
        ElseIf State = MouseState.Down Then
1907
            DrawGradient(DLB, DDB, ClientRectangle)
1908
        ElseIf State = MouseState.Over Then
1909
            DrawGradient(LLB, LDB, ClientRectangle)
1910
        End If
1911
        DrawBorders(Pens.Black)
1912
        DrawBorders(Pens.DeepSkyBlue, 1)
1913
        DrawText(Brushes.White, HorizontalAlignment.Center, -1, 0)
1914
    End Sub
1915
End Class
1916
1917
Class CheckBox
1918
    Inherits ThemeControl153
1919
    Private _CheckedState As Boolean
1920
    Public Property CheckedState() As Boolean
1921
        Get
1922
            Return _CheckedState
1923
        End Get
1924
        Set(ByVal v As Boolean)
1925
            _CheckedState = v
1926
            Invalidate()
1927
        End Set
1928
    End Property
1929
1930
    Sub New()
1931
        SetColor("tLB", 0, 223, 248)
1932
        SetColor("tDB", 0, 112, 186)
1933
        SetColor("tW", 204, 204, 204)
1934
        Size = New Size(18, 18)
1935
        MinimumSize = New Size(15, 15)
1936
        MaximumSize = New Size(600, 30)
1937
    End Sub
1938
    Dim LB, DB, W As Color
1939
    Protected Overrides Sub ColorHook()
1940
        LB = GetColor("tLB")
1941
        DB = GetColor("tDB")
1942
        W = GetColor("tW")
1943
    End Sub
1944
1945
    Protected Overrides Sub PaintHook()
1946
        DrawGradient(Color.White, W, ClientRectangle)
1947
        G.FillRectangle(Brushes.DimGray, 3, 3, Width - 6, Height - 6)
1948
        DrawBorders(Pens.Black)
1949
        DrawBorders(Pens.Black, 3)
1950
        Select Case CheckedState
1951
            Case True
1952
                DrawGradient(LB, DB, 4, 4, 10, 10)
1953
            Case False
1954
        End Select
1955
1956
    End Sub
1957
    Sub changeCheck() Handles Me.Click
1958
        Select Case CheckedState
1959
            Case True
1960
                CheckedState = False
1961
            Case False
1962
                CheckedState = True
1963
        End Select
1964
    End Sub
1965
End Class
1966-
1966+
1967-
1967+
Class RadioButton
1968
    Inherits ThemeControl153
1969
    Private _CheckedState As Boolean
1970
    Public Property CheckedState() As Boolean
1971
        Get
1972
            Return _CheckedState
1973
        End Get
1974
        Set(ByVal v As Boolean)
1975
            _CheckedState = v
1976
            Invalidate()
1977
        End Set
1978
    End Property
1979
    Sub New()
1980
        Size = New Size(90, 17)
1981
        MinimumSize = New Size(15, 15)
1982
        MaximumSize = New Size(600, 18)
1983
        SetColor("tLB", 0, 223, 248)
1984
        SetColor("tDB", 0, 112, 186)
1985
        SetColor("dB", 150, 150, 150)
1986
        SetColor("mB", 200, 200, 200)
1987
        SetColor("lB", 255, 255, 255)
1988
    End Sub
1989
    Dim Bl1, Bl2, Bl3, LB, DB As Color
1990
    Dim g1 As Pen
1991
    Dim br1 As SolidBrush
1992
    Protected Overrides Sub ColorHook()
1993
        Bl1 = GetColor("dB")
1994
        Bl2 = GetColor("mB")
1995
        Bl3 = GetColor("lB")
1996
        LB = GetColor("tLB")
1997
        DB = GetColor("tDB")
1998
        br1 = New SolidBrush(GetColor("mB"))
1999
    End Sub
2000
    Protected Overrides Sub PaintHook()
2001
        G.Clear(Color.FromArgb(238, 238, 238))
2002
        Dim gP As New GraphicsPath
2003
        gP.AddEllipse(0, 0, 16, 16)
2004
        Dim gP2 As New GraphicsPath
2005
        gP2.AddEllipse(0, 0, 16, 16)
2006
        Dim a2 As New LinearGradientBrush(New Rectangle(0, 0, Width, Height), Bl3, Bl1, 90S)
2007
        Dim b2 As New Pen(a2)
2008
        G.FillPath(a2, gP)
2009
        G.DrawPath(Pens.Black, gP)
2010
        DrawText(Brushes.DeepSkyBlue, HorizontalAlignment.Left, 18, 0)
2011
        If State = MouseState.Over Then
2012
            G.DrawPath(Pens.DeepSkyBlue, gP2)
2013
        End If
2014
        Select Case CheckedState
2015
            Case True
2016
                Dim mP As Single() = {0.0F, 1.0F}
2017
                Dim mC As Color() = {LB, DB}
2018
                Dim mB As New ColorBlend
2019
                Dim a3 As New LinearGradientBrush(New Rectangle(0, 0, Width, Height), Bl3, Bl1, 90S)
2020
                mB.Colors = mC
2021
                mB.Positions = mP
2022
                a3.InterpolationColors = mB
2023
                G.FillPath(a3, gP)
2024
                Dim gP4 As New GraphicsPath
2025
                gP4.AddEllipse(0, 0, 16, 16)
2026
                G.DrawPath(Pens.Black, gP)
2027
            Case False
2028
        End Select
2029
    End Sub
2030
    Sub changeCheck() Handles Me.Click
2031
        Select Case CheckedState
2032
            Case True
2033
                CheckedState = False
2034
            Case False
2035
                CheckedState = True
2036
        End Select
2037
    End Sub
2038
End Class