tangxu
2025-01-13 4f7cb65b079d88d5a829688b24d26d5145c5df47
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
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using Microsoft.Drawing;
using Microsoft.Windows.Forms.Layout;
 
namespace Microsoft.Windows.Forms
{
    partial class Sprite
    {
        //渲染时传递进来的临时变量
        private Rectangle m_BackColorRect;
        private Rectangle m_BackgroundImageRect;
        private Rectangle m_BackgroundImage9Rect;
        private Rectangle m_TextImageRect;
        private Rectangle m_StringRect;
        private Rectangle m_BorderColorRect;
 
        //渲染文本核心方法
        private void RenderTextCore(LayoutData layout)
        {
            layout.DoLayout();//执行布局
            this.CurrentTextPreferredRect = layout.OutTextBounds;//保存文本区域矩形
            bool needRotate = !(Single.IsNaN(this.m_TextRotateAngle) || this.m_TextRotateAngle % 360f == 0f);//是否需要旋转
            Rectangle textRect = needRotate ? RenderEngine.RotateRect(this.m_Graphics, this.CurrentTextPreferredRect, this.m_TextRotateAngle, false) : this.CurrentTextPreferredRect; //新绘图区域(如果旋转则为旋转后的区域)
 
            //绘制阴影或描边
            if (this.m_TextShadowShapeStyle != 0)
            {
                using (new SmoothingModeGraphics(this.m_Graphics, SmoothingMode.AntiAlias))
                {
                    using (GraphicsPath textPath = new GraphicsPath())
                    {
                        //添加文本
                        textPath.AddString(this.m_Text, this.m_Font.FontFamily, (int)this.m_Font.Style, this.m_Graphics.DpiY * this.m_Font.SizeInPoints / 72f, textRect, layout.CurrentStringFormat);
 
                        //绘制阴影和阴影描边
                        if (((this.m_TextShadowShapeStyle & ShadowShapeStyle.Shadow) != 0) || ((this.m_TextShadowShapeStyle & ShadowShapeStyle.ShapeOfShadow) != 0 && this.m_TextShapeOfShadowWidth > 0f))
                        {
                            using (GraphicsPath shadowPath = textPath.Clone() as GraphicsPath)
                            {
                                using (Matrix shadowMatrix = new Matrix(1, 0, 0, 1, this.m_TextShadowMatrixOffset.X, this.m_TextShadowMatrixOffset.Y))
                                {
                                    shadowPath.Transform(shadowMatrix);
                                }
 
                                //绘制阴影
                                if ((this.m_TextShadowShapeStyle & ShadowShapeStyle.Shadow) != 0)
                                {
                                    using (Brush shadowBrush = new SolidBrush(this.m_TextShadowColor))
                                    {
                                        this.m_Graphics.FillPath(shadowBrush, shadowPath);
                                    }
                                }
                                //阴影描边
                                if ((this.m_TextShadowShapeStyle & ShadowShapeStyle.ShapeOfShadow) != 0 && this.m_TextShapeOfShadowWidth > 0f)
                                {
                                    using (Pen shapeOfShadowPen = new Pen(this.m_TextShapeOfShadowColor, this.m_TextShapeOfShadowWidth))
                                    {
                                        this.m_Graphics.DrawPath(shapeOfShadowPen, shadowPath);
                                    }
                                }
                            }
                        }
 
                        //绘制文本
                        using (Brush textBrush = new SolidBrush(this.CurrentForeColor))
                        {
                            this.m_Graphics.FillPath(textBrush, textPath);
                        }
 
                        //文本描边
                        if ((this.m_TextShadowShapeStyle & ShadowShapeStyle.ShapeOfText) != 0 && this.m_TextShapeOfTextWidth > 0f)
                        {
                            using (Pen shapeOfTextPen = new Pen(this.m_TextShapeOfTextColor, this.m_TextShapeOfTextWidth))
                            {
                                this.m_Graphics.DrawPath(shapeOfTextPen, textPath);
                            }
                        }
                    }
                }
            }
            else
            {
                using (new TextRenderingHintGraphics(this.m_Graphics, this.m_TextRenderingHint))
                {
                    using (Brush textBrush = new SolidBrush(this.CurrentForeColor))
                    {
                        this.m_Graphics.DrawString(this.m_Text, this.m_Font, textBrush, textRect, layout.CurrentStringFormat);
                    }
                }
            }
 
            //恢复旋转
            if (needRotate)
                this.m_Graphics.ResetTransform();
        }
        //渲染图片核心方法
        private void RenderImageCore(LayoutData layout)
        {
            layout.DoLayout();//执行布局
            this.CurrentImagePreferredRect = layout.OutImageBounds;//保存图片区域矩形
            bool needRotate = !(float.IsNaN(this.m_ImageRotateAngle) || this.m_ImageRotateAngle % 360f == 0f);//是否需要旋转
            Rectangle imageBounds = needRotate ? RenderEngine.RotateRect(this.m_Graphics, this.CurrentImagePreferredRect, this.m_ImageRotateAngle, false) : this.CurrentImagePreferredRect;//新绘图区域(如果旋转则为旋转后的区域)
 
            //开始绘制
            if (this.m_State == State.Disabled && this.m_ImageGrayOnDisabled)
            {
                using (Image grayImg = RenderEngine.GetGrayImage(this.CurrentImage))
                {
                    this.m_Graphics.DrawImage(grayImg, imageBounds);
                }
            }
            else
            {
                this.m_Graphics.DrawImage(this.CurrentImage, imageBounds);
            }
 
            //恢复旋转
            if (needRotate)
                this.m_Graphics.ResetTransform();
        }
 
        /// <summary>
        /// 创建区域
        /// </summary>
        /// <param name="rect">区域位置和大小</param>
        /// <returns>区域</returns>
        public Region CreateRegion(Rectangle rect)
        {
            if (this.m_RoundStyle == RoundStyle.None)//直角
            {
                if ((this.m_RoundCornerStyle & CornerStyle.Horizontal) != 0)
                    rect.Inflate(2, 0);
                else if ((this.m_RoundCornerStyle & CornerStyle.Vertical) != 0)
                    rect.Inflate(0, 2);
                else
                    return null;
            }
            else//有圆角
            {
                if ((this.m_RoundCornerStyle & CornerStyle.Horizontal) != 0)
                    rect.Inflate(5, 1);
                else if ((this.m_RoundCornerStyle & CornerStyle.Vertical) != 0)
                    rect.Inflate(1, 5);
                else
                    return null;
            }
 
            using (GraphicsPath path = RenderEngine.CreateGraphicsPath(rect, this.m_RoundCornerStyle, this.m_RoundStyle, this.m_RoundRadius, false))
            {
                return new Region(path);
            }
        }
 
        /// <summary>
        /// 渲染背景色
        /// </summary>
        /// <param name="rect">渲染区域</param>
        public void RenderBackColor(Rectangle rect)
        {
            this.m_BackColorRect = rect;
 
            if (this.m_State == State.Hidden || !RectangleEx.IsVisible(this.m_BackColorRect))
                return;
 
            using (Brush brush = RenderEngine.CreateBrush(this.CurrentBackColorBrushRect, this.CurrentBackColor, this.m_BackColorPos1, this.m_BackColorPos2, this.CurrentBackColorReverse, this.CurrentBackColorMode, this.m_BackColorBlendStyle))
            {
                if (float.IsNaN(this.m_RoundRadius) || this.m_RoundRadius <= 0f)
                    this.m_Graphics.FillRectangle(brush, this.CurrentBackColorPathRect);
                else
                    this.m_Graphics.FillPath(brush, this.CurrentBackColorPath);
            }
        }
        /// <summary>
        /// 渲染背景色特效
        /// </summary>
        public void RenderBackColorAero()
        {
            if (this.m_State == State.Hidden || !RectangleEx.IsVisible(this.m_BackColorRect))
                return;
 
            //绘制模糊效果
            if ((this.m_BackColorAeroStyle & AeroStyle.Blur) != 0)
            {
                Rectangle blurRect = this.CurrentBackColorPathRect;
                int blurWidth = 0;
                int blurHeight = 0;
                switch (this.m_BackColorAlign)
                {
                    case TabAlignment.Top:
                        blurHeight = (int)(this.CurrentBackColorPathRect.Height * this.m_BackColorAeroPos);
                        blurRect.Height = blurHeight;
                        break;
 
                    case TabAlignment.Bottom:
                        blurHeight = (int)(this.CurrentBackColorPathRect.Height * this.m_BackColorAeroPos);
                        blurRect.Y = blurRect.Bottom - blurHeight;
                        blurRect.Height = blurHeight;
                        break;
 
                    case TabAlignment.Left:
                        blurWidth = (int)(this.CurrentBackColorPathRect.Width * this.m_BackColorAeroPos);
                        blurRect.Width = blurWidth;
                        break;
 
                    case TabAlignment.Right:
                        blurWidth = (int)(this.CurrentBackColorPathRect.Width * this.m_BackColorAeroPos);
                        blurRect.X = blurRect.Right - blurWidth;
                        blurRect.Width = blurWidth;
                        break;
 
                    default://同Top
                        blurHeight = (int)(this.CurrentBackColorPathRect.Height * this.m_BackColorAeroPos);
                        blurRect.Height = blurHeight;
                        break;
                }
 
                //绘制
                RenderEngine.DrawAeroBlur(this.m_Graphics, blurRect, this.m_BackColorAeroBlurColor);
            }
 
            //绘制玻璃效果
            if ((this.m_BackColorAeroStyle & AeroStyle.Glass) != 0)
            {
                Rectangle glassRect = this.CurrentBackColorPathRect;
                int blurWidth = 0;
                int blurHeight = 0;
                switch (this.m_BackColorAlign)
                {
                    case TabAlignment.Top:
                        blurHeight = (int)(glassRect.Height * this.BackColorAeroPos);
                        glassRect.Y += blurHeight;//底部
                        glassRect.Height = (glassRect.Height - blurHeight) * 2;//圆的一半
                        break;
 
                    case TabAlignment.Bottom:
                        blurHeight = (int)(glassRect.Height * this.BackColorAeroPos);
                        glassRect.Y -= (glassRect.Height - blurHeight);//顶部
                        glassRect.Height = (this.CurrentBackColorPathRect.Height - blurHeight) * 2;//圆的一半
                        break;
 
 
                    case TabAlignment.Left:
                        blurWidth = (int)(glassRect.Width * this.BackColorAeroPos);
                        glassRect.X += blurWidth;//右侧
                        glassRect.Width = (glassRect.Width - blurWidth) * 2;//圆的一半
                        break;
 
 
                    case TabAlignment.Right:
                        blurWidth = (int)(glassRect.Width * this.BackColorAeroPos);
                        glassRect.X -= (glassRect.Width - blurWidth);//左侧
                        glassRect.Width = (glassRect.Width - blurWidth) * 2;//圆的一般
                        break;
 
                    default://同Top
                        blurHeight = (int)(glassRect.Height * this.BackColorAeroPos);
                        glassRect.Y += blurHeight;//底部
                        glassRect.Height = (glassRect.Height - blurHeight) * 2;//圆的一半
                        break;
                }
 
                //绘制
                RenderEngine.DrawAeroGlass(this.m_Graphics, glassRect, this.BackColorAeroGlassCenterColor, this.BackColorAeroGlassSurroundColor);
            }
        }
        /// <summary>
        /// 渲染背景图
        /// </summary>
        /// <param name="rect">渲染区域</param>
        public void RenderBackgroundImage(Rectangle rect)
        {
            this.m_BackgroundImageRect = rect;
 
            if (this.m_State == State.Hidden || !RectangleEx.IsVisible(this.m_BackgroundImageRect) || this.CurrentBackgroundImage == null)
                return;
 
            if (this.m_State == State.Disabled && this.m_BackgroundImageGrayOnDisabled)//灰色图片
            {
                using (Image img = RenderEngine.GetGrayImage(this.CurrentBackgroundImage))
                {
                    RenderEngine.DrawBackgroundImage(this.m_Graphics, img, this.CurrentBackgroundImageRect, this.m_BackgroundImageLayout);
                }
            }
            else//原图
            {
                RenderEngine.DrawBackgroundImage(this.m_Graphics, this.CurrentBackgroundImage, this.CurrentBackgroundImageRect, this.m_BackgroundImageLayout);
            }
        }
        /// <summary>
        /// 渲染九宫格背景图
        /// </summary>
        /// <param name="rect">渲染区域</param>
        public void RenderBackgroundImage9(Rectangle rect)
        {
            this.m_BackgroundImage9Rect = rect;
 
            if (this.m_State == State.Hidden || !RectangleEx.IsVisible(this.m_BackgroundImage9Rect) || this.CurrentBackgroundImage9 == null)
                return;
 
            if (this.m_State == State.Disabled && this.m_BackgroundImage9GrayOnDisabled)//灰色图片
            {
                using (Image img = RenderEngine.GetGrayImage(this.CurrentBackgroundImage9))
                {
                    RenderEngine.DrawBackgroundImage9(this.m_Graphics, img, this.CurrentBackgroundImage9Rect, this.m_BackgroundImage9Padding.Left, this.m_BackgroundImage9Padding.Top, this.m_BackgroundImage9Padding.Right, this.m_BackgroundImage9Padding.Bottom, this.m_BackgroundImage9Layout);
                }
            }
            else//原图
            {
                RenderEngine.DrawBackgroundImage9(this.m_Graphics, this.CurrentBackgroundImage9, this.CurrentBackgroundImage9Rect, this.m_BackgroundImage9Padding.Left, this.m_BackgroundImage9Padding.Top, this.m_BackgroundImage9Padding.Right, this.m_BackgroundImage9Padding.Bottom, this.m_BackgroundImage9Layout);
            }
        }
        /// <summary>
        /// 渲染文本和图片
        /// </summary>
        /// <param name="rect">渲染区域</param>
        public void RenderTextAndImage(Rectangle rect)
        {
            this.m_TextImageRect = rect;
 
            if (this.m_State == State.Hidden || !RectangleEx.IsVisible(this.m_TextImageRect) || ((this.m_Text == null || this.m_Text.Length <= 0) && this.m_Image == null))
                return;
 
            using (LayoutData layout = new LayoutData())
            {
                layout.Graphics = this.m_Graphics;
 
                layout.ClientRectangle = this.CurrentTextImageClientRect;
                layout.Padding = this.m_Padding;
                layout.TextImageRelation = this.m_TextImageRelation;
                layout.RightToLeft = this.m_RightToLeft;
 
                layout.ImageSize = (this.CurrentImage == null ? Size.Empty : this.m_ImageSize);
                layout.ImageAlign = this.m_ImageAlign;
                layout.ImageOffset = this.m_ImageOffset;
 
                layout.Text = this.m_Text;
                layout.Font = this.m_Font;
                layout.TextAlign = this.m_TextAlign;
                layout.TextOffset = this.m_TextOffset;
 
                if (this.CurrentImage != null)
                    this.RenderImageCore(layout);
 
                if (this.Text != null && this.Text.Length > 0)
                    this.RenderTextCore(layout);
            }
        }
        /// <summary>
        /// 渲染文本
        /// </summary>
        /// <param name="rect">渲染区域</param>
        public void RenderText(Rectangle rect)
        {
            this.m_TextImageRect = rect;
 
            if (this.m_State == State.Hidden || !RectangleEx.IsVisible(this.m_TextImageRect) || this.Text == null || this.Text.Length <= 0)
                return;
 
            using (LayoutData layout = new LayoutData())
            {
                layout.Graphics = this.m_Graphics;
 
                layout.ClientRectangle = this.CurrentTextImageClientRect;
                layout.Padding = this.m_Padding;
                layout.TextImageRelation = this.m_TextImageRelation;
                layout.RightToLeft = this.m_RightToLeft;
 
                layout.Text = this.m_Text;
                layout.Font = this.m_Font;
                layout.TextAlign = this.m_TextAlign;
                layout.TextOffset = this.m_TextOffset;
 
                this.RenderTextCore(layout);
            }
        }
        /// <summary>
        /// 渲染图片
        /// </summary>
        /// <param name="rect">渲染区域</param>
        public void RenderImage(Rectangle rect)
        {
            this.m_TextImageRect = rect;
 
            if (this.m_State == State.Hidden || !RectangleEx.IsVisible(this.m_TextImageRect) || this.CurrentImage == null)
                return;
 
            using (LayoutData layout = new LayoutData())
            {
                layout.Graphics = this.m_Graphics;
 
                layout.ClientRectangle = this.CurrentTextImageClientRect;
                layout.Padding = this.m_Padding;
                layout.TextImageRelation = this.m_TextImageRelation;
                layout.RightToLeft = this.m_RightToLeft;
 
                layout.ImageSize = (this.CurrentImage == null ? Size.Empty : this.m_ImageSize);
                layout.ImageAlign = this.m_ImageAlign;
                layout.ImageOffset = this.m_ImageOffset;
 
                this.RenderImageCore(layout);
            }
        }
        /// <summary>
        /// 准备渲染字符串路径,返回字符串路径的大小(测量字符串路径大小,画布无限制)
        /// </summary>
        /// <returns>字符串路径大小</returns>
        public Size BeginRenderString()
        {
            if (this.m_State == State.Hidden || this.Text == null || this.Text.Length <= 0)
                return Size.Empty;
 
            Size strSize;
            this.m_CurrentStringPathRect = RenderEngine.BeginDrawString(this.m_Graphics, this.Text, this.Font, out strSize);
            this.m_CurrentStringSize = strSize;
            return this.CurrentStringPathRect.Size;
        }
        /// <summary>
        /// 准备渲染字符串路径,返回字符串路径的大小(测量字符串路径大小,画布有限制)
        /// </summary>
        /// <param name="rect">测量时,画布限制.与绘制区域无关</param>
        /// <returns>字符串路径大小</returns>
        public Size BeginRenderString(Rectangle rect)
        {
            if (this.m_State == State.Hidden || !RectangleEx.IsVisible(rect) || this.Text == null || this.Text.Length <= 0)
                return Size.Empty;
 
            Size strSize;
            this.m_CurrentStringPathRect = RenderEngine.BeginDrawString(this.m_Graphics, this.Text, this.Font, rect, out strSize);
            this.m_CurrentStringSize = strSize;
            return this.CurrentStringPathRect.Size;
        }
        /// <summary>
        /// 正式渲染字符串路径
        /// </summary>
        /// <param name="rect">渲染区域</param>
        public void EndRenderString(Rectangle rect)
        {
            this.m_StringRect = rect;
 
            if (this.m_State == State.Hidden || !RectangleEx.IsVisible(this.m_StringRect) || this.Text == null || this.Text.Length <= 0)
                return;
 
            using (Brush brush = new SolidBrush(this.CurrentForeColor))
            {
                RenderEngine.EndDrawString(this.m_Graphics, this.m_Text, this.m_Font, brush, this.CurrentStringRect, this.m_TextAlign, this.CurrentStringPathRect, this.CurrentStringSize);
            }
        }
        /// <summary>
        /// 渲染字符串路径
        /// </summary>
        /// <param name="rect">渲染区域</param>
        public void RenderString(Rectangle rect)
        {
            this.BeginRenderString(rect);
            this.EndRenderString(rect);
        }
        /// <summary>
        /// 渲染边框颜色(RoundStyle圆角样式,BorderStyle确定绘制哪个边,BlendStyle混合方式)
        /// </summary>
        /// <param name="rect">渲染区域</param>
        public void RenderBorder(Rectangle rect)
        {
            this.m_BorderColorRect = rect;
 
            if (this.m_State == State.Hidden || !RectangleEx.IsVisible(this.m_BorderColorRect))
                return;
 
            //重置剪切区
            this.m_Graphics.SetClip(this.m_GraphicsClip, CombineMode.Replace);
 
            //绘制内边框
            if (this.m_InnerBorderVisibleStyle != BorderVisibleStyle.None)
            {
                using (Brush brush = RenderEngine.CreateBrush(this.CurrentInnerBorderBrushRect, this.CurrentInnerBorderColor, this.m_InnerBorderColorPos1, this.m_InnerBorderColorPos2, this.CurrentBackColorReverse, this.CurrentBackColorMode, this.m_InnerBorderBlendStyle))
                {
                    using (Pen pen = RenderEngine.CreatePen(brush, 1, this.m_InnerBorderDashStyle, this.m_InnerBorderDashPattern, this.m_InnerBorderDashCap, this.m_InnerBorderDashOffset))
                    {
                        RenderEngine.DrawBorder(this.m_Graphics, pen, this.CurrentInnerBorderPathRect, this.m_InnerBorderVisibleStyle, this.m_RoundCornerStyle, this.m_RoundStyle, this.m_RoundRadius, false);
                    }
                }
            }
 
            //绘制边框
            if (this.m_BorderVisibleStyle != BorderVisibleStyle.None)
            {
                using (Brush brush = RenderEngine.CreateBrush(this.CurrentBorderBrushRect, this.CurrentBorderColor, this.m_BorderColorPos1, this.m_BorderColorPos2, this.CurrentBackColorReverse, this.CurrentBackColorMode, this.m_BorderBlendStyle))
                {
                    using (Pen pen = RenderEngine.CreatePen(brush, 1, this.m_BorderDashStyle, this.m_BorderDashPattern, this.m_BorderDashCap, this.m_BorderDashOffset))
                    {
                        RenderEngine.DrawBorder(this.m_Graphics, pen, this.CurrentBorderPathRect, this.m_BorderVisibleStyle, this.m_RoundCornerStyle, this.m_RoundStyle, this.m_RoundRadius, false);
                    }
                }
            }
        }
        /// <summary>
        /// 渲染线段
        /// </summary>
        /// <param name="pt1">起点</param>
        /// <param name="pt2">终点</param>
        public void RenderLine(Point pt1, Point pt2)
        {
            if (this.m_State == State.Hidden || pt1 == pt2)
                return;
 
            //使用边框颜色
            using (Brush brush = RenderEngine.CreateBrush(pt1, pt2, this.CurrentLineColor, this.m_LineBlendStyle))
            {
                using (Pen pen = RenderEngine.CreatePen(brush, this.m_LineWidth, this.m_LineDashStyle, this.m_LineDashPattern, this.m_LineDashCap, this.m_LineDashOffset))
                {
                    this.m_Graphics.DrawLine(pen, pt1, pt2);
                }
            }
        }
 
        /// <summary>
        /// 渲染对号(按比例渲染)
        /// </summary>
        /// <param name="rect">渲染区域</param>
        public void RenderCheck(Rectangle rect)
        {
            if (this.m_State == State.Hidden || !RectangleEx.IsVisible(rect))
                return;
 
            this.CurrentTextPreferredRect = rect;
            RenderEngine.DrawCheck(this.m_Graphics, this.CurrentTextPreferredRect, this.CurrentForeColor);
        }
        /// <summary>
        /// 渲染叉号(按比例渲染)
        /// </summary>
        /// <param name="rect">渲染区域</param>
        public void RenderCross(Rectangle rect)
        {
            if (this.m_State == State.Hidden || !RectangleEx.IsVisible(rect))
                return;
 
            this.CurrentTextPreferredRect = rect;
            RenderEngine.DrawCross(this.m_Graphics, this.CurrentTextPreferredRect, this.CurrentForeColor);
        }
        /// <summary>
        /// 渲染省略号(按比例渲染)
        /// </summary>
        /// <param name="rect">渲染区域</param>
        public void RenderEllipsis(Rectangle rect)
        {
            if (this.m_State == State.Hidden || !RectangleEx.IsVisible(rect))
                return;
 
            this.CurrentTextPreferredRect = rect;
            RenderEngine.DrawEllipsis(this.m_Graphics, this.CurrentTextPreferredRect, this.CurrentForeColor);
        }
        /// <summary>
        /// 渲染箭头(按比例渲染)
        /// </summary>
        /// <param name="rect">渲染区域</param>
        /// <param name="direction">箭头方向</param>
        public void RenderArrow(Rectangle rect, ArrowDirection direction)
        {
            if (this.m_State == State.Hidden || !RectangleEx.IsVisible(rect))
                return;
 
            this.CurrentTextPreferredRect = rect;
            RenderEngine.DrawArrow(this.m_Graphics, this.CurrentTextPreferredRect, this.CurrentForeColor, direction);
        }
        /// <summary>
        /// 渲染箭头(固定大小)
        /// </summary>
        /// <param name="rect">渲染区域</param>
        /// <param name="direction">箭头方向</param>
        /// <param name="style">大小样式</param>
        public void RenderArrow(Rectangle rect, ArrowDirection direction, SizeStyle style)
        {
            if (this.m_State == State.Hidden || !RectangleEx.IsVisible(rect))
                return;
 
            this.CurrentTextPreferredRect = rect;
            RenderEngine.DrawArrow(this.m_Graphics, this.CurrentTextPreferredRect, this.CurrentForeColor, direction, style);
        }
        /// <summary>
        /// 渲染Metrol按下边框
        /// </summary>
        /// <param name="rect">渲染区域</param>
        public void RenderMetroPress(Rectangle rect)
        {
            if (this.m_State == State.Hidden || !RectangleEx.IsVisible(rect))
                return;
 
            //左侧
            if ((this.m_InnerBorderVisibleStyle & BorderVisibleStyle.Left) != 0)
            {
                rect.X += 2;
                rect.Width -= 2;
            }
            else if ((this.m_BorderVisibleStyle & BorderVisibleStyle.Left) != 0)
            {
                rect.X += 1;
                rect.Width -= 1;
            }
 
            //上边
            if ((this.m_InnerBorderVisibleStyle & BorderVisibleStyle.Top) != 0)
            {
                rect.Y += 2;
                rect.Height -= 2;
            }
            else if ((this.m_BorderVisibleStyle & BorderVisibleStyle.Top) != 0)
            {
                rect.Y += 1;
                rect.Height -= 1;
            }
 
            //右边
            if ((this.m_InnerBorderVisibleStyle & BorderVisibleStyle.Right) != 0)
            {
                rect.Width -= 2;
            }
            else if ((this.m_BorderVisibleStyle & BorderVisibleStyle.Right) != 0)
            {
                rect.Width -= 1;
            }
 
            //下边
            if ((this.m_InnerBorderVisibleStyle & BorderVisibleStyle.Bottom) != 0)
            {
                rect.Height -= 2;
            }
            else if ((this.m_BorderVisibleStyle & BorderVisibleStyle.Bottom) != 0)
            {
                rect.Height -= 1;
            }
 
            //设置剪切区
            this.m_Graphics.SetClip(rect);
 
            //绘制宽边框
            using (GraphicsPath pathBorder = RenderEngine.CreateGraphicsPath(rect),
                pathBorderIn = RenderEngine.CreateGraphicsPath(Rectangle.Inflate(rect, -3, -3)))
            {
                //边框区域
                pathBorder.AddPath(pathBorderIn, true);
 
                //绘制
                using (Brush brush = new SolidBrush(this.CurrentBorderColor))
                {
                    this.m_Graphics.FillPath(brush, pathBorder);
                }
            }
        }
        /// <summary>
        /// 绘制Metrol选中边框
        /// </summary>
        /// <param name="rect">渲染区域</param>
        public void RenderMetroCheck(Rectangle rect)
        {
            if (this.m_State == State.Hidden || !RectangleEx.IsVisible(rect))
                return;
 
            //左侧
            if ((this.m_InnerBorderVisibleStyle & BorderVisibleStyle.Left) != 0)
            {
                rect.X += 2;
                rect.Width -= 2;
            }
            else if ((this.m_BorderVisibleStyle & BorderVisibleStyle.Left) != 0)
            {
                rect.X += 1;
                rect.Width -= 1;
            }
 
            //上边
            if ((this.m_InnerBorderVisibleStyle & BorderVisibleStyle.Top) != 0)
            {
                rect.Y += 2;
                rect.Height -= 2;
            }
            else if ((this.m_BorderVisibleStyle & BorderVisibleStyle.Top) != 0)
            {
                rect.Y += 1;
                rect.Height -= 1;
            }
 
            //右边
            if ((this.m_InnerBorderVisibleStyle & BorderVisibleStyle.Right) != 0)
            {
                rect.Width -= 2;
            }
            else if ((this.m_BorderVisibleStyle & BorderVisibleStyle.Right) != 0)
            {
                rect.Width -= 1;
            }
 
            //下边
            if ((this.m_InnerBorderVisibleStyle & BorderVisibleStyle.Bottom) != 0)
            {
                rect.Height -= 2;
            }
            else if ((this.m_BorderVisibleStyle & BorderVisibleStyle.Bottom) != 0)
            {
                rect.Height -= 1;
            }
 
            //设置剪切区
            this.m_Graphics.SetClip(rect);
 
            //绘制宽边框
            using (GraphicsPath pathBorder = RenderEngine.CreateGraphicsPath(rect),
                pathBorderIn = RenderEngine.CreateGraphicsPath(Rectangle.Inflate(rect, -3, -3)),
                pathTriangle = new GraphicsPath())
            {
                //边框区域
                pathBorder.AddPath(pathBorderIn, true);
 
                //右上角三角区域
                Point[] points = new Point[] {
                    new Point(rect.X + rect.Width - 40, rect.Y),
                    new Point(rect.X + rect.Width, rect.Y),
                    new Point(rect.X + rect.Width, rect.Y + 40) 
                };
                pathTriangle.AddPolygon(points);
 
                //绘制
                using (Brush brush = new SolidBrush(this.CurrentBackColor))
                {
                    this.m_Graphics.FillPath(brush, pathBorder);
                    this.m_Graphics.FillPath(brush, pathTriangle);
                }
            }
 
            //绘制对号
            RenderEngine.DrawCheck(this.m_Graphics, new Rectangle(rect.Right - 22, rect.Y + 2, 20, 20), this.CurrentForeColor);
        }
        /// <summary>
        /// 渲染标签样式分组控件背景色
        /// </summary>
        /// <param name="rect">渲染区域</param>
        /// <param name="tabSize">左上角标签大小</param>
        /// <param name="tabRound">标签右上角是否发圆角</param>
        /// <param name="tabRadius">标签右上角圆角半径</param>
        public void RenderBackColorGroupBoxTab(Rectangle rect, Size tabSize, bool tabRound, float tabRadius)
        {
            this.m_BackColorRect = rect;
 
            if (this.m_State == State.Hidden || !RectangleEx.IsVisible(this.m_BackColorRect))
                return;
 
            using (Brush brush = RenderEngine.CreateBrush(this.CurrentBackColorBrushRect, this.CurrentBackColor, this.m_BackColorPos1, this.m_BackColorPos2, this.CurrentBackColorReverse, this.CurrentBackColorMode, this.m_BackColorBlendStyle))
            {
                //校正背景区域
                if (this.m_InnerBorderVisibleStyle != BorderVisibleStyle.None)
                    tabSize.Width -= 4;
                else if (this.m_BorderVisibleStyle != BorderVisibleStyle.None)
                    tabSize.Width -= 2;
                using (GraphicsPath path = RenderEngine.CreateGroupBoxTabGraphicsPath(this.CurrentBackColorPathRect, this.m_RoundStyle, this.m_RoundRadius, tabSize, tabRound, tabRadius, false))
                {
                    this.m_Graphics.SetClip(path, CombineMode.Intersect);
                    this.m_Graphics.FillPath(brush, path);
                }
            }
        }
        /// <summary>
        /// 渲染标签样式分组控件边框色
        /// </summary>
        /// <param name="rect">渲染区域</param>
        /// <param name="tabSize">左上角标签大小</param>
        /// <param name="tabRound">标签右上角是否发圆角</param>
        /// <param name="tabRadius">标签右上角圆角半径</param>
        public void RenderBorderColorGroupBoxTab(Rectangle rect, Size tabSize, bool tabRound, float tabRadius)
        {
            this.m_BorderColorRect = rect;
 
            if (this.m_State == State.Hidden || !RectangleEx.IsVisible(this.m_BorderColorRect))
                return;
 
            //重置剪切区
            this.m_Graphics.SetClip(this.m_GraphicsClip, CombineMode.Replace);
 
            //绘制内边框
            if (this.m_InnerBorderVisibleStyle != BorderVisibleStyle.None)
            {
                using (Brush brush = RenderEngine.CreateBrush(this.CurrentInnerBorderBrushRect, this.CurrentInnerBorderColor, this.m_InnerBorderColorPos1, this.m_InnerBorderColorPos2, this.CurrentBackColorReverse, this.CurrentBackColorMode, this.m_InnerBorderBlendStyle))
                {
                    using (Pen pen = RenderEngine.CreatePen(brush, 1, this.m_InnerBorderDashStyle, this.m_InnerBorderDashPattern, this.m_InnerBorderDashCap, this.m_InnerBorderDashOffset))
                    {
                        Size innerBorderTabSize = new Size(tabSize.Width - 3, tabSize.Height);
                        using (GraphicsPath path = RenderEngine.CreateGroupBoxTabGraphicsPath(this.CurrentInnerBorderPathRect, this.m_RoundStyle, this.m_RoundRadius, innerBorderTabSize, tabRound, tabRadius, false))
                        {
                            this.m_Graphics.DrawPath(pen, path);
                        }
                    }
                }
            }
 
            //绘制边框
            if (this.m_BorderVisibleStyle != BorderVisibleStyle.None)
            {
                using (Brush brush = RenderEngine.CreateBrush(this.CurrentBorderBrushRect, this.CurrentBorderColor, this.m_BorderColorPos1, this.m_BorderColorPos2, this.CurrentBackColorReverse, this.CurrentBackColorMode, this.m_BorderBlendStyle))
                {
                    using (Pen pen = RenderEngine.CreatePen(brush, 1, this.m_BorderDashStyle, this.m_BorderDashPattern, this.m_BorderDashCap, this.m_BorderDashOffset))
                    {
                        Size borderTabSize = new Size(tabSize.Width - 1, tabSize.Height);
                        using (GraphicsPath path = RenderEngine.CreateGroupBoxTabGraphicsPath(this.CurrentBorderPathRect, this.m_RoundStyle, this.m_RoundRadius, borderTabSize, tabRound, tabRadius, false))
                        {
                            this.m_Graphics.DrawPath(pen, path);
                        }
                    }
                }
            }
        }
    }
}