tangxu
2024-10-22 7a0d1efa4784d176a32f182ecae671711e98ca92
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
#region Imports
 
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Runtime.InteropServices;
using System.Windows.Forms;
 
#endregion
 
// |---------DO-NOT-REMOVE---------|
//
//     Creator: Taiizor
//     Website: www.vegalya.com
//     Created: 15.May.2019
//     Changed: 10.Oct.2024
//     Version: 3.8.0.8
//
// |---------DO-NOT-REMOVE---------|
 
namespace DPumpHydr.WinFrmUI.RLT
{
    #region Core
 
    #region RoundRectangle
 
    public sealed class RoundRectangle
    {
        public static GraphicsPath RoundRect(Rectangle Rectangle, int Curve)
        {
            GraphicsPath GP = new();
 
            int ArcRectangleWidth = Curve * 2;
 
            GP.AddArc(new(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90);
            GP.AddArc(new(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90);
            GP.AddArc(new(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90);
            GP.AddArc(new(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90);
            GP.AddLine(new Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + 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(X, Y, Width, Height);
 
            GraphicsPath GP = new();
 
            int EndArcWidth = Curve * 2;
 
            GP.AddArc(new(Rectangle.X, Rectangle.Y, EndArcWidth, EndArcWidth), -180, 90);
            GP.AddArc(new(Rectangle.Width - EndArcWidth + Rectangle.X, Rectangle.Y, EndArcWidth, EndArcWidth), -90, 90);
            GP.AddArc(new(Rectangle.Width - EndArcWidth + Rectangle.X, Rectangle.Height - EndArcWidth + Rectangle.Y, EndArcWidth, EndArcWidth), 0, 90);
            GP.AddArc(new(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 RoundedTopRect(Rectangle Rectangle, int Curve)
        {
            GraphicsPath GP = new();
 
            int ArcRectangleWidth = Curve * 2;
 
            GP.AddArc(new(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90);
            GP.AddArc(new(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90);
            GP.AddLine(new Point(Rectangle.X + Rectangle.Width, Rectangle.Y + ArcRectangleWidth), new Point(Rectangle.X + Rectangle.Width, Rectangle.Y + Rectangle.Height - 1));
            GP.AddLine(new Point(Rectangle.X, Rectangle.Height - 1 + Rectangle.Y), new Point(Rectangle.X, Rectangle.Y + Curve));
 
            return GP;
        }
 
        public static GraphicsPath CreateRoundRect(float X, float Y, float Width, float Height, float Radius)
        {
            GraphicsPath GP = new();
            GP.AddLine(X + Radius, Y, X + Width - (Radius * 2), Y);
            GP.AddArc(X + Width - (Radius * 2), Y, Radius * 2, Radius * 2, 270, 90);
 
            GP.AddLine(X + Width, Y + Radius, X + Width, Y + Height - (Radius * 2));
            GP.AddArc(X + Width - (Radius * 2), Y + Height - (Radius * 2), Radius * 2, Radius * 2, 0, 90);
 
            GP.AddLine(X + Width - (Radius * 2), Y + Height, X + Radius, Y + Height);
            GP.AddArc(X, Y + Height - (Radius * 2), Radius * 2, Radius * 2, 90, 90);
 
            GP.AddLine(X, Y + Height - (Radius * 2), X, Y + Radius);
            GP.AddArc(X, Y, Radius * 2, Radius * 2, 180, 90);
 
            GP.CloseFigure();
 
            return GP;
        }
 
        public static GraphicsPath CreateUpRoundRect(float X, float Y, float Width, float Height, float Radius)
        {
            GraphicsPath GP = new();
 
            GP.AddLine(X + Radius, Y, X + Width - (Radius * 2), Y);
            GP.AddArc(X + Width - (Radius * 2), Y, Radius * 2, Radius * 2, 270, 90);
 
            GP.AddLine(X + Width, Y + Radius, X + Width, Y + Height - (Radius * 2) + 1);
            GP.AddArc(X + Width - (Radius * 2), Y + Height - (Radius * 2), Radius * 2, 2, 0, 90);
 
            GP.AddLine(X + Width, Y + Height, X + Radius, Y + Height);
            GP.AddArc(X, Y + Height - (Radius * 2) + 1, Radius * 2, 1, 90, 90);
 
            GP.AddLine(X, Y + Height, X, Y + Radius);
            GP.AddArc(X, Y, Radius * 2, Radius * 2, 180, 90);
 
            GP.CloseFigure();
 
            return GP;
        }
 
        public static GraphicsPath CreateLeftRoundRect(float X, float Y, float Width, float Height, float Radius)
        {
            GraphicsPath GP = new();
            GP.AddLine(X + Radius, Y, X + Width - (Radius * 2), Y);
            GP.AddArc(X + Width - (Radius * 2), Y, Radius * 2, Radius * 2, 270, 90);
 
            GP.AddLine(X + Width, Y + 0, X + Width, Y + Height);
            GP.AddArc(X + Width - (Radius * 2), Y + Height - 1, Radius * 2, 1, 0, 90);
 
            GP.AddLine(X + Width - (Radius * 2), Y + Height, X + Radius, Y + Height);
            GP.AddArc(X, Y + Height - (Radius * 2), Radius * 2, Radius * 2, 90, 90);
 
            GP.AddLine(X, Y + Height - (Radius * 2), X, Y + Radius);
            GP.AddArc(X, Y, Radius * 2, Radius * 2, 180, 90);
 
            GP.CloseFigure();
 
            return GP;
        }
 
        public static Color BlendColor(Color BackgroundColor, Color FrontColor)
        {
            double Ratio = 0 / 255d;
            double InvRatio = 1d - Ratio;
 
            int R = (int)((BackgroundColor.R * InvRatio) + (FrontColor.R * Ratio));
            int G = (int)((BackgroundColor.G * InvRatio) + (FrontColor.G * Ratio));
            int B = (int)((BackgroundColor.B * InvRatio) + (FrontColor.B * Ratio));
 
            return Color.FromArgb(R, G, B);
        }
 
        public static Color BackColor = ColorTranslator.FromHtml("#DADCDF"); //BCBFC4
        public static Color DarkBackColor = ColorTranslator.FromHtml("#90949A");
        public static Color LightBackColor = ColorTranslator.FromHtml("#F5F5F5");
    }
 
    #endregion
 
    #region ControlRenderer
 
    #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 readonly XColorTable _CommonColorTable;
 
        public MSColorTable()
        {
            _CommonColorTable = new DefaultCColorTable();
        }
 
        public override XColorTable CommonColorTable => _CommonColorTable;
 
        public override Color BackgroundTopGradient => Color.FromArgb(246, 246, 246);
 
        public override Color BackgroundBottomGradient => Color.FromArgb(226, 226, 226);
 
        public override Color DropdownTopGradient => Color.FromArgb(246, 246, 246);
 
        public override Color DropdownBottomGradient => Color.FromArgb(246, 246, 246);
 
        public override Color DroppedDownItemBackground => Color.FromArgb(240, 240, 240);
 
        public override Color Separator => Color.FromArgb(190, 195, 203);
 
        public override Color ImageMargin => Color.FromArgb(240, 240, 240);
    }
 
    public class DefaultCColorTable : XColorTable
    {
 
        public override Color CheckedBackground => Color.FromArgb(230, 230, 230);
 
        public override Color CheckedSelectedBackground => Color.FromArgb(230, 230, 230);
 
        public override Color SelectionBorder => Color.FromArgb(180, 180, 180);
 
        public override Color SelectionTopGradient => Color.FromArgb(240, 240, 240);
 
        public override Color SelectionMidGradient => Color.FromArgb(235, 235, 235);
 
        public override Color SelectionBottomGradient => Color.FromArgb(230, 230, 230);
 
        public override Color PressedBackground => Color.FromArgb(232, 232, 232);
 
        public override Color TextColor => Color.FromArgb(80, 80, 80);
 
        public override Color Background => Color.FromArgb(188, 199, 216);
 
        public override Color DropdownBorder => Color.LightGray;
 
        public override Color Arrow => Color.Black;
 
        public override Color OverflowBackground => Color.FromArgb(213, 220, 232);
    }
 
    #endregion
 
    #region Renderer
 
    public class ControlRenderer : ToolStripProfessionalRenderer
    {
        public ControlRenderer() : this(new MSColorTable()) { }
 
        public ControlRenderer(ColorTable ColorTable)
        {
            ControlRenderer thisis = this;
            thisis.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(ToolStripRenderEventArgs e)
        {
            base.OnRenderToolStripBackground(e);
 
            // Menu strip bar gradient
            using LinearGradientBrush LGB = new(e.AffectedBounds, ColorTable.BackgroundTopGradient, ColorTable.BackgroundBottomGradient, LinearGradientMode.Vertical);
            e.Graphics.FillRectangle(LGB, e.AffectedBounds);
        }
 
        protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e)
        {
            if (e.ToolStrip.Parent == null)
            {
                // Draw border around the menu drop-down
                Rectangle Rect = new(0, 0, e.ToolStrip.Width - 1, e.ToolStrip.Height - 1);
                using (Pen P1 = new(ColorTable.CommonColorTable.DropdownBorder))
                {
                    e.Graphics.DrawRectangle(P1, Rect);
                }
 
                // Fill the gap between menu drop-down and owner item
                using SolidBrush B1 = new(ColorTable.DroppedDownItemBackground);
                e.Graphics.FillRectangle(B1, e.ConnectedArea);
            }
        }
 
        protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
        {
            if (e.Item.Enabled)
            {
                if (e.Item.Selected)
                {
                    if (!e.Item.IsOnDropDown)
                    {
                        Rectangle SelRect = new(0, 0, e.Item.Width - 1, e.Item.Height - 1);
                        RectDrawing.DrawSelection(e.Graphics, ColorTable.CommonColorTable, SelRect);
                    }
                    else
                    {
                        Rectangle SelRect = new(2, 0, e.Item.Width - 4, e.Item.Height - 1);
                        RectDrawing.DrawSelection(e.Graphics, ColorTable.CommonColorTable, SelRect);
                    }
                }
 
                if (((ToolStripMenuItem)e.Item).DropDown.Visible && !e.Item.IsOnDropDown)
                {
                    Rectangle BorderRect = new(0, 0, e.Item.Width - 1, e.Item.Height);
                    // Fill the background
                    Rectangle BackgroundRect = new(1, 1, e.Item.Width - 2, e.Item.Height + 2);
                    using (SolidBrush B1 = new(ColorTable.DroppedDownItemBackground))
                    {
                        e.Graphics.FillRectangle(B1, BackgroundRect);
                    }
 
                    // Draw border
                    using Pen P1 = new(ColorTable.CommonColorTable.DropdownBorder);
                    RectDrawing.DrawRoundedRectangle(e.Graphics, P1, Convert.ToSingle(BorderRect.X), Convert.ToSingle(BorderRect.Y), Convert.ToSingle(BorderRect.Width), Convert.ToSingle(BorderRect.Height), 2);
                }
                e.Item.ForeColor = ColorTable.CommonColorTable.TextColor;
            }
        }
 
        protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
        {
            e.TextColor = ColorTable.CommonColorTable.TextColor;
            base.OnRenderItemText(e);
        }
 
        protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e)
        {
            base.OnRenderItemCheck(e);
 
            Rectangle rect = new(3, 1, e.Item.Height - 3, e.Item.Height - 3);
            Color c = default;
 
            if (e.Item.Selected)
            {
                c = ColorTable.CommonColorTable.CheckedSelectedBackground;
            }
            //else
 
            using (SolidBrush b = new(c))
            {
                e.Graphics.FillRectangle(b, rect);
            }
 
            using (Pen p = new(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(ToolStripSeparatorRenderEventArgs e)
        {
            base.OnRenderSeparator(e);
            int PT1 = 28;
            int PT2 = Convert.ToInt32(e.Item.Width);
            int Y = 3;
            using Pen P1 = new(ColorTable.Separator);
            e.Graphics.DrawLine(P1, PT1, Y, PT2, Y);
        }
 
        protected override void OnRenderImageMargin(ToolStripRenderEventArgs e)
        {
            base.OnRenderImageMargin(e);
 
            Rectangle BackgroundRect = new(0, -1, e.ToolStrip.Width, e.ToolStrip.Height + 1);
            using (LinearGradientBrush LGB = new(BackgroundRect, ColorTable.DropdownTopGradient, ColorTable.DropdownBottomGradient, LinearGradientMode.Vertical))
            {
                e.Graphics.FillRectangle(LGB, BackgroundRect);
            }
 
            using SolidBrush B1 = new(ColorTable.ImageMargin);
            e.Graphics.FillRectangle(B1, e.AffectedBounds);
        }
 
        protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
        {
            Rectangle rect = new(0, 0, e.Item.Width - 1, e.Item.Height - 1);
            bool @checked = Convert.ToBoolean(((ToolStripButton)e.Item).Checked);
            bool drawBorder = false;
 
            if (@checked)
            {
                drawBorder = true;
 
                if (e.Item.Selected && !e.Item.Pressed)
                {
                    using SolidBrush b = new(ColorTable.CommonColorTable.CheckedSelectedBackground);
                    e.Graphics.FillRectangle(b, rect);
                }
                else
                {
                    using SolidBrush b = new(ColorTable.CommonColorTable.CheckedBackground);
                    e.Graphics.FillRectangle(b, rect);
                }
 
            }
            else
            {
 
                if (e.Item.Pressed)
                {
                    drawBorder = true;
                    using SolidBrush b = new(ColorTable.CommonColorTable.PressedBackground);
                    e.Graphics.FillRectangle(b, rect);
                }
                else if (e.Item.Selected)
                {
                    drawBorder = true;
                    RectDrawing.DrawSelection(e.Graphics, ColorTable.CommonColorTable, rect);
                }
 
            }
 
            if (drawBorder)
            {
                using Pen p = new(ColorTable.CommonColorTable.SelectionBorder);
                e.Graphics.DrawRectangle(p, rect);
            }
        }
 
        protected override void OnRenderDropDownButtonBackground(ToolStripItemRenderEventArgs e)
        {
            Rectangle rect = new(0, 0, e.Item.Width - 1, e.Item.Height - 1);
            bool drawBorder = false;
 
            if (e.Item.Pressed)
            {
                drawBorder = true;
                using SolidBrush b = new(ColorTable.CommonColorTable.PressedBackground);
                e.Graphics.FillRectangle(b, rect);
            }
            else if (e.Item.Selected)
            {
                drawBorder = true;
                RectDrawing.DrawSelection(e.Graphics, ColorTable.CommonColorTable, rect);
            }
 
            if (drawBorder)
            {
                using Pen p = new(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(0, 0, item.ButtonBounds.Width - 1, item.ButtonBounds.Height - 1);
                Rectangle borderRect = new(0, 0, item.Bounds.Width - 1, item.Bounds.Height - 1);
                bool flag = item.DropDownButtonPressed;
                if (flag)
                {
                    drawBorder = true;
                    drawSeparator = false;
                    SolidBrush b = new(ColorTable.CommonColorTable.PressedBackground);
                    try
                    {
                        e.Graphics.FillRectangle(b, borderRect);
                    }
                    finally
                    {
                        flag = b != null;
                        if (flag)
                        {
                            b.Dispose();
                        }
                    }
                }
                else
                {
                    flag = item.DropDownButtonSelected;
                    if (flag)
                    {
                        drawBorder = true;
                        RectDrawing.DrawSelection(e.Graphics, ColorTable.CommonColorTable, borderRect);
                    }
                }
                flag = item.ButtonPressed;
                if (flag)
                {
                    SolidBrush b2 = new(ColorTable.CommonColorTable.PressedBackground);
                    try
                    {
                        e.Graphics.FillRectangle(b2, btnRect);
                    }
                    finally
                    {
                        flag = b2 != null;
                        if (flag)
                        {
                            b2.Dispose();
                        }
                    }
                }
                flag = drawBorder;
                if (flag)
                {
                    Pen p = new(ColorTable.CommonColorTable.SelectionBorder);
                    try
                    {
                        e.Graphics.DrawRectangle(p, borderRect);
                        flag = drawSeparator;
                        if (flag)
                        {
                            e.Graphics.DrawRectangle(p, btnRect);
                        }
                    }
                    finally
                    {
                        flag = p != null;
                        if (flag)
                        {
                            p.Dispose();
                        }
                    }
                    DrawCustomArrow(e.Graphics, item);
                }
            }
        }
 
        private void DrawCustomArrow(Graphics g, ToolStripSplitButton item)
        {
            int dropWidth = Convert.ToInt32(item.DropDownButtonBounds.Width - 1);
            int dropHeight = Convert.ToInt32(item.DropDownButtonBounds.Height - 1);
            float triangleWidth = (dropWidth / 2.0F) + 1;
            float triangleLeft = Convert.ToSingle(item.DropDownButtonBounds.Left + ((dropWidth - triangleWidth) / 2.0F));
            float triangleHeight = triangleWidth / 2.0F;
            float triangleTop = Convert.ToSingle(item.DropDownButtonBounds.Top + ((dropHeight - triangleHeight) / 2.0F) + 1);
            RectangleF arrowRect = new(triangleLeft, triangleTop, triangleWidth, triangleHeight);
 
            DrawCustomArrow(g, item, Rectangle.Round(arrowRect));
        }
 
        private void DrawCustomArrow(Graphics g, ToolStripItem item, Rectangle rect)
        {
            ToolStripArrowRenderEventArgs arrowEventArgs = new(g, item, rect, ColorTable.CommonColorTable.Arrow, ArrowDirection.Down);
            base.OnRenderArrow(arrowEventArgs);
        }
 
        protected override void OnRenderOverflowButtonBackground(ToolStripItemRenderEventArgs e)
        {
            Rectangle rect = new(0, 0, e.Item.Width - 1, e.Item.Height - 2);
            Rectangle rectEnd = new(rect.X - 5, rect.Y, rect.Width - 5, rect.Height);
 
            if (e.Item.Pressed)
            {
                using SolidBrush b = new(ColorTable.CommonColorTable.PressedBackground);
                e.Graphics.FillRectangle(b, rect);
            }
            else if (e.Item.Selected)
            {
                RectDrawing.DrawSelection(e.Graphics, ColorTable.CommonColorTable, rect);
            }
            else
            {
                using SolidBrush b = new(ColorTable.CommonColorTable.OverflowBackground);
                e.Graphics.FillRectangle(b, rect);
            }
 
            using (Pen P1 = new(ColorTable.CommonColorTable.Background))
            {
                RectDrawing.DrawRoundedRectangle(e.Graphics, P1, Convert.ToSingle(rectEnd.X), Convert.ToSingle(rectEnd.Y), Convert.ToSingle(rectEnd.Width), Convert.ToSingle(rectEnd.Height), 3);
            }
 
            // Icon
            int w = Convert.ToInt32(rect.Width - 1);
            int h = Convert.ToInt32(rect.Height - 1);
            float triangleWidth = (w / 2.0F) + 1;
            float triangleLeft = Convert.ToSingle(rect.Left + ((w - triangleWidth) / 2.0F) + 3);
            float triangleHeight = triangleWidth / 2.0F;
            float triangleTop = Convert.ToSingle(rect.Top + ((h - triangleHeight) / 2.0F) + 7);
            RectangleF arrowRect = new(triangleLeft, triangleTop, triangleWidth, triangleHeight);
            DrawCustomArrow(e.Graphics, e.Item, Rectangle.Round(arrowRect));
 
            using Pen p = new(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 FillRect = new(Rect.X + 1, Rect.Y + 1, Rect.Width - 1, Rect.Height - 1);
 
            Rectangle TopRect = FillRect;
            TopRect.Height -= Convert.ToInt32(TopRect.Height / 2);
            Rectangle BottomRect = new(TopRect.X, TopRect.Bottom, TopRect.Width, FillRect.Height - TopRect.Height);
 
            // Top gradient
            using (LinearGradientBrush LGB = new(TopRect, ColorTable.SelectionTopGradient, ColorTable.SelectionMidGradient, LinearGradientMode.Vertical))
            {
                G.FillRectangle(LGB, TopRect);
            }
 
            // Bottom
            using (SolidBrush B1 = new(ColorTable.SelectionBottomGradient))
            {
                G.FillRectangle(B1, BottomRect);
            }
 
            // Border
            using Pen P1 = new(ColorTable.SelectionBorder);
            RectDrawing.DrawRoundedRectangle(G, P1, Convert.ToSingle(Rect.X), Convert.ToSingle(Rect.Y), Convert.ToSingle(Rect.Width), 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();
            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 PaintHelper
 
    public abstract class PaintHelperA
    {
        [DllImport("user32.dll")]
        public static extern int SendMessage(IntPtr hWnd, int wMsg, bool wParam, int lParam);
 
        private const int WM_SETREDRAW = 11;
 
        public static void Suspend(Control Parent)
        {
            _ = SendMessage(Parent.Handle, WM_SETREDRAW, false, 0);
        }
 
        public static void Resume(Control Parent)
        {
            _ = SendMessage(Parent.Handle, WM_SETREDRAW, true, 0);
            Parent.Refresh();
        }
    }
 
    public abstract class PaintHelperB
    {
        private const int WM_SETREDRAW = 0x000B;
 
        public static void Suspend(Control Parent)
        {
            Message msgSuspendUpdate = Message.Create(Parent.Handle, WM_SETREDRAW, IntPtr.Zero, IntPtr.Zero);
 
            NativeWindow window = NativeWindow.FromHandle(Parent.Handle);
            window.DefWndProc(ref msgSuspendUpdate);
        }
 
        public static void Resume(Control Parent)
        {
            // Create a C "true" boolean as an IntPtr
            IntPtr wparam = new(1);
            Message msgResumeUpdate = Message.Create(Parent.Handle, WM_SETREDRAW, wparam, IntPtr.Zero);
 
            NativeWindow window = NativeWindow.FromHandle(Parent.Handle);
            window.DefWndProc(ref msgResumeUpdate);
 
            Parent.Invalidate();
        }
    }
 
    #endregion
 
    #endregion
}