tangxu
2024-12-24 91105b77c916d06dd30380e20594e29f85eae3da
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
#region Imports
 
using DPumpHydr.WinFrmUI.RLT.Colors;
using DPumpHydr.WinFrmUI.RLT.Util;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Windows.Forms;
 
#endregion
 
namespace DPumpHydr.WinFrmUI.RLT.Controls
{
    #region HopeGroupBox
 
    public class HopeGroupBox : System.Windows.Forms.GroupBox
    {
        #region Variables
 
 
        #endregion
 
        #region Settings
 
        [RefreshProperties(RefreshProperties.Repaint)]
        public Color ThemeColor { get; set; } = HopeColors.PrimaryColor;
 
        [RefreshProperties(RefreshProperties.Repaint)]
        public bool ShowText { get; set; } = false;
 
        [RefreshProperties(RefreshProperties.Repaint)]
        public Color LineColor { get; set; } = HopeColors.OneLevelBorder;
 
        [RefreshProperties(RefreshProperties.Repaint)]
        public Color BorderColor { get; set; } = HopeColors.OneLevelBorder;
 
        #endregion
 
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics graphics = e.Graphics;
            graphics.SmoothingMode = SmoothingMode.HighQuality;
            graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
            graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            graphics.Clear(Parent.BackColor);
 
            GraphicsPath BG = RoundRectangle.CreateRoundRect(1, 1, Width - 2, Height - 2, 3);
            graphics.FillPath(new SolidBrush(ThemeColor), BG);
            graphics.DrawPath(new(BorderColor), BG);
 
            if (ShowText)
            {
                graphics.DrawLine(new(LineColor, 1), 0, 38, Width, 38);
                graphics.DrawString(Text, Font, new SolidBrush(ForeColor), new RectangleF(15, 0, Width - 50, 38), HopeStringAlign.Left);
            }
        }
 
        public HopeGroupBox()
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true);
            DoubleBuffered = true;
            Font = new("Segoe UI", 12);
            ForeColor = HopeColors.MainText;
        }
    }
 
    #endregion
}