SHOW:
|
|
- or go back to the newest paste.
1 | using System; | |
2 | using System.Windows.Forms; | |
3 | using System.Drawing.Drawing2D; | |
4 | using System.ComponentModel; | |
5 | using System.Runtime.InteropServices; | |
6 | using System.Drawing; | |
7 | ||
8 | //.::Tweety Theme::. | |
9 | //Author: UnReLaTeDScript | |
10 | - | //Converted to C# by: Delirium™ @ HackForums.Net |
10 | + | |
11 | //Version: 1.0 | |
12 | abstract class Theme : ContainerControl | |
13 | { | |
14 | ||
15 | #region " Initialization " | |
16 | ||
17 | protected Graphics G; | |
18 | public Theme() | |
19 | { | |
20 | SetStyle((ControlStyles)139270, true); | |
21 | } | |
22 | ||
23 | private bool ParentIsForm; | |
24 | protected override void OnHandleCreated(EventArgs e) | |
25 | { | |
26 | Dock = DockStyle.Fill; | |
27 | ParentIsForm = Parent is Form; | |
28 | if (ParentIsForm) | |
29 | { | |
30 | if (!(_TransparencyKey == Color.Empty)) | |
31 | ParentForm.TransparencyKey = _TransparencyKey; | |
32 | ParentForm.FormBorderStyle = FormBorderStyle.None; | |
33 | } | |
34 | base.OnHandleCreated(e); | |
35 | } | |
36 | ||
37 | public override string Text | |
38 | { | |
39 | get { return base.Text; } | |
40 | set | |
41 | { | |
42 | base.Text = value; | |
43 | Invalidate(); | |
44 | } | |
45 | } | |
46 | #endregion | |
47 | ||
48 | #region " Sizing and Movement " | |
49 | ||
50 | private bool _Resizable = true; | |
51 | public bool Resizable | |
52 | { | |
53 | get { return _Resizable; } | |
54 | set { _Resizable = value; } | |
55 | } | |
56 | ||
57 | private int _MoveHeight = 24; | |
58 | public int MoveHeight | |
59 | { | |
60 | get { return _MoveHeight; } | |
61 | set | |
62 | { | |
63 | _MoveHeight = value; | |
64 | Header = new Rectangle(7, 7, Width - 14, _MoveHeight - 7); | |
65 | } | |
66 | } | |
67 | ||
68 | private IntPtr Flag; | |
69 | protected override void OnMouseDown(MouseEventArgs e) | |
70 | { | |
71 | if (!(e.Button == MouseButtons.Left)) | |
72 | return; | |
73 | if (ParentIsForm) | |
74 | if (ParentForm.WindowState == FormWindowState.Maximized) | |
75 | return; | |
76 | ||
77 | if (Header.Contains(e.Location)) | |
78 | { | |
79 | Flag = new IntPtr(2); | |
80 | } | |
81 | else if (Current.Position == 0 | !_Resizable) | |
82 | { | |
83 | return; | |
84 | } | |
85 | else | |
86 | { | |
87 | Flag = new IntPtr(Current.Position); | |
88 | } | |
89 | ||
90 | Capture = false; | |
91 | Message m = Message.Create(Parent.Handle, 161, Flag, IntPtr.Zero); | |
92 | DefWndProc(ref m); | |
93 | ||
94 | base.OnMouseDown(e); | |
95 | } | |
96 | ||
97 | private struct Pointer | |
98 | { | |
99 | public readonly Cursor Cursor; | |
100 | public readonly byte Position; | |
101 | public Pointer(Cursor c, byte p) | |
102 | { | |
103 | Cursor = c; | |
104 | Position = p; | |
105 | } | |
106 | } | |
107 | ||
108 | private bool F1; | |
109 | private bool F2; | |
110 | private bool F3; | |
111 | private bool F4; | |
112 | private Point PTC; | |
113 | private Pointer GetPointer() | |
114 | { | |
115 | PTC = PointToClient(MousePosition); | |
116 | F1 = PTC.X < 7; | |
117 | F2 = PTC.X > Width - 7; | |
118 | F3 = PTC.Y < 7; | |
119 | F4 = PTC.Y > Height - 7; | |
120 | ||
121 | if (F1 & F3) | |
122 | return new Pointer(Cursors.SizeNWSE, 13); | |
123 | if (F1 & F4) | |
124 | return new Pointer(Cursors.SizeNESW, 16); | |
125 | if (F2 & F3) | |
126 | return new Pointer(Cursors.SizeNESW, 14); | |
127 | if (F2 & F4) | |
128 | return new Pointer(Cursors.SizeNWSE, 17); | |
129 | if (F1) | |
130 | return new Pointer(Cursors.SizeWE, 10); | |
131 | if (F2) | |
132 | return new Pointer(Cursors.SizeWE, 11); | |
133 | if (F3) | |
134 | return new Pointer(Cursors.SizeNS, 12); | |
135 | if (F4) | |
136 | return new Pointer(Cursors.SizeNS, 15); | |
137 | return new Pointer(Cursors.Default, 0); | |
138 | } | |
139 | ||
140 | private Pointer Current; | |
141 | private Pointer Pending; | |
142 | private void SetCurrent() | |
143 | { | |
144 | Pending = GetPointer(); | |
145 | if (Current.Position == Pending.Position) | |
146 | return; | |
147 | Current = GetPointer(); | |
148 | Cursor = Current.Cursor; | |
149 | } | |
150 | ||
151 | protected override void OnMouseMove(MouseEventArgs e) | |
152 | { | |
153 | if (_Resizable) | |
154 | SetCurrent(); | |
155 | base.OnMouseMove(e); | |
156 | } | |
157 | ||
158 | protected Rectangle Header; | |
159 | protected override void OnSizeChanged(EventArgs e) | |
160 | { | |
161 | if (Width == 0 || Height == 0) | |
162 | return; | |
163 | Header = new Rectangle(7, 7, Width - 14, _MoveHeight - 7); | |
164 | Invalidate(); | |
165 | base.OnSizeChanged(e); | |
166 | } | |
167 | ||
168 | #endregion | |
169 | ||
170 | #region " Convienence " | |
171 | ||
172 | public abstract void PaintHook(); | |
173 | protected override sealed void OnPaint(PaintEventArgs e) | |
174 | { | |
175 | if (Width == 0 || Height == 0) | |
176 | return; | |
177 | G = e.Graphics; | |
178 | PaintHook(); | |
179 | } | |
180 | ||
181 | private Color _TransparencyKey; | |
182 | public Color TransparencyKey | |
183 | { | |
184 | get { return _TransparencyKey; } | |
185 | set | |
186 | { | |
187 | _TransparencyKey = value; | |
188 | Invalidate(); | |
189 | } | |
190 | } | |
191 | ||
192 | private Image _Image; | |
193 | public Image Image | |
194 | { | |
195 | get { return _Image; } | |
196 | set | |
197 | { | |
198 | _Image = value; | |
199 | Invalidate(); | |
200 | } | |
201 | } | |
202 | public int ImageWidth | |
203 | { | |
204 | get | |
205 | { | |
206 | if (_Image == null) | |
207 | return 0; | |
208 | return _Image.Width; | |
209 | } | |
210 | } | |
211 | ||
212 | private Size _Size; | |
213 | private Rectangle _Rectangle; | |
214 | private LinearGradientBrush _Gradient; | |
215 | ||
216 | private SolidBrush _Brush; | |
217 | protected void DrawCorners(Color c, Rectangle rect) | |
218 | { | |
219 | _Brush = new SolidBrush(c); | |
220 | G.FillRectangle(_Brush, rect.X, rect.Y, 1, 1); | |
221 | G.FillRectangle(_Brush, rect.X + (rect.Width - 1), rect.Y, 1, 1); | |
222 | G.FillRectangle(_Brush, rect.X, rect.Y + (rect.Height - 1), 1, 1); | |
223 | G.FillRectangle(_Brush, rect.X + (rect.Width - 1), rect.Y + (rect.Height - 1), 1, 1); | |
224 | } | |
225 | ||
226 | protected void DrawBorders(Pen p1, Pen p2, Rectangle rect) | |
227 | { | |
228 | G.DrawRectangle(p1, rect.X, rect.Y, rect.Width - 1, rect.Height - 1); | |
229 | G.DrawRectangle(p2, rect.X + 1, rect.Y + 1, rect.Width - 3, rect.Height - 3); | |
230 | } | |
231 | ||
232 | protected void DrawText(HorizontalAlignment a, Color c, int x) | |
233 | { | |
234 | DrawText(a, c, x, 0); | |
235 | } | |
236 | protected void DrawText(HorizontalAlignment a, Color c, int x, int y) | |
237 | { | |
238 | if (string.IsNullOrEmpty(Text)) | |
239 | return; | |
240 | _Size = G.MeasureString(Text, Font).ToSize(); | |
241 | _Brush = new SolidBrush(c); | |
242 | ||
243 | switch (a) | |
244 | { | |
245 | case HorizontalAlignment.Left: | |
246 | G.DrawString(Text, Font, _Brush, x, _MoveHeight / 2 - _Size.Height / 2 + y); | |
247 | break; | |
248 | case HorizontalAlignment.Right: | |
249 | G.DrawString(Text, Font, _Brush, Width - _Size.Width - x, _MoveHeight / 2 - _Size.Height / 2 + y); | |
250 | break; | |
251 | case HorizontalAlignment.Center: | |
252 | G.DrawString(Text, Font, _Brush, Width / 2 - _Size.Width / 2 + x, _MoveHeight / 2 - _Size.Height / 2 + y); | |
253 | break; | |
254 | } | |
255 | } | |
256 | ||
257 | protected void DrawIcon(HorizontalAlignment a, int x) | |
258 | { | |
259 | DrawIcon(a, x, 0); | |
260 | } | |
261 | protected void DrawIcon(HorizontalAlignment a, int x, int y) | |
262 | { | |
263 | if (_Image == null) | |
264 | return; | |
265 | switch (a) | |
266 | { | |
267 | case HorizontalAlignment.Left: | |
268 | G.DrawImage(_Image, x, _MoveHeight / 2 - _Image.Height / 2 + y); | |
269 | break; | |
270 | case HorizontalAlignment.Right: | |
271 | G.DrawImage(_Image, Width - _Image.Width - x, _MoveHeight / 2 - _Image.Height / 2 + y); | |
272 | break; | |
273 | case HorizontalAlignment.Center: | |
274 | G.DrawImage(_Image, Width / 2 - _Image.Width / 2, _MoveHeight / 2 - _Image.Height / 2); | |
275 | break; | |
276 | } | |
277 | } | |
278 | ||
279 | protected void DrawGradient(Color c1, Color c2, int x, int y, int width, int height, float angle) | |
280 | { | |
281 | _Rectangle = new Rectangle(x, y, width, height); | |
282 | _Gradient = new LinearGradientBrush(_Rectangle, c1, c2, angle); | |
283 | G.FillRectangle(_Gradient, _Rectangle); | |
284 | } | |
285 | ||
286 | #endregion | |
287 | ||
288 | } | |
289 | static class Draw | |
290 | { | |
291 | public static GraphicsPath RoundRect(Rectangle Rectangle, int Curve) | |
292 | { | |
293 | GraphicsPath P = new GraphicsPath(); | |
294 | int ArcRectangleWidth = Curve * 2; | |
295 | P.AddArc(new Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90); | |
296 | P.AddArc(new Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90); | |
297 | P.AddArc(new Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90); | |
298 | P.AddArc(new Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90); | |
299 | P.AddLine(new Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), new Point(Rectangle.X, Curve + Rectangle.Y)); | |
300 | return P; | |
301 | } | |
302 | //Public Function RoundRect(ByVal X As Integer, ByVal Y As Integer, ByVal Width As Integer, ByVal Height As Integer, ByVal Curve As Integer) As GraphicsPath | |
303 | // Dim Rectangle As Rectangle = New Rectangle(X, Y, Width, Height) | |
304 | // Dim P As GraphicsPath = New GraphicsPath() | |
305 | // Dim ArcRectangleWidth As Integer = Curve * 2 | |
306 | // P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90) | |
307 | // P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90) | |
308 | // P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90) | |
309 | // P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90) | |
310 | // P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y)) | |
311 | // Return P | |
312 | //End Function | |
313 | } | |
314 | abstract class ThemeControl : Control | |
315 | { | |
316 | ||
317 | #region " Initialization " | |
318 | ||
319 | protected Graphics G; | |
320 | protected Bitmap B; | |
321 | public ThemeControl() | |
322 | { | |
323 | SetStyle((ControlStyles)139270, true); | |
324 | B = new Bitmap(1, 1); | |
325 | G = Graphics.FromImage(B); | |
326 | } | |
327 | ||
328 | public void AllowTransparent() | |
329 | { | |
330 | SetStyle(ControlStyles.Opaque, false); | |
331 | SetStyle(ControlStyles.SupportsTransparentBackColor, true); | |
332 | } | |
333 | ||
334 | public override string Text | |
335 | { | |
336 | get { return base.Text; } | |
337 | set | |
338 | { | |
339 | base.Text = value; | |
340 | Invalidate(); | |
341 | } | |
342 | } | |
343 | #endregion | |
344 | ||
345 | #region " Mouse Handling " | |
346 | ||
347 | protected enum State : byte | |
348 | { | |
349 | MouseNone = 0, | |
350 | MouseOver = 1, | |
351 | MouseDown = 2 | |
352 | } | |
353 | ||
354 | protected State MouseState; | |
355 | protected override void OnMouseLeave(EventArgs e) | |
356 | { | |
357 | ChangeMouseState(State.MouseNone); | |
358 | base.OnMouseLeave(e); | |
359 | } | |
360 | protected override void OnMouseEnter(EventArgs e) | |
361 | { | |
362 | ChangeMouseState(State.MouseOver); | |
363 | base.OnMouseEnter(e); | |
364 | } | |
365 | protected override void OnMouseUp(MouseEventArgs e) | |
366 | { | |
367 | ChangeMouseState(State.MouseOver); | |
368 | base.OnMouseUp(e); | |
369 | } | |
370 | protected override void OnMouseDown(MouseEventArgs e) | |
371 | { | |
372 | if (e.Button == MouseButtons.Left) | |
373 | ChangeMouseState(State.MouseDown); | |
374 | base.OnMouseDown(e); | |
375 | } | |
376 | ||
377 | private void ChangeMouseState(State e) | |
378 | { | |
379 | MouseState = e; | |
380 | Invalidate(); | |
381 | } | |
382 | ||
383 | #endregion | |
384 | ||
385 | #region " Convienence " | |
386 | ||
387 | public abstract void PaintHook(); | |
388 | protected override sealed void OnPaint(PaintEventArgs e) | |
389 | { | |
390 | if (Width == 0 || Height == 0) | |
391 | return; | |
392 | PaintHook(); | |
393 | e.Graphics.DrawImage(B, 0, 0); | |
394 | } | |
395 | ||
396 | protected override void OnSizeChanged(EventArgs e) | |
397 | { | |
398 | if (!(Width == 0) && !(Height == 0)) | |
399 | { | |
400 | B = new Bitmap(Width, Height); | |
401 | G = Graphics.FromImage(B); | |
402 | Invalidate(); | |
403 | } | |
404 | base.OnSizeChanged(e); | |
405 | } | |
406 | ||
407 | private bool _NoRounding; | |
408 | public bool NoRounding | |
409 | { | |
410 | get { return _NoRounding; } | |
411 | set | |
412 | { | |
413 | _NoRounding = value; | |
414 | Invalidate(); | |
415 | } | |
416 | } | |
417 | ||
418 | private Image _Image; | |
419 | public Image Image | |
420 | { | |
421 | get { return _Image; } | |
422 | set | |
423 | { | |
424 | _Image = value; | |
425 | Invalidate(); | |
426 | } | |
427 | } | |
428 | public int ImageWidth | |
429 | { | |
430 | get | |
431 | { | |
432 | if (_Image == null) | |
433 | return 0; | |
434 | return _Image.Width; | |
435 | } | |
436 | } | |
437 | public int ImageTop | |
438 | { | |
439 | get | |
440 | { | |
441 | if (_Image == null) | |
442 | return 0; | |
443 | return Height / 2 - _Image.Height / 2; | |
444 | } | |
445 | } | |
446 | ||
447 | private Size _Size; | |
448 | private Rectangle _Rectangle; | |
449 | private LinearGradientBrush _Gradient; | |
450 | ||
451 | private SolidBrush _Brush; | |
452 | protected void DrawCorners(Color c, Rectangle rect) | |
453 | { | |
454 | if (_NoRounding) | |
455 | return; | |
456 | ||
457 | B.SetPixel(rect.X, rect.Y, c); | |
458 | B.SetPixel(rect.X + (rect.Width - 1), rect.Y, c); | |
459 | B.SetPixel(rect.X, rect.Y + (rect.Height - 1), c); | |
460 | B.SetPixel(rect.X + (rect.Width - 1), rect.Y + (rect.Height - 1), c); | |
461 | } | |
462 | ||
463 | protected void DrawBorders(Pen p1, Pen p2, Rectangle rect) | |
464 | { | |
465 | G.DrawRectangle(p1, rect.X, rect.Y, rect.Width - 1, rect.Height - 1); | |
466 | G.DrawRectangle(p2, rect.X + 1, rect.Y + 1, rect.Width - 3, rect.Height - 3); | |
467 | } | |
468 | ||
469 | protected void DrawText(HorizontalAlignment a, Color c, int x) | |
470 | { | |
471 | DrawText(a, c, x, 0); | |
472 | } | |
473 | protected void DrawText(HorizontalAlignment a, Color c, int x, int y) | |
474 | { | |
475 | if (string.IsNullOrEmpty(Text)) | |
476 | return; | |
477 | _Size = G.MeasureString(Text, Font).ToSize(); | |
478 | _Brush = new SolidBrush(c); | |
479 | ||
480 | switch (a) | |
481 | { | |
482 | case HorizontalAlignment.Left: | |
483 | G.DrawString(Text, Font, _Brush, x, Height / 2 - _Size.Height / 2 + y); | |
484 | break; | |
485 | case HorizontalAlignment.Right: | |
486 | G.DrawString(Text, Font, _Brush, Width - _Size.Width - x, Height / 2 - _Size.Height / 2 + y); | |
487 | break; | |
488 | case HorizontalAlignment.Center: | |
489 | G.DrawString(Text, Font, _Brush, Width / 2 - _Size.Width / 2 + x, Height / 2 - _Size.Height / 2 + y); | |
490 | break; | |
491 | } | |
492 | } | |
493 | ||
494 | protected void DrawIcon(HorizontalAlignment a, int x) | |
495 | { | |
496 | DrawIcon(a, x, 0); | |
497 | } | |
498 | protected void DrawIcon(HorizontalAlignment a, int x, int y) | |
499 | { | |
500 | if (_Image == null) | |
501 | return; | |
502 | switch (a) | |
503 | { | |
504 | case HorizontalAlignment.Left: | |
505 | G.DrawImage(_Image, x, Height / 2 - _Image.Height / 2 + y); | |
506 | break; | |
507 | case HorizontalAlignment.Right: | |
508 | G.DrawImage(_Image, Width - _Image.Width - x, Height / 2 - _Image.Height / 2 + y); | |
509 | break; | |
510 | case HorizontalAlignment.Center: | |
511 | G.DrawImage(_Image, Width / 2 - _Image.Width / 2, Height / 2 - _Image.Height / 2); | |
512 | break; | |
513 | } | |
514 | } | |
515 | ||
516 | protected void DrawGradient(Color c1, Color c2, int x, int y, int width, int height, float angle) | |
517 | { | |
518 | _Rectangle = new Rectangle(x, y, width, height); | |
519 | _Gradient = new LinearGradientBrush(_Rectangle, c1, c2, angle); | |
520 | G.FillRectangle(_Gradient, _Rectangle); | |
521 | } | |
522 | #endregion | |
523 | ||
524 | } | |
525 | abstract class ThemeContainerControl : ContainerControl | |
526 | { | |
527 | ||
528 | #region " Initialization " | |
529 | ||
530 | protected Graphics G; | |
531 | protected Bitmap B; | |
532 | public ThemeContainerControl() | |
533 | { | |
534 | SetStyle((ControlStyles)139270, true); | |
535 | B = new Bitmap(1, 1); | |
536 | G = Graphics.FromImage(B); | |
537 | } | |
538 | ||
539 | public void AllowTransparent() | |
540 | { | |
541 | SetStyle(ControlStyles.Opaque, false); | |
542 | SetStyle(ControlStyles.SupportsTransparentBackColor, true); | |
543 | } | |
544 | ||
545 | #endregion | |
546 | #region " Convienence " | |
547 | ||
548 | public abstract void PaintHook(); | |
549 | protected override sealed void OnPaint(PaintEventArgs e) | |
550 | { | |
551 | if (Width == 0 || Height == 0) | |
552 | return; | |
553 | PaintHook(); | |
554 | e.Graphics.DrawImage(B, 0, 0); | |
555 | } | |
556 | ||
557 | protected override void OnSizeChanged(EventArgs e) | |
558 | { | |
559 | if (!(Width == 0) && !(Height == 0)) | |
560 | { | |
561 | B = new Bitmap(Width, Height); | |
562 | G = Graphics.FromImage(B); | |
563 | Invalidate(); | |
564 | } | |
565 | base.OnSizeChanged(e); | |
566 | } | |
567 | ||
568 | private bool _NoRounding; | |
569 | public bool NoRounding | |
570 | { | |
571 | get { return _NoRounding; } | |
572 | set | |
573 | { | |
574 | _NoRounding = value; | |
575 | Invalidate(); | |
576 | } | |
577 | } | |
578 | ||
579 | private Rectangle _Rectangle; | |
580 | ||
581 | private LinearGradientBrush _Gradient; | |
582 | protected void DrawCorners(Color c, Rectangle rect) | |
583 | { | |
584 | if (_NoRounding) | |
585 | return; | |
586 | B.SetPixel(rect.X, rect.Y, c); | |
587 | B.SetPixel(rect.X + (rect.Width - 1), rect.Y, c); | |
588 | B.SetPixel(rect.X, rect.Y + (rect.Height - 1), c); | |
589 | B.SetPixel(rect.X + (rect.Width - 1), rect.Y + (rect.Height - 1), c); | |
590 | } | |
591 | ||
592 | protected void DrawBorders(Pen p1, Pen p2, Rectangle rect) | |
593 | { | |
594 | G.DrawRectangle(p1, rect.X, rect.Y, rect.Width - 1, rect.Height - 1); | |
595 | G.DrawRectangle(p2, rect.X + 1, rect.Y + 1, rect.Width - 3, rect.Height - 3); | |
596 | } | |
597 | ||
598 | protected void DrawGradient(Color c1, Color c2, int x, int y, int width, int height, float angle) | |
599 | { | |
600 | _Rectangle = new Rectangle(x, y, width, height); | |
601 | _Gradient = new LinearGradientBrush(_Rectangle, c1, c2, angle); | |
602 | G.FillRectangle(_Gradient, _Rectangle); | |
603 | } | |
604 | #endregion | |
605 | ||
606 | } | |
607 | ||
608 | class TxtBox : ThemeControl | |
609 | { | |
610 | #region "lol" | |
611 | TextBox txtbox = new TextBox(); | |
612 | private bool _passmask = false; | |
613 | public bool UseSystemPasswordChar | |
614 | { | |
615 | get { return _passmask; } | |
616 | set | |
617 | { | |
618 | txtbox.UseSystemPasswordChar = UseSystemPasswordChar; | |
619 | _passmask = value; | |
620 | Invalidate(); | |
621 | } | |
622 | } | |
623 | private int _maxchars = 32767; | |
624 | public int MaxLength | |
625 | { | |
626 | get { return _maxchars; } | |
627 | set | |
628 | { | |
629 | _maxchars = value; | |
630 | txtbox.MaxLength = MaxLength; | |
631 | Invalidate(); | |
632 | } | |
633 | } | |
634 | private HorizontalAlignment _align; | |
635 | public HorizontalAlignment TextAlignment | |
636 | { | |
637 | get { return _align; } | |
638 | set | |
639 | { | |
640 | _align = value; | |
641 | Invalidate(); | |
642 | } | |
643 | } | |
644 | ||
645 | protected override void OnPaintBackground(System.Windows.Forms.PaintEventArgs pevent) | |
646 | { | |
647 | } | |
648 | protected override void OnTextChanged(System.EventArgs e) | |
649 | { | |
650 | base.OnTextChanged(e); | |
651 | Invalidate(); | |
652 | } | |
653 | protected override void OnBackColorChanged(System.EventArgs e) | |
654 | { | |
655 | base.OnBackColorChanged(e); | |
656 | txtbox.BackColor = BackColor; | |
657 | Invalidate(); | |
658 | } | |
659 | protected override void OnForeColorChanged(System.EventArgs e) | |
660 | { | |
661 | base.OnForeColorChanged(e); | |
662 | txtbox.ForeColor = ForeColor; | |
663 | Invalidate(); | |
664 | } | |
665 | protected override void OnFontChanged(System.EventArgs e) | |
666 | { | |
667 | base.OnFontChanged(e); | |
668 | txtbox.Font = Font; | |
669 | } | |
670 | protected override void OnGotFocus(System.EventArgs e) | |
671 | { | |
672 | base.OnGotFocus(e); | |
673 | txtbox.Focus(); | |
674 | } | |
675 | public void // ERROR: Handles clauses are not supported in C# | |
676 | TextChngTxtBox() | |
677 | { | |
678 | Text = txtbox.Text; | |
679 | } | |
680 | public void // ERROR: Handles clauses are not supported in C# | |
681 | TextChng() | |
682 | { | |
683 | txtbox.Text = Text; | |
684 | } | |
685 | ||
686 | #endregion | |
687 | ||
688 | protected override void WndProc(ref Message m) | |
689 | { | |
690 | switch (m.Msg) | |
691 | { | |
692 | case 15: | |
693 | Invalidate(); | |
694 | base.WndProc(ref m); | |
695 | this.PaintHook(); | |
696 | break; // TODO: might not be correct. Was : Exit Select | |
697 | default: | |
698 | base.WndProc(ref m); | |
699 | break; // TODO: might not be correct. Was : Exit Select | |
700 | } | |
701 | } | |
702 | ||
703 | public TxtBox() | |
704 | : base() | |
705 | { | |
706 | ||
707 | Controls.Add(txtbox); | |
708 | { | |
709 | txtbox.Multiline = false; | |
710 | txtbox.BackColor = Color.FromArgb(0, 0, 0); | |
711 | txtbox.ForeColor = ForeColor; | |
712 | txtbox.Text = string.Empty; | |
713 | txtbox.TextAlign = HorizontalAlignment.Center; | |
714 | txtbox.BorderStyle = BorderStyle.None; | |
715 | txtbox.Location = new Point(5, 8); | |
716 | txtbox.Font = new Font("Arial", 8.25f, FontStyle.Bold); | |
717 | txtbox.Size = new Size(Width - 8, Height - 11); | |
718 | txtbox.UseSystemPasswordChar = UseSystemPasswordChar; | |
719 | } | |
720 | ||
721 | Text = ""; | |
722 | ||
723 | DoubleBuffered = true; | |
724 | } | |
725 | ||
726 | public override void PaintHook() | |
727 | { | |
728 | this.BackColor = Color.White; | |
729 | G.Clear(Parent.BackColor); | |
730 | Pen p = new Pen(Color.FromArgb(204, 204, 204), 1); | |
731 | Pen o = new Pen(Color.FromArgb(249, 249, 249), 8); | |
732 | G.FillPath(Brushes.White, Draw.RoundRect(new Rectangle(0, 0, Width - 1, Height - 1), 2)); | |
733 | G.DrawPath(o, Draw.RoundRect(new Rectangle(0, 0, Width - 1, Height - 1), 2)); | |
734 | G.DrawPath(p, Draw.RoundRect(new Rectangle(0, 0, Width - 1, Height - 1), 2)); | |
735 | Height = txtbox.Height + 16; | |
736 | Font drawFont = new Font("Tahoma", 9, FontStyle.Regular); | |
737 | { | |
738 | txtbox.Width = Width - 12; | |
739 | txtbox.ForeColor = Color.FromArgb(72, 72, 72); | |
740 | txtbox.Font = drawFont; | |
741 | txtbox.TextAlign = TextAlignment; | |
742 | txtbox.UseSystemPasswordChar = UseSystemPasswordChar; | |
743 | } | |
744 | DrawCorners(Parent.BackColor, ClientRectangle); | |
745 | } | |
746 | } | |
747 | ||
748 | class PanelBox : ThemeContainerControl | |
749 | { | |
750 | public PanelBox() | |
751 | { | |
752 | AllowTransparent(); | |
753 | } | |
754 | public override void PaintHook() | |
755 | { | |
756 | this.Font = new Font("Tahoma", 10); | |
757 | this.ForeColor = Color.FromArgb(40, 40, 40); | |
758 | G.SmoothingMode = SmoothingMode.AntiAlias; | |
759 | G.FillRectangle(new SolidBrush(Color.FromArgb(235, 235, 235)), new Rectangle(2, 0, Width, Height)); | |
760 | G.FillRectangle(new SolidBrush(Color.FromArgb(249, 249, 249)), new Rectangle(1, 0, Width - 3, Height - 4)); | |
761 | G.DrawRectangle(new Pen(Color.FromArgb(214, 214, 214)), 0, 0, Width - 2, Height - 3); | |
762 | } | |
763 | } | |
764 | class GroupDropBox : ThemeContainerControl | |
765 | { | |
766 | private bool _Checked; | |
767 | private int X; | |
768 | private int y; | |
769 | private Size _OpenedSize; | |
770 | public bool Checked | |
771 | { | |
772 | get { return _Checked; } | |
773 | set | |
774 | { | |
775 | _Checked = value; | |
776 | Invalidate(); | |
777 | } | |
778 | } | |
779 | public Size OpenSize | |
780 | { | |
781 | get { return _OpenedSize; } | |
782 | set | |
783 | { | |
784 | _OpenedSize = value; | |
785 | Invalidate(); | |
786 | } | |
787 | } | |
788 | public GroupDropBox() | |
789 | { | |
790 | ||
791 | AllowTransparent(); | |
792 | Size = new Size(90, 30); | |
793 | MinimumSize = new Size(5, 30); | |
794 | _Checked = true; | |
795 | this.Resize += new EventHandler(GroupDropBox_Resize); | |
796 | this.MouseDown += new MouseEventHandler(GroupDropBox_MouseDown); | |
797 | } | |
798 | public override void PaintHook() | |
799 | { | |
800 | this.Font = new Font("Tahoma", 10); | |
801 | this.ForeColor = Color.FromArgb(40, 40, 40); | |
802 | if (_Checked == true) | |
803 | { | |
804 | G.SmoothingMode = SmoothingMode.AntiAlias; | |
805 | G.Clear(Color.FromArgb(245, 245, 245)); | |
806 | G.FillRectangle(new SolidBrush(Color.FromArgb(231, 231, 231)), new Rectangle(0, 0, Width, 30)); | |
807 | G.DrawLine(new Pen(Color.FromArgb(233, 238, 240)), 1, 1, Width - 2, 1); | |
808 | G.DrawRectangle(new Pen(Color.FromArgb(214, 214, 214)), 0, 0, Width - 1, Height - 1); | |
809 | G.DrawRectangle(new Pen(Color.FromArgb(214, 214, 214)), 0, 0, Width - 1, 30); | |
810 | this.Size = _OpenedSize; | |
811 | G.DrawString("t", new Font("Marlett", 12), new SolidBrush(this.ForeColor), Width - 25, 5); | |
812 | } | |
813 | else | |
814 | { | |
815 | G.SmoothingMode = SmoothingMode.AntiAlias; | |
816 | G.Clear(Color.FromArgb(245, 245, 245)); | |
817 | G.FillRectangle(new SolidBrush(Color.FromArgb(231, 231, 231)), new Rectangle(0, 0, Width, 30)); | |
818 | G.DrawLine(new Pen(Color.FromArgb(231, 236, 238)), 1, 1, Width - 2, 1); | |
819 | G.DrawRectangle(new Pen(Color.FromArgb(214, 214, 214)), 0, 0, Width - 1, Height - 1); | |
820 | G.DrawRectangle(new Pen(Color.FromArgb(214, 214, 214)), 0, 0, Width - 1, 30); | |
821 | this.Size = new Size(Width, 30); | |
822 | G.DrawString("u", new Font("Marlett", 12), new SolidBrush(this.ForeColor), Width - 25, 5); | |
823 | } | |
824 | G.DrawString(Text, Font, new SolidBrush(this.ForeColor), 7, 6); | |
825 | } | |
826 | ||
827 | private void GroupDropBox_Resize(object sender, System.EventArgs e) | |
828 | { | |
829 | if (_Checked == true) | |
830 | { | |
831 | _OpenedSize = this.Size; | |
832 | } | |
833 | } | |
834 | ||
835 | ||
836 | protected override void OnMouseMove(System.Windows.Forms.MouseEventArgs e) | |
837 | { | |
838 | base.OnMouseMove(e); | |
839 | X = e.X; | |
840 | y = e.Y; | |
841 | Invalidate(); | |
842 | } | |
843 | ||
844 | ||
845 | private void GroupDropBox_MouseDown(object sender, MouseEventArgs e) | |
846 | { | |
847 | ||
848 | if (X >= Width - 22) | |
849 | { | |
850 | if (y <= 30) | |
851 | { | |
852 | switch (Checked) | |
853 | { | |
854 | case true: | |
855 | Checked = false; | |
856 | break; | |
857 | case false: | |
858 | Checked = true; | |
859 | break; | |
860 | } | |
861 | } | |
862 | } | |
863 | } | |
864 | } | |
865 | class GroupPanelBox : ThemeContainerControl | |
866 | { | |
867 | public GroupPanelBox() | |
868 | { | |
869 | AllowTransparent(); | |
870 | } | |
871 | public override void PaintHook() | |
872 | { | |
873 | this.Font = new Font("Tahoma", 10); | |
874 | this.ForeColor = Color.FromArgb(40, 40, 40); | |
875 | G.SmoothingMode = SmoothingMode.AntiAlias; | |
876 | G.Clear(Color.FromArgb(245, 245, 245)); | |
877 | G.FillRectangle(new SolidBrush(Color.FromArgb(231, 231, 231)), new Rectangle(0, 0, Width, 30)); | |
878 | G.DrawLine(new Pen(Color.FromArgb(233, 238, 240)), 1, 1, Width - 2, 1); | |
879 | G.DrawRectangle(new Pen(Color.FromArgb(214, 214, 214)), 0, 0, Width - 1, Height - 1); | |
880 | G.DrawRectangle(new Pen(Color.FromArgb(214, 214, 214)), 0, 0, Width - 1, 30); | |
881 | G.DrawString(Text, Font, new SolidBrush(this.ForeColor), 7, 6); | |
882 | } | |
883 | } | |
884 | ||
885 | class ButtonGreen : ThemeControl | |
886 | { | |
887 | public override void PaintHook() | |
888 | { | |
889 | this.Font = new Font("Arial", 10); | |
890 | G.Clear(this.BackColor); | |
891 | G.SmoothingMode = SmoothingMode.HighQuality; | |
892 | switch (MouseState) | |
893 | { | |
894 | case State.MouseNone: | |
895 | Pen p1 = new Pen(Color.FromArgb(120, 159, 22), 1); | |
896 | LinearGradientBrush x1 = new LinearGradientBrush(ClientRectangle, Color.FromArgb(157, 209, 57), Color.FromArgb(130, 181, 18), LinearGradientMode.Vertical); | |
897 | G.FillPath(x1, Draw.RoundRect(ClientRectangle, 4)); | |
898 | G.DrawPath(p1, Draw.RoundRect(new Rectangle(0, 0, Width - 1, Height - 1), 3)); | |
899 | G.DrawLine(new Pen(Color.FromArgb(190, 232, 109)), 2, 1, Width - 3, 1); | |
900 | DrawText(HorizontalAlignment.Center, Color.FromArgb(240, 240, 240), 0); | |
901 | break; | |
902 | case State.MouseDown: | |
903 | Pen p2 = new Pen(Color.FromArgb(120, 159, 22), 1); | |
904 | LinearGradientBrush x2 = new LinearGradientBrush(ClientRectangle, Color.FromArgb(125, 171, 25), Color.FromArgb(142, 192, 40), LinearGradientMode.Vertical); | |
905 | G.FillPath(x2, Draw.RoundRect(ClientRectangle, 4)); | |
906 | G.DrawPath(p2, Draw.RoundRect(new Rectangle(0, 0, Width - 1, Height - 1), 3)); | |
907 | G.DrawLine(new Pen(Color.FromArgb(142, 172, 30)), 2, 1, Width - 3, 1); | |
908 | DrawText(HorizontalAlignment.Center, Color.FromArgb(250, 250, 250), 1); | |
909 | break; | |
910 | case State.MouseOver: | |
911 | Pen p3 = new Pen(Color.FromArgb(120, 159, 22), 1); | |
912 | LinearGradientBrush x3 = new LinearGradientBrush(ClientRectangle, Color.FromArgb(165, 220, 59), Color.FromArgb(137, 191, 18), LinearGradientMode.Vertical); | |
913 | G.FillPath(x3, Draw.RoundRect(ClientRectangle, 4)); | |
914 | G.DrawPath(p3, Draw.RoundRect(new Rectangle(0, 0, Width - 1, Height - 1), 3)); | |
915 | G.DrawLine(new Pen(Color.FromArgb(190, 232, 109)), 2, 1, Width - 3, 1); | |
916 | DrawText(HorizontalAlignment.Center, Color.FromArgb(240, 240, 240), -1); | |
917 | break; | |
918 | } | |
919 | this.Cursor = Cursors.Hand; | |
920 | } | |
921 | } | |
922 | class ButtonBlue : ThemeControl | |
923 | { | |
924 | public override void PaintHook() | |
925 | { | |
926 | this.Font = new Font("Arial", 10); | |
927 | G.Clear(this.BackColor); | |
928 | G.SmoothingMode = SmoothingMode.HighQuality; | |
929 | switch (MouseState) | |
930 | { | |
931 | case State.MouseNone: | |
932 | Pen p = new Pen(Color.FromArgb(34, 112, 171), 1); | |
933 | LinearGradientBrush x = new LinearGradientBrush(ClientRectangle, Color.FromArgb(51, 159, 231), Color.FromArgb(33, 128, 206), LinearGradientMode.Vertical); | |
934 | G.FillPath(x, Draw.RoundRect(ClientRectangle, 4)); | |
935 | G.DrawPath(p, Draw.RoundRect(new Rectangle(0, 0, Width - 1, Height - 1), 3)); | |
936 | G.DrawLine(new Pen(Color.FromArgb(131, 197, 241)), 2, 1, Width - 3, 1); | |
937 | DrawText(HorizontalAlignment.Center, Color.FromArgb(240, 240, 240), 0); | |
938 | break; | |
939 | case State.MouseDown: | |
940 | Pen p1 = new Pen(Color.FromArgb(34, 112, 171), 1); | |
941 | LinearGradientBrush x1 = new LinearGradientBrush(ClientRectangle, Color.FromArgb(37, 124, 196), Color.FromArgb(53, 153, 219), LinearGradientMode.Vertical); | |
942 | G.FillPath(x1, Draw.RoundRect(ClientRectangle, 4)); | |
943 | G.DrawPath(p1, Draw.RoundRect(new Rectangle(0, 0, Width - 1, Height - 1), 3)); | |
944 | ||
945 | DrawText(HorizontalAlignment.Center, Color.FromArgb(250, 250, 250), 1); | |
946 | break; | |
947 | case State.MouseOver: | |
948 | Pen p2 = new Pen(Color.FromArgb(34, 112, 171), 1); | |
949 | LinearGradientBrush x2 = new LinearGradientBrush(ClientRectangle, Color.FromArgb(54, 167, 243), Color.FromArgb(35, 165, 217), LinearGradientMode.Vertical); | |
950 | G.FillPath(x2, Draw.RoundRect(ClientRectangle, 4)); | |
951 | G.DrawPath(p2, Draw.RoundRect(new Rectangle(0, 0, Width - 1, Height - 1), 3)); | |
952 | G.DrawLine(new Pen(Color.FromArgb(131, 197, 241)), 2, 1, Width - 3, 1); | |
953 | DrawText(HorizontalAlignment.Center, Color.FromArgb(240, 240, 240), -1); | |
954 | break; | |
955 | } | |
956 | this.Cursor = Cursors.Hand; | |
957 | } | |
958 | } |