forked from zeroitdev/Zeroit.Framework.Button
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Helpers.cs
3964 lines (3346 loc) · 119 KB
/
Helpers.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ***********************************************************************
// Assembly : Zeroit.Framework.Button
// Author : ZEROIT
// Created : 11-22-2018
//
// Last Modified By : ZEROIT
// Last Modified On : 12-15-2018
// ***********************************************************************
// <copyright file="Helpers.cs" company="Zeroit Dev Technologies">
// This program is for creating a Button controls.
// Copyright © 2017 Zeroit Dev Technologies
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//
// You can contact me at [email protected] or [email protected]
// </copyright>
// <summary></summary>
// ***********************************************************************
#region Imports
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
using System.Runtime.InteropServices;
//using System.Windows.Forms.VisualStyles;
using System.Windows.Forms;
#endregion
namespace Zeroit.Framework.Button
{
#region RoundRect
// [CREDIT][DO NOT REMOVE]
//
// This module was written by Aeonhack
//
// [CREDIT][DO NOT REMOVE]
static class RoundRectangle
{
public static GraphicsPath RoundRect(Rectangle Rectangle, int Curve)
{
GraphicsPath GP = new GraphicsPath();
int EndArcWidth = Curve * 2;
GP.AddArc(new Rectangle(Rectangle.X, Rectangle.Y, EndArcWidth, EndArcWidth), -180, 90);
GP.AddArc(new Rectangle(Rectangle.Width - EndArcWidth + Rectangle.X, Rectangle.Y, EndArcWidth, EndArcWidth), -90, 90);
GP.AddArc(new Rectangle(Rectangle.Width - EndArcWidth + Rectangle.X, Rectangle.Height - EndArcWidth + Rectangle.Y, EndArcWidth, EndArcWidth), 0, 90);
GP.AddArc(new Rectangle(Rectangle.X, Rectangle.Height - EndArcWidth + Rectangle.Y, EndArcWidth, EndArcWidth), 90, 90);
GP.AddLine(new Point(Rectangle.X, Rectangle.Height - EndArcWidth + Rectangle.Y), new Point(Rectangle.X, Curve + Rectangle.Y));
return GP;
}
public static GraphicsPath RoundRect(int X, int Y, int Width, int Height, int Curve)
{
Rectangle Rectangle = new Rectangle(X, Y, Width, Height);
GraphicsPath GP = new GraphicsPath();
int EndArcWidth = Curve * 2;
GP.AddArc(new Rectangle(Rectangle.X, Rectangle.Y, EndArcWidth, EndArcWidth), -180, 90);
GP.AddArc(new Rectangle(Rectangle.Width - EndArcWidth + Rectangle.X, Rectangle.Y, EndArcWidth, EndArcWidth), -90, 90);
GP.AddArc(new Rectangle(Rectangle.Width - EndArcWidth + Rectangle.X, Rectangle.Height - EndArcWidth + Rectangle.Y, EndArcWidth, EndArcWidth), 0, 90);
GP.AddArc(new Rectangle(Rectangle.X, Rectangle.Height - EndArcWidth + Rectangle.Y, EndArcWidth, EndArcWidth), 90, 90);
GP.AddLine(new Point(Rectangle.X, Rectangle.Height - EndArcWidth + Rectangle.Y), new Point(Rectangle.X, Curve + Rectangle.Y));
return GP;
}
}
#endregion
#region Control Renderer
#region Color Table
public abstract class xColorTable
{
public abstract Color TextColor { get; }
public abstract Color Background { get; }
public abstract Color SelectionBorder { get; }
public abstract Color SelectionTopGradient { get; }
public abstract Color SelectionMidGradient { get; }
public abstract Color SelectionBottomGradient { get; }
public abstract Color PressedBackground { get; }
public abstract Color CheckedBackground { get; }
public abstract Color CheckedSelectedBackground { get; }
public abstract Color DropdownBorder { get; }
public abstract Color Arrow { get; }
public abstract Color OverflowBackground { get; }
}
public abstract class ColorTable
{
public abstract xColorTable CommonColorTable { get; }
public abstract Color BackgroundTopGradient { get; }
public abstract Color BackgroundBottomGradient { get; }
public abstract Color DroppedDownItemBackground { get; }
public abstract Color DropdownTopGradient { get; }
public abstract Color DropdownBottomGradient { get; }
public abstract Color Separator { get; }
public abstract Color ImageMargin { get; }
}
public class MSColorTable : ColorTable
{
private xColorTable _CommonColorTable;
public MSColorTable()
{
_CommonColorTable = new DefaultCColorTable();
}
public override xColorTable CommonColorTable
{
get
{
return _CommonColorTable;
}
}
public override System.Drawing.Color BackgroundTopGradient
{
get
{
return Color.FromArgb(246, 246, 246);
}
}
public override System.Drawing.Color BackgroundBottomGradient
{
get
{
return Color.FromArgb(226, 226, 226);
}
}
public override System.Drawing.Color DropdownTopGradient
{
get
{
return Color.FromArgb(246, 246, 246);
}
}
public override System.Drawing.Color DropdownBottomGradient
{
get
{
return Color.FromArgb(246, 246, 246);
}
}
public override System.Drawing.Color DroppedDownItemBackground
{
get
{
return Color.FromArgb(240, 240, 240);
}
}
public override System.Drawing.Color Separator
{
get
{
return Color.FromArgb(190, 195, 203);
}
}
public override System.Drawing.Color ImageMargin
{
get
{
return Color.FromArgb(240, 240, 240);
}
}
}
public class DefaultCColorTable : xColorTable
{
public override System.Drawing.Color CheckedBackground
{
get
{
return Color.FromArgb(230, 230, 230);
}
}
public override System.Drawing.Color CheckedSelectedBackground
{
get
{
return Color.FromArgb(230, 230, 230);
}
}
public override System.Drawing.Color SelectionBorder
{
get
{
return Color.FromArgb(180, 180, 180);
}
}
public override System.Drawing.Color SelectionTopGradient
{
get
{
return Color.FromArgb(240, 240, 240);
}
}
public override System.Drawing.Color SelectionMidGradient
{
get
{
return Color.FromArgb(235, 235, 235);
}
}
public override System.Drawing.Color SelectionBottomGradient
{
get
{
return Color.FromArgb(230, 230, 230);
}
}
public override System.Drawing.Color PressedBackground
{
get
{
return Color.FromArgb(232, 232, 232);
}
}
public override System.Drawing.Color TextColor
{
get
{
return Color.FromArgb(80, 80, 80);
}
}
public override System.Drawing.Color Background
{
get
{
return Color.FromArgb(188, 199, 216);
}
}
public override System.Drawing.Color DropdownBorder
{
get
{
return Color.LightGray;
}
}
public override System.Drawing.Color Arrow
{
get
{
return Color.Black;
}
}
public override System.Drawing.Color OverflowBackground
{
get
{
return Color.FromArgb(213, 220, 232);
}
}
}
#endregion
#region Renderer
public class ControlRenderer : ToolStripProfessionalRenderer
{
public ControlRenderer()
: this(new MSColorTable())
{
}
public ControlRenderer(ColorTable ColorTable)
{
this.ColorTable = ColorTable;
}
private ColorTable _ColorTable;
public new ColorTable ColorTable
{
get
{
if (_ColorTable == null)
{
_ColorTable = new MSColorTable();
}
return _ColorTable;
}
set
{
_ColorTable = value;
}
}
protected override void OnRenderToolStripBackground(System.Windows.Forms.ToolStripRenderEventArgs e)
{
base.OnRenderToolStripBackground(e);
// Menu strip bar gradient
using (LinearGradientBrush LGB = new LinearGradientBrush(e.AffectedBounds, this.ColorTable.BackgroundTopGradient, this.ColorTable.BackgroundBottomGradient, LinearGradientMode.Vertical))
{
e.Graphics.FillRectangle(LGB, e.AffectedBounds);
}
}
protected override void OnRenderToolStripBorder(System.Windows.Forms.ToolStripRenderEventArgs e)
{
if (e.ToolStrip.Parent == null)
{
// Draw border around the menu drop-down
Rectangle Rect = new Rectangle(0, 0, e.ToolStrip.Width - 1, e.ToolStrip.Height - 1);
using (Pen P1 = new Pen(this.ColorTable.CommonColorTable.DropdownBorder))
{
e.Graphics.DrawRectangle(P1, Rect);
}
// Fill the gap between menu drop-down and owner item
using (SolidBrush B1 = new SolidBrush(this.ColorTable.DroppedDownItemBackground))
{
e.Graphics.FillRectangle(B1, e.ConnectedArea);
}
}
}
protected override void OnRenderMenuItemBackground(System.Windows.Forms.ToolStripItemRenderEventArgs e)
{
if (e.Item.Enabled)
{
if (e.Item.Selected)
{
if (!e.Item.IsOnDropDown)
{
Rectangle SelRect = new Rectangle(0, 0, e.Item.Width - 1, e.Item.Height - 1);
RectDrawing.DrawSelection(e.Graphics, this.ColorTable.CommonColorTable, SelRect);
}
else
{
Rectangle SelRect = new Rectangle(2, 0, e.Item.Width - 4, e.Item.Height - 1);
RectDrawing.DrawSelection(e.Graphics, this.ColorTable.CommonColorTable, SelRect);
}
}
if (((ToolStripMenuItem)e.Item).DropDown.Visible && !e.Item.IsOnDropDown)
{
Rectangle BorderRect = new Rectangle(0, 0, e.Item.Width - 1, e.Item.Height);
// Fill the background
Rectangle BackgroundRect = new Rectangle(1, 1, e.Item.Width - 2, e.Item.Height + 2);
using (SolidBrush B1 = new SolidBrush(this.ColorTable.DroppedDownItemBackground))
{
e.Graphics.FillRectangle(B1, BackgroundRect);
}
// Draw border
using (Pen P1 = new Pen(this.ColorTable.CommonColorTable.DropdownBorder))
{
RectDrawing.DrawRoundedRectangle(e.Graphics, P1, System.Convert.ToSingle(BorderRect.X), System.Convert.ToSingle(BorderRect.Y), System.Convert.ToSingle(BorderRect.Width), System.Convert.ToSingle(BorderRect.Height), 2);
}
}
e.Item.ForeColor = this.ColorTable.CommonColorTable.TextColor;
}
}
protected override void OnRenderItemText(System.Windows.Forms.ToolStripItemTextRenderEventArgs e)
{
e.TextColor = this.ColorTable.CommonColorTable.TextColor;
base.OnRenderItemText(e);
}
protected override void OnRenderItemCheck(System.Windows.Forms.ToolStripItemImageRenderEventArgs e)
{
base.OnRenderItemCheck(e);
Rectangle rect = new Rectangle(3, 1, e.Item.Height - 3, e.Item.Height - 3);
Color c = default(Color);
if (e.Item.Selected)
{
c = this.ColorTable.CommonColorTable.CheckedSelectedBackground;
}
else
{
c = this.ColorTable.CommonColorTable.CheckedBackground;
}
using (SolidBrush b = new SolidBrush(c))
{
e.Graphics.FillRectangle(b, rect);
}
using (Pen p = new Pen(this.ColorTable.CommonColorTable.SelectionBorder))
{
e.Graphics.DrawRectangle(p, rect);
}
e.Graphics.DrawString("ü", new Font("Wingdings", 13, FontStyle.Regular), Brushes.Black, new Point(4, 2));
}
protected override void OnRenderSeparator(System.Windows.Forms.ToolStripSeparatorRenderEventArgs e)
{
base.OnRenderSeparator(e);
int PT1 = 28;
int PT2 = System.Convert.ToInt32(e.Item.Width);
int Y = 3;
using (Pen P1 = new Pen(this.ColorTable.Separator))
{
e.Graphics.DrawLine(P1, PT1, Y, PT2, Y);
}
}
protected override void OnRenderImageMargin(System.Windows.Forms.ToolStripRenderEventArgs e)
{
base.OnRenderImageMargin(e);
Rectangle BackgroundRect = new Rectangle(0, -1, e.ToolStrip.Width, e.ToolStrip.Height + 1);
using (LinearGradientBrush LGB = new LinearGradientBrush(BackgroundRect,
this.ColorTable.DropdownTopGradient,
this.ColorTable.DropdownBottomGradient,
LinearGradientMode.Vertical))
{
e.Graphics.FillRectangle(LGB, BackgroundRect);
}
using (SolidBrush B1 = new SolidBrush(this.ColorTable.ImageMargin))
{
e.Graphics.FillRectangle(B1, e.AffectedBounds);
}
}
protected override void OnRenderButtonBackground(System.Windows.Forms.ToolStripItemRenderEventArgs e)
{
Rectangle rect = new Rectangle(0, 0, e.Item.Width - 1, e.Item.Height - 1);
bool @checked = System.Convert.ToBoolean(((ToolStripButton)e.Item).Checked);
bool drawBorder = false;
if (@checked)
{
drawBorder = true;
if (e.Item.Selected && !e.Item.Pressed)
{
using (SolidBrush b = new SolidBrush(this.ColorTable.CommonColorTable.CheckedSelectedBackground))
{
e.Graphics.FillRectangle(b, rect);
}
}
else
{
using (SolidBrush b = new SolidBrush(this.ColorTable.CommonColorTable.CheckedBackground))
{
e.Graphics.FillRectangle(b, rect);
}
}
}
else
{
if (e.Item.Pressed)
{
drawBorder = true;
using (SolidBrush b = new SolidBrush(this.ColorTable.CommonColorTable.PressedBackground))
{
e.Graphics.FillRectangle(b, rect);
}
}
else if (e.Item.Selected)
{
drawBorder = true;
RectDrawing.DrawSelection(e.Graphics, this.ColorTable.CommonColorTable, rect);
}
}
if (drawBorder)
{
using (Pen p = new Pen(this.ColorTable.CommonColorTable.SelectionBorder))
{
e.Graphics.DrawRectangle(p, rect);
}
}
}
protected override void OnRenderDropDownButtonBackground(System.Windows.Forms.ToolStripItemRenderEventArgs e)
{
Rectangle rect = new Rectangle(0, 0, e.Item.Width - 1, e.Item.Height - 1);
bool drawBorder = false;
if (e.Item.Pressed)
{
drawBorder = true;
using (SolidBrush b = new SolidBrush(this.ColorTable.CommonColorTable.PressedBackground))
{
e.Graphics.FillRectangle(b, rect);
}
}
else if (e.Item.Selected)
{
drawBorder = true;
RectDrawing.DrawSelection(e.Graphics, this.ColorTable.CommonColorTable, rect);
}
if (drawBorder)
{
using (Pen p = new Pen(this.ColorTable.CommonColorTable.SelectionBorder))
{
e.Graphics.DrawRectangle(p, rect);
}
}
}
protected override void OnRenderSplitButtonBackground(ToolStripItemRenderEventArgs e)
{
base.OnRenderSplitButtonBackground(e);
bool drawBorder = false;
bool drawSeparator = true;
ToolStripSplitButton item = (ToolStripSplitButton)e.Item;
checked
{
Rectangle btnRect = new Rectangle(0, 0, item.ButtonBounds.Width - 1, item.ButtonBounds.Height - 1);
Rectangle borderRect = new Rectangle(0, 0, item.Bounds.Width - 1, item.Bounds.Height - 1);
bool flag = item.DropDownButtonPressed;
if (flag)
{
drawBorder = true;
drawSeparator = false;
SolidBrush b = new SolidBrush(this.ColorTable.CommonColorTable.PressedBackground);
try
{
e.Graphics.FillRectangle(b, borderRect);
}
finally
{
flag = (b != null);
if (flag)
{
((IDisposable)b).Dispose();
}
}
}
else
{
flag = item.DropDownButtonSelected;
if (flag)
{
drawBorder = true;
RectDrawing.DrawSelection(e.Graphics, this.ColorTable.CommonColorTable, borderRect);
}
}
flag = item.ButtonPressed;
if (flag)
{
SolidBrush b2 = new SolidBrush(this.ColorTable.CommonColorTable.PressedBackground);
try
{
e.Graphics.FillRectangle(b2, btnRect);
}
finally
{
flag = (b2 != null);
if (flag)
{
((IDisposable)b2).Dispose();
}
}
}
flag = drawBorder;
if (flag)
{
Pen p = new Pen(this.ColorTable.CommonColorTable.SelectionBorder);
try
{
e.Graphics.DrawRectangle(p, borderRect);
flag = drawSeparator;
if (flag)
{
e.Graphics.DrawRectangle(p, btnRect);
}
}
finally
{
flag = (p != null);
if (flag)
{
((IDisposable)p).Dispose();
}
}
this.DrawCustomArrow(e.Graphics, item);
}
}
}
private void DrawCustomArrow(Graphics g, ToolStripSplitButton item)
{
int dropWidth = System.Convert.ToInt32(item.DropDownButtonBounds.Width - 1);
int dropHeight = System.Convert.ToInt32(item.DropDownButtonBounds.Height - 1);
float triangleWidth = dropWidth / 2.0F + 1;
float triangleLeft = System.Convert.ToSingle(item.DropDownButtonBounds.Left + (dropWidth - triangleWidth) / 2.0F);
float triangleHeight = triangleWidth / 2.0F;
float triangleTop = System.Convert.ToSingle(item.DropDownButtonBounds.Top + (dropHeight - triangleHeight) / 2.0F + 1);
RectangleF arrowRect = new RectangleF(triangleLeft, triangleTop, triangleWidth, triangleHeight);
this.DrawCustomArrow(g, item, Rectangle.Round(arrowRect));
}
private void DrawCustomArrow(Graphics g, ToolStripItem item, Rectangle rect)
{
ToolStripArrowRenderEventArgs arrowEventArgs = new ToolStripArrowRenderEventArgs(g, item, rect, this.ColorTable.CommonColorTable.Arrow, ArrowDirection.Down);
base.OnRenderArrow(arrowEventArgs);
}
protected override void OnRenderOverflowButtonBackground(System.Windows.Forms.ToolStripItemRenderEventArgs e)
{
Rectangle rect = default(Rectangle);
Rectangle rectEnd = default(Rectangle);
rect = new Rectangle(0, 0, e.Item.Width - 1, e.Item.Height - 2);
rectEnd = new Rectangle(rect.X - 5, rect.Y, rect.Width - 5, rect.Height);
if (e.Item.Pressed)
{
using (SolidBrush b = new SolidBrush(this.ColorTable.CommonColorTable.PressedBackground))
{
e.Graphics.FillRectangle(b, rect);
}
}
else if (e.Item.Selected)
{
RectDrawing.DrawSelection(e.Graphics, this.ColorTable.CommonColorTable, rect);
}
else
{
using (SolidBrush b = new SolidBrush(this.ColorTable.CommonColorTable.OverflowBackground))
{
e.Graphics.FillRectangle(b, rect);
}
}
using (Pen P1 = new Pen(this.ColorTable.CommonColorTable.Background))
{
RectDrawing.DrawRoundedRectangle(e.Graphics, P1, System.Convert.ToSingle(rectEnd.X), System.Convert.ToSingle(rectEnd.Y), System.Convert.ToSingle(rectEnd.Width), System.Convert.ToSingle(rectEnd.Height), 3);
}
// Icon
int w = System.Convert.ToInt32(rect.Width - 1);
int h = System.Convert.ToInt32(rect.Height - 1);
float triangleWidth = w / 2.0F + 1;
float triangleLeft = System.Convert.ToSingle(rect.Left + (w - triangleWidth) / 2.0F + 3);
float triangleHeight = triangleWidth / 2.0F;
float triangleTop = System.Convert.ToSingle(rect.Top + (h - triangleHeight) / 2.0F + 7);
RectangleF arrowRect = new RectangleF(triangleLeft, triangleTop, triangleWidth, triangleHeight);
this.DrawCustomArrow(e.Graphics, e.Item, Rectangle.Round(arrowRect));
using (Pen p = new Pen(this.ColorTable.CommonColorTable.Arrow))
{
e.Graphics.DrawLine(p, triangleLeft + 2, triangleTop - 2, triangleLeft + triangleWidth - 2, triangleTop - 2);
}
}
}
#endregion
#region Drawing
public class RectDrawing
{
public static void DrawSelection(Graphics G, xColorTable ColorTable, Rectangle Rect)
{
Rectangle TopRect = default(Rectangle);
Rectangle BottomRect = default(Rectangle);
Rectangle FillRect = new Rectangle(Rect.X + 1, Rect.Y + 1, Rect.Width - 1, Rect.Height - 1);
TopRect = FillRect;
TopRect.Height -= System.Convert.ToInt32(TopRect.Height / 2);
BottomRect = new Rectangle(TopRect.X, TopRect.Bottom, TopRect.Width, FillRect.Height - TopRect.Height);
// Top gradient
using (LinearGradientBrush LGB = new LinearGradientBrush(TopRect, ColorTable.SelectionTopGradient, ColorTable.SelectionMidGradient, LinearGradientMode.Vertical))
{
G.FillRectangle(LGB, TopRect);
}
// Bottom
using (SolidBrush B1 = new SolidBrush(ColorTable.SelectionBottomGradient))
{
G.FillRectangle(B1, BottomRect);
}
// Border
using (Pen P1 = new Pen(ColorTable.SelectionBorder))
{
RectDrawing.DrawRoundedRectangle(G, P1, System.Convert.ToSingle(Rect.X), System.Convert.ToSingle(Rect.Y), System.Convert.ToSingle(Rect.Width), System.Convert.ToSingle(Rect.Height), 2);
}
}
public static void DrawRoundedRectangle(Graphics G, Pen P, float X, float Y, float W, float H, float Rad)
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddLine(X + Rad, Y, X + W - (Rad * 2), Y);
gp.AddArc(X + W - (Rad * 2), Y, Rad * 2, Rad * 2, 270, 90);
gp.AddLine(X + W, Y + Rad, X + W, Y + H - (Rad * 2));
gp.AddArc(X + W - (Rad * 2), Y + H - (Rad * 2), Rad * 2, Rad * 2, 0, 90);
gp.AddLine(X + W - (Rad * 2), Y + H, X + Rad, Y + H);
gp.AddArc(X, Y + H - (Rad * 2), Rad * 2, Rad * 2, 90, 90);
gp.AddLine(X, Y + H - (Rad * 2), X, Y + Rad);
gp.AddArc(X, Y, Rad * 2, Rad * 2, 180, 90);
gp.CloseFigure();
G.SmoothingMode = SmoothingMode.AntiAlias;
G.DrawPath(P, gp);
G.SmoothingMode = SmoothingMode.Default;
}
}
}
#endregion
#endregion
#region ThemeContainer154 for ZeroitKeyBoard
public abstract class ThemeContainer154 : ContainerControl
{
#region " Initialization "
protected Graphics G;
protected Bitmap B;
public ThemeContainer154()
{
SetStyle((ControlStyles)139270, true);
_ImageSize = Size.Empty;
Font = new Font("Verdana", 8);
MeasureBitmap = new Bitmap(1, 1);
MeasureGraphics = Graphics.FromImage(MeasureBitmap);
DrawRadialPath = new GraphicsPath();
InvalidateCustimization();
}
protected override sealed void OnHandleCreated(EventArgs e)
{
if (DoneCreation)
InitializeMessages();
InvalidateCustimization();
ColorHook();
if (!(_LockWidth == 0))
Width = _LockWidth;
if (!(_LockHeight == 0))
Height = _LockHeight;
if (!_ControlMode)
base.Dock = DockStyle.Fill;
Transparent = _Transparent;
if (_Transparent && _BackColor)
BackColor = Color.Transparent;
base.OnHandleCreated(e);
}
private bool DoneCreation;
protected override sealed void OnParentChanged(EventArgs e)
{
base.OnParentChanged(e);
if (Parent == null)
return;
_IsParentForm = Parent is System.Windows.Forms.Form;
if (!_ControlMode)
{
InitializeMessages();
if (_IsParentForm)
{
ParentForm.FormBorderStyle = _BorderStyle;
ParentForm.TransparencyKey = _TransparencyKey;
if (!DesignMode)
{
ParentForm.Shown += FormShown;
}
}
Parent.BackColor = BackColor;
}
OnCreation();
DoneCreation = true;
InvalidateTimer();
}
#endregion
private void DoAnimation(bool i)
{
OnAnimation();
if (i)
Invalidate();
}
protected override sealed void OnPaint(PaintEventArgs e)
{
if (Width == 0 || Height == 0)
return;
if (_Transparent && _ControlMode)
{
PaintHook();
e.Graphics.DrawImage(B, 0, 0);
}
else
{
G = e.Graphics;
PaintHook();
}
}
protected override void OnHandleDestroyed(EventArgs e)
{
ThemeShare.RemoveAnimationCallback(DoAnimation);
base.OnHandleDestroyed(e);
}
private bool HasShown;
private void FormShown(object sender, EventArgs e)
{
if (_ControlMode || HasShown)
return;
if (_StartPosition == FormStartPosition.CenterParent || _StartPosition == FormStartPosition.CenterScreen)
{
Rectangle SB = Screen.PrimaryScreen.Bounds;
Rectangle CB = ParentForm.Bounds;
ParentForm.Location = new Point(SB.Width / 2 - CB.Width / 2, SB.Height / 2 - CB.Width / 2);
}
HasShown = true;
}
#region " Size Handling "
private Rectangle Frame;
protected override sealed void OnSizeChanged(EventArgs e)
{
if (_Movable && !_ControlMode)
{
Frame = new Rectangle(7, 7, Width - 14, _Header - 7);
}
InvalidateBitmap();
Invalidate();
base.OnSizeChanged(e);
}
protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)
{
if (!(_LockWidth == 0))
width = _LockWidth;
if (!(_LockHeight == 0))
height = _LockHeight;
base.SetBoundsCore(x, y, width, height, specified);
}
#endregion
#region " State Handling "
protected MouseState State;
private void SetState(MouseState current)
{
State = current;
Invalidate();
}
protected override void OnMouseMove(MouseEventArgs e)
{
if (!(_IsParentForm && ParentForm.WindowState == FormWindowState.Maximized))
{
if (_Sizable && !_ControlMode)
InvalidateMouse();
}
base.OnMouseMove(e);
}
protected override void OnEnabledChanged(EventArgs e)
{
if (Enabled)
SetState(MouseState.None);
else
SetState(MouseState.Block);
base.OnEnabledChanged(e);
}
protected override void OnMouseEnter(EventArgs e)
{
SetState(MouseState.Over);
base.OnMouseEnter(e);
}
protected override void OnMouseUp(MouseEventArgs e)
{
SetState(MouseState.Over);
base.OnMouseUp(e);
}
protected override void OnMouseLeave(EventArgs e)
{
SetState(MouseState.None);
if (GetChildAtPoint(PointToClient(MousePosition)) != null)
{
if (_Sizable && !_ControlMode)
{
Cursor = Cursors.Default;
Previous = 0;
}
}
base.OnMouseLeave(e);
}
protected override void OnMouseDown(MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
SetState(MouseState.Down);
if (!(_IsParentForm && ParentForm.WindowState == FormWindowState.Maximized || _ControlMode))
{
if (_Movable && Frame.Contains(e.Location))
{
Capture = false;
WM_LMBUTTONDOWN = true;
DefWndProc(ref Messages[0]);
}