ホテル管理システム
ogi
yesterday 1a1c8e71fcd14858f595029f089b2d4a00202b32
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
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;
 
namespace HotelPms.Share.Windows.Component
{
    public partial class FunctionKeyBar : System.Windows.Forms.Control
    {
        private float m_Split = 5;
        StringFormat format = new StringFormat();
        RectangleF[] cellsRectTitle = new RectangleF[12];
        RectangleF[] cellsRectKey = new RectangleF[12];
        private string[] m_KeyContext = new string[] { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty,
                                                       string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty};
 
        /// <summary>
        /// F1の機能名
        /// </summary>
        public string KeyContextF01
        {
            set { m_KeyContext[0] = value; Invalidate(); }
            get { return m_KeyContext[0]; }
        }
 
        /// <summary>
        /// F2の機能名
        /// </summary>
        public string KeyContextF02
        {
            set { m_KeyContext[1] = value; Invalidate(); }
            get { return m_KeyContext[1]; }
        }
 
        /// <summary>
        /// F3の機能名
        /// </summary>
        public string KeyContextF03
        {
            set { m_KeyContext[2] = value; Invalidate(); }
            get { return m_KeyContext[2]; }
        }
 
        /// <summary>
        /// F4の機能名
        /// </summary>
        public string KeyContextF04
        {
            set { m_KeyContext[3] = value; Invalidate(); }
            get { return m_KeyContext[3]; }
        }
 
        /// <summary>
        /// F5の機能名
        /// </summary>
        public string KeyContextF05
        {
            set { m_KeyContext[4] = value; Invalidate(); }
            get { return m_KeyContext[4]; }
        }
 
        /// <summary>
        /// F6の機能名
        /// </summary>
        public string KeyContextF06
        {
            set { m_KeyContext[5] = value; Invalidate(); }
            get { return m_KeyContext[5]; }
        }
 
        /// <summary>
        /// F7の機能名
        /// </summary>
        public string KeyContextF07
        {
            set { m_KeyContext[6] = value; Invalidate(); }
            get { return m_KeyContext[6]; }
        }
 
        /// <summary>
        /// F8の機能名
        /// </summary>
        public string KeyContextF08
        {
            set { m_KeyContext[7] = value; Invalidate(); }
            get { return m_KeyContext[7]; }
        }
 
        /// <summary>
        /// F9の機能名
        /// </summary>
        public string KeyContextF09
        {
            set { m_KeyContext[8] = value; Invalidate(); }
            get { return m_KeyContext[8]; }
        }
 
        /// <summary>
        /// F10の機能名
        /// </summary>
        public string KeyContextF10
        {
            set { m_KeyContext[9] = value; Invalidate(); }
            get { return m_KeyContext[9]; }
        }
 
        /// <summary>
        /// F11の機能名
        /// </summary>
        public string KeyContextF11
        {
            set { m_KeyContext[10] = value; Invalidate(); }
            get { return m_KeyContext[10]; }
        }
 
        /// <summary>
        /// F12の機能名
        /// </summary>
        public string KeyContextF12
        {
            set { m_KeyContext[11] = value; Invalidate(); }
            get { return m_KeyContext[11]; }
        }
 
        private Color m_CaptionBeginColor = Color.Maroon;
 
        public Color CaptionBeginColor
        {
            get { return m_CaptionBeginColor; }
            set { m_CaptionBeginColor = value; Invalidate(); }
        }
 
        private Color m_CaptionEndColor = Color.Gold;
 
        public Color CaptionEndColor
        {
            get { return m_CaptionEndColor; }
            set { m_CaptionEndColor = value; Invalidate(); }
        }
 
 
        public FunctionKeyBar()
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw | ControlStyles.Opaque | ControlStyles.UserPaint | ControlStyles.DoubleBuffer | ControlStyles.Selectable | ControlStyles.UserMouse, true);
            format.Alignment = StringAlignment.Center;
            format.LineAlignment = StringAlignment.Center;            
        }
 
        protected override void OnPaint(PaintEventArgs e)
        {
            float width = (float)(this.Width - this.Padding.Left - this.Padding.Right - 2 * m_Split);
            float height = (float)(this.Height - this.Padding.Top - this.Padding.Bottom);
 
            float cellWidth = width / 12F;
            float cellHeight = height / 2F;
 
            float x = this.Padding.Left;
            for (int i = 0; i < 12; i++)
            { 
                //上
                cellsRectTitle[i] = new RectangleF(new PointF(x, this.Padding.Top), new SizeF(cellWidth, cellHeight));
                
                //下
                cellsRectKey[i] = new RectangleF(new PointF(x, this.Padding.Top + cellHeight), new SizeF(cellWidth, cellHeight));
               
                x += cellWidth;
                if ((i + 1) % 4 == 0) { x += m_Split; }
            }
 
            e.Graphics.FillRectangle(new SolidBrush(this.BackColor), 0, 0, this.Width, this.Height);
            //e.Graphics.FillRectangles(Brushes.Maroon, cellsRectTitle);
 
            for (int i = 0; i < 12; i++)
            {
                using (LinearGradientBrush brush = new LinearGradientBrush(cellsRectTitle[i], m_CaptionBeginColor, m_CaptionEndColor, LinearGradientMode.Vertical))
                {
                    brush.SetSigmaBellShape(0.4f, 0.45f);   //创建基于钟形曲线的渐变过渡过程。
                    e.Graphics.FillRectangle(brush, cellsRectTitle[i]);
                }
            }
           
            e.Graphics.DrawRectangles(System.Drawing.Pens.Black, cellsRectTitle);
 
            for (int i = 0; i < 12; i++)
            {
                string key = string.Format("F{0}", i + 1);
                e.Graphics.DrawString(key, this.Font, Brushes.White, cellsRectTitle[i], format);
 
                if (m_KeyContext[i].Length > 0)
                {
                    using (LinearGradientBrush brush = new LinearGradientBrush(cellsRectKey[i], Color.FromArgb(50, 169, 200), Color.FromArgb(0, 109, 189), LinearGradientMode.Vertical))
                    {
 
                        brush.SetSigmaBellShape(0.4f, 0.45f);   //创建基于钟形曲线的渐变过渡过程。
                        e.Graphics.FillRectangle(brush, cellsRectKey[i]);
                    }
                }
                else
                {
                    e.Graphics.FillRectangle(new SolidBrush((m_KeyContext[i].Length > 0) ? Color.FromArgb(0, 109, 189) : this.BackColor), cellsRectKey[i].X, cellsRectKey[i].Y, cellsRectKey[i].Width, cellsRectKey[i].Height);
                }
                e.Graphics.DrawRectangle(System.Drawing.Pens.Black, cellsRectKey[i].X, cellsRectKey[i].Y, cellsRectKey[i].Width, cellsRectKey[i].Height);
                if (m_KeyContext[i].Length > 0) { e.Graphics.DrawString(m_KeyContext[i], this.Font, Brushes.Yellow, cellsRectKey[i], format); }
            }
            
 
            base.OnPaint(e);
        }
        
    }
}