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
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ShiftUI.Theming.Default;
using System.Drawing;
using ShiftUI.ShiftOS;
using System.Drawing.Drawing2D;
namespace ShiftUI.Theming
{
class ThemeElementsMemphis : ThemeElementsDefault
{
public ThemeElementsMemphis()
{
}
public override ButtonPainter ButtonPainter
{
get
{
return new Memphis.ButtonPainter();
}
}
public override CheckBoxPainter CheckBoxPainter
{
get
{
return new Memphis.CheckBoxPainter();
}
}
}
namespace Memphis
{
internal class CheckBoxPainter : Default.CheckBoxPainter
{
#region Standard
public override void DrawNormalCheckBox(Graphics g, Rectangle bounds, Color backColor, Color foreColor, CheckState state)
{
int check_box_visible_size = (bounds.Height > bounds.Width) ? bounds.Width : bounds.Height;
int x_pos = Math.Max(0, bounds.X + (bounds.Width / 2) - check_box_visible_size / 2);
int y_pos = Math.Max(0, bounds.Y + (bounds.Height / 2) - check_box_visible_size / 2);
Rectangle rect = new Rectangle(x_pos, y_pos, check_box_visible_size, check_box_visible_size);
g.FillRectangle(new SolidBrush(Application.CurrentSkin.CheckBoxBackgroundColor), rect.X + 2, rect.Y + 2, rect.Width - 3, rect.Height - 3);
Pen pen = new Pen(Application.CurrentSkin.Border3DTopLeftInner, 1);
g.DrawLine(pen, rect.X, rect.Y, rect.X, rect.Bottom - 2);
g.DrawLine(pen, rect.X + 1, rect.Y, rect.Right - 2, rect.Y);
pen = new Pen(Application.CurrentSkin.Border3DBottomRight, 1);
g.DrawLine(pen, rect.X + 1, rect.Y + 1, rect.X + 1, rect.Bottom - 3);
g.DrawLine(pen, rect.X + 2, rect.Y + 1, rect.Right - 3, rect.Y + 1);
pen = new Pen(Application.CurrentSkin.Border3DTopLeftInner, 1);
g.DrawLine(pen, rect.Right - 1, rect.Y, rect.Right - 1, rect.Bottom - 1);
g.DrawLine(pen, rect.X, rect.Bottom - 1, rect.Right - 1, rect.Bottom - 1);
// oh boy, matching ms is like fighting against windmills
using (Pen h_pen = new Pen(Application.CurrentSkin.CheckBoxCheckColor))
{
g.DrawLine(h_pen, rect.X + 1, rect.Bottom - 2, rect.Right - 2, rect.Bottom - 2);
g.DrawLine(h_pen, rect.Right - 2, rect.Y + 1, rect.Right - 2, rect.Bottom - 2);
}
if (state == CheckState.Checked)
DrawCheck(g, bounds, Application.CurrentSkin.CheckBoxCheckColor);
else if (state == CheckState.Indeterminate)
DrawCheck(g, bounds, Application.CurrentSkin.CheckBoxCheckColor);
}
public override void DrawHotCheckBox(Graphics g, Rectangle bounds, Color backColor, Color foreColor, CheckState state)
{
DrawNormalCheckBox(g, bounds, backColor, foreColor, state);
}
public override void DrawPressedCheckBox(Graphics g, Rectangle bounds, Color backColor, Color foreColor, CheckState state)
{
int check_box_visible_size = (bounds.Height > bounds.Width) ? bounds.Width : bounds.Height;
int x_pos = Math.Max(0, bounds.X + (bounds.Width / 2) - check_box_visible_size / 2);
int y_pos = Math.Max(0, bounds.Y + (bounds.Height / 2) - check_box_visible_size / 2);
Rectangle rect = new Rectangle(x_pos, y_pos, check_box_visible_size, check_box_visible_size);
g.FillRectangle(new SolidBrush(Application.CurrentSkin.CheckBoxCheckColor), rect.X + 2, rect.Y + 2, rect.Width - 3, rect.Height - 3);
Pen pen = new Pen(Application.CurrentSkin.Border3DBottomRightInner, 1);
g.DrawLine(pen, rect.X, rect.Y, rect.X, rect.Bottom - 2);
g.DrawLine(pen, rect.X + 1, rect.Y, rect.Right - 2, rect.Y);
pen = new Pen(Application.CurrentSkin.Border3DBottomRight, 1);
g.DrawLine(pen, rect.X + 1, rect.Y + 1, rect.X + 1, rect.Bottom - 3);
g.DrawLine(pen, rect.X + 2, rect.Y + 1, rect.Right - 3, rect.Y + 1);
pen = new Pen(Application.CurrentSkin.Border3DTopLeftInner, 1);
g.DrawLine(pen, rect.Right - 1, rect.Y, rect.Right - 1, rect.Bottom - 1);
g.DrawLine(pen, rect.X, rect.Bottom - 1, rect.Right - 1, rect.Bottom - 1);
// oh boy, matching ms is like fighting against windmills
using (Pen h_pen = new Pen(Application.CurrentSkin.CheckBoxCheckColor))
{
g.DrawLine(h_pen, rect.X + 1, rect.Bottom - 2, rect.Right - 2, rect.Bottom - 2);
g.DrawLine(h_pen, rect.Right - 2, rect.Y + 1, rect.Right - 2, rect.Bottom - 2);
}
if (state == CheckState.Checked)
DrawCheck(g, bounds, Application.CurrentSkin.CheckBoxCheckColor);
else if (state == CheckState.Indeterminate)
DrawCheck(g, bounds, Application.CurrentSkin.CheckBoxCheckColor);
}
public override void DrawDisabledCheckBox(Graphics g, Rectangle bounds, Color backColor, Color foreColor, CheckState state)
{
DrawPressedCheckBox(g, bounds, backColor, foreColor, CheckState.Unchecked);
if (state == CheckState.Checked || state == CheckState.Indeterminate)
DrawCheck(g, bounds, SystemColors.ControlDark);
}
#endregion
#region FlatStyle
public override void DrawFlatNormalCheckBox(Graphics g, Rectangle bounds, Color backColor, Color foreColor, CheckState state)
{
DrawNormalCheckBox(g, bounds, backColor, foreColor, state);
}
public override void DrawFlatHotCheckBox(Graphics g, Rectangle bounds, Color backColor, Color foreColor, CheckState state)
{
DrawFlatNormalCheckBox(g, bounds, backColor, foreColor, state);
}
public override void DrawFlatPressedCheckBox(Graphics g, Rectangle bounds, Color backColor, Color foreColor, CheckState state)
{
DrawPressedCheckBox(g, bounds, backColor, foreColor, state);
}
/* public override void DrawFlatDisabledCheckBox(Graphics g, Rectangle bounds, Color backColor, Color foreColor, CheckState state)
{
Rectangle checkbox_rectangle;
checkbox_rectangle = new Rectangle(bounds.X, bounds.Y, Math.Max(bounds.Width - 2, 0), Math.Max(bounds.Height - 2, 0));
WidgetPaint.DrawBorder(g, checkbox_rectangle, foreColor, ButtonBorderStyle.Solid);
bounds.Offset(-1, 0);
if (state == CheckState.Checked || state == CheckState.Indeterminate)
DrawCheck(g, bounds, SystemColors.ControlDarkDark);
}*/
#endregion
#region Popup
public override void DrawPopupNormalCheckBox(Graphics g, Rectangle bounds, Color backColor, Color foreColor, CheckState state)
{
DrawFlatNormalCheckBox(g, bounds, backColor, foreColor, state);
}
public override void DrawPopupHotCheckBox(Graphics g, Rectangle bounds, Color backColor, Color foreColor, CheckState state)
{
DrawFlatNormalCheckBox(g, bounds, backColor, foreColor, state);
}
public override void DrawPopupPressedCheckBox(Graphics g, Rectangle bounds, Color backColor, Color foreColor, CheckState state)
{
DrawFlatPressedCheckBox(g, bounds, backColor, foreColor, state);
}
public override void DrawPopupDisabledCheckBox(Graphics g, Rectangle bounds, Color backColor, Color foreColor, CheckState state)
{
}
#endregion
#region Check
public override void DrawCheck(Graphics g, Rectangle bounds, Color checkColor)
{
int check_size = (bounds.Height > bounds.Width) ? bounds.Width / 2 : bounds.Height / 2;
Pen check_pen = ResPool.GetPen(checkColor);
if (check_size < 7)
{
int lineWidth = Math.Max(3, check_size / 3);
int Scale = Math.Max(1, check_size / 9);
Rectangle rect = new Rectangle(bounds.X + (bounds.Width / 2) - (check_size / 2) - 1, bounds.Y + (bounds.Height / 2) - (check_size / 2) - 1,
check_size, check_size);
for (int i = 0; i < lineWidth; i++)
{
g.DrawLine(check_pen, rect.Left + lineWidth / 2, rect.Top + lineWidth + i, rect.Left + lineWidth / 2 + 2 * Scale, rect.Top + lineWidth + 2 * Scale + i);
g.DrawLine(check_pen, rect.Left + lineWidth / 2 + 2 * Scale, rect.Top + lineWidth + 2 * Scale + i, rect.Left + lineWidth / 2 + 6 * Scale, rect.Top + lineWidth - 2 * Scale + i);
}
}
else
{
int lineWidth = Math.Max(3, check_size / 3) + 1;
int x_half = bounds.Width / 2;
int y_half = bounds.Height / 2;
Rectangle rect = new Rectangle(bounds.X + x_half - (check_size / 2) - 1, bounds.Y + y_half - (check_size / 2),
check_size, check_size);
int gradient_left = check_size / 3;
int gradient_right = check_size - gradient_left - 1;
for (int i = 0; i < lineWidth; i++)
{
g.DrawLine(check_pen, rect.X, rect.Bottom - 1 - gradient_left - i, rect.X + gradient_left, rect.Bottom - 1 - i);
g.DrawLine(check_pen, rect.X + gradient_left, rect.Bottom - 1 - i, rect.Right - 1, rect.Bottom - i - 1 - gradient_right);
}
}
}
#endregion
}
internal class ButtonPainter : Default.ButtonPainter
{
#region Buttons
#region Standard Button
public override void Draw(Graphics g, Rectangle bounds, ButtonThemeState state, Color backColor, Color foreColor)
{
bool is_themecolor = backColor.ToArgb() == ThemeEngine.Current.ColorControl.ToArgb() || backColor == Color.Empty ? true : false;
CPColor cpcolor = is_themecolor ? CPColor.Empty : ResPool.GetCPColor(backColor);
Pen pen;
switch (state)
{
case ButtonThemeState.Disabled:
case ButtonThemeState.Normal:
case ButtonThemeState.Entered:
case ButtonThemeState.Default:
pen = new Pen(foreColor, Application.CurrentSkin.ButtonBorderWidth);
g.DrawRectangle(pen, bounds);
break;
case ButtonThemeState.Pressed:
g.FillRectangle(new SolidBrush(backColor), bounds);
pen = new Pen(foreColor, Application.CurrentSkin.ButtonBorderWidth);
g.DrawRectangle(pen, bounds);
break;
}
}
#endregion
#region FlatStyle Button
public override void DrawFlat(Graphics g, Rectangle bounds, ButtonThemeState state, Color backColor, Color foreColor, FlatButtonAppearance appearance)
{
Draw(g, bounds, state, backColor, foreColor);
}
#endregion
#region Popup Button
public override void DrawPopup(Graphics g, Rectangle bounds, ButtonThemeState state, Color backColor, Color foreColor)
{
Draw(g, bounds, state, backColor, foreColor);
}
#endregion
#endregion
private static Color ChangeIntensity(Color baseColor, float percent)
{
int H, I, S;
WidgetPaint.Color2HBS(baseColor, out H, out I, out S);
int NewIntensity = Math.Min(255, (int)(I * percent));
return WidgetPaint.HBS2Color(H, NewIntensity, S);
}
}
}
}
|