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