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