Advertisement
Astekk

aevion theme c#

Dec 31st, 2014
422
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.78 KB | None | 0 0
  1.  
  2. // aevion theme convertered to c#
  3. using System;
  4. using System.Linq;
  5. using System.Drawing;
  6. using System.Windows.Forms;
  7. using System.Drawing.Drawing2D;
  8.  
  9. namespace Aevion_r2
  10. {
  11.  
  12. public static class Helper
  13. {
  14. public struct Fonts
  15. {
  16. public static Font Primary = new Font("Segoe UI", 9);
  17. public static Font PrimaryBold = new Font("Segoe UI", 9, FontStyle.Bold);
  18. }
  19.  
  20. public struct Colors
  21. {
  22. public static Color Foreground = Color.White;
  23. public static Color Background = Color.FromArgb(48, 57, 65);
  24. }
  25.  
  26.  
  27. public enum MouseState : byte
  28. {
  29. None = 0,
  30. Hover = 1,
  31. Down = 2
  32. }
  33.  
  34. public enum Direction : byte
  35. {
  36. Up = 0,
  37. Down = 1,
  38. Left = 3,
  39. Right = 4
  40. }
  41.  
  42. public static void RoundRect(Graphics g, Int32 x, Int32 y, Int32 Width, Int32 Height, Int32 Curve, Color c)
  43. {
  44. if (Curve <= 0) throw new ArgumentException("Curve must be Greater than 0.", "Curve");
  45.  
  46. var p = new Pen(c);
  47.  
  48. var BaseRect = new RectangleF(x, y, Width, Height);
  49. var ArcRect = new RectangleF(BaseRect.Location, new SizeF(Curve, Curve));
  50.  
  51. g.DrawArc(p, ArcRect, 180, 90);
  52. g.DrawLine(p, x + (Curve / 2), y, y + Width - (Curve / 2), y);
  53.  
  54. ArcRect.X = BaseRect.Right - Curve;
  55. g.DrawArc(p, ArcRect, 270, 90);
  56. g.DrawLine(p, x + Width, y + (Curve / 2), x + Width, y + Height - (Curve / 2));
  57.  
  58. ArcRect.Y = BaseRect.Bottom - Curve;
  59. g.DrawArc(p, ArcRect, 0, 90);
  60. g.DrawLine(p, x + (Curve / 2), y + Height, x + Width - (Curve / 2), y + Height);
  61.  
  62. ArcRect.X = BaseRect.Left;
  63. g.DrawArc(p, ArcRect, 90, 30);
  64. g.DrawLine(p, x, y + (Curve / 2), x, y + Height - (Curve / 2));
  65.  
  66. p.Dispose();
  67. }
  68.  
  69. public static void DrawTriangle(Graphics g, Rectangle r, Direction d, Color c)
  70. {
  71. var w = r.Width/2;
  72. var y = r.Height/2;
  73.  
  74. Point p0 = Point.Empty, p1 = Point.Empty, p2 = Point.Empty;
  75.  
  76. switch (d)
  77. {
  78. case Direction.Up:
  79. p0 = new Point(r.Left + w, r.Top);
  80. p1 = new Point(r.Left, r.Bottom);
  81. p2 = new Point(r.Right, r.Bottom);
  82. break;
  83.  
  84. case Direction.Down:
  85. p0 = new Point(r.Left + w, r.Bottom);
  86. p1 = new Point(r.Left, r.Top);
  87. p2 = new Point(r.Right, r.Top);
  88. break;
  89.  
  90. case Direction.Left:
  91. p0 = new Point(r.Left, r.Top + y);
  92. p1 = new Point(r.Right, r.Top);
  93. p2 = new Point(r.Right, r.Bottom);
  94. break;
  95.  
  96. case Direction.Right:
  97. p0 = new Point(r.Right, r.Top + y);
  98. p1 = new Point(r.Left, r.Bottom);
  99. p2 = new Point(r.Left, r.Top);
  100. break;
  101. }
  102.  
  103. var s = new SolidBrush(c);
  104. g.FillPolygon(s, new [] {p0, p1, p2});
  105.  
  106. MultiDispose(s);
  107. }
  108.  
  109. public static void CenterString(Graphics g, String Text, Font Font, Color c, Rectangle rect, Boolean Shadow = false, Int32 yOffset = 1)
  110. {
  111. CenterString(g, Text, Font, new SolidBrush(c), rect, Shadow, yOffset);
  112. }
  113.  
  114. public static void CenterString(Graphics g, String Text, Font Font, Brush b, Rectangle rect, Boolean Shadow = false, Int32 yOffset = 1)
  115. {
  116. var TextSize = g.MeasureString(Text, Font);
  117. var x = rect.X + (rect.Width / 2) - (TextSize.Width / 2);
  118. var y = rect.Y + (rect.Height / 2) - (TextSize.Height / 2) + yOffset;
  119.  
  120. if (Shadow)
  121. g.DrawString(Text, Font, Brushes.Black, x + 1, y + 1);
  122. g.DrawString(Text, Font, b, x, y);
  123.  
  124. b.Dispose();
  125. }
  126.  
  127. public static Single ValueToPercentage(Int32 Value, Int32 Maximum, Int32 Minimum)
  128. {
  129. return (Single)(Value - Minimum) / (Maximum - Minimum);
  130. }
  131.  
  132. public static void MultiDispose(params IDisposable[] Disposables)
  133. {
  134. foreach (var Disposable in Disposables.Where(Disposable => Disposable != null))
  135. {
  136. Disposable.Dispose();
  137. }
  138. }
  139. }
  140.  
  141. sealed class AevionForm : Control
  142. {
  143. public AevionForm()
  144. {
  145. DoubleBuffered = true;
  146. Font = Helper.Fonts.Primary;
  147. ForeColor = Helper.Colors.Foreground;
  148. BackColor = Helper.Colors.Background;
  149. Dock = DockStyle.Fill;
  150. }
  151.  
  152. protected override void OnPaint(PaintEventArgs e)
  153. {
  154. base.OnPaint(e);
  155. var g = e.Graphics;
  156. g.SmoothingMode=SmoothingMode.HighQuality;
  157. g.Clear(Helper.Colors.Background);
  158. }
  159.  
  160. }
  161.  
  162. sealed class AevionButton : Button
  163. {
  164. private Helper.MouseState State = Helper.MouseState.None;
  165. private LinearGradientBrush l1, l2, l3 = null;
  166.  
  167. public enum Style
  168. {
  169. Default,
  170. Green,
  171. Red
  172. }
  173.  
  174. private Style _ButtonStyle = Style.Default;
  175. private Image _Icon;
  176. private Boolean _ShowIcon = false;
  177.  
  178. public Style ButtonStyle
  179. {
  180. get { return _ButtonStyle; }
  181. set { _ButtonStyle = value; Invalidate(); }
  182. }
  183.  
  184. public Image Icon
  185. {
  186. get { return _Icon; }
  187. set { _Icon = value; Invalidate(); }
  188. }
  189.  
  190. public Boolean ShowIcon
  191. {
  192. get { return _ShowIcon; }
  193. set { _ShowIcon = value; Invalidate(); }
  194. }
  195.  
  196. public override string Text
  197. {
  198. get { return base.Text; }
  199. set { base.Text = value; Invalidate(); }
  200. }
  201.  
  202. public override Font Font
  203. {
  204. get { return base.Font; }
  205. set { base.Font = value; Invalidate(); }
  206. }
  207.  
  208. public AevionButton()
  209. {
  210. DoubleBuffered = true;
  211. Font = Helper.Fonts.PrimaryBold;
  212. SetStyle(ControlStyles.UserPaint | ControlStyles.SupportsTransparentBackColor, true);
  213. }
  214.  
  215. protected override void OnMouseDown(MouseEventArgs mevent)
  216. {
  217. base.OnMouseDown(mevent);
  218. State = Helper.MouseState.Down;
  219. Invalidate();
  220. }
  221.  
  222. protected override void OnMouseUp(MouseEventArgs mevent)
  223. {
  224. base.OnMouseUp(mevent);
  225. State = Helper.MouseState.None;
  226. Invalidate();
  227. }
  228.  
  229. protected override void OnMouseEnter(EventArgs e)
  230. {
  231. base.OnMouseEnter(e);
  232. State = Helper.MouseState.Hover;
  233. Invalidate();
  234. }
  235.  
  236. protected override void OnMouseLeave(EventArgs e)
  237. {
  238. base.OnMouseLeave(e);
  239. State = Helper.MouseState.None;
  240. Invalidate();
  241. }
  242.  
  243. protected override void OnPaint(PaintEventArgs e)
  244. {
  245. base.OnPaint(e);
  246. var g = e.Graphics;
  247. g.SmoothingMode = SmoothingMode.HighQuality;
  248. g.Clear(Helper.Colors.Background);
  249.  
  250. switch (ButtonStyle)
  251. {
  252. case Style.Default:
  253. l1 = new LinearGradientBrush(new Rectangle(0, 0, Width, Height + 35), Color.FromArgb(88, 105, 123), Color.Black, LinearGradientMode.Vertical);
  254. l2 = new LinearGradientBrush(new Rectangle(0, 0, Width, Height + 35), Color.FromArgb(108, 125, 143), Color.Black, LinearGradientMode.Vertical);
  255. l3 = new LinearGradientBrush(new Rectangle(0, 0, Width, Height + 35), Color.FromArgb(98, 115, 133), Color.Black, LinearGradientMode.Vertical);
  256. break;
  257. case Style.Red:
  258. l1 = new LinearGradientBrush(new Rectangle(0, 0, Width, Height + 35), Color.FromArgb(173, 83, 74), Color.Black, LinearGradientMode.Vertical);
  259. l2 = new LinearGradientBrush(new Rectangle(0, 0, Width, Height + 35), Color.FromArgb(193, 103, 94), Color.Black, LinearGradientMode.Vertical);
  260. l3 = new LinearGradientBrush(new Rectangle(0, 0, Width, Height + 35), Color.FromArgb(183, 93, 84), Color.Black, LinearGradientMode.Vertical);
  261. break;
  262. case Style.Green:
  263. l1 = new LinearGradientBrush(new Rectangle(0, 0, Width, Height + 35), Color.FromArgb(127, 177, 80), Color.Black, LinearGradientMode.Vertical);
  264. l2 = new LinearGradientBrush(new Rectangle(0, 0, Width, Height + 35), Color.FromArgb(157, 197, 100), Color.Black, LinearGradientMode.Vertical);
  265. l3 = new LinearGradientBrush(new Rectangle(0, 0, Width, Height + 35), Color.FromArgb(147, 187, 90), Color.Black, LinearGradientMode.Vertical);
  266. break;
  267. }
  268.  
  269. switch (State)
  270. {
  271. case Helper.MouseState.Down:
  272. g.FillRectangle(l1, new Rectangle(1, 1, Width - 2, Height - 2));
  273. break;
  274. case Helper.MouseState.Hover:
  275. g.FillRectangle(l2, new Rectangle(1, 1, Width - 2, Height - 2));
  276. break;
  277. case Helper.MouseState.None:
  278. g.FillRectangle(l3, new Rectangle(1, 1, Width - 2, Height - 2));
  279. break;
  280. }
  281.  
  282. Helper.RoundRect(g, 0, 0, Width - 1, Height - 1, 3, Color.FromArgb(38, 38, 38));
  283.  
  284. if (ShowIcon)
  285. g.DrawImage(Icon, new Point(Width / 8, Height / 2 - 8));
  286.  
  287. Helper.CenterString(g, Text, Font, Helper.Colors.Foreground, new Rectangle(0, 0, Width, Height));
  288.  
  289. }
  290. }
  291.  
  292. sealed class AevionRadioButton : Control
  293. {
  294. public event EventHandler CheckedChanged = delegate { };
  295.  
  296. private Boolean _Checked;
  297.  
  298. public Boolean Checked
  299. {
  300. get { return _Checked; }
  301. set {
  302. _Checked = value;
  303. Invalidate();
  304. CheckedChanged(this, new EventArgs());
  305. }
  306. }
  307.  
  308. public override string Text
  309. {
  310. get { return base.Text; }
  311. set { base.Text = value; Invalidate(); }
  312. }
  313.  
  314. public override Font Font
  315. {
  316. get { return base.Font; }
  317. set { base.Font = value; Invalidate(); }
  318. }
  319.  
  320. public AevionRadioButton()
  321. {
  322. DoubleBuffered = true;
  323. Size = new Size(Width, 16);
  324. Font = Helper.Fonts.Primary;
  325. SetStyle(ControlStyles.UserPaint | ControlStyles.SupportsTransparentBackColor, true);
  326. }
  327.  
  328. protected override void OnResize(EventArgs e)
  329. {
  330. base.OnResize(e);
  331. Size = new Size(Width, 16);
  332. }
  333.  
  334. protected override void OnMouseUp(MouseEventArgs e)
  335. {
  336. base.OnMouseUp(e);
  337. Checked = !Checked;
  338. }
  339.  
  340. protected override void OnPaint(PaintEventArgs e)
  341. {
  342. base.OnPaint(e);
  343. var g = e.Graphics;
  344. var p = new Pen(Color.FromArgb(35, 35, 40));
  345. var s = new SolidBrush(Color.FromArgb(220, 220, 255));
  346.  
  347. g.SmoothingMode = SmoothingMode.HighQuality;
  348. g.Clear(Helper.Colors.Background);
  349.  
  350. var l = new LinearGradientBrush(new Rectangle(0, 0, Width, Height + 35), Color.FromArgb(98, 115, 133), Color.Black, LinearGradientMode.Vertical);
  351.  
  352. g.FillEllipse(l, new Rectangle(1, 1, 14, 14));
  353. g.DrawEllipse(p, new Rectangle(5, 5, 5, 5));
  354.  
  355. if (Checked)
  356. g.FillEllipse(s, new Rectangle(5, 5, 5, 5));
  357.  
  358. s.Color = Helper.Colors.Foreground;
  359. g.DrawString(Text, Font, s, new PointF(20, 0));
  360.  
  361. Helper.MultiDispose(s, p, l);
  362.  
  363. }
  364. }
  365.  
  366. sealed class AevionCheckBox : Control
  367. {
  368. public event EventHandler CheckedChanged = delegate { };
  369.  
  370. private Boolean _Checked;
  371.  
  372. public Boolean Checked
  373. {
  374. get { return _Checked; }
  375. set {
  376. _Checked = value;
  377. Invalidate();
  378. CheckedChanged(this, new EventArgs());
  379. }
  380. }
  381.  
  382. public override string Text
  383. {
  384. get { return base.Text; }
  385. set { base.Text = value; Invalidate(); }
  386. }
  387.  
  388. public override Font Font
  389. {
  390. get { return base.Font; }
  391. set { base.Font = value; Invalidate(); }
  392. }
  393.  
  394. public AevionCheckBox()
  395. {
  396. DoubleBuffered = true;
  397. Font = Helper.Fonts.Primary;
  398. Size = new Size(Width, 16);
  399. }
  400.  
  401. protected override void OnResize(EventArgs e)
  402. {
  403. base.OnResize(e);
  404. Size = new Size(Width, 16);
  405. }
  406.  
  407. protected override void OnMouseUp(MouseEventArgs e)
  408. {
  409. base.OnMouseUp(e);
  410. Checked = !Checked;
  411. }
  412.  
  413. protected override void OnPaint(PaintEventArgs e)
  414. {
  415. base.OnPaint(e);
  416. var g = e.Graphics;
  417. var s = new SolidBrush(Helper.Colors.Foreground);
  418. var l = new LinearGradientBrush(new Rectangle(0, 0, Width, Height + 35), Color.FromArgb(98, 115, 133), Color.Black, LinearGradientMode.Vertical);
  419.  
  420. g.SmoothingMode = SmoothingMode.HighQuality;
  421. g.Clear(Helper.Colors.Background);
  422.  
  423. g.FillRectangle(l, new Rectangle(1, 1, 13, 13));
  424. Helper.RoundRect(g, 0, 0, 14, 14, 3, Color.FromArgb(35, 35, 40));
  425.  
  426. if (Checked)
  427. Helper.CenterString(g, "b", new Font("Marlett", 10), Helper.Colors.Foreground, new Rectangle(2, 1, 13, 13));
  428.  
  429. g.DrawString(Text, Font, s, new Point(20, -1));
  430.  
  431. Helper.MultiDispose(s, l);
  432.  
  433. }
  434. }
  435.  
  436. sealed class AevionProgressBar : Control
  437. {
  438. private Int32 _Maximum = 100;
  439. private Int32 _Minimum, _Value = 0;
  440. private Boolean _ShowText = true;
  441.  
  442. public Int32 Maximum
  443. {
  444. get { return _Maximum; }
  445. set
  446. {
  447. if (value > Int32.MaxValue)
  448. throw new OverflowException();
  449. if (value < _Minimum)
  450. _Minimum = value - 1;
  451. if (_Value > _Maximum)
  452. _Value = value;
  453. _Maximum = value;
  454. Invalidate();
  455. }
  456. }
  457.  
  458. public Int32 Minimum
  459. {
  460. get { return _Minimum; }
  461. set
  462. {
  463. if (value < 0)
  464. throw new ArgumentOutOfRangeException("Minimum", "Value cannot go below 0.");
  465. if (value < _Minimum)
  466. _Value = value;
  467. if (value > _Maximum)
  468. _Maximum = value + 1;
  469. _Minimum = value;
  470. Invalidate();
  471. }
  472. }
  473.  
  474. public Int32 Value
  475. {
  476. get { return _Value; }
  477. set
  478. {
  479. if (value > _Maximum)
  480. _Value = _Maximum;
  481. else if (value < _Minimum)
  482. _Value = _Minimum;
  483. else _Value = value;
  484. Invalidate();
  485. }
  486. }
  487.  
  488. public Boolean ShowText
  489. {
  490. get { return _ShowText; }
  491. set { _ShowText = value; Invalidate(); }
  492. }
  493.  
  494. public override string Text
  495. {
  496. get { return base.Text; }
  497. set { base.Text = value; Invalidate(); }
  498. }
  499.  
  500. public override Font Font
  501. {
  502. get { return base.Font; }
  503. set { base.Font = value; Invalidate(); }
  504. }
  505.  
  506. public AevionProgressBar()
  507. {
  508. DoubleBuffered = true;
  509. Font = Helper.Fonts.Primary;
  510. }
  511.  
  512. protected override void OnPaint(PaintEventArgs e)
  513. {
  514. base.OnPaint(e);
  515. var g = e.Graphics;
  516. var l = new LinearGradientBrush(new Point(0, 0), new Point(Width + Value + 50, Height), Color.FromArgb(98, 115, 133), Color.Black);
  517.  
  518. g.SmoothingMode = SmoothingMode.HighQuality;
  519. g.Clear(Helper.Colors.Background);
  520.  
  521. g.FillRectangle(l, new Rectangle(0, 0, (int)(Helper.ValueToPercentage(Value, Maximum, Minimum) * Width), Height));
  522.  
  523. Helper.RoundRect(g, 0, 0, Width - 1, Height - 1, 3, Color.FromArgb(38, 38, 38));
  524.  
  525. if (ShowText)
  526. Helper.CenterString(g, Text, Font, Helper.Colors.Foreground, new Rectangle(0, 0, Width, Height));
  527.  
  528. Helper.MultiDispose(l);
  529.  
  530. }
  531.  
  532. }
  533.  
  534. sealed class AevionNotice : TextBox
  535. {
  536.  
  537. public AevionNotice()
  538. {
  539. DoubleBuffered = true;
  540. Font = Helper.Fonts.Primary;
  541. Enabled = false;
  542. Multiline = true;
  543. BorderStyle = BorderStyle.None;
  544. SetStyle(ControlStyles.UserPaint | ControlStyles.SupportsTransparentBackColor, true);
  545. }
  546.  
  547. protected override void OnPaint(PaintEventArgs e)
  548. {
  549. base.OnPaint(e);
  550. var g = e.Graphics;
  551. var s = new SolidBrush(Color.FromArgb(38, 38, 38));
  552.  
  553. g.SmoothingMode = SmoothingMode.HighQuality;
  554. g.Clear(Helper.Colors.Background);
  555.  
  556. g.FillRectangle(s, new Rectangle(1, 1, Width - 2, Height - 2));
  557. Helper.RoundRect(g, 0, 0, Width - 1, Height - 1, 3, Color.FromArgb(35, 35, 40));
  558.  
  559. s.Color = Helper.Colors.Foreground;
  560. g.DrawString(Text, Font, s, new Point(12, 8));
  561.  
  562. }
  563. }
  564.  
  565. sealed class AevionLabel : Label
  566. {
  567. public AevionLabel()
  568. {
  569. DoubleBuffered = true;
  570. Font = Helper.Fonts.Primary;
  571. ForeColor = Helper.Colors.Foreground;
  572. BackColor = Helper.Colors.Background;
  573. }
  574. }
  575.  
  576. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement