View difference between Paste ID: 3LpcaUt7 and 0Eh6kp1B
SHOW: | | - or go back to the newest paste.
1
//Credit to ๖ۣۜMephobia for the original theme
2-
//Credit to Ecco for recoding in C#
2+
3
using System.ComponentModel;
4
using System.Drawing;
5
using System.Drawing.Drawing2D;
6
using System.Windows.Forms;
7
public enum MouseState : byte
8
{
9
    None = 0,
10
    Over = 1,
11
    Down = 2,
12
    Block = 3,
13
}
14
public static class Draw
15
{
16
    public static GraphicsPath RoundRect(Rectangle rect, int Curve)
17
    {
18
        GraphicsPath P = new GraphicsPath();
19
        int ArcRectWidth = Curve * 2;
20
        P.AddArc(new Rectangle(rect.X, rect.Y, ArcRectWidth, ArcRectWidth), -180, 90);
21
        P.AddArc(new Rectangle(rect.Width - ArcRectWidth + rect.X, rect.Y, ArcRectWidth, ArcRectWidth), -90, 90);
22
        P.AddArc(new Rectangle(rect.Width - ArcRectWidth + rect.X, rect.Height - ArcRectWidth + rect.Y, ArcRectWidth, ArcRectWidth), 0, 90);
23
        P.AddArc(new Rectangle(rect.X, rect.Height - ArcRectWidth + rect.Y, ArcRectWidth, ArcRectWidth), 90, 90);
24
        P.AddLine(new Point(rect.X, rect.Height - ArcRectWidth + rect.Y), new Point(rect.X, Curve + rect.Y));
25
        return P;
26
    }
27
    public static GraphicsPath RoundRect(int X, int Y, int Width, int Height, int Curve)
28
    {
29
        return RoundRect(new Rectangle(X, Y, Width, Height), Curve);
30
    }
31
}
32
public class PerplexTheme : ContainerControl
33
{
34
    public PerplexTheme()
35
    {
36
        SetStyle(ControlStyles.SupportsTransparentBackColor, true);
37
        SetStyle(ControlStyles.UserPaint, true);
38
        BackColor = Color.FromArgb(25, 25, 25);
39
        DoubleBuffered = true;
40
    }
41
    protected override void OnPaint(PaintEventArgs e)
42
    {
43
        Bitmap B = new Bitmap(Width, Height);
44
        Graphics G = Graphics.FromImage(B);
45
        Rectangle TopLeft = new Rectangle(0, 0, Width - 125, 28);
46
        Rectangle TopRight = new Rectangle(Width - 82, 0, 81, 28);
47
        Rectangle Body = new Rectangle(10, 10, Width - 21, Height - 16);
48
        Rectangle Body2 = new Rectangle(5, 5, Width - 11, Height - 6);
49
        base.OnPaint(e);
50
        LinearGradientBrush BodyBrush = new LinearGradientBrush(Body2, Color.FromArgb(25, 25, 25), Color.FromArgb(30, 35, 48), 90);
51
        LinearGradientBrush BodyBrush2 = new LinearGradientBrush(Body, Color.FromArgb(46, 46, 46), Color.FromArgb(50, 55, 58), 120);
52
        LinearGradientBrush gloss = new LinearGradientBrush(new Rectangle(0, 0, Width - 128, 28 / 2), Color.FromArgb(240, Color.FromArgb(26, 26, 26)), Color.FromArgb(5, 255, 255, 255), 90);
53
        LinearGradientBrush gloss2 = new LinearGradientBrush(new Rectangle(Width - 82, 0,Width - 205, 28 / 2), Color.FromArgb(240, Color.FromArgb(26, 26, 26)), Color.FromArgb(5, 255, 255, 255), 90);
54
        LinearGradientBrush mainbrush = new LinearGradientBrush(TopLeft, Color.FromArgb(26, 26, 26), Color.FromArgb(30, 30, 30), 90);
55
        LinearGradientBrush mainbrush2 = new LinearGradientBrush(TopRight, Color.FromArgb(26, 26, 26), Color.FromArgb(30, 30, 30), 90);
56
        Pen P1 = new Pen(Color.FromArgb(174, 195, 30), 2);
57
        Font drawFont = new Font("Tahoma", 10, FontStyle.Bold);
58
            
59
        G.Clear(Color.Fuchsia);
60
        G.FillPath(BodyBrush, Draw.RoundRect(Body2, 3));
61
        G.DrawPath(Pens.Black, Draw.RoundRect(Body2, 3));
62
            
63
        G.FillPath(BodyBrush2, Draw.RoundRect(Body, 3));
64
        G.DrawPath(Pens.Black, Draw.RoundRect(Body, 3));
65
66
        G.FillPath(mainbrush, Draw.RoundRect(TopLeft, 3));
67
        G.FillPath(gloss, Draw.RoundRect(TopLeft, 3));
68
        G.DrawPath(Pens.Black, Draw.RoundRect(TopLeft, 3));
69
70
        G.FillPath(mainbrush, Draw.RoundRect(TopRight, 3));
71
        G.FillPath(gloss2, Draw.RoundRect(TopRight, 3));
72
        G.DrawPath(Pens.Black, Draw.RoundRect(TopRight, 3));
73
74
        G.DrawLine(P1, 14, 9, 14, 22);
75
        G.DrawLine(P1, 17, 6, 17, 25);
76
        G.DrawLine(P1, 20, 9, 20, 22);
77
        G.DrawLine(P1, 11, 12, 11, 19);
78
        G.DrawLine(P1, 23, 12, 23, 19);
79
        G.DrawLine(P1, 8, 14, 8, 17);
80
        G.DrawLine(P1, 26, 14, 26, 17);
81
        G.DrawString(Text, drawFont, new SolidBrush(Color.WhiteSmoke), new Rectangle(32, 1, Width - 1, 27), new StringFormat() { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center });
82
        e.Graphics.DrawImage((Image)B.Clone(), 0, 0);
83
        G.Dispose();
84
        B.Dispose();
85
    }
86
    private Point MouseP = new Point(0, 0);
87
    private bool cap = false;
88
    private int moveheight = 29;
89
    protected override void OnMouseDown(MouseEventArgs e)
90
    {
91
        base.OnMouseDown(e);
92
        if (e.Button == MouseButtons.Left && new Rectangle(0, 0, Width, moveheight).Contains(e.Location))
93
        {
94
            cap = true;
95
            MouseP = e.Location;
96
        }
97
    }
98
    protected override void OnMouseUp(MouseEventArgs e)
99
    {
100
        base.OnMouseUp(e);
101
        cap = false;
102
    }
103
    protected override void OnMouseMove(MouseEventArgs e)
104
    {
105
        base.OnMouseMove(e);
106
        if (cap)
107
        {
108
            Point p = new Point();
109
            p.X = MousePosition.X - MouseP.X;
110
            p.Y = MousePosition.Y - MouseP.Y;
111
            Parent.Location = p;
112
        }
113
    }
114
    protected override void OnCreateControl()
115
    {
116
        base.OnCreateControl();
117
        ParentForm.FormBorderStyle = FormBorderStyle.None;
118
        ParentForm.TransparencyKey = Color.Fuchsia;
119
        Dock = DockStyle.Fill;
120
    }
121
}
122
public class PerplexButton : Control
123
{
124
    MouseState State = MouseState.None;
125
    protected override void OnMouseDown(MouseEventArgs e)
126
    {
127
        base.OnMouseDown(e);
128
        State = MouseState.Down;
129
        Invalidate();
130
    }
131
    protected override void OnMouseUp(MouseEventArgs e)
132
    {
133
        base.OnMouseUp(e);
134
        State = MouseState.Over;
135
        Invalidate();
136
    }
137
    protected override void OnMouseEnter(EventArgs e)
138
    {
139
        base.OnMouseEnter(e);
140
        State = MouseState.Over;
141
        Invalidate();
142
    }
143
    protected override void OnMouseLeave(EventArgs e)
144
    {
145
        base.OnMouseLeave(e);
146
        State = MouseState.None;
147
        Invalidate();
148
    }
149
    public PerplexButton()
150
    {
151
        SetStyle(ControlStyles.SupportsTransparentBackColor, true);
152
        SetStyle(ControlStyles.UserPaint, true);
153
        BackColor = Color.Transparent;
154
        ForeColor = Color.FromArgb(205, 205, 205);
155
        DoubleBuffered = true;
156
    }
157
158
    protected override void OnPaint(PaintEventArgs e)
159
    {
160
        Bitmap B = new Bitmap(Width, Height);
161
        Graphics G = Graphics.FromImage(B);
162
        Rectangle ClientRectangle = new Rectangle(0, 0, Width - 1, Height - 1);
163
        base.OnPaint(e);
164
        G.Clear(BackColor);
165
        Font drawFont = new Font("Tahoma", 8, FontStyle.Bold);
166
        G.SmoothingMode = SmoothingMode.HighQuality;
167
        Rectangle R1 = new Rectangle(0, 0, Width - 125, 35 / 2);
168
        Rectangle R2 = new Rectangle(5, Height - 10, Width - 11, 5);
169
        Rectangle R3 = new Rectangle(6, Height - 9, Width - 13, 3);
170
        Rectangle R4 = new Rectangle(1, 1, Width - 3, Height - 3);
171
        Rectangle R5 = new Rectangle(1, 0, Width - 1, Height - 1);
172
        Rectangle R6 = new Rectangle(0, -1, Width - 1, Height - 1);
173
        LinearGradientBrush lgb = new LinearGradientBrush(ClientRectangle, Color.FromArgb(66, 67, 70), Color.FromArgb(43, 44, 48), 90);
174
        LinearGradientBrush botbar = new LinearGradientBrush(R2, Color.FromArgb(44, 45, 49), Color.FromArgb(45, 46, 50), 90);
175
        LinearGradientBrush fill = new LinearGradientBrush(R3, Color.FromArgb(174, 195, 30), Color.FromArgb(141, 153, 16), 90);
176
        LinearGradientBrush gloss = null;
177
        Pen o = new Pen(Color.FromArgb(50, 50, 50), 1);
178
        StringFormat format = new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center };
179
        if (State == MouseState.Over)
180
            gloss = new LinearGradientBrush(R1, Color.FromArgb(15, Color.FromArgb(26, 26, 26)), Color.FromArgb(1, 255, 255, 255), 90);
181
        else if (State == MouseState.Down)
182
            gloss = new LinearGradientBrush(R1, Color.FromArgb(100, Color.FromArgb(26, 26, 26)), Color.FromArgb(1, 255, 255, 255), 90);
183
        else
184
            gloss = new LinearGradientBrush(R1, Color.FromArgb(75, Color.FromArgb(26, 26, 26)), Color.FromArgb(3, 255, 255, 255), 90);
185
186
        G.FillPath(lgb, Draw.RoundRect(ClientRectangle, 2));
187
        G.FillPath(gloss, Draw.RoundRect(ClientRectangle, 2));
188
        G.FillPath(botbar, Draw.RoundRect(R2, 1));
189
        G.FillPath(fill, Draw.RoundRect(R3, 1));
190
        G.DrawPath(o, Draw.RoundRect(ClientRectangle, 2));
191
        G.DrawPath(Pens.Black, Draw.RoundRect(R4, 2));
192
        G.DrawString(Text, drawFont, new SolidBrush(Color.FromArgb(5, 5, 5)), R5, format);
193
        G.DrawString(Text, drawFont, new SolidBrush(Color.FromArgb(205, 205, 205)), R6, format);
194
195
        e.Graphics.DrawImage((Image)B.Clone(), 0, 0);
196
        G.Dispose();
197
        B.Dispose();
198
    }
199
}
200
public class PerplexControlBox : Control
201
{
202
    MouseState State = MouseState.None;
203
    Rectangle MinBtn = new Rectangle(0, 0, 20, 20);
204
    Rectangle MaxBtn = new Rectangle(25, 0, 20, 20);
205
    int x = 0;
206
207
    protected override void OnMouseDown(MouseEventArgs e)
208
    {
209
        base.OnMouseDown(e);
210
        if (e.Location.X > 0 && e.Location.X < 20)
211
            FindForm().WindowState = FormWindowState.Minimized;
212
        else if (e.Location.X > 25 && e.Location.X < 45)
213
            FindForm().Close();
214
        State = MouseState.Down;
215
        Invalidate();
216
    }
217
    protected override void OnMouseUp(MouseEventArgs e)
218
    {
219
        base.OnMouseUp(e);
220
        State = MouseState.Over;
221
        Invalidate();
222
    }
223
    protected override void OnMouseEnter(EventArgs e)
224
    {
225
        base.OnMouseEnter(e);
226
        State = MouseState.Over;
227
        Invalidate();
228
    }
229
    protected override void OnMouseLeave(EventArgs e)
230
    {
231
        base.OnMouseLeave(e);
232
        State = MouseState.None;
233
        Invalidate();
234
    }
235
    public PerplexControlBox()
236
    {
237
        SetStyle(ControlStyles.SupportsTransparentBackColor, true);
238
        SetStyle(ControlStyles.UserPaint, true);
239
        BackColor = Color.Transparent;
240
        ForeColor = Color.FromArgb(205, 205, 205);
241
        DoubleBuffered = true;
242
    }
243
    protected override void OnPaint(PaintEventArgs e)
244
    {
245
        Bitmap B = new Bitmap(Width, Height);
246
        Graphics G = Graphics.FromImage(B);
247
        base.OnPaint(e);
248
        G.Clear(BackColor);
249
        G.SmoothingMode = SmoothingMode.HighQuality;
250
251
        LinearGradientBrush mlgb = null;
252
        Font mf = new Font("Marlett", 9);
253
        SolidBrush mfb = new SolidBrush(Color.FromArgb(174, 195, 30));
254
        Pen P1 = new Pen(Color.FromArgb(21, 21, 21), 1);
255
        Color C1 = Color.FromArgb(66, 67, 70);
256
        Color C2 = Color.FromArgb(43, 44, 48);
257
        GraphicsPath GP1 = Draw.RoundRect(MinBtn, 4);
258
        GraphicsPath GP2 = Draw.RoundRect(MaxBtn, 4);
259
        switch (State)
260
        {
261
            case MouseState.None:
262
                mlgb = new LinearGradientBrush(MinBtn, C1, C2, 90);
263
                G.FillPath(mlgb, GP1);
264
                G.DrawPath(P1, GP1);
265
                G.DrawString("0", mf, mfb, 4, 4);
266
267
                G.FillPath(mlgb, GP2);
268
                G.DrawPath(P1, GP2);
269
                G.DrawString("r", mf, mfb, 28, 4);
270
                break;
271
            case MouseState.Over:
272
                if (x > 0 && x < 20)
273
                {
274
                    mlgb = new LinearGradientBrush(MinBtn, Color.FromArgb(100, C1), Color.FromArgb(100, C2), 90);
275
                    G.FillPath(mlgb, GP1);
276
                    G.DrawPath(P1, GP1);
277
                    G.DrawString("0", mf, mfb, 4, 4);
278
279
                    mlgb = new LinearGradientBrush(MaxBtn, C1, C2, 90);
280
                    G.FillPath(mlgb, Draw.RoundRect(MaxBtn, 4));
281
                    G.DrawPath(P1, GP2);
282
                    G.DrawString("r", mf, mfb, 4, 4);
283
                }
284
                else if (x > 25 && x < 45)
285
                {
286
                    mlgb = new LinearGradientBrush(MinBtn, C1, C2, 90);
287
                    G.FillPath(mlgb, GP1);
288
                    G.DrawPath(P1, GP1);
289
                    G.DrawString("0", mf, mfb, 4, 4);
290
                    mlgb = new LinearGradientBrush(MaxBtn, Color.FromArgb(100, C1), Color.FromArgb(100, C2), 90);
291
                    G.FillPath(mlgb, GP2);
292
                    G.DrawPath(P1, GP2);
293
                    G.DrawString("r", mf, mfb, 28, 4);
294
                }
295
                else
296
                {
297
                    mlgb = new LinearGradientBrush(MinBtn, C1, C2, 90);
298
                    G.FillPath(mlgb, GP1);
299
                    G.DrawPath(P1, GP1);
300
                    G.DrawString("0", mf, mfb, 4, 4);
301
302
                    LinearGradientBrush lgb = new LinearGradientBrush(MaxBtn, C1, C2, 90);
303
                    G.FillPath(lgb, GP2);
304
                    G.DrawPath(P1, GP2);
305
                    G.DrawString("r", mf, mfb, 28, 4);
306
                }
307
                break;
308
            case MouseState.Down:
309
                mlgb = new LinearGradientBrush(MinBtn, C1, C2, 90);
310
                G.FillPath(mlgb, GP1);
311
                G.DrawPath(P1, GP1);
312
                G.DrawString("0", mf, mfb, 4, 4);
313
314
                mlgb = new LinearGradientBrush(MaxBtn, C1, C2, 90);
315
                G.FillPath(mlgb, GP2);
316
                G.DrawPath(P1, GP2);
317
                G.DrawString("r", mf, mfb, 28, 4);
318
                break;
319
            default:
320
                mlgb = new LinearGradientBrush(MinBtn, C1, C2, 90);
321
                G.FillPath(mlgb, GP1);
322
                G.DrawPath(P1, GP1);
323
                G.DrawString("0", mf, mfb, 4, 4);
324
325
                mlgb = new LinearGradientBrush(MaxBtn, C1, C2, 90);
326
                G.FillPath(mlgb, GP2);
327
                G.DrawPath(P1, GP2);
328
                G.DrawString("r", mf, mfb, 28, 4);
329
                break;
330
        }
331
        e.Graphics.DrawImage((Image)B.Clone(), 0, 0);
332
        G.Dispose();
333
        B.Dispose();
334
    }
335
}
336
public class PerplexGroupBox : ContainerControl
337
{
338
    public PerplexGroupBox()
339
    {
340
        SetStyle(ControlStyles.SupportsTransparentBackColor, true);
341
        BackColor = Color.Transparent;
342
        DoubleBuffered = true;
343
    }
344
    protected override void OnPaint(PaintEventArgs e)
345
    {
346
        Bitmap B = new Bitmap(Width, Height);
347
        Graphics G = Graphics.FromImage(B);
348
        Rectangle Body = new Rectangle(4, 25, Width - 9, Height - 30);
349
        Rectangle Body2 = new Rectangle(0, 0, Width - 1, Height - 1);
350
        base.OnPaint(e);
351
        G.Clear(Color.Transparent);
352
        G.SmoothingMode = SmoothingMode.HighQuality;
353
        G.CompositingQuality = CompositingQuality.HighQuality;
354
355
        Pen P1 = new Pen(Color.Black);
356
        LinearGradientBrush BodyBrush = new LinearGradientBrush(Body2, Color.FromArgb(26, 26, 26), Color.FromArgb(30, 30, 30), 90);
357
        LinearGradientBrush BodyBrush2 = new LinearGradientBrush(Body, Color.FromArgb(46, 46, 46), Color.FromArgb(50, 55, 58), 120);
358
        Font drawFont = new Font("Tahoma", 9, FontStyle.Bold);
359
        G.FillPath(BodyBrush, Draw.RoundRect(Body2, 3));
360
        G.DrawPath(P1, Draw.RoundRect(Body2, 3));
361
362
        G.FillPath(BodyBrush2, Draw.RoundRect(Body, 3));
363
        G.DrawPath(P1, Draw.RoundRect(Body, 3));
364
365
        G.DrawString(Text, drawFont, new SolidBrush(Color.WhiteSmoke), 67, 14, new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center });
366
        e.Graphics.DrawImage((Image)B.Clone(), 0, 0);
367
        G.Dispose();
368
        B.Dispose();
369
    }
370
}
371
public class PerplexProgressBar : Control
372
{
373
    private int _Maximum = 100;
374
375
    public int Maximum {
376
        get { return _Maximum; }
377
        set {
378
            _Maximum = value;
379
            Invalidate();
380
        }
381
    }
382
    private int _Value = 0;
383
    public int Value
384
    {
385
        get
386
        {
387
            if (_Value == 0)
388
                return 0;
389
            else return _Value;
390
        }
391
        set
392
        {
393
            _Value = value;
394
            if (_Value > _Maximum)
395
                _Value = _Maximum;
396
            Invalidate();
397
        }
398
    }
399
    private bool _ShowPercentage = false;
400
    public bool ShowPercentage {
401
        get { return _ShowPercentage; }
402
        set {
403
            _ShowPercentage = value;
404
            Invalidate();
405
        }
406
    }
407
408
    public PerplexProgressBar() : base()
409
    {
410
        DoubleBuffered = true;
411
        SetStyle(ControlStyles.SupportsTransparentBackColor, true);
412
        SetStyle(ControlStyles.UserPaint, true);
413
        BackColor = Color.Transparent;
414
    }
415
416
    protected override void OnPaint(PaintEventArgs e)
417
    {
418
        Bitmap B = new Bitmap(Width, Height);
419
        Graphics G = Graphics.FromImage(B);
420
421
        G.SmoothingMode = SmoothingMode.HighQuality;
422
423
        double val = (double)_Value / _Maximum;
424
        int intValue = Convert.ToInt32(val * Width);
425
        G.Clear(BackColor);
426
        Color C1 = Color.FromArgb(174, 195, 30);
427
        Color C2 = Color.FromArgb(141, 153, 16); 
428
        Rectangle R1 = new Rectangle(0, 0, Width - 1, Height - 1);
429
        Rectangle R2 = new Rectangle(0, 0, intValue - 1, Height - 1);
430
        Rectangle R3 = new Rectangle(0, 0, intValue - 1, Height - 2);
431
        GraphicsPath GP1 = Draw.RoundRect(R1, 1);
432
        GraphicsPath GP2 = Draw.RoundRect(R2, 2);
433
        GraphicsPath GP3 = Draw.RoundRect(R3, 1);
434
        LinearGradientBrush gB = new LinearGradientBrush(R1, Color.FromArgb(26, 26, 26), Color.FromArgb(30, 30, 30), 90);
435
        LinearGradientBrush g1 = new LinearGradientBrush(new Rectangle(2, 2, intValue - 1, Height - 2), C1, C2, 90);
436
        HatchBrush h1 = new HatchBrush(HatchStyle.DarkUpwardDiagonal, Color.FromArgb(50, C1), Color.FromArgb(25, C2));
437
        Pen P1 = new Pen(Color.Black);
438
439
        G.FillPath(gB, GP1);
440
        G.FillPath(g1, GP3);
441
        G.FillPath(h1, GP3);
442
        G.DrawPath(P1, GP1);
443
        G.DrawPath(new Pen(Color.FromArgb(150, 97, 94, 90)), GP2);
444
        G.DrawPath(P1, GP2);
445
446
        if (_ShowPercentage) 
447
            G.DrawString(Convert.ToString(string.Concat(Value, "%")), Font, Brushes.White, R1, new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center });
448
449
        e.Graphics.DrawImage((Image)B.Clone(), 0, 0);
450
        G.Dispose();
451
        B.Dispose();
452
    }
453
}
454
[DefaultEvent("CheckedChanged")]
455
public class PerplexCheckBox : Control
456
{
457
    MouseState State = MouseState.None;
458
    protected override void OnMouseDown(MouseEventArgs e)
459
    {
460
        base.OnMouseDown(e);
461
        State = MouseState.Down;
462
        Invalidate();
463
    }
464
    protected override void OnMouseUp(MouseEventArgs e)
465
    {
466
        base.OnMouseUp(e);
467
        State = MouseState.Over;
468
        Invalidate();
469
    }
470
    protected override void OnMouseEnter(EventArgs e)
471
    {
472
        base.OnMouseEnter(e);
473
        State = MouseState.Over;
474
        Invalidate();
475
    }
476
    protected override void OnMouseLeave(EventArgs e)
477
    {
478
        base.OnMouseLeave(e);
479
        State = MouseState.None;
480
        Invalidate();
481
    }
482
    protected override void OnSizeChanged(EventArgs e)
483
    {
484
        base.OnSizeChanged(e);
485
        Height = 16;
486
    }
487
    protected override void OnTextChanged(EventArgs e)
488
    {
489
        base.OnTextChanged(e);
490
        Invalidate();
491
    }
492
    protected override void OnClick(EventArgs e)
493
    {
494
        _Checked = !_Checked;
495
        if (CheckedChanged != null)
496
            CheckedChanged(this, EventArgs.Empty);
497
        base.OnClick(e);
498
    }
499
    private bool _Checked = false;
500
    public bool Checked
501
    {
502
        get { return _Checked; }
503
        set
504
        {
505
            _Checked = value;
506
            if (CheckedChanged != null)
507
                CheckedChanged(this, EventArgs.Empty);
508
            Invalidate();
509
        }
510
    }
511
    public PerplexCheckBox()
512
    {
513
        SetStyle(ControlStyles.SupportsTransparentBackColor, true);
514
        SetStyle(ControlStyles.UserPaint, true);
515
        BackColor = Color.Transparent;
516
        ForeColor = Color.Black;
517
        Size = new Size(145, 16);
518
        DoubleBuffered = true;
519
    }
520
    protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
521
    {
522
        Bitmap B = new Bitmap(Width, Height);
523
        Graphics G = Graphics.FromImage(B);
524
        G.SmoothingMode = SmoothingMode.HighQuality;
525
        G.CompositingQuality = CompositingQuality.HighQuality;
526
        Rectangle checkBoxRectangle = new Rectangle(0, 0, Height - 1, Height - 1);
527
        LinearGradientBrush bodyGrad = new LinearGradientBrush(checkBoxRectangle, Color.FromArgb(174, 195, 30), Color.FromArgb(141, 153, 16), 90);
528
        SolidBrush nb = new SolidBrush(Color.FromArgb(205, 205, 205));
529
        StringFormat format = new StringFormat() { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center };
530
        Font drawFont = new Font("Tahoma", 9, FontStyle.Bold);
531
        G.Clear(BackColor);
532
        G.FillRectangle(bodyGrad, bodyGrad.Rectangle);
533
        G.DrawRectangle(new Pen(Color.Black), checkBoxRectangle);
534
        G.DrawString(Text, drawFont, Brushes.Black, new Point(17, 9), format);
535
        G.DrawString(Text, drawFont, nb, new Point(16, 8), format);
536
537
        if (_Checked)
538
        {
539
            Rectangle chkPoly = new Rectangle(checkBoxRectangle.X + checkBoxRectangle.Width / 4, checkBoxRectangle.Y + checkBoxRectangle.Height / 4, checkBoxRectangle.Width / 2, checkBoxRectangle.Height / 2);
540
            Point[] p = new Point[] {new Point(chkPoly.X, chkPoly.Y + chkPoly.Height /2), 
541
                        new Point(chkPoly.X + chkPoly.Width / 2, chkPoly.Y + chkPoly.Height), 
542
                        new Point(chkPoly.X + chkPoly.Width, chkPoly.Y)};
543
            Pen P1 = new Pen(Color.FromArgb(12, 12, 12), 2);
544
            for (int i = 0; i <= p.Length - 2; i++)
545
                G.DrawLine(P1, p[i], p[i + 1]);
546
        }
547
        e.Graphics.DrawImage((Image)B.Clone(), 0, 0);
548
        G.Dispose();
549
        B.Dispose();
550
    }
551
552
    public event EventHandler CheckedChanged;
553
}
554
[DefaultEvent("CheckedChanged")]
555
public class PerplexRadioButton : Control
556
{
557
    MouseState State = MouseState.None;
558
    protected override void OnMouseDown(MouseEventArgs e)
559
    {
560
        base.OnMouseDown(e);
561
        State = MouseState.Down;
562
        Invalidate();
563
    }
564
    protected override void OnMouseUp(MouseEventArgs e)
565
    {
566
        base.OnMouseUp(e);
567
        State = MouseState.Over;
568
        Invalidate();
569
    }
570
    protected override void OnMouseEnter(EventArgs e)
571
    {
572
        base.OnMouseEnter(e);
573
        State = MouseState.Over;
574
        Invalidate();
575
    }
576
    protected override void OnMouseLeave(EventArgs e)
577
    {
578
        base.OnMouseLeave(e);
579
        State = MouseState.None;
580
        Invalidate();
581
    }
582
    protected override void OnSizeChanged(EventArgs e)
583
    {
584
        base.OnSizeChanged(e);
585
        Height = 16;
586
    }
587
    protected override void OnTextChanged(EventArgs e)
588
    {
589
        base.OnTextChanged(e);
590
        Invalidate();
591
    }
592
    protected override void OnClick(EventArgs e)
593
    {
594
        Checked = !Checked;
595
        base.OnClick(e);
596
    }
597
    private bool _Checked = false;
598
    public bool Checked
599
    {
600
        get { return _Checked; }
601
        set
602
        {
603
            _Checked = value;
604
            InvalidateControls();
605
            if (CheckedChanged != null)
606
                CheckedChanged(this, EventArgs.Empty);
607
            Invalidate();
608
        }
609
    }
610
    protected override void OnCreateControl()
611
    {
612
        base.OnCreateControl();
613
        InvalidateControls();
614
    }
615
    private void InvalidateControls()
616
    {
617
        if (!IsHandleCreated || !_Checked) return;
618
        foreach (Control C in Parent.Controls)
619
            if (C is PerplexRadioButton && C != this)
620
                ((PerplexRadioButton)C).Checked = false;
621
    }
622
    public PerplexRadioButton()
623
    {
624
        SetStyle(ControlStyles.SupportsTransparentBackColor, true);
625
        SetStyle(ControlStyles.UserPaint, true);
626
        BackColor = Color.Transparent;
627
        ForeColor = Color.Black;
628
        Size = new Size(150, 16);
629
        DoubleBuffered = true;
630
    }
631
    protected override void OnPaint(PaintEventArgs e)
632
    {
633
        Bitmap B = new Bitmap(Width, Height);
634
        Graphics G = Graphics.FromImage(B);
635
        G.Clear(BackColor);
636
        Rectangle radioBtnRectangle = new Rectangle(0, 0, Height - 1, Height - 1);
637
        Rectangle R1 = new Rectangle(4, 4, Height - 9, Height - 9);
638
        StringFormat format = new StringFormat() { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Near };
639
        LinearGradientBrush bgGrad = new LinearGradientBrush(radioBtnRectangle, Color.FromArgb(174, 195, 30), Color.FromArgb(141, 153, 16), 90);
640
        Color C1 = Color.FromArgb(250, 15, 15, 15);
641
        SolidBrush nb = new SolidBrush(Color.FromArgb(205, 205, 205));
642
        G.SmoothingMode = SmoothingMode.HighQuality;
643
        G.CompositingQuality = CompositingQuality.HighQuality;
644
        Font drawFont = new Font("Tahoma", 10, FontStyle.Bold);
645
646
        G.FillEllipse(bgGrad, radioBtnRectangle);
647
        G.DrawEllipse(new Pen(Color.Black), radioBtnRectangle);
648
649
        if (Checked)
650
        {
651
            LinearGradientBrush chkGrad = new LinearGradientBrush(R1, C1, C1, 90);
652
            G.FillEllipse(chkGrad, R1);
653
        }
654
655
        G.DrawString(Text, drawFont, Brushes.Black, new Point(17, 2), format);
656
        G.DrawString(Text, drawFont, nb, new Point(16, 1), format);
657
658
        e.Graphics.DrawImage((Image)B.Clone(), 0, 0);
659
        G.Dispose();
660
        B.Dispose();
661
    }
662
    public event EventHandler CheckedChanged;
663
}
664
public class PerplexLabel : Control
665
{
666
    public PerplexLabel()
667
    {
668
        SetStyle(ControlStyles.SupportsTransparentBackColor, true);
669
        SetStyle(ControlStyles.UserPaint, true);
670
        BackColor = Color.Transparent;
671
        ForeColor = Color.FromArgb(205, 205, 205);
672
        DoubleBuffered = true;
673
    }
674
    protected override void OnPaint(PaintEventArgs e)
675
    {
676
        Bitmap B = new Bitmap(Width, Height);
677
        Graphics G = Graphics.FromImage(B);
678
        Rectangle ClientRectangle = new Rectangle(0, 0, Width - 1, Height - 1);
679
        base.OnPaint(e);
680
        G.Clear(BackColor);
681
        Font drawFont = new Font("Tahoma", 9, FontStyle.Bold);
682
        StringFormat format = new StringFormat() { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center};
683
        G.CompositingQuality = CompositingQuality.HighQuality;
684
        G.SmoothingMode = SmoothingMode.HighQuality;
685
        G.DrawString(Text, drawFont, new SolidBrush(Color.FromArgb(5, 5, 5)), new Rectangle(1, 0, Width - 1, Height - 1), format);
686
        G.DrawString(Text, drawFont, new SolidBrush(Color.FromArgb(205, 205, 205)), new Rectangle(0, -1, Width - 1, Height - 1), format);
687
        e.Graphics.DrawImage((Image)B.Clone(), 0, 0);
688
        G.Dispose();
689
        B.Dispose();
690
    }
691
}