Advertisement
VmX5

Velocity Theme -C#

May 6th, 2017
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 20.66 KB | None | 0 0
  1. using Microsoft.VisualBasic;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.Data;
  6. using System.Diagnostics;
  7. public static class Helpers
  8. {
  9.  
  10.     public enum MouseState
  11.     {
  12.         Hover = 1,
  13.         Down = 2,
  14.         None = 3
  15.     }
  16.     public enum TxtAlign
  17.     {
  18.         Left = 1,
  19.         Center = 2,
  20.         Right = 3
  21.     }
  22.  
  23.     public static Image b64Image(string b64)
  24.     {
  25.         return Image.FromStream(new System.IO.MemoryStream(Convert.FromBase64String(b64)));
  26.     }
  27.  
  28.     public static Color FromHex(string hex)
  29.     {
  30.         return ColorTranslator.FromHtml(hex);
  31.     }
  32. }
  33.  
  34. public class VelocityButton : Control
  35. {
  36.  
  37.     private MouseState state = MouseState.None;
  38.  
  39.     private bool _enabled = true;
  40.     private TxtAlign _txtAlign = TxtAlign.Center;
  41.     public TxtAlign TextAlign {
  42.         get { return _txtAlign; }
  43.         set {
  44.             _txtAlign = value;
  45.             Invalidate();
  46.         }
  47.     }
  48.  
  49.     public VelocityButton()
  50.     {
  51.         DoubleBuffered = true;
  52.         Font = new Font("Segoe UI Semilight", 9);
  53.         ForeColor = Color.White;
  54.         Size = new Size(94, 40);
  55.     }
  56.  
  57.     public bool Enabled {
  58.         get { return _enabled; }
  59.         set {
  60.             _enabled = value;
  61.             Invalidate();
  62.         }
  63.     }
  64.  
  65.     public void PerformClick()
  66.     {
  67.         base.OnClick(EventArgs.Empty);
  68.     }
  69.  
  70.     protected override void OnPaint(PaintEventArgs e)
  71.     {
  72.         base.OnPaint(e);
  73.         Graphics g = e.Graphics;
  74.         switch (_enabled) {
  75.             case true:
  76.                 switch (state) {
  77.                     case MouseState.None:
  78.                         g.Clear(Helpers.FromHex("#435363"));
  79.                         break;
  80.                     case MouseState.Hover:
  81.                         g.Clear(Helpers.FromHex("#38495A"));
  82.                         break;
  83.                     case MouseState.Down:
  84.                         g.Clear(BackColor);
  85.                         g.FillRectangle(new SolidBrush(Helpers.FromHex("#2c3e50")), 1, 1, Width - 2, Height - 2);
  86.                         break;
  87.                 }
  88.                 break;
  89.             case false:
  90.                 g.Clear(Helpers.FromHex("#38495A"));
  91.                 break;
  92.         }
  93.  
  94.         switch (_txtAlign) {
  95.             case TxtAlign.Left:
  96.                 g.DrawString(Text, Font, new SolidBrush(ForeColor), new Rectangle(8, 0, Width, Height), new StringFormat {
  97.                     Alignment = StringAlignment.Near,
  98.                     LineAlignment = StringAlignment.Center
  99.                 });
  100.                 break;
  101.             case TxtAlign.Center:
  102.                 g.DrawString(Text, Font, new SolidBrush(ForeColor), new Rectangle(0, 0, Width, Height), new StringFormat {
  103.                     Alignment = StringAlignment.Center,
  104.                     LineAlignment = StringAlignment.Center
  105.                 });
  106.                 break;
  107.             case TxtAlign.Right:
  108.                 g.DrawString(Text, Font, new SolidBrush(ForeColor), new Rectangle(0, 0, Width - 8, Height), new StringFormat {
  109.                     Alignment = StringAlignment.Far,
  110.                     LineAlignment = StringAlignment.Center
  111.                 });
  112.                 break;
  113.         }
  114.     }
  115.  
  116.     protected override void OnMouseEnter(EventArgs e)
  117.     {
  118.         base.OnMouseEnter(e);
  119.         state = MouseState.Hover;
  120.         Invalidate();
  121.     }
  122.  
  123.     protected override void OnMouseHover(EventArgs e)
  124.     {
  125.         base.OnMouseHover(e);
  126.         state = MouseState.Hover;
  127.         Invalidate();
  128.     }
  129.  
  130.     protected override void OnMouseLeave(EventArgs e)
  131.     {
  132.         base.OnMouseLeave(e);
  133.         state = MouseState.None;
  134.         Invalidate();
  135.     }
  136.  
  137.     protected override void OnMouseDown(MouseEventArgs e)
  138.     {
  139.         base.OnMouseDown(e);
  140.         state = MouseState.Down;
  141.         Invalidate();
  142.     }
  143.  
  144.     protected override void OnMouseUp(MouseEventArgs e)
  145.     {
  146.         base.OnMouseUp(e);
  147.         state = MouseState.Hover;
  148.         Invalidate();
  149.     }
  150.  
  151.     protected override void OnTextChanged(EventArgs e)
  152.     {
  153.         base.OnTextChanged(e);
  154.         Invalidate();
  155.     }
  156. }
  157.  
  158. [DefaultEvent("CheckChanged")]
  159. public class VelocityCheckBox : Control
  160. {
  161.  
  162.     MouseState _state = MouseState.None;
  163.     public event CheckChangedEventHandler CheckChanged;
  164.     public delegate void CheckChangedEventHandler(object sender, EventArgs e);
  165.  
  166.     private bool _autoSize = true;
  167.     public override bool AutoSize {
  168.         get { return _autoSize; }
  169.         set {
  170.             _autoSize = value;
  171.             Invalidate();
  172.         }
  173.     }
  174.  
  175.     private bool _checked = false;
  176.     public bool Checked {
  177.         get { return _checked; }
  178.         set {
  179.             _checked = value;
  180.             Invalidate();
  181.         }
  182.     }
  183.  
  184.     public VelocityCheckBox()
  185.     {
  186.         DoubleBuffered = true;
  187.     }
  188.  
  189.     protected override void OnPaint(PaintEventArgs e)
  190.     {
  191.         base.OnPaint(e);
  192.         switch (AutoSize) {
  193.             case true:
  194.                 Size = new Size(TextRenderer.MeasureText(Text, Font).Width + 28, Height);
  195.                 break;
  196.         }
  197.         Graphics g = e.Graphics;
  198.         switch (_state) {
  199.             case MouseState.Hover:
  200.                 g.FillRectangle(new SolidBrush(Helpers.FromHex("#DBDBDB")), 4, 4, 14, 14);
  201.                 break;
  202.             default:
  203.                 g.FillRectangle(Brushes.White, 4, 4, 14, 14);
  204.                 break;
  205.         }
  206.         if (_checked) {
  207.             g.FillRectangle(new SolidBrush(Helpers.FromHex("#435363")), 7, 7, 9, 9);
  208.         }
  209.         g.DrawRectangle(new Pen(Helpers.FromHex("#435363")), new Rectangle(4, 4, 14, 14));
  210.         g.DrawString(Text, Font, new SolidBrush(ForeColor), new Rectangle(22, 0, Width, Height), new StringFormat { LineAlignment = StringAlignment.Center });
  211.     }
  212.  
  213.     protected override void OnTextChanged(EventArgs e)
  214.     {
  215.         base.OnTextChanged(e);
  216.         Invalidate();
  217.     }
  218.  
  219.     protected override void OnMouseUp(MouseEventArgs e)
  220.     {
  221.         base.OnMouseUp(e);
  222.         switch (Checked) {
  223.             case true:
  224.                 Checked = false;
  225.                 break;
  226.             case false:
  227.                 Checked = true;
  228.                 break;
  229.         }
  230.         _state = MouseState.Hover;
  231.         Invalidate();
  232.     }
  233.  
  234.     protected override void OnMouseEnter(EventArgs e)
  235.     {
  236.         base.OnMouseEnter(e);
  237.         _state = MouseState.Hover;
  238.         Invalidate();
  239.     }
  240.  
  241.     protected override void OnMouseHover(EventArgs e)
  242.     {
  243.         base.OnMouseHover(e);
  244.         _state = MouseState.Hover;
  245.         Invalidate();
  246.     }
  247.  
  248.     protected override void OnMouseLeave(EventArgs e)
  249.     {
  250.         base.OnMouseLeave(e);
  251.         _state = MouseState.None;
  252.         Invalidate();
  253.     }
  254.  
  255.     protected override void OnMouseDown(MouseEventArgs e)
  256.     {
  257.         base.OnMouseDown(e);
  258.         _state = MouseState.Down;
  259.         Invalidate();
  260.     }
  261.  
  262.     protected override void OnResize(EventArgs e)
  263.     {
  264.         base.OnResize(e);
  265.         Invalidate();
  266.     }
  267. }
  268.  
  269. [DefaultEvent("CheckChanged")]
  270. public class VelocityRadioButton : Control
  271. {
  272.  
  273.     MouseState _state;
  274.     public event CheckChangedEventHandler CheckChanged;
  275.     public delegate void CheckChangedEventHandler(object sender, EventArgs e);
  276.  
  277.     private bool _autoSize = true;
  278.     public override bool AutoSize {
  279.         get { return _autoSize; }
  280.         set {
  281.             _autoSize = value;
  282.             Invalidate();
  283.         }
  284.     }
  285.  
  286.     private bool _checked = false;
  287.     public bool Checked {
  288.         get { return _checked; }
  289.         set {
  290.             _checked = value;
  291.             Invalidate();
  292.         }
  293.     }
  294.  
  295.     public VelocityRadioButton()
  296.     {
  297.         DoubleBuffered = true;
  298.         InvalidateControls();
  299.     }
  300.  
  301.     protected override void OnPaint(PaintEventArgs e)
  302.     {
  303.         base.OnPaint(e);
  304.         switch (AutoSize) {
  305.             case true:
  306.                 Size = new Size(TextRenderer.MeasureText(Text, Font).Width + 24, Height);
  307.                 break;
  308.         }
  309.         Graphics g = e.Graphics;
  310.         g.SmoothingMode = Drawing2D.SmoothingMode.HighQuality;
  311.         switch (_state) {
  312.             case MouseState.Hover:
  313.                 g.FillEllipse(new SolidBrush(Helpers.FromHex("#DBDBDB")), 4, 4, 14, 14);
  314.                 break;
  315.             default:
  316.                 g.FillEllipse(Brushes.White, 4, 4, 14, 14);
  317.                 break;
  318.         }
  319.         g.DrawEllipse(new Pen(Helpers.FromHex("#435363")), new Rectangle(4, 4, 14, 14));
  320.         g.DrawString(Text, Font, new SolidBrush(ForeColor), new Rectangle(22, 0, Width, Height), new StringFormat { LineAlignment = StringAlignment.Center });
  321.         if (_checked == true) {
  322.             g.FillEllipse(new SolidBrush(Helpers.FromHex("#435363")), 7, 7, 8, 8);
  323.         }
  324.     }
  325.  
  326.     private void InvalidateControls()
  327.     {
  328.         if (!IsHandleCreated || !_checked)
  329.             return;
  330.         foreach (Control C in Parent.Controls) {
  331.             if (!object.ReferenceEquals(C, this) && C is VelocityRadioButton) {
  332.                 ((VelocityRadioButton)C).Checked = false;
  333.                 Invalidate();
  334.             }
  335.         }
  336.     }
  337.  
  338.     protected override void OnTextChanged(EventArgs e)
  339.     {
  340.         base.OnTextChanged(e);
  341.         Invalidate();
  342.     }
  343.  
  344.     protected override void OnMouseUp(MouseEventArgs e)
  345.     {
  346.         base.OnMouseUp(e);
  347.         _state = MouseState.Hover;
  348.         switch (Checked) {
  349.             case true:
  350.                 Checked = false;
  351.                 break;
  352.             case false:
  353.                 Checked = true;
  354.                 break;
  355.         }
  356.         _state = MouseState.Hover;
  357.         InvalidateControls();
  358.     }
  359.  
  360.     protected override void OnMouseHover(EventArgs e)
  361.     {
  362.         base.OnMouseHover(e);
  363.         _state = MouseState.Hover;
  364.         Invalidate();
  365.     }
  366.  
  367.     protected override void OnMouseLeave(EventArgs e)
  368.     {
  369.         base.OnMouseLeave(e);
  370.         _state = MouseState.None;
  371.         Invalidate();
  372.     }
  373.  
  374.     protected override void OnMouseDown(MouseEventArgs e)
  375.     {
  376.         base.OnMouseDown(e);
  377.         _state = MouseState.None;
  378.         Invalidate();
  379.     }
  380.  
  381.     protected override void OnResize(EventArgs e)
  382.     {
  383.         base.OnResize(e);
  384.         Invalidate();
  385.     }
  386. }
  387.  
  388. public class VelocityTitle : Control
  389. {
  390.  
  391.     private TxtAlign _txtAlign = TxtAlign.Left;
  392.     public TxtAlign TextAlign {
  393.         get { return _txtAlign; }
  394.         set {
  395.             _txtAlign = value;
  396.             Invalidate();
  397.         }
  398.     }
  399.  
  400.     public VelocityTitle()
  401.     {
  402.         DoubleBuffered = true;
  403.         Size = new Size(180, 23);
  404.     }
  405.  
  406.     protected override void OnPaint(PaintEventArgs e)
  407.     {
  408.         base.OnPaint(e);
  409.         Graphics g = e.Graphics;
  410.         g.DrawLine(new Pen(Helpers.FromHex("#435363")), new Point(0, Height / 2), new Point(Width, Height / 2));
  411.         Size txtRect = new Size(g.MeasureString(Text, Font).ToSize);
  412.         switch (_txtAlign) {
  413.             case TxtAlign.Left:
  414.                 g.FillRectangle(new SolidBrush(BackColor), new Rectangle(18, Height / 2 - txtRect.Height - 2, txtRect.Width + 6, Height / 2 + txtRect.Height / 2 + 6));
  415.                 g.DrawString(Text, Font, new SolidBrush(ForeColor), 20, Height / 2 - txtRect.Height / 2);
  416.                 break;
  417.             case TxtAlign.Center:
  418.                 g.FillRectangle(new SolidBrush(BackColor), new Rectangle(Width / 2 - txtRect.Width / 2 - 2, Height / 2 - txtRect.Height / 2 - 2, txtRect.Width + 2, txtRect.Height + 2));
  419.                 g.DrawString(Text, Font, new SolidBrush(ForeColor), Width / 2 - txtRect.Width / 2, Height / 2 - txtRect.Height / 2);
  420.                 break;
  421.             case TxtAlign.Right:
  422.                 g.FillRectangle(new SolidBrush(BackColor), new Rectangle(Width - (txtRect.Width + 18), Height / 2 - txtRect.Height - 2, txtRect.Width + 4, Height + 6));
  423.                 g.DrawString(Text, Font, new SolidBrush(ForeColor), Width - (txtRect.Width + 16), Height / 2 - txtRect.Height / 2);
  424.                 break;
  425.         }
  426.     }
  427.  
  428.     protected override void OnFontChanged(EventArgs e)
  429.     {
  430.         base.OnFontChanged(e);
  431.         Invalidate();
  432.     }
  433.  
  434.     protected override void OnTextChanged(EventArgs e)
  435.     {
  436.         base.OnTextChanged(e);
  437.         Invalidate();
  438.     }
  439. }
  440.  
  441. public class VelocitySplitter : Control
  442. {
  443.  
  444.     private int _offset = 8;
  445.     public int Offset {
  446.         get { return _offset; }
  447.         set {
  448.             _offset = value;
  449.             Invalidate();
  450.         }
  451.     }
  452.     public VelocitySplitter()
  453.     {
  454.         DoubleBuffered = true;
  455.     }
  456.  
  457.     protected override void OnPaint(PaintEventArgs e)
  458.     {
  459.         base.OnPaint(e);
  460.         Graphics g = e.Graphics;
  461.         g.DrawLine(new Pen(ForeColor), new Point(_offset, Height / 2 - 2), new Point(Width - _offset, Height / 2 - 1));
  462.     }
  463. }
  464.  
  465. [DefaultEvent("XClicked")]
  466. public class VelocityAlert : Control
  467. {
  468.  
  469.     public event XClickedEventHandler XClicked;
  470.     public delegate void XClickedEventHandler(object sender, EventArgs e);
  471.  
  472.     bool _xHover = false;
  473.     #region "Filler Image Base64"
  474.         #endregion
  475.     string FillerImage = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAIAAAAlC+aJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMTM0A1t6AAADZUlEQVRoQ+2W2ytsYRjG9x85Cikpp1KORSkihITkyinkdCERm0wi3IiS5ELKIQkXkiQkh9m/tZ7PNHuwWi707dl9v4vpfd/1zut51ncYvyIpzv9iIJaCSLkzYA8pdwbsIeXOgD2k3Bmwh5Q7A/aQcmfAHlLuDNhDyp0Be0i5M2APKXcG7CHlzoA9pPx7Bh4fH4+Pj/f29m5vb03pHSpnZ2cmCeTt7Y1OhlxdXZnSO8/PzyGHgJR/w8Dc3Fx6err6s7OzTdXn9fW1sLCQ+urqqil9AQ15eXkaAkdHR+aBT21tLcWJiQmTB6IJYQ1sbW3RtrKyovTy8lKBGBsb05zl5WVT+ozT01N6pqenlSatwNLSkoaMjIyYUiBqDmugoaGhr6/PJH/DojNhf3+fz2g0SoXPqampu7s7Nfz2Iejt7W1sbFQxiaenJ1YG/wwZHBw01UA83eENsHnW1tZ4Z4eHh/f396bq09bW1tLSQpE5MgBFRUWdnZ0EJycn1Dc2NojLysrYHhhjSNIpGh4ezs/PJ6C5v79fxWA83SENXF9f01NVVaVmGBgY0KPNzU1SgiQDKCZlx1dUVHR0dKiYlZVVWlrqfd+nvb1ddS4G0ouLC2ICFkr1YPwZ4Qycn5/TMzQ0pHRmZoYU6cTl5eXaHkkGoLm52Rsdidzc3JBy+RC3trZqASV6dnaWmAXs6enxvvNDBlh0era3t00eixUUFKCb45iZmcnqj4+P6xwjJf5eFxYWqLACSiEnJ4erzCSxWF1dHedKa8W+ZwIbjJillrFg6ISwZyA3N3d+fl4xvwZpaWmsAAa6u7u7uro4Bk1NTcwpLi4uKSmhhy3OsRkdHaUY/2JNTU187wHNTMAAQwDnGsJhYKZp+hpPd3gD/IHq6moOw8vLC++JG4O73zzzeXh4YA4HXSn99fX1BLzajIwM7aLJyUl+Lg4ODogXFxfpZ3N63QmwpD9yjfJGWXE18+Z2d3fNg3cSDezs7BDHf1MrKytJFbNW3ohIhO20vr6uYiIsNXvJJIFoTlgDgs3DhW2SD3z8/+JTmJB0EScScghI+fcM/FNIuTNgDyl3Buwh5c6APaTcGbCHlDsD9pByZ8AeUu4M2EPKnQF7SLkzYA8pdwbsIeXOgD2k3Bmwh5QbA6lLihuIRP4AXubLj7lh8ksAAAAASUVORK5CYII=";
  476.  
  477.     private bool _xChangeCursor = true;
  478.     public bool XChangeCursor {
  479.         get { return _xChangeCursor; }
  480.         set {
  481.             _xChangeCursor = value;
  482.             Invalidate();
  483.         }
  484.     }
  485.  
  486.     private string _title = Name;
  487.     public string Title {
  488.         get { return _title; }
  489.         set {
  490.             _title = value;
  491.             Invalidate();
  492.         }
  493.     }
  494.  
  495.     private bool _exitButton = false;
  496.     public bool ShowExit {
  497.         get { return _exitButton; }
  498.         set {
  499.             _exitButton = value;
  500.             Invalidate();
  501.         }
  502.     }
  503.  
  504.     private bool _showImage = true;
  505.     public bool ShowImage {
  506.         get { return _showImage; }
  507.         set {
  508.             _showImage = value;
  509.             Invalidate();
  510.         }
  511.     }
  512.  
  513.     private Image _image;
  514.     public Image Image {
  515.         get { return _image; }
  516.         set {
  517.             _image = value;
  518.             Invalidate();
  519.         }
  520.     }
  521.  
  522.     private Color _border = Helpers.FromHex("#435363");
  523.     public Color Border {
  524.         get { return _border; }
  525.         set {
  526.             _border = value;
  527.             Invalidate();
  528.         }
  529.     }
  530.  
  531.     public VelocityAlert()
  532.     {
  533.         Size = new Size(370, 80);
  534.         DoubleBuffered = true;
  535.     }
  536.  
  537.     protected override void OnPaint(PaintEventArgs e)
  538.     {
  539.         base.OnPaint(e);
  540.         Graphics g = e.Graphics;
  541.         g.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit;
  542.  
  543.  
  544.         switch (ShowImage) {
  545.             case true:
  546.                 if (_image == null) {
  547.                     g.DrawImage(Helpers.b64Image(FillerImage), 13, 8);
  548.                 } else {
  549.                     g.DrawImage(_image, 12, 8, 64, 64);
  550.                 }
  551.                 g.DrawString(_title, new Font("Segoe UI Semilight", 14), new SolidBrush(ForeColor), 84, 6);
  552.                 g.DrawString(Text, Font, new SolidBrush(ForeColor), new Rectangle(86, 33, Width - 88, Height - 10));
  553.                 break;
  554.             case false:
  555.                 g.DrawString(_title, new Font("Segoe UI Semilight", 14), new SolidBrush(ForeColor), 18, 6);
  556.                 g.DrawString(Text, Font, new SolidBrush(ForeColor), new Rectangle(20, 33, Width - 28, Height - 10));
  557.                 break;
  558.         }
  559.  
  560.         if (ShowExit) {
  561.             if (_xHover) {
  562.                 g.DrawString("r", new Font("Marlett", 9), new SolidBrush(Helpers.FromHex("#596372")), Width - 18, 4);
  563.             } else {
  564.                 g.DrawString("r", new Font("Marlett", 9), new SolidBrush(Helpers.FromHex("#435363")), Width - 18, 4);
  565.             }
  566.         }
  567.  
  568.         g.DrawRectangle(new Pen(_border), 0, 0, Width - 1, Height - 1);
  569.         g.FillRectangle(new SolidBrush(_border), 0, 0, 6, Height);
  570.     }
  571.  
  572.     protected override void OnMouseMove(MouseEventArgs e)
  573.     {
  574.         base.OnMouseMove(e);
  575.         if (_exitButton) {
  576.             if (new Rectangle(Width - 16, 4, 12, 13).Contains(e.X, e.Y)) {
  577.                 _xHover = true;
  578.                 if (_xChangeCursor) {
  579.                     Cursor = Cursors.Hand;
  580.                 }
  581.             } else {
  582.                 _xHover = false;
  583.                 Cursor = Cursors.Default;
  584.             }
  585.         }
  586.         Invalidate();
  587.     }
  588.  
  589.     protected override void OnMouseUp(MouseEventArgs e)
  590.     {
  591.         base.OnMouseUp(e);
  592.         if (_exitButton) {
  593.             if (_xHover) {
  594.                 if (XClicked != null) {
  595.                     XClicked(this, EventArgs.Empty);
  596.                 }
  597.             }
  598.         }
  599.     }
  600.  
  601.     protected override void OnTextChanged(EventArgs e)
  602.     {
  603.         base.OnTextChanged(e);
  604.         Invalidate();
  605.     }
  606. }
  607.  
  608. public class VelocityTabControl : TabControl
  609. {
  610.  
  611.  
  612.     private int _overtab = 0;
  613.     private TxtAlign _txtAlign = TxtAlign.Center;
  614.     public TxtAlign TextAlign {
  615.         get { return _txtAlign; }
  616.         set {
  617.             _txtAlign = value;
  618.             Invalidate();
  619.         }
  620.     }
  621.  
  622.     public VelocityTabControl()
  623.     {
  624.         SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.UserPaint, true);
  625.         DoubleBuffered = true;
  626.         SizeMode = TabSizeMode.Fixed;
  627.         ItemSize = new Size(40, 130);
  628.         Alignment = TabAlignment.Left;
  629.         Font = new Font("Segoe UI Semilight", 9);
  630.     }
  631.  
  632.     protected override void OnPaint(PaintEventArgs e)
  633.     {
  634.         base.OnPaint(e);
  635.         Bitmap b = new Bitmap(Width, Height);
  636.         Graphics g = Graphics.FromImage(b);
  637.         g.Clear(Helpers.FromHex("#435363"));
  638.         for (i = 0; i <= TabCount - 1; i++) {
  639.             Rectangle tabRect = GetTabRect(i);
  640.             if (i == SelectedIndex) {
  641.                 g.FillRectangle(new SolidBrush(Helpers.FromHex("#2c3e50")), tabRect);
  642.             } else if (i == _overtab) {
  643.                 g.FillRectangle(new SolidBrush(Helpers.FromHex("#435363")), tabRect);
  644.             } else {
  645.                 g.FillRectangle(new SolidBrush(Helpers.FromHex("#38495A")), tabRect);
  646.             }
  647.             switch (_txtAlign) {
  648.                 case TxtAlign.Left:
  649.                     g.DrawString(TabPages(i).Text, Font, Brushes.White, new Rectangle(tabRect.X + 8, tabRect.Y, tabRect.Width, tabRect.Height), new StringFormat {
  650.                         Alignment = StringAlignment.Near,
  651.                         LineAlignment = StringAlignment.Center
  652.                     });
  653.                     break;
  654.                 case TxtAlign.Center:
  655.                     g.DrawString(TabPages(i).Text, Font, Brushes.White, tabRect, new StringFormat {
  656.                         Alignment = StringAlignment.Center,
  657.                         LineAlignment = StringAlignment.Center
  658.                     });
  659.                     break;
  660.                 case TxtAlign.Right:
  661.                     g.DrawString(TabPages(i).Text, Font, Brushes.White, new Rectangle(tabRect.X - 8, tabRect.Y, tabRect.Width, tabRect.Height), new StringFormat {
  662.                         Alignment = StringAlignment.Far,
  663.                         LineAlignment = StringAlignment.Center
  664.                     });
  665.                     break;
  666.             }
  667.         }
  668.  
  669.         e.Graphics.DrawImage(b.Clone, 0, 0);
  670.         g.Dispose();
  671.         b.Dispose();
  672.     }
  673.  
  674.     protected override void OnMouseMove(MouseEventArgs e)
  675.     {
  676.         base.OnMouseMove(e);
  677.         for (i = 0; i <= TabPages.Count - 1; i++) {
  678.             if (GetTabRect(i).Contains(e.Location)) {
  679.                 _overtab = i;
  680.             }
  681.             Invalidate();
  682.         }
  683.     }
  684. }
  685.  
  686. public class VelocityTag : Control
  687. {
  688.  
  689.     private Color _border = Helpers.FromHex("#2c3e50");
  690.     public Color Border {
  691.         get { return _border; }
  692.         set {
  693.             _border = value;
  694.             Invalidate();
  695.         }
  696.     }
  697.  
  698.     public VelocityTag()
  699.     {
  700.         DoubleBuffered = true;
  701.         BackColor = Helpers.FromHex("#34495e");
  702.         ForeColor = Color.White;
  703.     }
  704.  
  705.     protected override void OnPaint(PaintEventArgs e)
  706.     {
  707.         base.OnPaint(e);
  708.         Graphics g = e.Graphics;
  709.         g.Clear(BackColor);
  710.         g.DrawRectangle(new Pen(_border), 0, 0, Width - 1, Height - 1);
  711.         g.DrawString(Text, Font, new SolidBrush(ForeColor), new Rectangle(0, 0, Width, Height), new StringFormat {
  712.             Alignment = StringAlignment.Center,
  713.             LineAlignment = StringAlignment.Center
  714.         });
  715.     }
  716.  
  717.     protected override void OnTextChanged(EventArgs e)
  718.     {
  719.         base.OnTextChanged(e);
  720.         Invalidate();
  721.     }
  722. }
  723.  
  724. public class VelocityProgressBar : Control
  725. {
  726.  
  727.     private Color _border = Helpers.FromHex("#485e75");
  728.     public Color Border {
  729.         get { return _border; }
  730.         set {
  731.             _border = value;
  732.             Invalidate();
  733.         }
  734.     }
  735.  
  736.     private Color _progressColor = Helpers.FromHex("#2c3e50");
  737.     public Color ProgressColor {
  738.         get { return _progressColor; }
  739.         set {
  740.             _progressColor = value;
  741.             Invalidate();
  742.         }
  743.     }
  744.  
  745.     private int _val = 0;
  746.     public int Value {
  747.         get { return _val; }
  748.         set {
  749.             _val = value;
  750.             ValChanged();
  751.             Invalidate();
  752.         }
  753.     }
  754.  
  755.     private int _min = 0;
  756.     public int Min {
  757.         get { return _min; }
  758.         set {
  759.             _min = value;
  760.             Invalidate();
  761.         }
  762.     }
  763.  
  764.     private int _max = 100;
  765.     public int Max {
  766.         get { return _max; }
  767.         set {
  768.             _max = value;
  769.             Invalidate();
  770.         }
  771.     }
  772.  
  773.     private bool _showPercent = false;
  774.     public bool ShowPercent {
  775.         get { return _showPercent; }
  776.         set {
  777.             _showPercent = value;
  778.             Invalidate();
  779.         }
  780.     }
  781.  
  782.     private void ValChanged()
  783.     {
  784.         if (_val > _max) {
  785.             _val = _max;
  786.         }
  787.     }
  788.  
  789.     public VelocityProgressBar()
  790.     {
  791.         DoubleBuffered = true;
  792.     }
  793.  
  794.     protected override void OnPaint(PaintEventArgs e)
  795.     {
  796.         base.OnPaint(e);
  797.         Graphics g = e.Graphics;
  798.  
  799.         if (_showPercent) {
  800.             g.FillRectangle(new SolidBrush(Helpers.FromHex("#506070")), 0, 0, Width - 35, Height - 1);
  801.             g.FillRectangle(new SolidBrush(_progressColor), new Rectangle(0, 0, _val * (Width - 35) / (_max - _min), Height));
  802.             g.DrawRectangle(new Pen(Color.Black), 0, 0, Width - 35, Height - 1);
  803.             g.DrawString(_val + "%", Font, new SolidBrush(ForeColor), Width - 30, Height / 2 - g.MeasureString(_val + "%", Font).Height / 2 - 1);
  804.         } else {
  805.             g.Clear(Helpers.FromHex("#506070"));
  806.             g.FillRectangle(new SolidBrush(_progressColor), new Rectangle(0, 0, (_val - 0) * (Width - 0) / (_max - _min) + 0, Height));
  807.             g.DrawRectangle(new Pen(Color.Black), 0, 0, Width - 1, Height - 1);
  808.         }
  809.     }
  810. }
  811.  
  812. public class VelocityToggle : Control
  813. {
  814.  
  815.     private bool _checked = false;
  816.     public bool Checked {
  817.         get { return _checked; }
  818.         set {
  819.             _checked = value;
  820.             Invalidate();
  821.         }
  822.     }
  823.  
  824.     public VelocityToggle()
  825.     {
  826.         Size = new Size(50, 23);
  827.         DoubleBuffered = true;
  828.     }
  829.  
  830.     protected override void OnPaint(PaintEventArgs e)
  831.     {
  832.         base.OnPaint(e);
  833.         Graphics g = e.Graphics;
  834.         g.Clear(Helpers.FromHex("#435363"));
  835.  
  836.         switch (_checked) {
  837.             case true:
  838.                 g.FillRectangle(Brushes.White, Width - 19, Height - 19, 15, 15);
  839.                 break;
  840.             case false:
  841.                 g.FillRectangle(new SolidBrush(Helpers.FromHex("#2c3e50")), 4, 4, 15, 15);
  842.                 break;
  843.         }
  844.     }
  845.  
  846.     protected override void OnMouseDown(MouseEventArgs e)
  847.     {
  848.         base.OnMouseDown(e);
  849.         _checked = !(_checked);
  850.         Invalidate();
  851.     }
  852. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement