tangxu
2024-10-22 6a07c4c846ffbb1e93afdf0260e123e4c145f419
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
 
namespace DPumpHydr.WinFrmUI.WenSkin.Forms
{
    public class WenBottomInfoForm : WenForm
    {
        public WenBottomInfoForm() : base()
        {
            this.Name = "WenBottomInfoForm";
            this.Text = "WenBottomInfoForm";
            RefreshPadding();
        }
        private int bottomWidth = 30;
        private string bottomText;
 
        [Category("Wen")]
        [Description("底部信息栏大小")]
        [RefreshProperties(RefreshProperties.All)]
        public int BottomWidth
        {
            get => bottomWidth;
            set
            {
                bottomWidth = value;
                RefreshPadding();
            }
        }
        [Category("Wen")]
        [Description("底部信息栏显示内容")]
        [RefreshProperties(RefreshProperties.All)]
        public string BottomText
        {
            get => bottomText;
            set
            {
                bottomText = value;
                RefreshPadding();
            }
        }
 
        [DefaultValue(typeof(Padding), "30,0,0,30"), Category("布局"), Description("指定控件内部间距")]
        public new Padding Padding { get => base.Padding; set => base.Padding = value; }
 
        protected override void RefreshPadding()
        {
            //this.Padding = new Padding() { Top = TitleHeight, Left = FrameWidth, Bottom = bottomWidth, Right = FrameWidth };
            //this.Invalidate();
            this.Padding = new Padding() { Top = TitleHeight, Left = FrameWidth, Bottom = bottomWidth, Right = FrameWidth };
            this.Invalidate();
        }
 
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics g = e.Graphics;
            DrawBottomInfo(g); 
        }
 
 
        private void DrawBottomInfo(Graphics g)
        {
            Brush b = new SolidBrush(FrameColor);
            g.FillRectangle(b, 0, this.Height - BottomWidth, this.Width, BottomWidth);
 
            //绘制底部信息
            _ = TextRenderer.MeasureText(bottomText, this.Font).Width;
 
            Rectangle rec = new Rectangle(0, this.Height - BottomWidth, this.Width, BottomWidth);
            Rectangle recStr = new Rectangle(10, rec.Y, rec.Width - 20, rec.Height);
 
            g.DrawString(bottomText, this.Font, new SolidBrush(this.ForeColor), recStr,
                new StringFormat(StringFormatFlags.NoClip | StringFormatFlags.NoWrap)
                {
                    LineAlignment = StringAlignment.Center,
                    Alignment = StringAlignment.Far,
                    Trimming = StringTrimming.EllipsisCharacter
                });
        }
 
    }
}