yangyin
2025-03-27 b0de14c2670b9ff0079dacfb4b7457b438368f11
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
#region Imports
 
using System.Drawing;
using System.Windows.Forms;
 
#endregion
 
namespace DPumpHydr.WinFrmUI.RLT.Controls
{
    #region DungeonTabPage
 
    public class DungeonTabPage : TabControl
    {
        public Color BaseColor { get; set; } = Color.Transparent;
        public Color DeactivePageTextColor { get; set; } = Color.FromArgb(80, 76, 76);
        public Color PageEdgeColor { get; set; } = Color.FromArgb(247, 246, 246);
        public Color PageEdgeBorderColor { get; set; } = Color.FromArgb(201, 198, 195);
        public Color ActivePageBorderColor { get; set; } = Color.FromArgb(201, 198, 195);
        public Color ActivePageBackColor { get; set; } = Color.FromArgb(247, 246, 246);
        public Color PageBackColor { get; set; } = Color.FromArgb(247, 246, 246);
        public Color ActivePageTextColor { get; set; } = Color.FromArgb(80, 76, 76);
 
        public DungeonTabPage()
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.UserPaint, true);
        }
 
        protected override void CreateHandle()
        {
            base.CreateHandle();
 
            ItemSize = new(80, 24);
            Alignment = TabAlignment.Top;
        }
 
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics G = e.Graphics;
            Rectangle ItemBoundsRect = new();
            G.Clear(BaseColor);
            for (int TabIndex = 0; TabIndex <= TabCount - 1; TabIndex++)
            {
                ItemBoundsRect = GetTabRect(TabIndex);
                if (!(TabIndex == SelectedIndex))
                {
                    G.DrawString(TabPages[TabIndex].Text, new Font(Font.Name, Font.Size - 2, FontStyle.Bold), new SolidBrush(DeactivePageTextColor), new Rectangle(GetTabRect(TabIndex).Location, GetTabRect(TabIndex).Size), new StringFormat
                    {
                        LineAlignment = StringAlignment.Center,
                        Alignment = StringAlignment.Center
                    });
                }
            }
 
            // Draw container rectangle
            G.FillPath(new SolidBrush(PageEdgeColor), RoundRectangle.RoundRect(0, 23, Width - 1, Height - 24, 2));
            G.DrawPath(new(PageEdgeBorderColor), RoundRectangle.RoundRect(0, 23, Width - 1, Height - 24, 2));
 
            for (int ItemIndex = 0; ItemIndex <= TabCount - 1; ItemIndex++)
            {
                ItemBoundsRect = GetTabRect(ItemIndex);
                if (ItemIndex == SelectedIndex)
                {
 
                    // Draw header tabs
                    G.DrawPath(new(ActivePageBorderColor), RoundRectangle.RoundedTopRect(new Rectangle(new Point(ItemBoundsRect.X - 2, ItemBoundsRect.Y - 2), new Size(ItemBoundsRect.Width + 3, ItemBoundsRect.Height)), 7));
                    G.FillPath(new SolidBrush(ActivePageBackColor), RoundRectangle.RoundedTopRect(new Rectangle(new Point(ItemBoundsRect.X - 1, ItemBoundsRect.Y - 1), new Size(ItemBoundsRect.Width + 2, ItemBoundsRect.Height)), 7));
 
                    try
                    {
                        G.DrawString(TabPages[ItemIndex].Text, new Font(Font.Name, Font.Size - 1, FontStyle.Bold), new SolidBrush(ActivePageTextColor), new Rectangle(GetTabRect(ItemIndex).Location, GetTabRect(ItemIndex).Size), new StringFormat
                        {
                            LineAlignment = StringAlignment.Center,
                            Alignment = StringAlignment.Center
                        });
                        TabPages[ItemIndex].BackColor = PageBackColor;
                    }
                    catch
                    {
                    }
                }
            }
        }
    }
 
    #endregion
}