Advertisement
modernaesthetics

Anima theme- C#

Sep 14th, 2019
608
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 42.97 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Globalization;
  5. using System.IO;
  6. using System.Linq;
  7. using System.Reflection;
  8. using System.Runtime.CompilerServices;
  9. using System.Security;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using Microsoft.VisualBasic;
  13. using System.Threading;
  14. using System.Drawing;
  15. using System.Windows.Forms;
  16. /*
  17.  * Anima theme by Naywyn - HF
  18.  * Converted to C# by UniveX
  19.  * */
  20.  
  21. internal static class Helpers
  22. {
  23.     public static SizeF Size;
  24.  
  25.     public static Point MiddlePoint(Graphics G, string TargetText, Font TargetFont, Rectangle Rect)
  26.     {
  27.         Size = G.MeasureString(TargetText, TargetFont);
  28.         return new Point((int)Rect.Width / 2 - (int)Size.Width / 2, (int)Rect.Height / 2 - (int)Size.Height / 2);
  29.     }
  30. }
  31.  
  32. public class AnimaExperimentalListView : Control
  33. {
  34.     public string[] Columns { get; set; }
  35.  
  36.     public ListViewItem[] Items { get; set; }
  37.  
  38.     public int ColumnWidth { get; set; } = 120;
  39.  
  40.     public int SelectedIndex { get; set; } = -1;
  41.  
  42.     public List<int> SelectedIndexes { get; set; } = new List<int>();
  43.  
  44.     public bool Multiselect { get; set; }
  45.  
  46.     public int Highlight { get; set; } = -1;
  47.  
  48.     public bool HandleItemsForeColor { get; set; }
  49.  
  50.     public bool Grid { get; set; }
  51.  
  52.     public int ItemSize { get; set; } = 16;
  53.  
  54.     public int SelectedCount
  55.     {
  56.         get
  57.         {
  58.             return SelectedIndexes.Count;
  59.         }
  60.     }
  61.  
  62.     public ListViewItem FocusedItem
  63.     {
  64.         get
  65.         {
  66.             if (SelectedIndexes == null)
  67.                 return new ListViewItem();
  68.  
  69.             return Items[SelectedIndexes[0]];
  70.         }
  71.     }
  72.  
  73.     public void Add(ListViewItem Item)
  74.     {
  75.         List<ListViewItem> ItemsList = Items.ToList();
  76.         ItemsList.Add(Item);
  77.         Items = ItemsList.ToArray();
  78.         Invalidate();
  79.     }
  80.  
  81.     private int BorderIndex = -1;
  82.  
  83.     public event SelectedIndexChangedEventHandler SelectedIndexChanged;
  84.  
  85.     public delegate void SelectedIndexChangedEventHandler(object Sender, int Index);
  86.  
  87.     public AnimaExperimentalListView()
  88.     {
  89.         DoubleBuffered = true;
  90.         ForeColor = Color.FromArgb(200, 200, 200);
  91.         Font = new Font("Segoe UI", 9);
  92.         SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
  93.     }
  94.  
  95.     private SolidBrush ReturnForeFromItem(int I, ListViewItem Item)
  96.     {
  97.         if (SelectedIndexes.Contains(I))
  98.             return new SolidBrush(Color.FromArgb(10, 10, 10));
  99.         if (HandleItemsForeColor)
  100.             return new SolidBrush(Item.ForeColor);
  101.         else
  102.             return new SolidBrush(ForeColor);
  103.     }
  104.  
  105.     private SolidBrush ReturnForeFromSubItem(int I, ListViewItem.ListViewSubItem Item)
  106.     {
  107.         if (SelectedIndexes.Contains(I))
  108.             return new SolidBrush(Color.FromArgb(10, 10, 10));
  109.         if (HandleItemsForeColor)
  110.             return new SolidBrush(Item.ForeColor);
  111.         else
  112.             return new SolidBrush(ForeColor);
  113.     }
  114.  
  115.     protected override void OnPaint(PaintEventArgs e)
  116.     {
  117.         e.Graphics.Clear(Color.FromArgb(50, 50, 53));
  118.  
  119.         using (SolidBrush Background = new SolidBrush(Color.FromArgb(55, 55, 58)))
  120.         {
  121.             e.Graphics.FillRectangle(Background, new Rectangle(1, 1, Width - 2, 26));
  122.         }
  123.  
  124.         using (Pen Border = new Pen(Color.FromArgb(42, 42, 45)))
  125.         using (Pen Shadow = new Pen(Color.FromArgb(65, 65, 68))
  126. )
  127.         {
  128.             e.Graphics.DrawRectangle(Border, new Rectangle(0, 0, Width - 1, Height - 1));
  129.             e.Graphics.DrawRectangle(Border, new Rectangle(0, 0, Width - 1, 26));
  130.             e.Graphics.DrawLine(Shadow, 1, 1, Width - 2, 1);
  131.         }
  132.  
  133.         if (Columns != null)
  134.         {
  135.             for (var I = 0; I <= Columns.Count() - 1; I++)
  136.             {
  137.                 if (!(I == 0))
  138.                 {
  139.                     using (SolidBrush Separator = new SolidBrush(Color.FromArgb(42, 42, 45)))
  140.                     using (SolidBrush Shadow = new SolidBrush(Color.FromArgb(65, 65, 68))
  141. )
  142.                     {
  143.                         e.Graphics.FillRectangle(Separator, new Rectangle(ColumnWidth * I, 1, 1, 26));
  144.                         e.Graphics.FillRectangle(Shadow, new Rectangle(ColumnWidth * I - 1, 1, 1, 25));
  145.  
  146.                         if (Grid && Items != null)
  147.                         {
  148.                             e.Graphics.FillRectangle(Separator, new Rectangle(ColumnWidth * I, 1, 1, 26 + (Items.Count() * ItemSize)));
  149.                             e.Graphics.FillRectangle(Shadow, new Rectangle(ColumnWidth * I - 1, 1, 1, 25 + (Items.Count() * ItemSize)));
  150.                         }
  151.                     }
  152.                 }
  153.  
  154.                 using (SolidBrush Fore = new SolidBrush(ForeColor))
  155.                 {
  156.                     e.Graphics.DrawString(Columns[I], Font, Fore, new Point((ColumnWidth * I) + 6, 4));
  157.                 }
  158.             }
  159.         }
  160.  
  161.         if (Items != null)
  162.         {
  163.             if (!(Highlight == -1))
  164.             {
  165.                 using (SolidBrush Background = new SolidBrush(Color.FromArgb(66, 66, 69)))
  166.                 using (Pen Line = new Pen(Color.FromArgb(45, 45, 48))
  167. )
  168.                 {
  169.                     e.Graphics.FillRectangle(Background, new Rectangle(1, 26 + Highlight * ItemSize, Width - 2, ItemSize));
  170.                     e.Graphics.DrawRectangle(Line, new Rectangle(1, 26 + Highlight * ItemSize, Width - 2, ItemSize));
  171.                 }
  172.             }
  173.  
  174.             using (SolidBrush Selection = new SolidBrush(Color.FromArgb(41, 130, 232)))
  175.             using (Pen Line = new Pen(Color.FromArgb(40, 40, 40))
  176. )
  177.             {
  178.                 if (Multiselect && !(SelectedIndexes.Count == 0))
  179.                 {
  180.                     foreach (int Selected in SelectedIndexes)
  181.                     {
  182.                         e.Graphics.FillRectangle(Selection, new Rectangle(1, 26 + Selected * ItemSize, Width - 2, ItemSize));
  183.  
  184.                         if (Selected == 0 && SelectedIndexes.Count == 1)
  185.                             e.Graphics.DrawLine(Line, 1, 26 + ItemSize, Width - 2, 26 + ItemSize);
  186.                         else if (SelectedIndexes.Count == 1)
  187.                             e.Graphics.DrawLine(Line, 1, 26 + ItemSize + Selected * ItemSize, Width - 2, 26 + ItemSize + Selected * ItemSize);
  188.                     }
  189.                 }
  190.                 else if (!(SelectedIndexes.Count == 0))
  191.                     e.Graphics.FillRectangle(Selection, new Rectangle(1, 26 + SelectedIndex * ItemSize, Width - 2, ItemSize));
  192.             }
  193.  
  194.             if (SelectedIndexes.Count > 0)
  195.                 BorderIndex = SelectedIndexes.Max();
  196.  
  197.             for (var I = 0; I <= Items.Count() - 1; I++)
  198.             {
  199.                 e.Graphics.DrawString(Items[I].Text, Font, ReturnForeFromItem(I, Items[I]), new Point(6, 26 + I * ItemSize + 2));
  200.  
  201.                 if (Items[I].SubItems != null)
  202.                 {
  203.                     for (var X = 0; X <= Items[I].SubItems.Count - 1; X++)
  204.                     {
  205.                         if (!(Items[I].SubItems[X].Text == Items[I].Text))
  206.                             e.Graphics.DrawString(Items[I].SubItems[X].Text, Font, ReturnForeFromSubItem(I, Items[I].SubItems[X]), new Rectangle((ColumnWidth * X) + 6, 26 + I * ItemSize + 2, ColumnWidth - 8, 16));
  207.                     }
  208.                 }
  209.             }
  210.  
  211.             if (SelectedIndexes.Contains(BorderIndex))
  212.             {
  213.                 using (Pen Line = new Pen(Color.FromArgb(40, 40, 40)))
  214.                 {
  215.                     e.Graphics.DrawLine(Line, 1, 26 + ItemSize + BorderIndex * ItemSize, Width - 2, 26 + ItemSize + BorderIndex * ItemSize);
  216.                 }
  217.             }
  218.         }
  219.  
  220.         base.OnPaint(e);
  221.     }
  222.     public static bool IsControlDown()
  223.     {
  224.         return (Control.ModifierKeys & Keys.Control) != 0;
  225.     }
  226.     protected override void OnMouseUp(MouseEventArgs e)
  227.     {
  228.         int Selection = GetSelectedFromLocation(e.Location);
  229.  
  230.         if (Selection == -1 || !(e.Button == MouseButtons.Left))
  231.             return;
  232.  
  233.         if (Multiselect && IsControlDown())
  234.         {
  235.             if (!SelectedIndexes.Contains(Selection))
  236.                 SelectedIndexes.Add(Selection);
  237.             else
  238.                 SelectedIndexes.Remove(Selection);
  239.         }
  240.         else if (Multiselect && !IsControlDown())
  241.             SelectedIndexes = new List<int>()
  242.             {
  243.                 Selection
  244.             };
  245.         else
  246.         {
  247.             SelectedIndexes = new List<int>()
  248.             {
  249.                 Selection
  250.             };
  251.             SelectedIndex = Selection;
  252.         }
  253.  
  254.         if (Selection == -1)
  255.             SelectedIndexes = new List<int>();
  256.  
  257.         Invalidate();
  258.  
  259.         SelectedIndexChanged?.Invoke(this, Selection);
  260.         base.OnMouseUp(e);
  261.     }
  262.  
  263.     private int GetSelectedFromLocation(Point P)
  264.     {
  265.         if (Items != null)
  266.         {
  267.             for (var I = 0; I <= Items.Count() - 1; I++)
  268.             {
  269.                 if (new Rectangle(1, 26 + I * ItemSize, Width - 2, ItemSize).Contains(P))
  270.                     return I;
  271.             }
  272.         }
  273.  
  274.         return -1;
  275.     }
  276. }
  277.  
  278. public class AnimaTextBox : Control
  279. {
  280.     private Graphics G;
  281.     private TextBox _T;
  282.  
  283.     private TextBox T
  284.     {
  285.         [MethodImpl(MethodImplOptions.Synchronized)]
  286.         get
  287.         {
  288.             return _T;
  289.         }
  290.  
  291.         [MethodImpl(MethodImplOptions.Synchronized)]
  292.         set
  293.         {
  294.             if (_T != null)
  295.             {
  296.                 _T.Enter -= _T_Enter;
  297.                 _T.KeyPress -= _T_KeyPress;
  298.                 _T.Leave -= _T_Leave;
  299.                 _T.TextChanged -= _T_TextChanged;
  300.             }
  301.  
  302.             _T = value;
  303.             if (_T != null)
  304.             {
  305.                 _T.Enter += _T_Enter;
  306.                 _T.KeyPress += _T_KeyPress;
  307.                 _T.Leave += _T_Leave;
  308.                 _T.TextChanged += _T_TextChanged;
  309.             }
  310.         }
  311.     }
  312.  
  313.     private void _T_TextChanged(object sender, EventArgs e)
  314.     {
  315.         OnTextChanged(EventArgs.Empty);
  316.     }
  317.  
  318.     private void _T_Leave(object sender, EventArgs e)
  319.     {
  320.         AnimatingT2 = new Thread(UndoAnimation) { IsBackground = true };
  321.         AnimatingT2.Start();
  322.     }
  323.  
  324.     private void _T_KeyPress(object sender, KeyPressEventArgs e)
  325.     {
  326.         if (Numeric)
  327.         {
  328.             if ((int)(e.KeyChar) != 8)
  329.             {
  330.                 if ((int)(e.KeyChar) < 48 | (int)(e.KeyChar) > 57)
  331.                     e.Handled = true;
  332.             }
  333.         }
  334.     }
  335.  
  336.     private void _T_Enter(object sender, EventArgs e)
  337.     {
  338.         if (!Block)
  339.         {
  340.             AnimatingT = new Thread(DoAnimation) { IsBackground = true };
  341.             AnimatingT.Start();
  342.         }
  343.     }
  344.  
  345.     private Thread AnimatingT;
  346.     private Thread AnimatingT2;
  347.  
  348.     private int[] RGB = new[] { 45, 45, 48 };
  349.     private int RGB1 = 45;
  350.     private bool Block;
  351.  
  352.     public bool Dark { get; set; }
  353.  
  354.     public bool Numeric { get; set; }
  355.  
  356.     public new string Text
  357.     {
  358.         get
  359.         {
  360.             return T.Text;
  361.         }
  362.         set
  363.         {
  364.             base.Text = value;
  365.             T.Text = value;
  366.             Invalidate();
  367.         }
  368.     }
  369.  
  370.     public int MaxLength
  371.     {
  372.         get
  373.         {
  374.             return T.MaxLength;
  375.         }
  376.         set
  377.         {
  378.             T.MaxLength = value;
  379.             Invalidate();
  380.         }
  381.     }
  382.  
  383.     public bool UseSystemPasswordChar
  384.     {
  385.         get
  386.         {
  387.             return T.UseSystemPasswordChar;
  388.         }
  389.         set
  390.         {
  391.             T.UseSystemPasswordChar = value;
  392.             Invalidate();
  393.         }
  394.     }
  395.  
  396.     public bool MultiLine
  397.     {
  398.         get
  399.         {
  400.             return T.Multiline;
  401.         }
  402.         set
  403.         {
  404.             T.Multiline = value;
  405.             Helpers.Size = new Size(T.Width + 2, T.Height + 2);
  406.             Invalidate();
  407.         }
  408.     }
  409.  
  410.     public bool ReadOnly
  411.     {
  412.         get
  413.         {
  414.             return T.ReadOnly;
  415.         }
  416.         set
  417.         {
  418.             T.ReadOnly = value;
  419.             Invalidate();
  420.         }
  421.     }
  422.  
  423.     public AnimaTextBox()
  424.     {
  425.         DoubleBuffered = true;
  426.  
  427.         T = new TextBox() { BorderStyle = BorderStyle.None, ForeColor = Color.FromArgb(200, 200, 200), BackColor = Color.FromArgb(55, 55, 58), Location = new Point(6, 5), Multiline = false };
  428.  
  429.         Controls.Add(T);
  430.     }
  431.  
  432.     protected override void CreateHandle()
  433.     {
  434.         if (Dark)
  435.         {
  436.             RGB = new[] { 42, 42, 45 };
  437.             RGB1 = 45;
  438.             T.BackColor = Color.FromArgb(45, 45, 48);
  439.         }
  440.         else
  441.         {
  442.             RGB = new[] { 70, 70, 70 };
  443.             RGB1 = 70;
  444.             T.BackColor = Color.FromArgb(55, 55, 58);
  445.         }
  446.         base.CreateHandle();
  447.     }
  448.  
  449.     protected override void OnEnter(EventArgs e)
  450.     {
  451.         T.Select();
  452.         base.OnEnter(e);
  453.     }
  454.  
  455.     protected override void OnPaint(PaintEventArgs e)
  456.     {
  457.         G = e.Graphics;
  458.  
  459.         if (Enabled)
  460.         {
  461.             if (Dark)
  462.             {
  463.                 G.Clear(Color.FromArgb(45, 45, 48));
  464.  
  465.                 using (Pen Border = new Pen(Color.FromArgb(RGB[0], RGB[1], RGB[2])))
  466.                 {
  467.                     G.DrawRectangle(Border, new Rectangle(0, 0, Width - 1, Height - 1));
  468.                 }
  469.             }
  470.             else
  471.             {
  472.                 G.Clear(Color.FromArgb(55, 55, 58));
  473.  
  474.                 using (Pen Shadow = new Pen(Color.FromArgb(42, 42, 45)))
  475.                 using (Pen Border = new Pen(Color.FromArgb(RGB[0], RGB[1], RGB[2]))
  476. )
  477.                 {
  478.                     G.DrawRectangle(Border, new Rectangle(1, 1, Width - 3, Height - 3));
  479.                     G.DrawRectangle(Shadow, new Rectangle(0, 0, Width - 1, Height - 1));
  480.                 }
  481.             }
  482.         }
  483.         else
  484.         {
  485.             G.Clear(Color.FromArgb(50, 50, 53));
  486.             T.BackColor = Color.FromArgb(50, 50, 53);
  487.  
  488.             using (Pen Border = new Pen(Color.FromArgb(42, 42, 45)))
  489.             using (Pen Shadow = new Pen(Color.FromArgb(66, 66, 69))
  490. )
  491.             {
  492.                 e.Graphics.DrawRectangle(Border, new Rectangle(0, 0, Width - 1, Height - 1));
  493.                 e.Graphics.DrawRectangle(Shadow, new Rectangle(1, 1, Width - 3, Height - 3));
  494.             }
  495.         }
  496.  
  497.         base.OnPaint(e);
  498.     }
  499.  
  500.  
  501.     protected override void OnResize(EventArgs e)
  502.     {
  503.         if (MultiLine)
  504.         {
  505.             T.Size = new Size(Width - 7, Height - 7); Invalidate();
  506.         }
  507.         else
  508.         {
  509.             T.Size = new Size(Width - 8, Height - 15); Invalidate();
  510.         }
  511.         base.OnResize(e);
  512.     }
  513.  
  514.  
  515.     private void DoAnimation()
  516.     {
  517.         while (RGB[2] < 204 && !Block)
  518.         {
  519.             RGB[1] += 1;
  520.             RGB[2] += 2;
  521.  
  522.             Invalidate();
  523.             Thread.Sleep(5);
  524.         }
  525.     }
  526.  
  527.     private void UndoAnimation()
  528.     {
  529.         Block = true;
  530.  
  531.         while (RGB[2] > RGB1)
  532.         {
  533.             RGB[1] -= 1;
  534.             RGB[2] -= 2;
  535.  
  536.             Invalidate();
  537.             Thread.Sleep(5);
  538.         }
  539.  
  540.         Block = false;
  541.     }
  542. }
  543.  
  544. public class AnimaProgressBar : ProgressBar
  545. {
  546.     private Graphics G;
  547.  
  548.     public AnimaProgressBar()
  549.     {
  550.         SetStyle(ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
  551.     }
  552.  
  553.     protected override void OnPaint(PaintEventArgs e)
  554.     {
  555.         G = e.Graphics;
  556.  
  557.         base.OnPaint(e);
  558.  
  559.         G.Clear(Color.FromArgb(37, 37, 40));
  560.  
  561.         using (Pen Border = new Pen(Color.FromArgb(35, 35, 38)))
  562.         {
  563.             G.DrawRectangle(Border, new Rectangle(0, 0, Width - 1, Height - 1));
  564.         }
  565.         int area = Convert.ToInt32((Value * Width) / Maximum);
  566.         using (SolidBrush Background = new SolidBrush(Color.FromArgb(0, 122, 204)))
  567.         {
  568.             G.FillRectangle(Background, new Rectangle(1, 1, area - 2, Height - 2));
  569.         }
  570.     }
  571. }
  572.  
  573. public class AnimaCheckBox : CheckBox
  574. {
  575.     private Graphics G;
  576.  
  577.     private Thread AnimatingT;
  578.     private Thread AnimatingT2;
  579.  
  580.     private int[] RGB = new[] { 36, 36, 39 };
  581.  
  582.     private bool Block;
  583.  
  584.     public bool Radio { get; set; }
  585.  
  586.     public bool Caution { get; set; }
  587.  
  588.     private const string CheckedIcon = "iVBORw0KGgoAAAANSUhEUgAAAAsAAAAKCAMAAABVLlSxAAAASFBMVEUlJSYuLi8oKCmlpaXx8fGioqJoaGjOzs8+Pj/k5OTu7u5LS0zIyMiBgYKFhYXo6OhUVFWVlZW7u7t+fn7h4eE5OTlfX1+YmJn8uq7eAAAAA3RSTlMAAAD6dsTeAAAACXBIWXMAAABIAAAASABGyWs+AAAAO0lEQVQI12NgwAKYWVhhTDYWdkYok4OTixvCYGDiYeEFM/n4BQRZhCDywiz8XCKiDDAOixjcPGFxDCsASakBdDYGvzAAAAAldEVYdGRhdGU6Y3JlYXRlADIwMTYtMTItMTRUMTI6MDM6MjktMDY6MDB4J65tAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDE2LTEyLTE0VDEyOjAzOjI5LTA2OjAwCXoW0QAAAABJRU5ErkJggg==";
  589.  
  590.     public AnimaCheckBox()
  591.     {
  592.         DoubleBuffered = true;
  593.         Font = new Font("Segoe UI", 9);
  594.         ForeColor = Color.FromArgb(200, 200, 200);
  595.         SetStyle(ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
  596.     }
  597.  
  598.     protected override void OnPaint(PaintEventArgs e)
  599.     {
  600.         G = e.Graphics;
  601.         G.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
  602.  
  603.         G.Clear(BackColor);
  604.  
  605.         using (SolidBrush Background = new SolidBrush(Color.FromArgb(38, 38, 41)))
  606.         {
  607.             G.FillRectangle(Background, new Rectangle(0, 0, 16, 16));
  608.         }
  609.  
  610.         using (Pen Border = new Pen(Color.FromArgb(RGB[0], RGB[1], RGB[2])))
  611.         {
  612.             G.DrawRectangle(Border, new Rectangle(0, 0, 16, 16));
  613.         }
  614.  
  615.         using (SolidBrush Fore = new SolidBrush(ForeColor))
  616.         {
  617.             G.DrawString(Text, Font, Fore, new Point(22, 0));
  618.         }
  619.  
  620.         if (Checked)
  621.         {
  622.             using (Image Mark = Image.FromStream(new System.IO.MemoryStream(Convert.FromBase64String(CheckedIcon))))
  623.             {
  624.                 G.DrawImage(Mark, new Point(2, 3));
  625.             }
  626.         }
  627.     }
  628.  
  629.     protected override void OnMouseEnter(EventArgs e)
  630.     {
  631.         if (!Block)
  632.         {
  633.             AnimatingT = new Thread(DoAnimation) { IsBackground = true };
  634.             AnimatingT.Start();
  635.         }
  636.  
  637.         base.OnMouseEnter(e);
  638.     }
  639.  
  640.     protected override void OnMouseLeave(EventArgs e)
  641.     {
  642.         AnimatingT2 = new Thread(UndoAnimation) { IsBackground = true };
  643.         AnimatingT2.Start();
  644.  
  645.         base.OnMouseLeave(e);
  646.     }
  647.  
  648.     protected override void OnMouseUp(MouseEventArgs e)
  649.     {
  650.         if (Radio)
  651.         {
  652.             foreach (AnimaCheckBox C in Parent.Controls.OfType<AnimaCheckBox>())
  653.             {
  654.                 if (C.Radio)
  655.                     C.Checked = false;
  656.             }
  657.            
  658.         }
  659.  
  660.         base.OnMouseUp(e);
  661.     }
  662.  
  663.     private void DoAnimation()
  664.     {
  665.         if (Caution)
  666.         {
  667.             while (RGB[2] < 130 && !Block)
  668.             {
  669.                 RGB[1] += 1;
  670.                 RGB[2] += 1;
  671.  
  672.                 Invalidate();
  673.                 Thread.Sleep(4);
  674.             }
  675.         }
  676.         else
  677.             while (RGB[2] < 204 && !Block)
  678.             {
  679.                 RGB[1] += 1;
  680.                 RGB[2] += 2;
  681.  
  682.                 Invalidate();
  683.                 Thread.Sleep(4);
  684.             }
  685.     }
  686.  
  687.     private void UndoAnimation()
  688.     {
  689.         Block = true;
  690.  
  691.         if (Caution)
  692.         {
  693.             while (RGB[2] > 42)
  694.             {
  695.                 RGB[1] -= 1;
  696.                 RGB[2] -= 1;
  697.  
  698.                 Invalidate();
  699.                 Thread.Sleep(4);
  700.             }
  701.         }
  702.         else
  703.             while (RGB[2] > 42)
  704.             {
  705.                 RGB[1] -= 1;
  706.                 RGB[2] -= 2;
  707.  
  708.                 Invalidate();
  709.                 Thread.Sleep(4);
  710.             }
  711.  
  712.         Block = false;
  713.     }
  714. }
  715.  
  716. public class AnimaHeader : Control
  717. {
  718.     private Graphics G;
  719.  
  720.     public AnimaHeader()
  721.     {
  722.         DoubleBuffered = true;
  723.         Font = new Font("Segoe UI", 9);
  724.         Location = new Point(1, 1);
  725.         Helpers.Size = new Size(Width - 2, 36);
  726.         ForeColor = Color.FromArgb(200, 200, 200);
  727.     }
  728.  
  729.     protected override void OnPaint(PaintEventArgs e)
  730.     {
  731.         G = e.Graphics;
  732.  
  733.         using (SolidBrush Background = new SolidBrush(Color.FromArgb(55, 55, 58)))
  734.         {
  735.             G.FillRectangle(Background, new Rectangle(0, 0, Width - 1, Height - 1));
  736.         }
  737.  
  738.         using (Pen Line = new Pen(Color.FromArgb(43, 43, 46)))
  739.         {
  740.             G.DrawLine(Line, 0, Height - 1, Width - 1, Height - 1);
  741.         }
  742.  
  743.         using (SolidBrush Fore = new SolidBrush(ForeColor))
  744.         {
  745.             G.DrawString(Text, Font, Fore, new Point(6, 6));
  746.         }
  747.  
  748.         base.OnPaint(e);
  749.     }
  750. }
  751.  
  752. public class AnimaForm : ContainerControl
  753. {
  754.     private Graphics G;
  755.  
  756.     public AnimaForm()
  757.     {
  758.         BackColor = Color.FromArgb(45, 45, 48);
  759.         DoubleBuffered = true;
  760.         Font = new Font("Segoe UI", 9);
  761.         Dock = DockStyle.Fill;
  762.         ForeColor = Color.FromArgb(200, 200, 200);
  763.     }
  764.  
  765.     protected override void OnCreateControl()
  766.     {
  767.         ParentForm.FormBorderStyle = FormBorderStyle.None;
  768.         base.OnCreateControl();
  769.     }
  770.  
  771.     protected override void OnPaint(PaintEventArgs e)
  772.     {
  773.         G = e.Graphics;
  774.  
  775.         using (SolidBrush Background = new SolidBrush(Color.FromArgb(55, 55, 58)))
  776.         {
  777.             G.FillRectangle(Background, new Rectangle(0, 0, Width - 1, 36));
  778.         }
  779.  
  780.         using (Pen Line = new Pen(Color.FromArgb(43, 43, 46)))
  781.         {
  782.             G.DrawLine(Line, 0, 36, Width - 1, 36);
  783.         }
  784.  
  785.         using (SolidBrush Fore = new SolidBrush(ForeColor))
  786.         {
  787.             G.DrawString(Text, Font, Fore, new Point(10, 10));
  788.         }
  789.  
  790.         using (Pen Border = new Pen(Color.FromArgb(35, 35, 38)))
  791.         {
  792.             e.Graphics.DrawRectangle(Border, new Rectangle(0, 0, Width - 1, Height - 1));
  793.         }
  794.  
  795.         base.OnPaint(e);
  796.     }
  797.  
  798.     private bool Drag;
  799.     private Point MousePoint = new Point(), Temporary = new Point();
  800.  
  801.     protected override void OnMouseDown(MouseEventArgs e)
  802.     {
  803.         if (e.Button == MouseButtons.Left && e.Y < 36)
  804.         {
  805.             Drag = true;
  806.             MousePoint.X = e.X;
  807.             MousePoint.Y = e.Y;
  808.         }
  809.  
  810.         base.OnMouseDown(e);
  811.     }
  812.  
  813.     protected override void OnMouseUp(MouseEventArgs e)
  814.     {
  815.         if (e.Button == MouseButtons.Left)
  816.             Drag = false;
  817.  
  818.         base.OnMouseUp(e);
  819.     }
  820.  
  821.     protected override void OnMouseMove(MouseEventArgs e)
  822.     {
  823.         if (Drag)
  824.         {
  825.             Temporary.X = Parent.Location.X + (e.X - MousePoint.X);
  826.             Temporary.Y = Parent.Location.Y + (e.Y - MousePoint.Y);
  827.             Parent.Location = Temporary;
  828.             Temporary = Point.Empty;
  829.         }
  830.  
  831.         base.OnMouseMove(e);
  832.     }
  833. }
  834.  
  835. public class AnimaButton : Button
  836. {
  837.     private Graphics G;
  838.  
  839.     private Thread HoverAnim, CHoverAnim, DownAnimationT;
  840.  
  841.     private int[] RGB = new[] { 42, 42, 45 };
  842.  
  843.     private Point Loc = new Point();
  844.     private Size RSize = new Size();
  845.  
  846.     private bool Block;
  847.  
  848.     private bool Animate;
  849.  
  850.     public Point ImageLocation { get; set; }
  851.  
  852.     public Size ImageSize { get; set; } = new Size(14, 14);
  853.  
  854.     public AnimaButton()
  855.     {
  856.         DoubleBuffered = true;
  857.         Font = new Font("Segoe UI", 9);
  858.         ForeColor = Color.FromArgb(200, 200, 200);
  859.         SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true);
  860.         ImageLocation = new Point(Width / 2 - 7, 6);
  861.     }
  862.  
  863.     protected override void OnPaint(PaintEventArgs e)
  864.     {
  865.         G = e.Graphics;
  866.  
  867.         G.Clear(BackColor);
  868.  
  869.         using (SolidBrush Background = new SolidBrush(Color.FromArgb(55, 55, 58)))
  870.         {
  871.             G.FillRectangle(Background, new Rectangle(0, 0, Width - 1, Height - 1));
  872.         }
  873.  
  874.         if (Animate)
  875.         {
  876.             using (SolidBrush Background = new SolidBrush(Color.FromArgb(66, 66, 69)))
  877.             {
  878.                 G.FillEllipse(Background, new Rectangle(Loc.X, -30, RSize.Width, 80));
  879.             }
  880.         }
  881.  
  882.         using (Pen Border = new Pen(Color.FromArgb(RGB[0], RGB[1], RGB[2])))
  883.         {
  884.             G.DrawRectangle(Border, new Rectangle(0, 0, Width - 1, Height - 1));
  885.         }
  886.  
  887.         if (Image != null)
  888.             G.DrawImage(Image, new Rectangle(ImageLocation, ImageSize));
  889.         else
  890.             using (SolidBrush Fore = new SolidBrush(ForeColor))
  891.             {
  892.                 G.DrawString(Text, Font, Fore, Helpers.MiddlePoint(G, Text, Font, new Rectangle(0, 0, Width - 1, Height - 1)));
  893.             }
  894.     }
  895.  
  896.     protected override void OnMouseEnter(EventArgs e)
  897.     {
  898.         if (!Block)
  899.         {
  900.             HoverAnim = new Thread(DoAnimation) { IsBackground = true };
  901.             HoverAnim.Start();
  902.         }
  903.  
  904.         base.OnMouseEnter(e);
  905.     }
  906.  
  907.     protected override void OnMouseLeave(EventArgs e)
  908.     {
  909.         CHoverAnim = new Thread(UndoAnimation) { IsBackground = true };
  910.         CHoverAnim.Start();
  911.  
  912.         base.OnMouseLeave(e);
  913.     }
  914.  
  915.     protected override void OnMouseDown(MouseEventArgs e)
  916.     {
  917.         DownAnimationT = new Thread(() => DoBackAnimation(e.Location)) { IsBackground = true };
  918.         DownAnimationT.Start();
  919.  
  920.         base.OnMouseDown(e);
  921.     }
  922.  
  923.     private void DoBackAnimation(Point P)
  924.     {
  925.         Loc = P;
  926.         RSize = new Size();
  927.  
  928.         Animate = true; Invalidate();
  929.  
  930.         while (RSize.Width < Width * 3)
  931.         {
  932.             Loc.X -= 1;
  933.             RSize.Width += 2;
  934.             Thread.Sleep(4);
  935.             Invalidate();
  936.         }
  937.  
  938.         Animate = false; Invalidate();
  939.     }
  940.  
  941.     private void DoAnimation()
  942.     {
  943.         while (RGB[2] < 204 && !Block)
  944.         {
  945.             RGB[1] += 1;
  946.             RGB[2] += 2;
  947.  
  948.             Invalidate();
  949.             Thread.Sleep(5);
  950.         }
  951.     }
  952.  
  953.     private void UndoAnimation()
  954.     {
  955.         Block = true;
  956.  
  957.         while (RGB[2] > 45)
  958.         {
  959.             RGB[1] -= 1;
  960.             RGB[2] -= 2;
  961.  
  962.             Invalidate();
  963.             Thread.Sleep(5);
  964.         }
  965.  
  966.         Block = false;
  967.     }
  968. }
  969.  
  970. public class Renderer : ToolStripRenderer
  971. {
  972.     public event PaintMenuBackgroundEventHandler PaintMenuBackground;
  973.  
  974.     public delegate void PaintMenuBackgroundEventHandler(object sender, ToolStripRenderEventArgs e);
  975.  
  976.     public event PaintMenuBorderEventHandler PaintMenuBorder;
  977.  
  978.     public delegate void PaintMenuBorderEventHandler(object sender, ToolStripRenderEventArgs e);
  979.  
  980.     public event PaintMenuImageMarginEventHandler PaintMenuImageMargin;
  981.  
  982.     public delegate void PaintMenuImageMarginEventHandler(object sender, ToolStripRenderEventArgs e);
  983.  
  984.     public event PaintItemCheckEventHandler PaintItemCheck;
  985.  
  986.     public delegate void PaintItemCheckEventHandler(object sender, ToolStripItemImageRenderEventArgs e);
  987.  
  988.     public event PaintItemImageEventHandler PaintItemImage;
  989.  
  990.     public delegate void PaintItemImageEventHandler(object sender, ToolStripItemImageRenderEventArgs e);
  991.  
  992.     public event PaintItemTextEventHandler PaintItemText;
  993.  
  994.     public delegate void PaintItemTextEventHandler(object sender, ToolStripItemTextRenderEventArgs e);
  995.  
  996.     public event PaintItemBackgroundEventHandler PaintItemBackground;
  997.  
  998.     public delegate void PaintItemBackgroundEventHandler(object sender, ToolStripItemRenderEventArgs e);
  999.  
  1000.     public event PaintItemArrowEventHandler PaintItemArrow;
  1001.  
  1002.     public delegate void PaintItemArrowEventHandler(object sender, ToolStripArrowRenderEventArgs e);
  1003.  
  1004.     public event PaintSeparatorEventHandler PaintSeparator;
  1005.  
  1006.     public delegate void PaintSeparatorEventHandler(object sender, ToolStripSeparatorRenderEventArgs e);
  1007.  
  1008.     protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e)
  1009.     {
  1010.         PaintMenuBackground?.Invoke(this, e);
  1011.     }
  1012.  
  1013.     protected override void OnRenderImageMargin(ToolStripRenderEventArgs e)
  1014.     {
  1015.         PaintMenuImageMargin?.Invoke(this, e);
  1016.     }
  1017.  
  1018.     protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e)
  1019.     {
  1020.         PaintMenuBorder?.Invoke(this, e);
  1021.     }
  1022.  
  1023.     protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e)
  1024.     {
  1025.         PaintItemCheck?.Invoke(this, e);
  1026.     }
  1027.  
  1028.     protected override void OnRenderItemImage(ToolStripItemImageRenderEventArgs e)
  1029.     {
  1030.         PaintItemImage?.Invoke(this, e);
  1031.     }
  1032.  
  1033.     protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
  1034.     {
  1035.         PaintItemText?.Invoke(this, e);
  1036.     }
  1037.  
  1038.     protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
  1039.     {
  1040.         PaintItemBackground?.Invoke(this, e);
  1041.     }
  1042.  
  1043.     protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e)
  1044.     {
  1045.         PaintItemArrow?.Invoke(this, e);
  1046.     }
  1047.  
  1048.     protected override void OnRenderSeparator(ToolStripSeparatorRenderEventArgs e)
  1049.     {
  1050.         PaintSeparator?.Invoke(this, e);
  1051.     }
  1052. }
  1053.  
  1054. public class AnimaContextMenuStrip : ContextMenuStrip
  1055. {
  1056.     private Graphics G;
  1057.     private Rectangle Rect;
  1058.  
  1059.     public AnimaContextMenuStrip()
  1060.     {
  1061.         Font = new Font("Segoe UI", 9);
  1062.         ForeColor = Color.FromArgb(200, 200, 200);
  1063.         Renderer Render = new Renderer();
  1064.         Render.PaintMenuBackground += Renderer_PaintMenuBackground;
  1065.         Render.PaintMenuBorder += Renderer_PaintMenuBorder;
  1066.         Render.PaintItemImage += Renderer_PaintItemImage;
  1067.         Render.PaintItemText += Renderer_PaintItemText;
  1068.         Render.PaintItemBackground += Renderer_PaintItemBackground;
  1069.         Render.PaintItemArrow += Rendered_PaintItemArrow;
  1070.  
  1071.         Renderer = Render;
  1072.     }
  1073.  
  1074.     private void Rendered_PaintItemArrow(object sender, ToolStripArrowRenderEventArgs e)
  1075.     {
  1076.         G = e.Graphics;
  1077.  
  1078.         using (Font F = new Font("Marlett", 10))
  1079.         using (SolidBrush Fore = new SolidBrush(Color.FromArgb(130, 130, 130))
  1080. )
  1081.         {
  1082.             G.DrawString("4", F, Fore, new Point(e.ArrowRectangle.X, e.ArrowRectangle.Y + 2));
  1083.         }
  1084.     }
  1085.  
  1086.     private void Renderer_PaintMenuBackground(object sender, ToolStripRenderEventArgs e)
  1087.     {
  1088.         G = e.Graphics;
  1089.  
  1090.         G.Clear(Color.FromArgb(55, 55, 58));
  1091.     }
  1092.  
  1093.     private void Renderer_PaintMenuBorder(object sender, ToolStripRenderEventArgs e)
  1094.     {
  1095.         G = e.Graphics;
  1096.  
  1097.         using (Pen Border = new Pen(Color.FromArgb(35, 35, 38)))
  1098.         {
  1099.             G.DrawRectangle(Border, new Rectangle(e.AffectedBounds.X, e.AffectedBounds.Y, e.AffectedBounds.Width - 1, e.AffectedBounds.Height - 1));
  1100.         }
  1101.     }
  1102.  
  1103.     private void Renderer_PaintItemImage(object sender, ToolStripItemImageRenderEventArgs e)
  1104.     {
  1105.         G = e.Graphics;
  1106.  
  1107.         G.DrawImage(e.Image, new Point(10, 1));
  1108.     }
  1109.  
  1110.     private void Renderer_PaintItemText(object sender, ToolStripItemTextRenderEventArgs e)
  1111.     {
  1112.         G = e.Graphics;
  1113.  
  1114.         using (SolidBrush Fore = new SolidBrush(e.TextColor))
  1115.         {
  1116.             G.DrawString(e.Text, Font, Fore, new Point(e.TextRectangle.X, e.TextRectangle.Y - 1));
  1117.         }
  1118.     }
  1119.  
  1120.     private void Renderer_PaintItemBackground(object sender, ToolStripItemRenderEventArgs e)
  1121.     {
  1122.         G = e.Graphics;
  1123.  
  1124.         Rect = e.Item.ContentRectangle;
  1125.  
  1126.         if (e.Item.Selected)
  1127.         {
  1128.             using (SolidBrush Background = new SolidBrush(Color.FromArgb(85, 85, 85)))
  1129.             {
  1130.                 G.FillRectangle(Background, new Rectangle(Rect.X - 4, Rect.Y - 1, Rect.Width + 4, Rect.Height - 1));
  1131.             }
  1132.         }
  1133.     }
  1134. }
  1135.  
  1136. public class AnimaStatusBar : Control
  1137. {
  1138.     private Graphics G;
  1139.  
  1140.     private Color Body = Color.FromArgb(0, 122, 204);
  1141.     private Color Outline = Color.FromArgb(0, 126, 204);
  1142.  
  1143.     public Types Type { get; set; }
  1144.  
  1145.     public enum Types : byte
  1146.     {
  1147.         Basic = 0,
  1148.         Warning = 1,
  1149.         Wrong = 2,
  1150.         Success = 3
  1151.     }
  1152.  
  1153.     public AnimaStatusBar()
  1154.     {
  1155.         DoubleBuffered = true;
  1156.     }
  1157.  
  1158.     protected override void OnPaint(PaintEventArgs e)
  1159.     {
  1160.         G = e.Graphics;
  1161.  
  1162.         switch (Type)
  1163.         {
  1164.             case Types.Basic:
  1165.                 {
  1166.                     Body = Color.FromArgb(0, 122, 204);
  1167.                     Outline = Color.FromArgb(0, 126, 204);
  1168.                     break;
  1169.                 }
  1170.  
  1171.             case Types.Warning:
  1172.                 {
  1173.                     Body = Color.FromArgb(210, 143, 75);
  1174.                     Outline = Color.FromArgb(214, 147, 75);
  1175.                     break;
  1176.                 }
  1177.  
  1178.             case Types.Wrong:
  1179.                 {
  1180.                     Body = Color.FromArgb(212, 110, 110);
  1181.                     Outline = Color.FromArgb(216, 114, 114);
  1182.                     break;
  1183.                 }
  1184.  
  1185.             default:
  1186.                 {
  1187.                     Body = Color.FromArgb(45, 193, 90);
  1188.                     Outline = Color.FromArgb(45, 197, 90);
  1189.                     break;
  1190.                 }
  1191.         }
  1192.  
  1193.         using (SolidBrush Background = new SolidBrush(Body))
  1194.         using (Pen Line = new Pen(Outline)
  1195. )
  1196.         {
  1197.             G.FillRectangle(Background, new Rectangle(0, 0, Width - 1, Height - 1));
  1198.             G.DrawLine(Line, 0, 0, Width - 2, 0);
  1199.         }
  1200.  
  1201.         using (SolidBrush Fore = new SolidBrush(Color.FromArgb(255, 255, 255)))
  1202.         using (Font Font = new Font("Segoe UI semibold", 8)
  1203. )
  1204.         {
  1205.             G.DrawString(Text, Font, Fore, new Point(4, 2));
  1206.         }
  1207.  
  1208.         base.OnPaint(e);
  1209.     }
  1210.  
  1211.     protected override void OnTextChanged(EventArgs e)
  1212.     {
  1213.         Invalidate();
  1214.         base.OnTextChanged(e);
  1215.     }
  1216. }
  1217.  
  1218. public class AnimaTabControl : TabControl
  1219. {
  1220.     private Graphics G;
  1221.     private Rectangle Rect;
  1222.  
  1223.     protected override void OnControlAdded(ControlEventArgs e)
  1224.     {
  1225.         e.Control.BackColor = Color.FromArgb(45, 45, 48);
  1226.         e.Control.ForeColor = Color.FromArgb(200, 200, 200);
  1227.         e.Control.Font = new Font("Segoe UI", 9);
  1228.         base.OnControlAdded(e);
  1229.     }
  1230.  
  1231.     public AnimaTabControl()
  1232.     {
  1233.         DoubleBuffered = true;
  1234.         Font = new Font("Segoe UI", 9);
  1235.         ForeColor = Color.FromArgb(200, 200, 200);
  1236.         ItemSize = new Size(18, 18);
  1237.         SizeMode = TabSizeMode.Fixed;
  1238.         Alignment = TabAlignment.Top;
  1239.         SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque | ControlStyles.OptimizedDoubleBuffer, true);
  1240.     }
  1241.  
  1242.     protected override void OnPaint(PaintEventArgs e)
  1243.     {
  1244.         G = e.Graphics;
  1245.  
  1246.         G.Clear(Parent.BackColor);
  1247.  
  1248.         for (var I = 0; I <= TabPages.Count - 1; I++)
  1249.         {
  1250.             Rect = GetTabRect(I);
  1251.  
  1252.             if (SelectedIndex == I)
  1253.             {
  1254.                 using (SolidBrush Background = new SolidBrush(Color.FromArgb(41, 130, 232)))
  1255.                 using (Pen Border = new Pen(Color.FromArgb(38, 127, 229))
  1256. )
  1257.                 {
  1258.                     G.FillRectangle(Background, new Rectangle(Rect.X + 5, Rect.Y + 2, 12, 12));
  1259.                     G.DrawRectangle(Border, new Rectangle(Rect.X + 5, Rect.Y + 2, 12, 12));
  1260.                 }
  1261.             }
  1262.             else
  1263.                 using (SolidBrush Background = new SolidBrush(Color.FromArgb(70, 70, 73)))
  1264.                 using (Pen Border = new Pen(Color.FromArgb(42, 42, 45))
  1265. )
  1266.                 {
  1267.                     G.FillRectangle(Background, new Rectangle(Rect.X + 5, Rect.Y + 2, 12, 12));
  1268.                     G.DrawRectangle(Border, new Rectangle(Rect.X + 5, Rect.Y + 2, 12, 12));
  1269.                 }
  1270.         }
  1271.  
  1272.         base.OnPaint(e);
  1273.     }
  1274. }
  1275.  
  1276. public class AnimaGroupBox : Control
  1277. {
  1278.     public AnimaGroupBox()
  1279.     {
  1280.         DoubleBuffered = true;
  1281.         ForeColor = Color.FromArgb(200, 200, 200);
  1282.         BackColor = Color.FromArgb(50, 50, 53);
  1283.     }
  1284.  
  1285.     protected override void OnPaint(PaintEventArgs e)
  1286.     {
  1287.         e.Graphics.Clear(BackColor);
  1288.  
  1289.         using (Pen Border = new Pen(Color.FromArgb(42, 42, 45)))
  1290.         using (SolidBrush HBackground = new SolidBrush(Color.FromArgb(60, 60, 63)))
  1291.         using (Pen Shadow = new Pen(Color.FromArgb(66, 66, 69))
  1292. )
  1293.         {
  1294.             e.Graphics.FillRectangle(HBackground, new Rectangle(1, 0, Width - 2, 26));
  1295.             e.Graphics.DrawRectangle(Border, new Rectangle(0, 0, Width - 1, 26));
  1296.             e.Graphics.DrawLine(Shadow, 1, 25, Width - 2, 25);
  1297.             e.Graphics.DrawRectangle(Border, new Rectangle(0, 0, Width - 1, Height - 1));
  1298.         }
  1299.  
  1300.         using (SolidBrush Fore = new SolidBrush(ForeColor))
  1301.         {
  1302.             e.Graphics.DrawString(Text, Font, Fore, new Point(4, 4));
  1303.         }
  1304.  
  1305.         base.OnPaint(e);
  1306.     }
  1307. }
  1308.  
  1309. public class AnimaExperimentalControlBox : Control
  1310. {
  1311.     public int TextHeight { get; set; } = 4;
  1312.  
  1313.     public int ComboHeight { get; set; } = 24;
  1314.  
  1315.     public string[] Items { get; set; }
  1316.  
  1317.     public int SelectedIndex { get; set; } = 0;
  1318.  
  1319.     public int ItemSize { get; set; } = 24;
  1320.  
  1321.     public string SelectedItem { get; set; }
  1322.  
  1323.     public AnimaGroupBox AnimaGroupBoxContainer { get; set; }
  1324.  
  1325.     public Point CurrentLocation { get; set; }
  1326.  
  1327.     public event SelectedIndexChangedEventHandler SelectedIndexChanged;
  1328.  
  1329.     public delegate void SelectedIndexChangedEventHandler();
  1330.  
  1331.     private bool Open;
  1332.     private int ItemsHeight = 0;
  1333.     private int Hover = -1;
  1334.  
  1335.     public AnimaExperimentalControlBox()
  1336.     {
  1337.         DoubleBuffered = true;
  1338.         Font = new Font("Segoe UI", 9);
  1339.         ForeColor = Color.FromArgb(200, 200, 200);
  1340.     }
  1341.  
  1342.     protected override void OnPaint(PaintEventArgs e)
  1343.     {
  1344.         e.Graphics.Clear(Parent.BackColor);
  1345.  
  1346.         if (Enabled)
  1347.         {
  1348.             if (Items != null)
  1349.                 ItemsHeight = Items.Count() * ItemSize;
  1350.  
  1351.             if (!DesignMode)
  1352.             {
  1353.                 if (Open)
  1354.                     Height = ItemsHeight + ComboHeight + 5;
  1355.                 else
  1356.                     Height = ComboHeight + 1;
  1357.             }
  1358.  
  1359.             using (SolidBrush Background = new SolidBrush(Color.FromArgb(55, 55, 58)))
  1360.             using (Pen Border = new Pen(Color.FromArgb(42, 42, 45)))
  1361.             using (Pen Shadow = new Pen(Color.FromArgb(66, 66, 69))
  1362. )
  1363.             {
  1364.                 e.Graphics.FillRectangle(Background, new Rectangle(0, 0, Width - 1, ComboHeight - 1));
  1365.                 e.Graphics.DrawRectangle(Border, new Rectangle(0, 0, Width - 1, ComboHeight - 1));
  1366.                 e.Graphics.DrawRectangle(Shadow, new Rectangle(1, 1, Width - 3, ComboHeight - 3));
  1367.             }
  1368.  
  1369.             if (Items == null)
  1370.                 SelectedIndex = -1;
  1371.             else if (!(SelectedIndex == -1))
  1372.             {
  1373.                 using (SolidBrush Fore = new SolidBrush(ForeColor))
  1374.                 {
  1375.                     e.Graphics.DrawString(Items[SelectedIndex], Font, Fore, new Point(4, 4));
  1376.                 }
  1377.             }
  1378.  
  1379.             if (Open)
  1380.             {
  1381.                 using (SolidBrush Background = new SolidBrush(Color.FromArgb(60, 60, 63)))
  1382.                 using (Pen Border = new Pen(Color.FromArgb(41, 130, 232))
  1383. )
  1384.                 {
  1385.                     e.Graphics.FillRectangle(Background, new Rectangle(1, ComboHeight, Width - 3, ItemsHeight));
  1386.                     e.Graphics.DrawRectangle(Border, new Rectangle(1, ComboHeight, Width - 3, ItemsHeight));
  1387.                 }
  1388.  
  1389.                 if (!(Hover == -1))
  1390.                 {
  1391.                     using (SolidBrush Background = new SolidBrush(Color.FromArgb(41, 130, 232)))
  1392.                     using (Pen Border = new Pen(Color.FromArgb(40, 40, 40))
  1393. )
  1394.                     {
  1395.                         e.Graphics.FillRectangle(Background, new Rectangle(1, ComboHeight + Hover * ItemSize, Width - 2, ItemSize));
  1396.                         e.Graphics.DrawLine(Border, 1, ComboHeight + Hover * ItemSize + ItemSize, Width - 2, ComboHeight + Hover * ItemSize + ItemSize);
  1397.                     }
  1398.                 }
  1399.  
  1400.                 for (var I = 0; I <= Items.Count() - 1; I++)
  1401.                 {
  1402.                     if (Hover == I)
  1403.                     {
  1404.                         using (SolidBrush Fore = new SolidBrush(Color.FromArgb(15, 15, 15)))
  1405.                         {
  1406.                             e.Graphics.DrawString(Items[I], Font, Fore, new Point(4, ComboHeight + TextHeight + I * ItemSize));
  1407.                         }
  1408.                     }
  1409.                     else
  1410.                         using (SolidBrush Fore = new SolidBrush(ForeColor))
  1411.                         {
  1412.                             e.Graphics.DrawString(Items[I], Font, Fore, new Point(4, ComboHeight + TextHeight + I * ItemSize));
  1413.                         }
  1414.                 }
  1415.             }
  1416.         }
  1417.         else
  1418.         {
  1419.             using (SolidBrush Background = new SolidBrush(Color.FromArgb(50, 50, 53)))
  1420.             using (Pen Border = new Pen(Color.FromArgb(42, 42, 45)))
  1421.             using (Pen Shadow = new Pen(Color.FromArgb(66, 66, 69))
  1422. )
  1423.             {
  1424.                 e.Graphics.FillRectangle(Background, new Rectangle(0, 0, Width - 1, ComboHeight - 1));
  1425.                 e.Graphics.DrawRectangle(Border, new Rectangle(0, 0, Width - 1, ComboHeight - 1));
  1426.                 e.Graphics.DrawRectangle(Shadow, new Rectangle(1, 1, Width - 3, ComboHeight - 3));
  1427.             }
  1428.  
  1429.             if (Items != null && !(SelectedIndex == -1))
  1430.             {
  1431.                 using (SolidBrush Fore = new SolidBrush(Color.FromArgb(140, 140, 140)))
  1432.                 {
  1433.                     e.Graphics.DrawString(Items[SelectedIndex], Font, Fore, new Point(4, 4));
  1434.                 }
  1435.             }
  1436.         }
  1437.  
  1438.         base.OnPaint(e);
  1439.     }
  1440.  
  1441.     protected override void OnLostFocus(EventArgs e)
  1442.     {
  1443.         Open = false; Invalidate();
  1444.         base.OnLostFocus(e);
  1445.     }
  1446.  
  1447.     protected override void OnMouseDown(MouseEventArgs e)
  1448.     {
  1449.  
  1450.         // If Not Open Then Main.BTab1.SendToBack() : Else : BringToFront()
  1451.  
  1452.         if (Open && !(ItemsHeight == 0))
  1453.         {
  1454.             for (var I = 0; I <= Items.Count() - 1; I++)
  1455.             {
  1456.                 if (new Rectangle(0, ComboHeight + I * ItemSize, Width - 1, ItemSize).Contains(e.Location))
  1457.                 {
  1458.                     SelectedIndex = I; Invalidate();
  1459.                     SelectedItem = Items[SelectedIndex];
  1460.                     break;
  1461.                 }
  1462.             }
  1463.         }
  1464.  
  1465.         if (!new Rectangle(0, 0, Width - 1, ComboHeight + 4).Contains(e.Location))
  1466.         {
  1467.             if (Open && !(SelectedIndex == -1))
  1468.                 SelectedIndexChanged?.Invoke();
  1469.         }
  1470.  
  1471.         Open = !Open; Invalidate();
  1472.         this.Select();
  1473.         base.OnMouseDown(e);
  1474.     }
  1475.  
  1476.     protected override void OnMouseMove(MouseEventArgs e)
  1477.     {
  1478.         if (Open && !(ItemsHeight == 0))
  1479.         {
  1480.             for (var I = 0; I <= Items.Count() - 1; I++)
  1481.             {
  1482.                 if (new Rectangle(0, ComboHeight + I * ItemSize, Width - 1, ItemSize).Contains(e.Location))
  1483.                 {
  1484.                     Hover = I; Invalidate();
  1485.                     break;
  1486.                 }
  1487.             }
  1488.         }
  1489.  
  1490.         base.OnMouseMove(e);
  1491.     }
  1492. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement