Advertisement
Guest User

NSTheme - C#

a guest
Feb 25th, 2015
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 90.02 KB | None | 0 0
  1. using System;
  2. using System.Windows.Forms;
  3. using System.Drawing;
  4. using System.Drawing.Drawing2D;
  5. using System.Drawing.Text;
  6. using System.ComponentModel;
  7. using System.Text;
  8. using System.Collections.Generic;
  9.  
  10. //IMPORTANT:
  11. //Please leave these comments in place as they help protect intellectual rights and allow
  12. //developers to determine the version of the theme they are using. The preffered method
  13. //of distributing this theme is through the Nimoru Software home page at nimoru.com.
  14.  
  15. //Name: Net Seal Theme
  16. //Created: 6/21/2013
  17. //Version: 1.0.0.2 beta
  18. //Site: http://nimoru.com/
  19.  
  20. //This work is licensed under a Creative Commons Attribution 3.0 Unported License.
  21. //To view a copy of this license, please visit http://creativecommons.org/licenses/by/3.0/
  22.  
  23. //Copyright © 2013 Nimoru Software
  24.  
  25. static class ThemeModule
  26. {
  27.  
  28.     static ThemeModule()
  29.     {
  30.         TextBitmap = new Bitmap(1, 1);
  31.         TextGraphics = Graphics.FromImage(TextBitmap);
  32.     }
  33.  
  34.     private static Bitmap TextBitmap;
  35.  
  36.     private static Graphics TextGraphics;
  37.     static internal SizeF MeasureString(string text, Font font)
  38.     {
  39.         return TextGraphics.MeasureString(text, font);
  40.     }
  41.  
  42.     static internal SizeF MeasureString(string text, Font font, int width)
  43.     {
  44.         return TextGraphics.MeasureString(text, font, width, StringFormat.GenericTypographic);
  45.     }
  46.  
  47.     private static GraphicsPath CreateRoundPath;
  48.  
  49.     private static Rectangle CreateRoundRectangle;
  50.     static internal GraphicsPath CreateRound(int x, int y, int width, int height, int slope)
  51.     {
  52.         CreateRoundRectangle = new Rectangle(x, y, width, height);
  53.         return CreateRound(CreateRoundRectangle, slope);
  54.     }
  55.  
  56.     static internal GraphicsPath CreateRound(Rectangle r, int slope)
  57.     {
  58.         CreateRoundPath = new GraphicsPath(FillMode.Winding);
  59.         CreateRoundPath.AddArc(r.X, r.Y, slope, slope, 180f, 90f);
  60.         CreateRoundPath.AddArc(r.Right - slope, r.Y, slope, slope, 270f, 90f);
  61.         CreateRoundPath.AddArc(r.Right - slope, r.Bottom - slope, slope, slope, 0f, 90f);
  62.         CreateRoundPath.AddArc(r.X, r.Bottom - slope, slope, slope, 90f, 90f);
  63.         CreateRoundPath.CloseFigure();
  64.         return CreateRoundPath;
  65.     }
  66.  
  67. }
  68.  
  69. class NSTheme : ThemeContainer154
  70. {
  71.  
  72.     private int _AccentOffset = 0;
  73.     public int AccentOffset
  74.     {
  75.         get { return _AccentOffset; }
  76.         set
  77.         {
  78.             _AccentOffset = value;
  79.             Invalidate();
  80.         }
  81.     }
  82.  
  83.     public NSTheme()
  84.     {
  85.         Header = 30;
  86.         BackColor = Color.FromArgb(50, 50, 50);
  87.  
  88.         P1 = new Pen(Color.FromArgb(35, 35, 35));
  89.         P2 = new Pen(Color.FromArgb(60, 60, 60));
  90.  
  91.         B1 = new SolidBrush(Color.FromArgb(50, 50, 50));
  92.     }
  93.  
  94.  
  95.     protected override void ColorHook()
  96.     {
  97.     }
  98.  
  99.  
  100.     private Rectangle R1;
  101.     private Pen P1;
  102.     private Pen P2;
  103.  
  104.     private SolidBrush B1;
  105.  
  106.     private int Pad;
  107.     protected override void PaintHook()
  108.     {
  109.         G.Clear(BackColor);
  110.         DrawBorders(P2, 1);
  111.  
  112.         G.DrawLine(P1, 0, 26, Width, 26);
  113.         G.DrawLine(P2, 0, 25, Width, 25);
  114.  
  115.         Pad = Math.Max(Measure().Width + 20, 80);
  116.         R1 = new Rectangle(Pad, 17, Width - (Pad * 2) + _AccentOffset, 8);
  117.  
  118.         G.DrawRectangle(P2, R1);
  119.         G.DrawRectangle(P1, R1.X + 1, R1.Y + 1, R1.Width - 2, R1.Height);
  120.  
  121.         G.DrawLine(P1, 0, 29, Width, 29);
  122.         G.DrawLine(P2, 0, 30, Width, 30);
  123.  
  124.         DrawText(Brushes.Black, HorizontalAlignment.Left, 8, 1);
  125.         DrawText(Brushes.White, HorizontalAlignment.Left, 7, 0);
  126.  
  127.         G.FillRectangle(B1, 0, 27, Width, 2);
  128.         DrawBorders(Pens.Black);
  129.     }
  130.  
  131. }
  132.  
  133. class NSButton : Control
  134. {
  135.  
  136.     public NSButton()
  137.     {
  138.         SetStyle((ControlStyles)139286, true);
  139.         SetStyle(ControlStyles.Selectable, false);
  140.  
  141.         P1 = new Pen(Color.FromArgb(35, 35, 35));
  142.         P2 = new Pen(Color.FromArgb(65, 65, 65));
  143.     }
  144.  
  145.  
  146.     private bool IsMouseDown;
  147.     private GraphicsPath GP1;
  148.  
  149.     private GraphicsPath GP2;
  150.     private SizeF SZ1;
  151.  
  152.     private PointF PT1;
  153.     private Pen P1;
  154.  
  155.     private Pen P2;
  156.     private PathGradientBrush PB1;
  157.  
  158.     private LinearGradientBrush GB1;
  159.  
  160.     private Graphics G;
  161.     protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
  162.     {
  163.         G = e.Graphics;
  164.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
  165.  
  166.         G.Clear(BackColor);
  167.         G.SmoothingMode = SmoothingMode.AntiAlias;
  168.  
  169.         GP1 = ThemeModule.CreateRound(0, 0, Width - 1, Height - 1, 7);
  170.         GP2 = ThemeModule.CreateRound(1, 1, Width - 3, Height - 3, 7);
  171.  
  172.         if (IsMouseDown) {
  173.             PB1 = new PathGradientBrush(GP1);
  174.             PB1.CenterColor = Color.FromArgb(60, 60, 60);
  175.             PB1.SurroundColors = new Color[] { Color.FromArgb(55, 55, 55) };
  176.             PB1.FocusScales = new PointF(0.8f, 0.5f);
  177.  
  178.             G.FillPath(PB1, GP1);
  179.         } else {
  180.             GB1 = new LinearGradientBrush(ClientRectangle, Color.FromArgb(60, 60, 60), Color.FromArgb(55, 55, 55), 90f);
  181.             G.FillPath(GB1, GP1);
  182.         }
  183.  
  184.         G.DrawPath(P1, GP1);
  185.         G.DrawPath(P2, GP2);
  186.  
  187.         SZ1 = G.MeasureString(Text, Font);
  188.         PT1 = new PointF(5, Height / 2 - SZ1.Height / 2);
  189.  
  190.         if (IsMouseDown) {
  191.             PT1.X += 1f;
  192.             PT1.Y += 1f;
  193.         }
  194.  
  195.         G.DrawString(Text, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1);
  196.         G.DrawString(Text, Font, Brushes.White, PT1);
  197.     }
  198.  
  199.     protected override void OnMouseDown(MouseEventArgs e)
  200.     {
  201.         IsMouseDown = true;
  202.         Invalidate();
  203.     }
  204.  
  205.     protected override void OnMouseUp(MouseEventArgs e)
  206.     {
  207.         IsMouseDown = false;
  208.         Invalidate();
  209.     }
  210.  
  211. }
  212.  
  213. class NSProgressBar : Control
  214. {
  215.  
  216.     private int _Minimum;
  217.     public int Minimum
  218.     {
  219.         get { return _Minimum; }
  220.         set
  221.         {
  222.             if (value < 0)
  223.             {
  224.                 throw new Exception("Property value is not valid.");
  225.             }
  226.  
  227.             _Minimum = value;
  228.             if (value > _Value)
  229.                 _Value = value;
  230.             if (value > _Maximum)
  231.                 _Maximum = value;
  232.             Invalidate();
  233.         }
  234.     }
  235.  
  236.     private int _Maximum = 100;
  237.     public int Maximum
  238.     {
  239.         get { return _Maximum; }
  240.         set
  241.         {
  242.             if (value < 0)
  243.             {
  244.                 throw new Exception("Property value is not valid.");
  245.             }
  246.  
  247.             _Maximum = value;
  248.             if (value < _Value)
  249.                 _Value = value;
  250.             if (value < _Minimum)
  251.                 _Minimum = value;
  252.             Invalidate();
  253.         }
  254.     }
  255.  
  256.     private int _Value;
  257.     public int Value
  258.     {
  259.         get { return _Value; }
  260.         set
  261.         {
  262.             if (value > _Maximum || value < _Minimum)
  263.             {
  264.                 throw new Exception("Property value is not valid.");
  265.             }
  266.  
  267.             _Value = value;
  268.             Invalidate();
  269.         }
  270.     }
  271.  
  272.     private void Increment(int amount)
  273.     {
  274.         Value += amount;
  275.     }
  276.  
  277.     public NSProgressBar()
  278.     {
  279.         SetStyle((ControlStyles)139286, true);
  280.         SetStyle(ControlStyles.Selectable, false);
  281.  
  282.         P1 = new Pen(Color.FromArgb(35, 35, 35));
  283.         P2 = new Pen(Color.FromArgb(55, 55, 55));
  284.         B1 = new SolidBrush(Color.FromArgb(200, 160, 0));
  285.     }
  286.  
  287.     private GraphicsPath GP1;
  288.     private GraphicsPath GP2;
  289.  
  290.     private GraphicsPath GP3;
  291.     private Rectangle R1;
  292.  
  293.     private Rectangle R2;
  294.     private Pen P1;
  295.     private Pen P2;
  296.     private SolidBrush B1;
  297.     private LinearGradientBrush GB1;
  298.  
  299.     private LinearGradientBrush GB2;
  300.  
  301.     private int I1;
  302.     private Graphics G;
  303.  
  304.     protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
  305.     {
  306.         G = e.Graphics;
  307.  
  308.         G.Clear(BackColor);
  309.         G.SmoothingMode = SmoothingMode.AntiAlias;
  310.  
  311.         GP1 = ThemeModule.CreateRound(0, 0, Width - 1, Height - 1, 7);
  312.         GP2 = ThemeModule.CreateRound(1, 1, Width - 3, Height - 3, 7);
  313.  
  314.         R1 = new Rectangle(0, 2, Width - 1, Height - 1);
  315.         GB1 = new LinearGradientBrush(R1, Color.FromArgb(45, 45, 45), Color.FromArgb(50, 50, 50), 90f);
  316.  
  317.         G.SetClip(GP1);
  318.         G.FillRectangle(GB1, R1);
  319.  
  320.         I1 = Convert.ToInt32((_Value - _Minimum) / (_Maximum - _Minimum) * (Width - 3));
  321.  
  322.         if (I1 > 1)
  323.         {
  324.             GP3 = ThemeModule.CreateRound(1, 1, I1, Height - 3, 7);
  325.  
  326.             R2 = new Rectangle(1, 1, I1, Height - 3);
  327.             GB2 = new LinearGradientBrush(R2, Color.FromArgb(205, 150, 0), Color.FromArgb(150, 110, 0), 90f);
  328.  
  329.             G.FillPath(GB2, GP3);
  330.             G.DrawPath(P1, GP3);
  331.  
  332.             G.SetClip(GP3);
  333.             G.SmoothingMode = SmoothingMode.None;
  334.  
  335.             G.FillRectangle(B1, R2.X, R2.Y + 1, R2.Width, R2.Height / 2);
  336.  
  337.             G.SmoothingMode = SmoothingMode.AntiAlias;
  338.             G.ResetClip();
  339.         }
  340.  
  341.         G.DrawPath(P2, GP1);
  342.         G.DrawPath(P1, GP2);
  343.     }
  344.  
  345. }
  346.  
  347. class NSLabel : Control
  348. {
  349.  
  350.     public NSLabel()
  351.     {
  352.         SetStyle((ControlStyles)139286, true);
  353.         SetStyle(ControlStyles.Selectable, false);
  354.  
  355.         Font = new Font("Segoe UI", 11.25f, FontStyle.Bold);
  356.  
  357.         B1 = new SolidBrush(Color.FromArgb(205, 150, 0));
  358.     }
  359.  
  360.     private string _Value1 = "NET";
  361.     public string Value1
  362.     {
  363.         get { return _Value1; }
  364.         set
  365.         {
  366.             _Value1 = value;
  367.             Invalidate();
  368.         }
  369.     }
  370.  
  371.     private string _Value2 = "SEAL";
  372.     public string Value2
  373.     {
  374.         get { return _Value2; }
  375.         set
  376.         {
  377.             _Value2 = value;
  378.             Invalidate();
  379.         }
  380.     }
  381.  
  382.  
  383.     private SolidBrush B1;
  384.     private PointF PT1;
  385.     private PointF PT2;
  386.     private SizeF SZ1;
  387.  
  388.     private SizeF SZ2;
  389.     private Graphics G;
  390.  
  391.     protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
  392.     {
  393.         G = e.Graphics;
  394.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
  395.  
  396.         G.Clear(BackColor);
  397.  
  398.         SZ1 = G.MeasureString(Value1, Font, Width, StringFormat.GenericTypographic);
  399.         SZ2 = G.MeasureString(Value2, Font, Width, StringFormat.GenericTypographic);
  400.  
  401.         PT1 = new PointF(0, Height / 2 - SZ1.Height / 2);
  402.         PT2 = new PointF(SZ1.Width + 1, Height / 2 - SZ1.Height / 2);
  403.  
  404.         G.DrawString(Value1, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1);
  405.         G.DrawString(Value1, Font, Brushes.White, PT1);
  406.  
  407.         G.DrawString(Value2, Font, Brushes.Black, PT2.X + 1, PT2.Y + 1);
  408.         G.DrawString(Value2, Font, B1, PT2);
  409.     }
  410.  
  411. }
  412.  
  413. [DefaultEvent("TextChanged")]
  414. class NSTextBox : Control
  415. {
  416.  
  417.     private HorizontalAlignment _TextAlign = HorizontalAlignment.Left;
  418.     public HorizontalAlignment TextAlign
  419.     {
  420.         get { return _TextAlign; }
  421.         set
  422.         {
  423.             _TextAlign = value;
  424.             if (Base != null)
  425.             {
  426.                 Base.TextAlign = value;
  427.             }
  428.         }
  429.     }
  430.  
  431.     private int _MaxLength = 32767;
  432.     public int MaxLength
  433.     {
  434.         get { return _MaxLength; }
  435.         set
  436.         {
  437.             _MaxLength = value;
  438.             if (Base != null)
  439.             {
  440.                 Base.MaxLength = value;
  441.             }
  442.         }
  443.     }
  444.  
  445.     private bool _ReadOnly;
  446.     public bool ReadOnly
  447.     {
  448.         get { return _ReadOnly; }
  449.         set
  450.         {
  451.             _ReadOnly = value;
  452.             if (Base != null)
  453.             {
  454.                 Base.ReadOnly = value;
  455.             }
  456.         }
  457.     }
  458.  
  459.     private bool _UseSystemPasswordChar;
  460.     public bool UseSystemPasswordChar
  461.     {
  462.         get { return _UseSystemPasswordChar; }
  463.         set
  464.         {
  465.             _UseSystemPasswordChar = value;
  466.             if (Base != null)
  467.             {
  468.                 Base.UseSystemPasswordChar = value;
  469.             }
  470.         }
  471.     }
  472.  
  473.     private bool _Multiline;
  474.     public bool Multiline
  475.     {
  476.         get { return _Multiline; }
  477.         set
  478.         {
  479.             _Multiline = value;
  480.             if (Base != null)
  481.             {
  482.                 Base.Multiline = value;
  483.  
  484.                 if (value)
  485.                 {
  486.                     Base.Height = Height - 11;
  487.                 }
  488.                 else
  489.                 {
  490.                     Height = Base.Height + 11;
  491.                 }
  492.             }
  493.         }
  494.     }
  495.  
  496.     public override string Text
  497.     {
  498.         get { return base.Text; }
  499.         set
  500.         {
  501.             base.Text = value;
  502.             if (Base != null)
  503.             {
  504.                 Base.Text = value;
  505.             }
  506.         }
  507.     }
  508.  
  509.     public override Font Font
  510.     {
  511.         get { return base.Font; }
  512.         set
  513.         {
  514.             base.Font = value;
  515.             if (Base != null)
  516.             {
  517.                 Base.Font = value;
  518.                 Base.Location = new Point(5, 5);
  519.                 Base.Width = Width - 8;
  520.  
  521.                 if (!_Multiline)
  522.                 {
  523.                     Height = Base.Height + 11;
  524.                 }
  525.             }
  526.         }
  527.     }
  528.  
  529.     protected override void OnHandleCreated(EventArgs e)
  530.     {
  531.         if (!Controls.Contains(Base))
  532.         {
  533.             Controls.Add(Base);
  534.         }
  535.  
  536.         base.OnHandleCreated(e);
  537.     }
  538.  
  539.     private TextBox Base;
  540.     public NSTextBox()
  541.     {
  542.         SetStyle((ControlStyles)139286, true);
  543.         SetStyle(ControlStyles.Selectable, true);
  544.  
  545.         Cursor = Cursors.IBeam;
  546.  
  547.         Base = new TextBox();
  548.         Base.Font = Font;
  549.         Base.Text = Text;
  550.         Base.MaxLength = _MaxLength;
  551.         Base.Multiline = _Multiline;
  552.         Base.ReadOnly = _ReadOnly;
  553.         Base.UseSystemPasswordChar = _UseSystemPasswordChar;
  554.  
  555.         Base.ForeColor = Color.White;
  556.         Base.BackColor = Color.FromArgb(50, 50, 50);
  557.  
  558.         Base.BorderStyle = BorderStyle.None;
  559.  
  560.         Base.Location = new Point(5, 5);
  561.         Base.Width = Width - 14;
  562.  
  563.         if (_Multiline)
  564.         {
  565.             Base.Height = Height - 11;
  566.         }
  567.         else
  568.         {
  569.             Height = Base.Height + 11;
  570.         }
  571.  
  572.         Base.TextChanged += OnBaseTextChanged;
  573.         Base.KeyDown += OnBaseKeyDown;
  574.  
  575.         P1 = new Pen(Color.FromArgb(35, 35, 35));
  576.         P2 = new Pen(Color.FromArgb(55, 55, 55));
  577.     }
  578.  
  579.     private GraphicsPath GP1;
  580.  
  581.     private GraphicsPath GP2;
  582.     private Pen P1;
  583.     private Pen P2;
  584.  
  585.     private PathGradientBrush PB1;
  586.     private Graphics G;
  587.  
  588.     protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
  589.     {
  590.         G = e.Graphics;
  591.  
  592.         G.Clear(BackColor);
  593.         G.SmoothingMode = SmoothingMode.AntiAlias;
  594.  
  595.         GP1 = ThemeModule.CreateRound(0, 0, Width - 1, Height - 1, 7);
  596.         GP2 = ThemeModule.CreateRound(1, 1, Width - 3, Height - 3, 7);
  597.  
  598.         PB1 = new PathGradientBrush(GP1);
  599.         PB1.CenterColor = Color.FromArgb(50, 50, 50);
  600.         PB1.SurroundColors = new Color[]{ Color.FromArgb(45, 45, 45) };
  601.         PB1.FocusScales = new PointF(0.9f, 0.5f);
  602.  
  603.         G.FillPath(PB1, GP1);
  604.  
  605.         G.DrawPath(P2, GP1);
  606.         G.DrawPath(P1, GP2);
  607.     }
  608.  
  609.     private void OnBaseTextChanged(object s, EventArgs e)
  610.     {
  611.         Text = Base.Text;
  612.     }
  613.  
  614.     private void OnBaseKeyDown(object s, KeyEventArgs e)
  615.     {
  616.         if (e.Control && e.KeyCode == Keys.A)
  617.         {
  618.             Base.SelectAll();
  619.             e.SuppressKeyPress = true;
  620.         }
  621.     }
  622.  
  623.     protected override void OnResize(EventArgs e)
  624.     {
  625.         Base.Location = new Point(5, 5);
  626.  
  627.         Base.Width = Width - 10;
  628.         Base.Height = Height - 11;
  629.  
  630.         base.OnResize(e);
  631.     }
  632.  
  633.     protected override void OnMouseDown(MouseEventArgs e)
  634.     {
  635.         Base.Focus();
  636.         base.OnMouseDown(e);
  637.     }
  638.  
  639.     protected override void OnEnter(EventArgs e)
  640.     {
  641.         Base.Focus();
  642.         Invalidate();
  643.         base.OnEnter(e);
  644.     }
  645.  
  646.     protected override void OnLeave(EventArgs e)
  647.     {
  648.         Invalidate();
  649.         base.OnLeave(e);
  650.     }
  651.  
  652. }
  653.  
  654. [DefaultEvent("CheckedChanged")]
  655. class NSCheckBox : Control
  656. {
  657.  
  658.     public event CheckedChangedEventHandler CheckedChanged;
  659.     public delegate void CheckedChangedEventHandler(object sender);
  660.  
  661.     public NSCheckBox()
  662.     {
  663.         SetStyle((ControlStyles)139286, true);
  664.         SetStyle(ControlStyles.Selectable, false);
  665.  
  666.         P11 = new Pen(Color.FromArgb(55, 55, 55));
  667.         P22 = new Pen(Color.FromArgb(35, 35, 35));
  668.         P3 = new Pen(Color.Black, 2f);
  669.         P4 = new Pen(Color.White, 2f);
  670.     }
  671.  
  672.     private bool _Checked;
  673.     public bool Checked
  674.     {
  675.         get { return _Checked; }
  676.         set
  677.         {
  678.             _Checked = value;
  679.             if (CheckedChanged != null)
  680.             {
  681.                 CheckedChanged(this);
  682.             }
  683.  
  684.             Invalidate();
  685.         }
  686.     }
  687.  
  688.     private GraphicsPath GP1;
  689.  
  690.     private GraphicsPath GP2;
  691.     private SizeF SZ1;
  692.  
  693.     private PointF PT1;
  694.     private Pen P11;
  695.     private Pen P22;
  696.     private Pen P3;
  697.  
  698.     private Pen P4;
  699.  
  700.     private PathGradientBrush PB1;
  701.     private Graphics G;
  702.     protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
  703.     {
  704.         G = e.Graphics;
  705.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
  706.  
  707.         G.Clear(BackColor);
  708.         G.SmoothingMode = SmoothingMode.AntiAlias;
  709.  
  710.         GP1 = ThemeModule.CreateRound(0, 2, Height - 5, Height - 5, 5);
  711.         GP2 = ThemeModule.CreateRound(1, 3, Height - 7, Height - 7, 5);
  712.  
  713.         PB1 = new PathGradientBrush(GP1);
  714.         PB1.CenterColor = Color.FromArgb(50, 50, 50);
  715.         PB1.SurroundColors =new Color[] { Color.FromArgb(45, 45, 45) };
  716.         PB1.FocusScales = new PointF(0.3f, 0.3f);
  717.  
  718.         G.FillPath(PB1, GP1);
  719.         G.DrawPath(P11, GP1);
  720.         G.DrawPath(P22, GP2);
  721.  
  722.         if (_Checked) {
  723.             G.DrawLine(P3, 5, Height - 9, 8, Height - 7);
  724.             G.DrawLine(P3, 7, Height - 7, Height - 8, 7);
  725.  
  726.             G.DrawLine(P4, 4, Height - 10, 7, Height - 8);
  727.             G.DrawLine(P4, 6, Height - 8, Height - 9, 6);
  728.         }
  729.  
  730.         SZ1 = G.MeasureString(Text, Font);
  731.         PT1 = new PointF(Height - 3, Height / 2 - SZ1.Height / 2);
  732.  
  733.         G.DrawString(Text, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1);
  734.         G.DrawString(Text, Font, Brushes.White, PT1);
  735.     }
  736.  
  737.     protected override void OnMouseDown(MouseEventArgs e)
  738.     {
  739.         Checked = !Checked;
  740.     }
  741.  
  742. }
  743.  
  744. [DefaultEvent("CheckedChanged")]
  745. class NSRadioButton : Control
  746. {
  747.  
  748.     public event CheckedChangedEventHandler CheckedChanged;
  749.     public delegate void CheckedChangedEventHandler(object sender);
  750.  
  751.     public NSRadioButton()
  752.     {
  753.         SetStyle((ControlStyles)139286, true);
  754.         SetStyle(ControlStyles.Selectable, false);
  755.  
  756.         P1 = new Pen(Color.FromArgb(55, 55, 55));
  757.         P2 = new Pen(Color.FromArgb(35, 35, 35));
  758.     }
  759.  
  760.     private bool _Checked;
  761.     public bool Checked
  762.     {
  763.         get { return _Checked; }
  764.         set
  765.         {
  766.             _Checked = value;
  767.  
  768.             if (_Checked)
  769.             {
  770.                 InvalidateParent();
  771.             }
  772.  
  773.             if (CheckedChanged != null)
  774.             {
  775.                 CheckedChanged(this);
  776.             }
  777.             Invalidate();
  778.         }
  779.     }
  780.  
  781.     private void InvalidateParent()
  782.     {
  783.         if (Parent == null)
  784.             return;
  785.  
  786.         foreach (Control C in Parent.Controls)
  787.         {
  788.             if ((!object.ReferenceEquals(C, this)) && (C is NSRadioButton))
  789.             {
  790.                 ((NSRadioButton)C).Checked = false;
  791.             }
  792.         }
  793.     }
  794.  
  795.  
  796.     private GraphicsPath GP1;
  797.     private SizeF SZ1;
  798.  
  799.     private PointF PT1;
  800.     private Pen P1;
  801.  
  802.     private Pen P2;
  803.  
  804.     private PathGradientBrush PB1;
  805.     private Graphics G;
  806.     protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
  807.     {
  808.         G = e.Graphics;
  809.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
  810.  
  811.         G.Clear(BackColor);
  812.         G.SmoothingMode = SmoothingMode.AntiAlias;
  813.  
  814.         GP1 = new GraphicsPath();
  815.         GP1.AddEllipse(0, 2, Height - 5, Height - 5);
  816.  
  817.         PB1 = new PathGradientBrush(GP1);
  818.         PB1.CenterColor = Color.FromArgb(50, 50, 50);
  819.         PB1.SurroundColors = new Color[]{ Color.FromArgb(45, 45, 45) };
  820.         PB1.FocusScales = new PointF(0.3f, 0.3f);
  821.  
  822.         G.FillPath(PB1, GP1);
  823.  
  824.         G.DrawEllipse(P1, 0, 2, Height - 5, Height - 5);
  825.         G.DrawEllipse(P2, 1, 3, Height - 7, Height - 7);
  826.  
  827.         if (_Checked) {
  828.             G.FillEllipse(Brushes.Black, 6, 8, Height - 15, Height - 15);
  829.             G.FillEllipse(Brushes.White, 5, 7, Height - 15, Height - 15);
  830.         }
  831.  
  832.         SZ1 = G.MeasureString(Text, Font);
  833.         PT1 = new PointF(Height - 3, Height / 2 - SZ1.Height / 2);
  834.  
  835.         G.DrawString(Text, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1);
  836.         G.DrawString(Text, Font, Brushes.White, PT1);
  837.     }
  838.  
  839.     protected override void OnMouseDown(MouseEventArgs e)
  840.     {
  841.         Checked = true;
  842.         base.OnMouseDown(e);
  843.     }
  844.  
  845. }
  846.  
  847. class NSComboBox : ComboBox
  848. {
  849.  
  850.     public NSComboBox()
  851.     {
  852.         SetStyle((ControlStyles)139286, true);
  853.         SetStyle(ControlStyles.Selectable, false);
  854.  
  855.         DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
  856.         DropDownStyle = ComboBoxStyle.DropDownList;
  857.  
  858.         BackColor = Color.FromArgb(50, 50, 50);
  859.         ForeColor = Color.White;
  860.  
  861.         P1 = new Pen(Color.FromArgb(35, 35, 35));
  862.         P2 = new Pen(Color.White, 2f);
  863.         P3 = new Pen(Brushes.Black, 2f);
  864.         P4 = new Pen(Color.FromArgb(65, 65, 65));
  865.  
  866.         B1 = new SolidBrush(Color.FromArgb(65, 65, 65));
  867.         B2 = new SolidBrush(Color.FromArgb(55, 55, 55));
  868.     }
  869.  
  870.     private GraphicsPath GP1;
  871.  
  872.     private GraphicsPath GP2;
  873.     private SizeF SZ1;
  874.  
  875.     private PointF PT1;
  876.     private Pen P1;
  877.     private Pen P2;
  878.     private Pen P3;
  879.     private Pen P4;
  880.     private SolidBrush B1;
  881.  
  882.     private SolidBrush B2;
  883.  
  884.     private LinearGradientBrush GB1;
  885.     private Graphics G;
  886.     protected override void OnPaint(PaintEventArgs e)
  887.     {
  888.         G = e.Graphics;
  889.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
  890.  
  891.         G.Clear(BackColor);
  892.         G.SmoothingMode = SmoothingMode.AntiAlias;
  893.  
  894.         GP1 = ThemeModule.CreateRound(0, 0, Width - 1, Height - 1, 7);
  895.         GP2 = ThemeModule.CreateRound(1, 1, Width - 3, Height - 3, 7);
  896.  
  897.         GB1 = new LinearGradientBrush(ClientRectangle, Color.FromArgb(60, 60, 60), Color.FromArgb(55, 55, 55), 90f);
  898.         G.SetClip(GP1);
  899.         G.FillRectangle(GB1, ClientRectangle);
  900.         G.ResetClip();
  901.  
  902.         G.DrawPath(P1, GP1);
  903.         G.DrawPath(P4, GP2);
  904.  
  905.         SZ1 = G.MeasureString(Text, Font);
  906.         PT1 = new PointF(5, Height / 2 - SZ1.Height / 2);
  907.  
  908.         G.DrawString(Text, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1);
  909.         G.DrawString(Text, Font, Brushes.White, PT1);
  910.  
  911.         G.DrawLine(P3, Width - 15, 10, Width - 11, 13);
  912.         G.DrawLine(P3, Width - 7, 10, Width - 11, 13);
  913.         G.DrawLine(Pens.Black, Width - 11, 13, Width - 11, 14);
  914.  
  915.         G.DrawLine(P2, Width - 16, 9, Width - 12, 12);
  916.         G.DrawLine(P2, Width - 8, 9, Width - 12, 12);
  917.         G.DrawLine(Pens.White, Width - 12, 12, Width - 12, 13);
  918.  
  919.         G.DrawLine(P1, Width - 22, 0, Width - 22, Height);
  920.         G.DrawLine(P4, Width - 23, 1, Width - 23, Height - 2);
  921.         G.DrawLine(P4, Width - 21, 1, Width - 21, Height - 2);
  922.     }
  923.  
  924.     protected override void OnDrawItem(DrawItemEventArgs e)
  925.     {
  926.         e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
  927.  
  928.         if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
  929.         {
  930.             e.Graphics.FillRectangle(B1, e.Bounds);
  931.         }
  932.         else
  933.         {
  934.             e.Graphics.FillRectangle(B2, e.Bounds);
  935.         }
  936.  
  937.         if (!(e.Index == -1))
  938.         {
  939.             e.Graphics.DrawString(GetItemText(Items[e.Index]), e.Font, Brushes.White, e.Bounds);
  940.         }
  941.     }
  942.  
  943. }
  944.  
  945. class NSTabControl : TabControl
  946. {
  947.  
  948.     public NSTabControl()
  949.     {
  950.         SetStyle((ControlStyles)139286, true);
  951.         SetStyle(ControlStyles.Selectable, false);
  952.  
  953.         SizeMode = TabSizeMode.Fixed;
  954.         Alignment = TabAlignment.Left;
  955.         ItemSize = new Size(28, 115);
  956.  
  957.         DrawMode = TabDrawMode.OwnerDrawFixed;
  958.  
  959.         P1 = new Pen(Color.FromArgb(55, 55, 55));
  960.         P2 = new Pen(Color.FromArgb(35, 35, 35));
  961.         P3 = new Pen(Color.FromArgb(45, 45, 45), 2);
  962.  
  963.         B1 = new SolidBrush(Color.FromArgb(50, 50, 50));
  964.         B2 = new SolidBrush(Color.FromArgb(35, 35, 35));
  965.         B3 = new SolidBrush(Color.FromArgb(205, 150, 0));
  966.         B4 = new SolidBrush(Color.FromArgb(65, 65, 65));
  967.  
  968.         SF1 = new StringFormat();
  969.         SF1.LineAlignment = StringAlignment.Center;
  970.     }
  971.  
  972.     protected override void OnControlAdded(ControlEventArgs e)
  973.     {
  974.         if (e.Control is TabPage)
  975.         {
  976.             e.Control.BackColor = Color.FromArgb(50, 50, 50);
  977.         }
  978.  
  979.         base.OnControlAdded(e);
  980.     }
  981.  
  982.     private GraphicsPath GP1;
  983.     private GraphicsPath GP2;
  984.     private GraphicsPath GP3;
  985.  
  986.     private GraphicsPath GP4;
  987.     private Rectangle R1;
  988.  
  989.     private Rectangle R2;
  990.     private Pen P1;
  991.     private Pen P2;
  992.     private Pen P3;
  993.     private SolidBrush B1;
  994.     private SolidBrush B2;
  995.     private SolidBrush B3;
  996.  
  997.     private SolidBrush B4;
  998.  
  999.     private PathGradientBrush PB1;
  1000.     private TabPage TP1;
  1001.  
  1002.     private StringFormat SF1;
  1003.     private int Offset;
  1004.  
  1005.     private int ItemHeight;
  1006.     private Graphics G;
  1007.  
  1008.     protected override void OnPaint(PaintEventArgs e)
  1009.     {
  1010.         G = e.Graphics;
  1011.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
  1012.  
  1013.         G.Clear(Color.FromArgb(50, 50, 50));
  1014.         G.SmoothingMode = SmoothingMode.AntiAlias;
  1015.  
  1016.         ItemHeight = ItemSize.Height + 2;
  1017.  
  1018.         GP1 = ThemeModule.CreateRound(0, 0, ItemHeight + 3, Height - 1, 7);
  1019.         GP2 = ThemeModule.CreateRound(1, 1, ItemHeight + 3, Height - 3, 7);
  1020.  
  1021.         PB1 = new PathGradientBrush(GP1);
  1022.         PB1.CenterColor = Color.FromArgb(50, 50, 50);
  1023.         PB1.SurroundColors = new Color[] { Color.FromArgb(45, 45, 45) };
  1024.         PB1.FocusScales = new PointF(0.8f, 0.95f);
  1025.  
  1026.         G.FillPath(PB1, GP1);
  1027.  
  1028.         G.DrawPath(P1, GP1);
  1029.         G.DrawPath(P2, GP2);
  1030.  
  1031.         for (int I = 0; I <= TabCount - 1; I++) {
  1032.             R1 = GetTabRect(I);
  1033.             R1.Y += 2;
  1034.             R1.Height -= 3;
  1035.             R1.Width += 1;
  1036.             R1.X -= 1;
  1037.  
  1038.             TP1 = TabPages[I];
  1039.             Offset = 0;
  1040.  
  1041.             if (SelectedIndex == I) {
  1042.                 G.FillRectangle(B1, R1);
  1043.  
  1044.                 for (int J = 0; J <= 1; J++) {
  1045.                     G.FillRectangle(B2, R1.X + 5 + (J * 5), R1.Y + 6, 2, R1.Height - 9);
  1046.  
  1047.                     G.SmoothingMode = SmoothingMode.None;
  1048.                     G.FillRectangle(B3, R1.X + 5 + (J * 5), R1.Y + 5, 2, R1.Height - 9);
  1049.                     G.SmoothingMode = SmoothingMode.AntiAlias;
  1050.  
  1051.                     Offset += 5;
  1052.                 }
  1053.  
  1054.                 G.DrawRectangle(P3, R1.X + 1, R1.Y - 1, R1.Width, R1.Height + 2);
  1055.                 G.DrawRectangle(P1, R1.X + 1, R1.Y + 1, R1.Width - 2, R1.Height - 2);
  1056.                 G.DrawRectangle(P2, R1);
  1057.             } else {
  1058.                 for (int J = 0; J <= 1; J++) {
  1059.                     G.FillRectangle(B2, R1.X + 5 + (J * 5), R1.Y + 6, 2, R1.Height - 9);
  1060.  
  1061.                     G.SmoothingMode = SmoothingMode.None;
  1062.                     G.FillRectangle(B4, R1.X + 5 + (J * 5), R1.Y + 5, 2, R1.Height - 9);
  1063.                     G.SmoothingMode = SmoothingMode.AntiAlias;
  1064.  
  1065.                     Offset += 5;
  1066.                 }
  1067.             }
  1068.  
  1069.             R1.X += 5 + Offset;
  1070.  
  1071.             R2 = R1;
  1072.             R2.Y += 1;
  1073.             R2.X += 1;
  1074.  
  1075.             G.DrawString(TP1.Text, Font, Brushes.Black, R2, SF1);
  1076.             G.DrawString(TP1.Text, Font, Brushes.White, R1, SF1);
  1077.         }
  1078.  
  1079.         GP3 = ThemeModule.CreateRound(ItemHeight, 0, Width - ItemHeight - 1, Height - 1, 7);
  1080.         GP4 = ThemeModule.CreateRound(ItemHeight + 1, 1, Width - ItemHeight - 3, Height - 3, 7);
  1081.  
  1082.         G.DrawPath(P2, GP3);
  1083.         G.DrawPath(P1, GP4);
  1084.     }
  1085.  
  1086. }
  1087.  
  1088. [DefaultEvent("CheckedChanged")]
  1089. class NSOnOffBox : Control
  1090. {
  1091.  
  1092.     public event CheckedChangedEventHandler CheckedChanged;
  1093.     public delegate void CheckedChangedEventHandler(object sender);
  1094.  
  1095.     public NSOnOffBox()
  1096.     {
  1097.         SetStyle((ControlStyles)139286, true);
  1098.         SetStyle(ControlStyles.Selectable, false);
  1099.  
  1100.         P1 = new Pen(Color.FromArgb(55, 55, 55));
  1101.         P2 = new Pen(Color.FromArgb(35, 35, 35));
  1102.         P3 = new Pen(Color.FromArgb(65, 65, 65));
  1103.  
  1104.         B1 = new SolidBrush(Color.FromArgb(35, 35, 35));
  1105.         B2 = new SolidBrush(Color.FromArgb(85, 85, 85));
  1106.         B3 = new SolidBrush(Color.FromArgb(65, 65, 65));
  1107.         B4 = new SolidBrush(Color.FromArgb(205, 150, 0));
  1108.         B5 = new SolidBrush(Color.FromArgb(40, 40, 40));
  1109.  
  1110.         SF1 = new StringFormat();
  1111.         SF1.LineAlignment = StringAlignment.Center;
  1112.         SF1.Alignment = StringAlignment.Near;
  1113.  
  1114.         SF2 = new StringFormat();
  1115.         SF2.LineAlignment = StringAlignment.Center;
  1116.         SF2.Alignment = StringAlignment.Far;
  1117.  
  1118.         Size = new Size(56, 24);
  1119.         MinimumSize = Size;
  1120.         MaximumSize = Size;
  1121.     }
  1122.  
  1123.     private bool _Checked;
  1124.     public bool Checked
  1125.     {
  1126.         get { return _Checked; }
  1127.         set
  1128.         {
  1129.             _Checked = value;
  1130.             if (CheckedChanged != null)
  1131.             {
  1132.                 CheckedChanged(this);
  1133.             }
  1134.  
  1135.             Invalidate();
  1136.         }
  1137.     }
  1138.  
  1139.     private GraphicsPath GP1;
  1140.     private GraphicsPath GP2;
  1141.     private GraphicsPath GP3;
  1142.  
  1143.     private GraphicsPath GP4;
  1144.     private Pen P1;
  1145.     private Pen P2;
  1146.     private Pen P3;
  1147.     private SolidBrush B1;
  1148.     private SolidBrush B2;
  1149.     private SolidBrush B3;
  1150.     private SolidBrush B4;
  1151.  
  1152.     private SolidBrush B5;
  1153.     private PathGradientBrush PB1;
  1154.  
  1155.     private LinearGradientBrush GB1;
  1156.     private Rectangle R1;
  1157.     private Rectangle R2;
  1158.     private Rectangle R3;
  1159.     private StringFormat SF1;
  1160.  
  1161.     private StringFormat SF2;
  1162.  
  1163.     private int Offset;
  1164.     private Graphics G;
  1165.  
  1166.     protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
  1167.     {
  1168.         G = e.Graphics;
  1169.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
  1170.  
  1171.         G.Clear(BackColor);
  1172.         G.SmoothingMode = SmoothingMode.AntiAlias;
  1173.  
  1174.         GP1 = ThemeModule.CreateRound(0, 0, Width - 1, Height - 1, 7);
  1175.         GP2 = ThemeModule.CreateRound(1, 1, Width - 3, Height - 3, 7);
  1176.  
  1177.         PB1 = new PathGradientBrush(GP1);
  1178.         PB1.CenterColor = Color.FromArgb(50, 50, 50);
  1179.         PB1.SurroundColors = new Color[]{ Color.FromArgb(45, 45, 45) };
  1180.         PB1.FocusScales = new PointF(0.3f, 0.3f);
  1181.  
  1182.         G.FillPath(PB1, GP1);
  1183.         G.DrawPath(P1, GP1);
  1184.         G.DrawPath(P2, GP2);
  1185.  
  1186.         R1 = new Rectangle(5, 0, Width - 10, Height + 2);
  1187.         R2 = new Rectangle(6, 1, Width - 10, Height + 2);
  1188.  
  1189.         R3 = new Rectangle(1, 1, (Width / 2) - 1, Height - 3);
  1190.  
  1191.         if (_Checked) {
  1192.             G.DrawString("On", Font, Brushes.Black, R2, SF1);
  1193.             G.DrawString("On", Font, Brushes.White, R1, SF1);
  1194.  
  1195.             R3.X += (Width / 2) - 1;
  1196.         } else {
  1197.             G.DrawString("Off", Font, B1, R2, SF2);
  1198.             G.DrawString("Off", Font, B2, R1, SF2);
  1199.         }
  1200.  
  1201.         GP3 = ThemeModule.CreateRound(R3, 7);
  1202.         GP4 = ThemeModule.CreateRound(R3.X + 1, R3.Y + 1, R3.Width - 2, R3.Height - 2, 7);
  1203.  
  1204.         GB1 = new LinearGradientBrush(ClientRectangle, Color.FromArgb(60, 60, 60), Color.FromArgb(55, 55, 55), 90f);
  1205.  
  1206.         G.FillPath(GB1, GP3);
  1207.         G.DrawPath(P2, GP3);
  1208.         G.DrawPath(P3, GP4);
  1209.  
  1210.         Offset = R3.X + (R3.Width / 2) - 3;
  1211.  
  1212.         for (int I = 0; I <= 1; I++) {
  1213.             if (_Checked) {
  1214.                 G.FillRectangle(B1, Offset + (I * 5), 7, 2, Height - 14);
  1215.             } else {
  1216.                 G.FillRectangle(B3, Offset + (I * 5), 7, 2, Height - 14);
  1217.             }
  1218.  
  1219.             G.SmoothingMode = SmoothingMode.None;
  1220.  
  1221.             if (_Checked) {
  1222.                 G.FillRectangle(B4, Offset + (I * 5), 7, 2, Height - 14);
  1223.             } else {
  1224.                 G.FillRectangle(B5, Offset + (I * 5), 7, 2, Height - 14);
  1225.             }
  1226.  
  1227.             G.SmoothingMode = SmoothingMode.AntiAlias;
  1228.         }
  1229.     }
  1230.  
  1231.     protected override void OnMouseDown(MouseEventArgs e)
  1232.     {
  1233.         Checked = !Checked;
  1234.         base.OnMouseDown(e);
  1235.     }
  1236.  
  1237. }
  1238.  
  1239. class NSControlButton : Control
  1240. {
  1241.  
  1242.     public enum Button : byte
  1243.     {
  1244.         None = 0,
  1245.         Minimize = 1,
  1246.         MaximizeRestore = 2,
  1247.         Close = 3
  1248.     }
  1249.  
  1250.     private Button _ControlButton = Button.Close;
  1251.     public Button ControlButton
  1252.     {
  1253.         get { return _ControlButton; }
  1254.         set
  1255.         {
  1256.             _ControlButton = value;
  1257.             Invalidate();
  1258.         }
  1259.     }
  1260.  
  1261.     public NSControlButton()
  1262.     {
  1263.         SetStyle((ControlStyles)139286, true);
  1264.         SetStyle(ControlStyles.Selectable, false);
  1265.  
  1266.         Anchor = AnchorStyles.Top | AnchorStyles.Right;
  1267.  
  1268.         Width = 18;
  1269.         Height = 20;
  1270.  
  1271.         MinimumSize = Size;
  1272.         MaximumSize = Size;
  1273.  
  1274.         Margin = new Padding(0);
  1275.     }
  1276.  
  1277.     private Graphics G;
  1278.     protected override void OnPaint(PaintEventArgs e)
  1279.     {
  1280.         G = e.Graphics;
  1281.         G.Clear(BackColor);
  1282.  
  1283.         switch (_ControlButton)
  1284.         {
  1285.             case Button.Minimize:
  1286.                 DrawMinimize(3, 10);
  1287.                 break;
  1288.             case Button.MaximizeRestore:
  1289.                 if (FindForm().WindowState == FormWindowState.Normal)
  1290.                 {
  1291.                     DrawMaximize(3, 5);
  1292.                 }
  1293.                 else
  1294.                 {
  1295.                     DrawRestore(3, 4);
  1296.                 }
  1297.                 break;
  1298.             case Button.Close:
  1299.                 DrawClose(4, 5);
  1300.                 break;
  1301.         }
  1302.     }
  1303.  
  1304.     private void DrawMinimize(int x, int y)
  1305.     {
  1306.         G.FillRectangle(Brushes.White, x, y, 12, 5);
  1307.         G.DrawRectangle(Pens.Black, x, y, 11, 4);
  1308.     }
  1309.  
  1310.     private void DrawMaximize(int x, int y)
  1311.     {
  1312.         G.DrawRectangle(new Pen(Color.White, 2), x + 2, y + 2, 8, 6);
  1313.         G.DrawRectangle(Pens.Black, x, y, 11, 9);
  1314.         G.DrawRectangle(Pens.Black, x + 3, y + 3, 5, 3);
  1315.     }
  1316.  
  1317.     private void DrawRestore(int x, int y)
  1318.     {
  1319.         G.FillRectangle(Brushes.White, x + 3, y + 1, 8, 4);
  1320.         G.FillRectangle(Brushes.White, x + 7, y + 5, 4, 4);
  1321.         G.DrawRectangle(Pens.Black, x + 2, y + 0, 9, 9);
  1322.  
  1323.         G.FillRectangle(Brushes.White, x + 1, y + 3, 2, 6);
  1324.         G.FillRectangle(Brushes.White, x + 1, y + 9, 8, 2);
  1325.         G.DrawRectangle(Pens.Black, x, y + 2, 9, 9);
  1326.         G.DrawRectangle(Pens.Black, x + 3, y + 5, 3, 3);
  1327.     }
  1328.  
  1329.     private GraphicsPath ClosePath;
  1330.     private void DrawClose(int x, int y)
  1331.     {
  1332.         if (ClosePath == null)
  1333.         {
  1334.             ClosePath = new GraphicsPath();
  1335.             ClosePath.AddLine(x + 1, y, x + 3, y);
  1336.             ClosePath.AddLine(x + 5, y + 2, x + 7, y);
  1337.             ClosePath.AddLine(x + 9, y, x + 10, y + 1);
  1338.             ClosePath.AddLine(x + 7, y + 4, x + 7, y + 5);
  1339.             ClosePath.AddLine(x + 10, y + 8, x + 9, y + 9);
  1340.             ClosePath.AddLine(x + 7, y + 9, x + 5, y + 7);
  1341.             ClosePath.AddLine(x + 3, y + 9, x + 1, y + 9);
  1342.             ClosePath.AddLine(x + 0, y + 8, x + 3, y + 5);
  1343.             ClosePath.AddLine(x + 3, y + 4, x + 0, y + 1);
  1344.         }
  1345.  
  1346.         G.FillPath(Brushes.White, ClosePath);
  1347.         G.DrawPath(Pens.Black, ClosePath);
  1348.     }
  1349.  
  1350.     protected override void OnMouseClick(MouseEventArgs e)
  1351.     {
  1352.  
  1353.         if (e.Button == System.Windows.Forms.MouseButtons.Left)
  1354.         {
  1355.             Form F = FindForm();
  1356.  
  1357.             switch (_ControlButton)
  1358.             {
  1359.                 case Button.Minimize:
  1360.                     F.WindowState = FormWindowState.Minimized;
  1361.                     break;
  1362.                 case Button.MaximizeRestore:
  1363.                     if (F.WindowState == FormWindowState.Normal)
  1364.                     {
  1365.                         F.WindowState = FormWindowState.Maximized;
  1366.                     }
  1367.                     else
  1368.                     {
  1369.                         F.WindowState = FormWindowState.Normal;
  1370.                     }
  1371.                     break;
  1372.                 case Button.Close:
  1373.                     F.Close();
  1374.                     break;
  1375.             }
  1376.  
  1377.         }
  1378.  
  1379.         Invalidate();
  1380.         base.OnMouseClick(e);
  1381.     }
  1382.  
  1383. }
  1384.  
  1385. class NSGroupBox : ContainerControl
  1386. {
  1387.  
  1388.     private bool _DrawSeperator;
  1389.     public bool DrawSeperator
  1390.     {
  1391.         get { return _DrawSeperator; }
  1392.         set
  1393.         {
  1394.             _DrawSeperator = value;
  1395.             Invalidate();
  1396.         }
  1397.     }
  1398.  
  1399.     private string _Title = "GroupBox";
  1400.     public string Title
  1401.     {
  1402.         get { return _Title; }
  1403.         set
  1404.         {
  1405.             _Title = value;
  1406.             Invalidate();
  1407.         }
  1408.     }
  1409.  
  1410.     private string _SubTitle = "Details";
  1411.     public string SubTitle
  1412.     {
  1413.         get { return _SubTitle; }
  1414.         set
  1415.         {
  1416.             _SubTitle = value;
  1417.             Invalidate();
  1418.         }
  1419.     }
  1420.  
  1421.     private Font _TitleFont;
  1422.  
  1423.     private Font _SubTitleFont;
  1424.     public NSGroupBox()
  1425.     {
  1426.         SetStyle((ControlStyles)139286, true);
  1427.         SetStyle(ControlStyles.Selectable, false);
  1428.  
  1429.         _TitleFont = new Font("Verdana", 10f);
  1430.         _SubTitleFont = new Font("Verdana", 6.5f);
  1431.  
  1432.         P1 = new Pen(Color.FromArgb(35, 35, 35));
  1433.         P2 = new Pen(Color.FromArgb(55, 55, 55));
  1434.  
  1435.         B1 = new SolidBrush(Color.FromArgb(205, 150, 0));
  1436.     }
  1437.  
  1438.     private GraphicsPath GP1;
  1439.  
  1440.     private GraphicsPath GP2;
  1441.     private PointF PT1;
  1442.     private SizeF SZ1;
  1443.  
  1444.     private SizeF SZ2;
  1445.     private Pen P1;
  1446.     private Pen P2;
  1447.  
  1448.     private SolidBrush B1;
  1449.     private Graphics G;
  1450.  
  1451.     protected override void OnPaint(PaintEventArgs e)
  1452.     {
  1453.         G = e.Graphics;
  1454.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
  1455.  
  1456.         G.Clear(BackColor);
  1457.         G.SmoothingMode = SmoothingMode.AntiAlias;
  1458.  
  1459.         GP1 = ThemeModule.CreateRound(0, 0, Width - 1, Height - 1, 7);
  1460.         GP2 = ThemeModule.CreateRound(1, 1, Width - 3, Height - 3, 7);
  1461.  
  1462.         G.DrawPath(P1, GP1);
  1463.         G.DrawPath(P2, GP2);
  1464.  
  1465.         SZ1 = G.MeasureString(_Title, _TitleFont, Width, StringFormat.GenericTypographic);
  1466.         SZ2 = G.MeasureString(_SubTitle, _SubTitleFont, Width, StringFormat.GenericTypographic);
  1467.  
  1468.         G.DrawString(_Title, _TitleFont, Brushes.Black, 6, 6);
  1469.         G.DrawString(_Title, _TitleFont, B1, 5, 5);
  1470.  
  1471.         PT1 = new PointF(6f, SZ1.Height + 4f);
  1472.  
  1473.         G.DrawString(_SubTitle, _SubTitleFont, Brushes.Black, PT1.X + 1, PT1.Y + 1);
  1474.         G.DrawString(_SubTitle, _SubTitleFont, Brushes.White, PT1.X, PT1.Y);
  1475.  
  1476.         if (_DrawSeperator)
  1477.         {
  1478.             int Y = Convert.ToInt32(PT1.Y + SZ2.Height) + 8;
  1479.  
  1480.             G.DrawLine(P1, 4, Y, Width - 5, Y);
  1481.             G.DrawLine(P2, 4, Y + 1, Width - 5, Y + 1);
  1482.         }
  1483.     }
  1484.  
  1485. }
  1486.  
  1487. class NSSeperator : Control
  1488. {
  1489.  
  1490.     public NSSeperator()
  1491.     {
  1492.         SetStyle((ControlStyles)139286, true);
  1493.         SetStyle(ControlStyles.Selectable, false);
  1494.  
  1495.         Height = 10;
  1496.  
  1497.         P1 = new Pen(Color.FromArgb(35, 35, 35));
  1498.         P2 = new Pen(Color.FromArgb(55, 55, 55));
  1499.     }
  1500.  
  1501.     private Pen P1;
  1502.  
  1503.     private Pen P2;
  1504.     private Graphics G;
  1505.  
  1506.     protected override void OnPaint(PaintEventArgs e)
  1507.     {
  1508.         G = e.Graphics;
  1509.         G.Clear(BackColor);
  1510.  
  1511.         G.DrawLine(P1, 0, 5, Width, 5);
  1512.         G.DrawLine(P2, 0, 6, Width, 6);
  1513.     }
  1514.  
  1515. }
  1516.  
  1517. [DefaultEvent("Scroll")]
  1518. class NSTrackBar : Control
  1519. {
  1520.  
  1521.     public event ScrollEventHandler Scroll;
  1522.     public delegate void ScrollEventHandler(object sender);
  1523.  
  1524.     private int _Minimum;
  1525.     public int Minimum
  1526.     {
  1527.         get { return _Minimum; }
  1528.         set
  1529.         {
  1530.             if (value < 0)
  1531.             {
  1532.                 throw new Exception("Property value is not valid.");
  1533.             }
  1534.  
  1535.             _Minimum = value;
  1536.             if (value > _Value)
  1537.                 _Value = value;
  1538.             if (value > _Maximum)
  1539.                 _Maximum = value;
  1540.             Invalidate();
  1541.         }
  1542.     }
  1543.  
  1544.     private int _Maximum = 10;
  1545.     public int Maximum
  1546.     {
  1547.         get { return _Maximum; }
  1548.         set
  1549.         {
  1550.             if (value < 0)
  1551.             {
  1552.                 throw new Exception("Property value is not valid.");
  1553.             }
  1554.  
  1555.             _Maximum = value;
  1556.             if (value < _Value)
  1557.                 _Value = value;
  1558.             if (value < _Minimum)
  1559.                 _Minimum = value;
  1560.             Invalidate();
  1561.         }
  1562.     }
  1563.  
  1564.     private int _Value;
  1565.     public int Value
  1566.     {
  1567.         get { return _Value; }
  1568.         set
  1569.         {
  1570.             if (value == _Value)
  1571.                 return;
  1572.  
  1573.             if (value > _Maximum || value < _Minimum)
  1574.             {
  1575.                 throw new Exception("Property value is not valid.");
  1576.             }
  1577.  
  1578.             _Value = value;
  1579.             Invalidate();
  1580.  
  1581.             if (Scroll != null)
  1582.             {
  1583.                 Scroll(this);
  1584.             }
  1585.         }
  1586.     }
  1587.  
  1588.     public NSTrackBar()
  1589.     {
  1590.         SetStyle((ControlStyles)139286, true);
  1591.         SetStyle(ControlStyles.Selectable, false);
  1592.  
  1593.         Height = 17;
  1594.  
  1595.         P1 = new Pen(Color.FromArgb(150, 110, 0), 2);
  1596.         P2 = new Pen(Color.FromArgb(55, 55, 55));
  1597.         P3 = new Pen(Color.FromArgb(35, 35, 35));
  1598.         P4 = new Pen(Color.FromArgb(65, 65, 65));
  1599.     }
  1600.  
  1601.     private GraphicsPath GP1;
  1602.     private GraphicsPath GP2;
  1603.     private GraphicsPath GP3;
  1604.  
  1605.     private GraphicsPath GP4;
  1606.     private Rectangle R1;
  1607.     private Rectangle R2;
  1608.     private Rectangle R3;
  1609.  
  1610.     private int I1;
  1611.     private Pen P1;
  1612.     private Pen P2;
  1613.     private Pen P3;
  1614.  
  1615.     private Pen P4;
  1616.     private LinearGradientBrush GB1;
  1617.     private LinearGradientBrush GB2;
  1618.  
  1619.     private LinearGradientBrush GB3;
  1620.     private Graphics G;
  1621.  
  1622.     protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
  1623.     {
  1624.         G = e.Graphics;
  1625.  
  1626.         G.Clear(BackColor);
  1627.         G.SmoothingMode = SmoothingMode.AntiAlias;
  1628.  
  1629.         GP1 = ThemeModule.CreateRound(0, 5, Width - 1, 10, 5);
  1630.         GP2 = ThemeModule.CreateRound(1, 6, Width - 3, 8, 5);
  1631.  
  1632.         R1 = new Rectangle(0, 7, Width - 1, 5);
  1633.         GB1 = new LinearGradientBrush(R1, Color.FromArgb(45, 45, 45), Color.FromArgb(50, 50, 50), 90f);
  1634.  
  1635.         I1 = Convert.ToInt32((double)(_Value - _Minimum) / (double)(_Maximum - _Minimum) * (Width - 11));
  1636.         R2 = new Rectangle(I1, 0, 10, 20);
  1637.  
  1638.         G.SetClip(GP2);
  1639.         G.FillRectangle(GB1, R1);
  1640.  
  1641.         R3 = new Rectangle(1, 7, R2.X + R2.Width - 2, 8);
  1642.         GB2 = new LinearGradientBrush(R3, Color.FromArgb(205, 150, 0), Color.FromArgb(150, 110, 0), 90f);
  1643.  
  1644.         G.SmoothingMode = SmoothingMode.None;
  1645.         G.FillRectangle(GB2, R3);
  1646.         G.SmoothingMode = SmoothingMode.AntiAlias;
  1647.  
  1648.         for (int I = 0; I <= R3.Width - 15; I += 5)
  1649.         {
  1650.             G.DrawLine(P1, I, 0, I + 15, Height);
  1651.         }
  1652.  
  1653.         G.ResetClip();
  1654.  
  1655.         G.DrawPath(P2, GP1);
  1656.         G.DrawPath(P3, GP2);
  1657.  
  1658.         GP3 = ThemeModule.CreateRound(R2, 5);
  1659.         GP4 = ThemeModule.CreateRound(R2.X + 1, R2.Y + 1, R2.Width - 2, R2.Height - 2, 5);
  1660.         GB3 = new LinearGradientBrush(ClientRectangle, Color.FromArgb(60, 60, 60), Color.FromArgb(55, 55, 55), 90f);
  1661.  
  1662.         G.FillPath(GB3, GP3);
  1663.         G.DrawPath(P3, GP3);
  1664.         G.DrawPath(P4, GP4);
  1665.     }
  1666.  
  1667.     private bool TrackDown;
  1668.     protected override void OnMouseDown(MouseEventArgs e)
  1669.     {
  1670.         if (e.Button == System.Windows.Forms.MouseButtons.Left)
  1671.         {
  1672.             I1 = Convert.ToInt32((double)(_Value - _Minimum) / (double)(_Maximum - _Minimum) * (Width - 11));
  1673.             R2 = new Rectangle(I1, 0, 10, 20);
  1674.  
  1675.             TrackDown = R2.Contains(e.Location);
  1676.         }
  1677.  
  1678.         base.OnMouseDown(e);
  1679.     }
  1680.  
  1681.     protected override void OnMouseMove(MouseEventArgs e)
  1682.     {
  1683.         if (TrackDown && e.X > -1 && e.X < (Width + 1))
  1684.         {
  1685.             Value = _Minimum + Convert.ToInt32((_Maximum - _Minimum) * ((double)e.X / (double)Width));
  1686.         }
  1687.  
  1688.         base.OnMouseMove(e);
  1689.     }
  1690.  
  1691.     protected override void OnMouseUp(MouseEventArgs e)
  1692.     {
  1693.         TrackDown = false;
  1694.         base.OnMouseUp(e);
  1695.     }
  1696.  
  1697. }
  1698.  
  1699. [DefaultEvent("ValueChanged")]
  1700. class NSRandomPool : Control
  1701. {
  1702.  
  1703.     public event ValueChangedEventHandler ValueChanged;
  1704.     public delegate void ValueChangedEventHandler(object sender);
  1705.  
  1706.     private StringBuilder _Value = new StringBuilder();
  1707.     public string Value
  1708.     {
  1709.         get { return _Value.ToString(); }
  1710.     }
  1711.  
  1712.     public string FullValue
  1713.     {
  1714.         get { return BitConverter.ToString(Table).Replace("-", ""); }
  1715.     }
  1716.  
  1717.  
  1718.     private Random RNG = new Random();
  1719.     private int ItemSize = 9;
  1720.  
  1721.     private int DrawSize = 8;
  1722.  
  1723.     private Rectangle WA;
  1724.     private int RowSize;
  1725.  
  1726.     private int ColumnSize;
  1727.     public NSRandomPool()
  1728.     {
  1729.         SetStyle((ControlStyles)139286, true);
  1730.         SetStyle(ControlStyles.Selectable, false);
  1731.  
  1732.         P1 = new Pen(Color.FromArgb(55, 55, 55));
  1733.         P2 = new Pen(Color.FromArgb(35, 35, 35));
  1734.  
  1735.         B1 = new SolidBrush(Color.FromArgb(30, 30, 30));
  1736.     }
  1737.  
  1738.     protected override void OnHandleCreated(EventArgs e)
  1739.     {
  1740.         UpdateTable();
  1741.         base.OnHandleCreated(e);
  1742.     }
  1743.  
  1744.     private byte[] Table;
  1745.     private void UpdateTable()
  1746.     {
  1747.         WA = new Rectangle(5, 5, Width - 10, Height - 10);
  1748.  
  1749.         RowSize = WA.Width / ItemSize;
  1750.         ColumnSize = WA.Height / ItemSize;
  1751.  
  1752.         WA.Width = RowSize * ItemSize;
  1753.         WA.Height = ColumnSize * ItemSize;
  1754.  
  1755.         WA.X = (Width / 2) - (WA.Width / 2);
  1756.         WA.Y = (Height / 2) - (WA.Height / 2);
  1757.  
  1758.         Table = new byte[(RowSize * ColumnSize)];
  1759.  
  1760.         for (int I = 0; I <= Table.Length - 1; I++)
  1761.         {
  1762.             Table[I] = Convert.ToByte(RNG.Next(100));
  1763.         }
  1764.  
  1765.         Invalidate();
  1766.     }
  1767.  
  1768.     protected override void OnSizeChanged(EventArgs e)
  1769.     {
  1770.         UpdateTable();
  1771.     }
  1772.  
  1773.     private int Index1 = -1;
  1774.  
  1775.     private int Index2;
  1776.  
  1777.     private bool InvertColors;
  1778.     protected override void OnMouseMove(MouseEventArgs e)
  1779.     {
  1780.         HandleDraw(e);
  1781.     }
  1782.  
  1783.     protected override void OnMouseDown(MouseEventArgs e)
  1784.     {
  1785.         HandleDraw(e);
  1786.         base.OnMouseDown(e);
  1787.     }
  1788.  
  1789.     private void HandleDraw(MouseEventArgs e)
  1790.     {
  1791.         if (e.Button == System.Windows.Forms.MouseButtons.Left || e.Button == System.Windows.Forms.MouseButtons.Right)
  1792.         {
  1793.             if (!WA.Contains(e.Location))
  1794.                 return;
  1795.  
  1796.             InvertColors = (e.Button == System.Windows.Forms.MouseButtons.Right);
  1797.  
  1798.             Index1 = GetIndex(e.X, e.Y);
  1799.             if (Index1 == Index2)
  1800.                 return;
  1801.  
  1802.             bool L = !(Index1 % RowSize == 0);
  1803.             bool R = !(Index1 % RowSize == (RowSize - 1));
  1804.  
  1805.             Randomize(Index1 - RowSize);
  1806.             if (L)
  1807.                 Randomize(Index1 - 1);
  1808.             Randomize(Index1);
  1809.             if (R)
  1810.                 Randomize(Index1 + 1);
  1811.             Randomize(Index1 + RowSize);
  1812.  
  1813.             _Value.Append(Table[Index1].ToString("X"));
  1814.             if (_Value.Length > 32)
  1815.                 _Value.Remove(0, 2);
  1816.  
  1817.             if (ValueChanged != null)
  1818.             {
  1819.                 ValueChanged(this);
  1820.             }
  1821.  
  1822.             Index2 = Index1;
  1823.             Invalidate();
  1824.         }
  1825.     }
  1826.  
  1827.     private GraphicsPath GP1;
  1828.  
  1829.     private GraphicsPath GP2;
  1830.     private Pen P1;
  1831.     private Pen P2;
  1832.     private SolidBrush B1;
  1833.  
  1834.     private SolidBrush B2;
  1835.  
  1836.     private PathGradientBrush PB1;
  1837.     private Graphics G;
  1838.  
  1839.     protected override void OnPaint(PaintEventArgs e)
  1840.     {
  1841.         G = e.Graphics;
  1842.  
  1843.         G.Clear(BackColor);
  1844.         G.SmoothingMode = SmoothingMode.AntiAlias;
  1845.  
  1846.         GP1 = ThemeModule.CreateRound(0, 0, Width - 1, Height - 1, 7);
  1847.         GP2 = ThemeModule.CreateRound(1, 1, Width - 3, Height - 3, 7);
  1848.  
  1849.         PB1 = new PathGradientBrush(GP1);
  1850.         PB1.CenterColor = Color.FromArgb(50, 50, 50);
  1851.         PB1.SurroundColors = new Color[]{ Color.FromArgb(45, 45, 45) };
  1852.         PB1.FocusScales = new PointF(0.9f, 0.5f);
  1853.  
  1854.         G.FillPath(PB1, GP1);
  1855.  
  1856.         G.DrawPath(P1, GP1);
  1857.         G.DrawPath(P2, GP2);
  1858.  
  1859.         G.SmoothingMode = SmoothingMode.None;
  1860.  
  1861.         for (int I = 0; I <= Table.Length - 1; I++) {
  1862.             int C = Math.Max(Table[I], (byte)75);
  1863.  
  1864.             int X = ((I % RowSize) * ItemSize) + WA.X;
  1865.             int Y = ((I / RowSize) * ItemSize) + WA.Y;
  1866.  
  1867.             B2 = new SolidBrush(Color.FromArgb(C, C, C));
  1868.  
  1869.             G.FillRectangle(B1, X + 1, Y + 1, DrawSize, DrawSize);
  1870.             G.FillRectangle(B2, X, Y, DrawSize, DrawSize);
  1871.  
  1872.             B2.Dispose();
  1873.         }
  1874.  
  1875.     }
  1876.  
  1877.     private int GetIndex(int x, int y)
  1878.     {
  1879.         return (((y - WA.Y) / ItemSize) * RowSize) + ((x - WA.X) / ItemSize);
  1880.     }
  1881.  
  1882.     private void Randomize(int index)
  1883.     {
  1884.         if (index > -1 && index < Table.Length)
  1885.         {
  1886.             if (InvertColors)
  1887.             {
  1888.                 Table[index] = Convert.ToByte(RNG.Next(100));
  1889.             }
  1890.             else
  1891.             {
  1892.                 Table[index] = Convert.ToByte(RNG.Next(100, 256));
  1893.             }
  1894.         }
  1895.     }
  1896.  
  1897. }
  1898.  
  1899. class NSKeyboard : Control
  1900. {
  1901.  
  1902.     private Bitmap TextBitmap;
  1903.  
  1904.     private Graphics TextGraphics;
  1905.     const string LowerKeys = "1234567890-=qwertyuiop[]asdfghjkl\\;'zxcvbnm,./`";
  1906.  
  1907.     const string UpperKeys = "!@#$%^&*()_+QWERTYUIOP{}ASDFGHJKL|:\"ZXCVBNM<>?~";
  1908.     public NSKeyboard()
  1909.     {
  1910.         SetStyle((ControlStyles)139286, true);
  1911.         SetStyle(ControlStyles.Selectable, false);
  1912.  
  1913.         Font = new Font("Verdana", 8.25f);
  1914.  
  1915.         TextBitmap = new Bitmap(1, 1);
  1916.         TextGraphics = Graphics.FromImage(TextBitmap);
  1917.  
  1918.         MinimumSize = new Size(386, 162);
  1919.         MaximumSize = new Size(386, 162);
  1920.  
  1921.         Lower = LowerKeys.ToCharArray();
  1922.         Upper = UpperKeys.ToCharArray();
  1923.  
  1924.         PrepareCache();
  1925.  
  1926.         P1 = new Pen(Color.FromArgb(45, 45, 45));
  1927.         P2 = new Pen(Color.FromArgb(65, 65, 65));
  1928.         P3 = new Pen(Color.FromArgb(35, 35, 35));
  1929.  
  1930.         B1 = new SolidBrush(Color.FromArgb(100, 100, 100));
  1931.     }
  1932.  
  1933.     private Control _Target;
  1934.     public Control Target
  1935.     {
  1936.         get { return _Target; }
  1937.         set { _Target = value; }
  1938.     }
  1939.  
  1940.  
  1941.     private bool Shift;
  1942.     private int Pressed = -1;
  1943.  
  1944.     private Rectangle[] Buttons;
  1945.     private char[] Lower;
  1946.     private char[] Upper;
  1947.     private string[] Other = {
  1948.         "Shift",
  1949.         "Space",
  1950.         "Back"
  1951.  
  1952.     };
  1953.     private PointF[] UpperCache;
  1954.  
  1955.     private PointF[] LowerCache;
  1956.     private void PrepareCache()
  1957.     {
  1958.         Buttons = new Rectangle[51];
  1959.         UpperCache = new PointF[Upper.Length];
  1960.         LowerCache = new PointF[Lower.Length];
  1961.  
  1962.         int I = 0;
  1963.  
  1964.         SizeF S = default(SizeF);
  1965.         Rectangle R = default(Rectangle);
  1966.  
  1967.         for (int Y = 0; Y <= 3; Y++)
  1968.         {
  1969.             for (int X = 0; X <= 11; X++)
  1970.             {
  1971.                 I = (Y * 12) + X;
  1972.                 R = new Rectangle(X * 32, Y * 32, 32, 32);
  1973.  
  1974.                 Buttons[I] = R;
  1975.  
  1976.                 if (!(I == 47) && !char.IsLetter(Upper[I]))
  1977.                 {
  1978.                     S = TextGraphics.MeasureString(Upper[I].ToString(), Font);
  1979.                     UpperCache[I] = new PointF(R.X + (R.Width / 2 - S.Width / 2), R.Y + R.Height - S.Height - 2);
  1980.  
  1981.                     S = TextGraphics.MeasureString(Lower[I].ToString(), Font);
  1982.                     LowerCache[I] = new PointF(R.X + (R.Width / 2 - S.Width / 2), R.Y + R.Height - S.Height - 2);
  1983.                 }
  1984.             }
  1985.         }
  1986.  
  1987.         Buttons[48] = new Rectangle(0, 4 * 32, 2 * 32, 32);
  1988.         Buttons[49] = new Rectangle(Buttons[48].Right, 4 * 32, 8 * 32, 32);
  1989.         Buttons[50] = new Rectangle(Buttons[49].Right, 4 * 32, 2 * 32, 32);
  1990.     }
  1991.  
  1992.  
  1993.     private GraphicsPath GP1;
  1994.     private SizeF SZ1;
  1995.  
  1996.     private PointF PT1;
  1997.     private Pen P1;
  1998.     private Pen P2;
  1999.     private Pen P3;
  2000.  
  2001.     private SolidBrush B1;
  2002.     private PathGradientBrush PB1;
  2003.  
  2004.     private LinearGradientBrush GB1;
  2005.     private Graphics G;
  2006.     protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
  2007.     {
  2008.         G = e.Graphics;
  2009.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
  2010.  
  2011.         G.Clear(BackColor);
  2012.  
  2013.         Rectangle R = default(Rectangle);
  2014.  
  2015.         int Offset = 0;
  2016.         G.DrawRectangle(P1, 0, 0, (12 * 32) + 1, (5 * 32) + 1);
  2017.  
  2018.         for (int I = 0; I <= Buttons.Length - 1; I++) {
  2019.             R = Buttons[I];
  2020.  
  2021.             Offset = 0;
  2022.             if (I == Pressed) {
  2023.                 Offset = 1;
  2024.  
  2025.                 GP1 = new GraphicsPath();
  2026.                 GP1.AddRectangle(R);
  2027.  
  2028.                 PB1 = new PathGradientBrush(GP1);
  2029.                 PB1.CenterColor = Color.FromArgb(60, 60, 60);
  2030.                 PB1.SurroundColors = new Color[]{ Color.FromArgb(55, 55, 55) };
  2031.                 PB1.FocusScales = new PointF(0.8f, 0.5f);
  2032.  
  2033.                 G.FillPath(PB1, GP1);
  2034.             } else {
  2035.                 GB1 = new LinearGradientBrush(R, Color.FromArgb(60, 60, 60), Color.FromArgb(55, 55, 55), 90f);
  2036.                 G.FillRectangle(GB1, R);
  2037.             }
  2038.  
  2039.             switch (I) {
  2040.                 case 48:
  2041.                 case 49:
  2042.                 case 50:
  2043.                     SZ1 = G.MeasureString(Other[I - 48], Font);
  2044.                     G.DrawString(Other[I - 48], Font, Brushes.Black, R.X + (R.Width / 2 - SZ1.Width / 2) + Offset + 1, R.Y + (R.Height / 2 - SZ1.Height / 2) + Offset + 1);
  2045.                     G.DrawString(Other[I - 48], Font, Brushes.White, R.X + (R.Width / 2 - SZ1.Width / 2) + Offset, R.Y + (R.Height / 2 - SZ1.Height / 2) + Offset);
  2046.                     break;
  2047.                 case 47:
  2048.                     DrawArrow(Color.Black, R.X + Offset + 1, R.Y + Offset + 1);
  2049.                     DrawArrow(Color.White, R.X + Offset, R.Y + Offset);
  2050.                     break;
  2051.                 default:
  2052.                     if (Shift) {
  2053.                         G.DrawString(Upper[I].ToString(), Font, Brushes.Black, R.X + 3 + Offset + 1, R.Y + 2 + Offset + 1);
  2054.                         G.DrawString(Upper[I].ToString(), Font, Brushes.White, R.X + 3 + Offset, R.Y + 2 + Offset);
  2055.  
  2056.                         if (!char.IsLetter(Lower[I])) {
  2057.                             PT1 = LowerCache[I];
  2058.                             G.DrawString(Lower[I].ToString(), Font, B1, PT1.X + Offset, PT1.Y + Offset);
  2059.                         }
  2060.                     } else {
  2061.                         G.DrawString(Lower[I].ToString(), Font, Brushes.Black, R.X + 3 + Offset + 1, R.Y + 2 + Offset + 1);
  2062.                         G.DrawString(Lower[I].ToString(), Font, Brushes.White, R.X + 3 + Offset, R.Y + 2 + Offset);
  2063.  
  2064.                         if (!char.IsLetter(Upper[I])) {
  2065.                             PT1 = UpperCache[I];
  2066.                             G.DrawString(Upper[I].ToString(), Font, B1, PT1.X + Offset, PT1.Y + Offset);
  2067.                         }
  2068.                     }
  2069.                     break;
  2070.             }
  2071.  
  2072.             G.DrawRectangle(P2, R.X + 1 + Offset, R.Y + 1 + Offset, R.Width - 2, R.Height - 2);
  2073.             G.DrawRectangle(P3, R.X + Offset, R.Y + Offset, R.Width, R.Height);
  2074.  
  2075.             if (I == Pressed) {
  2076.                 G.DrawLine(P1, R.X, R.Y, R.Right, R.Y);
  2077.                 G.DrawLine(P1, R.X, R.Y, R.X, R.Bottom);
  2078.             }
  2079.         }
  2080.     }
  2081.  
  2082.     private void DrawArrow(Color color, int rx, int ry)
  2083.     {
  2084.         Rectangle R = new Rectangle(rx + 8, ry + 8, 16, 16);
  2085.         G.SmoothingMode = SmoothingMode.AntiAlias;
  2086.  
  2087.         Pen P = new Pen(color, 1);
  2088.         AdjustableArrowCap C = new AdjustableArrowCap(3, 2);
  2089.         P.CustomEndCap = C;
  2090.  
  2091.         G.DrawArc(P, R, 0f, 290f);
  2092.  
  2093.         P.Dispose();
  2094.         C.Dispose();
  2095.         G.SmoothingMode = SmoothingMode.None;
  2096.     }
  2097.  
  2098.     protected override void OnMouseDown(MouseEventArgs e)
  2099.     {
  2100.         int Index = ((e.Y / 32) * 12) + (e.X / 32);
  2101.  
  2102.         if (Index > 47)
  2103.         {
  2104.             for (int I = 48; I <= Buttons.Length - 1; I++)
  2105.             {
  2106.                 if (Buttons[I].Contains(e.X, e.Y))
  2107.                 {
  2108.                     Pressed = I;
  2109.                     break; // TODO: might not be correct. Was : Exit For
  2110.                 }
  2111.             }
  2112.         }
  2113.         else
  2114.         {
  2115.             Pressed = Index;
  2116.         }
  2117.  
  2118.         HandleKey();
  2119.         Invalidate();
  2120.     }
  2121.  
  2122.     protected override void OnMouseUp(MouseEventArgs e)
  2123.     {
  2124.         Pressed = -1;
  2125.         Invalidate();
  2126.     }
  2127.  
  2128.     private void HandleKey()
  2129.     {
  2130.         if (_Target == null)
  2131.             return;
  2132.         if (Pressed == -1)
  2133.             return;
  2134.  
  2135.         switch (Pressed)
  2136.         {
  2137.             case 47:
  2138.                 _Target.Text = string.Empty;
  2139.                 break;
  2140.             case 48:
  2141.                 Shift = !Shift;
  2142.                 break;
  2143.             case 49:
  2144.                 _Target.Text += " ";
  2145.                 break;
  2146.             case 50:
  2147.                 if (!(_Target.Text.Length == 0))
  2148.                 {
  2149.                     _Target.Text = _Target.Text.Remove(_Target.Text.Length - 1);
  2150.                 }
  2151.                 break;
  2152.             default:
  2153.                 if (Shift)
  2154.                 {
  2155.                     _Target.Text += Upper[Pressed];
  2156.                 }
  2157.                 else
  2158.                 {
  2159.                     _Target.Text += Lower[Pressed];
  2160.                 }
  2161.                 break;
  2162.         }
  2163.     }
  2164.  
  2165. }
  2166.  
  2167. [DefaultEvent("SelectedIndexChanged")]
  2168. class NSPaginator : Control
  2169. {
  2170.  
  2171.     public event SelectedIndexChangedEventHandler SelectedIndexChanged;
  2172.     public delegate void SelectedIndexChangedEventHandler(object sender, EventArgs e);
  2173.  
  2174.     private Bitmap TextBitmap;
  2175.  
  2176.     private Graphics TextGraphics;
  2177.     public NSPaginator()
  2178.     {
  2179.         SetStyle((ControlStyles)139286, true);
  2180.         SetStyle(ControlStyles.Selectable, false);
  2181.  
  2182.         Size = new Size(202, 26);
  2183.  
  2184.         TextBitmap = new Bitmap(1, 1);
  2185.         TextGraphics = Graphics.FromImage(TextBitmap);
  2186.  
  2187.         InvalidateItems();
  2188.  
  2189.         B1 = new SolidBrush(Color.FromArgb(50, 50, 50));
  2190.         B2 = new SolidBrush(Color.FromArgb(55, 55, 55));
  2191.  
  2192.         P1 = new Pen(Color.FromArgb(35, 35, 35));
  2193.         P2 = new Pen(Color.FromArgb(55, 55, 55));
  2194.         P3 = new Pen(Color.FromArgb(65, 65, 65));
  2195.     }
  2196.  
  2197.     private int _SelectedIndex;
  2198.     public int SelectedIndex
  2199.     {
  2200.         get { return _SelectedIndex; }
  2201.         set
  2202.         {
  2203.             _SelectedIndex = Math.Max(Math.Min(value, MaximumIndex), 0);
  2204.             Invalidate();
  2205.         }
  2206.     }
  2207.  
  2208.     private int _NumberOfPages;
  2209.     public int NumberOfPages
  2210.     {
  2211.         get { return _NumberOfPages; }
  2212.         set
  2213.         {
  2214.             _NumberOfPages = value;
  2215.             _SelectedIndex = Math.Max(Math.Min(_SelectedIndex, MaximumIndex), 0);
  2216.             Invalidate();
  2217.         }
  2218.     }
  2219.  
  2220.     public int MaximumIndex
  2221.     {
  2222.         get { return NumberOfPages - 1; }
  2223.     }
  2224.  
  2225.  
  2226.     private int ItemWidth;
  2227.     public override Font Font
  2228.     {
  2229.         get { return base.Font; }
  2230.         set
  2231.         {
  2232.             base.Font = value;
  2233.  
  2234.             InvalidateItems();
  2235.             Invalidate();
  2236.         }
  2237.     }
  2238.  
  2239.     private void InvalidateItems()
  2240.     {
  2241.         Size S = TextGraphics.MeasureString("000 ..", Font).ToSize();
  2242.         ItemWidth = S.Width + 10;
  2243.     }
  2244.  
  2245.     private GraphicsPath GP1;
  2246.  
  2247.     private GraphicsPath GP2;
  2248.  
  2249.     private Rectangle R1;
  2250.     private Size SZ1;
  2251.  
  2252.     private Point PT1;
  2253.     private Pen P1;
  2254.     private Pen P2;
  2255.     private Pen P3;
  2256.     private SolidBrush B1;
  2257.  
  2258.     private SolidBrush B2;
  2259.     private Graphics G;
  2260.     protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
  2261.     {
  2262.         G = e.Graphics;
  2263.         G.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
  2264.  
  2265.         G.Clear(BackColor);
  2266.         G.SmoothingMode = SmoothingMode.AntiAlias;
  2267.  
  2268.         bool LeftEllipse = false;
  2269.         bool RightEllipse = false;
  2270.  
  2271.         if (_SelectedIndex < 4)
  2272.         {
  2273.             for (int I = 0; I <= Math.Min(MaximumIndex, 4); I++)
  2274.             {
  2275.                 RightEllipse = (I == 4) && (MaximumIndex > 4);
  2276.                 DrawBox(I * ItemWidth, I, false, RightEllipse);
  2277.             }
  2278.         }
  2279.         else if (_SelectedIndex > 3 && _SelectedIndex < (MaximumIndex - 3))
  2280.         {
  2281.             for (int I = 0; I <= 4; I++)
  2282.             {
  2283.                 LeftEllipse = (I == 0);
  2284.                 RightEllipse = (I == 4);
  2285.                 DrawBox(I * ItemWidth, _SelectedIndex + I - 2, LeftEllipse, RightEllipse);
  2286.             }
  2287.         }
  2288.         else
  2289.         {
  2290.             for (int I = 0; I <= 4; I++)
  2291.             {
  2292.                 LeftEllipse = (I == 0) && (MaximumIndex > 4);
  2293.                 DrawBox(I * ItemWidth, MaximumIndex - (4 - I), LeftEllipse, false);
  2294.             }
  2295.         }
  2296.     }
  2297.  
  2298.     private void DrawBox(int x, int index, bool leftEllipse, bool rightEllipse)
  2299.     {
  2300.         R1 = new Rectangle(x, 0, ItemWidth - 4, Height - 1);
  2301.  
  2302.         GP1 = ThemeModule.CreateRound(R1, 7);
  2303.         GP2 = ThemeModule.CreateRound(R1.X + 1, R1.Y + 1, R1.Width - 2, R1.Height - 2, 7);
  2304.  
  2305.         string T = Convert.ToString(index + 1);
  2306.  
  2307.         if (leftEllipse)
  2308.             T = ".. " + T;
  2309.         if (rightEllipse)
  2310.             T = T + " ..";
  2311.  
  2312.         SZ1 = G.MeasureString(T, Font).ToSize();
  2313.         PT1 = new Point(R1.X + (R1.Width / 2 - SZ1.Width / 2), R1.Y + (R1.Height / 2 - SZ1.Height / 2));
  2314.  
  2315.         if (index == _SelectedIndex)
  2316.         {
  2317.             G.FillPath(B1, GP1);
  2318.  
  2319.             Font F = new Font(Font, FontStyle.Underline);
  2320.             G.DrawString(T, F, Brushes.Black, PT1.X + 1, PT1.Y + 1);
  2321.             G.DrawString(T, F, Brushes.White, PT1);
  2322.             F.Dispose();
  2323.  
  2324.             G.DrawPath(P1, GP2);
  2325.             G.DrawPath(P2, GP1);
  2326.         }
  2327.         else
  2328.         {
  2329.             G.FillPath(B2, GP1);
  2330.  
  2331.             G.DrawString(T, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1);
  2332.             G.DrawString(T, Font, Brushes.White, PT1);
  2333.  
  2334.             G.DrawPath(P3, GP2);
  2335.             G.DrawPath(P1, GP1);
  2336.         }
  2337.     }
  2338.  
  2339.     protected override void OnMouseDown(MouseEventArgs e)
  2340.     {
  2341.         if (e.Button == System.Windows.Forms.MouseButtons.Left)
  2342.         {
  2343.             int NewIndex = 0;
  2344.             int OldIndex = _SelectedIndex;
  2345.  
  2346.             if (_SelectedIndex < 4)
  2347.             {
  2348.                 NewIndex = (e.X / ItemWidth);
  2349.             }
  2350.             else if (_SelectedIndex > 3 && _SelectedIndex < (MaximumIndex - 3))
  2351.             {
  2352.                 NewIndex = (e.X / ItemWidth);
  2353.  
  2354.                 if (NewIndex == 2)
  2355.                 {
  2356.                     NewIndex = OldIndex;
  2357.                 }
  2358.                 else if (NewIndex < 2)
  2359.                 {
  2360.                     NewIndex = OldIndex - (2 - NewIndex);
  2361.                 }
  2362.                 else if (NewIndex > 2)
  2363.                 {
  2364.                     NewIndex = OldIndex + (NewIndex - 2);
  2365.                 }
  2366.             }
  2367.             else
  2368.             {
  2369.                 NewIndex = MaximumIndex - (4 - (e.X / ItemWidth));
  2370.             }
  2371.  
  2372.             if ((NewIndex < _NumberOfPages) && (!(NewIndex == OldIndex)))
  2373.             {
  2374.                 SelectedIndex = NewIndex;
  2375.                 if (SelectedIndexChanged != null)
  2376.                 {
  2377.                     SelectedIndexChanged(this, null);
  2378.                 }
  2379.             }
  2380.         }
  2381.  
  2382.         base.OnMouseDown(e);
  2383.     }
  2384.  
  2385. }
  2386.  
  2387. [DefaultEvent("Scroll")]
  2388. class NSVScrollBar : Control
  2389. {
  2390.  
  2391.     public event ScrollEventHandler Scroll;
  2392.     public delegate void ScrollEventHandler(object sender);
  2393.  
  2394.     private int _Minimum;
  2395.     public int Minimum
  2396.     {
  2397.         get { return _Minimum; }
  2398.         set
  2399.         {
  2400.             if (value < 0)
  2401.             {
  2402.                 throw new Exception("Property value is not valid.");
  2403.             }
  2404.  
  2405.             _Minimum = value;
  2406.             if (value > _Value)
  2407.                 _Value = value;
  2408.             if (value > _Maximum)
  2409.                 _Maximum = value;
  2410.  
  2411.             InvalidateLayout();
  2412.         }
  2413.     }
  2414.  
  2415.     private int _Maximum = 100;
  2416.     public int Maximum
  2417.     {
  2418.         get { return _Maximum; }
  2419.         set
  2420.         {
  2421.             if (value < 1)
  2422.                 value = 1;
  2423.  
  2424.             _Maximum = value;
  2425.             if (value < _Value)
  2426.                 _Value = value;
  2427.             if (value < _Minimum)
  2428.                 _Minimum = value;
  2429.  
  2430.             InvalidateLayout();
  2431.         }
  2432.     }
  2433.  
  2434.     private int _Value;
  2435.     public int Value
  2436.     {
  2437.         get
  2438.         {
  2439.             if (!ShowThumb)
  2440.                 return _Minimum;
  2441.             return _Value;
  2442.         }
  2443.         set
  2444.         {
  2445.             if (value == _Value)
  2446.                 return;
  2447.  
  2448.             if (value > _Maximum || value < _Minimum)
  2449.             {
  2450.                 throw new Exception("Property value is not valid.");
  2451.             }
  2452.  
  2453.             _Value = value;
  2454.             InvalidatePosition();
  2455.  
  2456.             if (Scroll != null)
  2457.             {
  2458.                 Scroll(this);
  2459.             }
  2460.         }
  2461.     }
  2462.  
  2463.     public double _Percent { get; set; }
  2464.     public double Percent
  2465.     {
  2466.         get
  2467.         {
  2468.             if (!ShowThumb)
  2469.                 return 0;
  2470.             return GetProgress();
  2471.         }
  2472.     }
  2473.  
  2474.     private int _SmallChange = 1;
  2475.     public int SmallChange
  2476.     {
  2477.         get { return _SmallChange; }
  2478.         set
  2479.         {
  2480.             if (value < 1)
  2481.             {
  2482.                 throw new Exception("Property value is not valid.");
  2483.             }
  2484.  
  2485.             _SmallChange = value;
  2486.         }
  2487.     }
  2488.  
  2489.     private int _LargeChange = 10;
  2490.     public int LargeChange
  2491.     {
  2492.         get { return _LargeChange; }
  2493.         set
  2494.         {
  2495.             if (value < 1)
  2496.             {
  2497.                 throw new Exception("Property value is not valid.");
  2498.             }
  2499.  
  2500.             _LargeChange = value;
  2501.         }
  2502.     }
  2503.  
  2504.     private int ButtonSize = 16;
  2505.     // 14 minimum
  2506.     private int ThumbSize = 24;
  2507.  
  2508.     private Rectangle TSA;
  2509.     private Rectangle BSA;
  2510.     private Rectangle Shaft;
  2511.  
  2512.     private Rectangle Thumb;
  2513.     private bool ShowThumb;
  2514.  
  2515.     private bool ThumbDown;
  2516.     public NSVScrollBar()
  2517.     {
  2518.         SetStyle((ControlStyles)139286, true);
  2519.         SetStyle(ControlStyles.Selectable, false);
  2520.  
  2521.         Width = 18;
  2522.  
  2523.         B1 = new SolidBrush(Color.FromArgb(55, 55, 55));
  2524.         B2 = new SolidBrush(Color.FromArgb(35, 35, 35));
  2525.  
  2526.         P1 = new Pen(Color.FromArgb(35, 35, 35));
  2527.         P2 = new Pen(Color.FromArgb(65, 65, 65));
  2528.         P3 = new Pen(Color.FromArgb(55, 55, 55));
  2529.         P4 = new Pen(Color.FromArgb(40, 40, 40));
  2530.     }
  2531.  
  2532.     private GraphicsPath GP1;
  2533.     private GraphicsPath GP2;
  2534.     private GraphicsPath GP3;
  2535.  
  2536.     private GraphicsPath GP4;
  2537.     private Pen P1;
  2538.     private Pen P2;
  2539.     private Pen P3;
  2540.     private Pen P4;
  2541.     private SolidBrush B1;
  2542.  
  2543.     private SolidBrush B2;
  2544.  
  2545.     int I1;
  2546.     private Graphics G;
  2547.  
  2548.     protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
  2549.     {
  2550.         G = e.Graphics;
  2551.         G.Clear(BackColor);
  2552.  
  2553.         GP1 = DrawArrow(4, 6, false);
  2554.         GP2 = DrawArrow(5, 7, false);
  2555.  
  2556.         G.FillPath(B1, GP2);
  2557.         G.FillPath(B2, GP1);
  2558.  
  2559.         GP3 = DrawArrow(4, Height - 11, true);
  2560.         GP4 = DrawArrow(5, Height - 10, true);
  2561.  
  2562.         G.FillPath(B1, GP4);
  2563.         G.FillPath(B2, GP3);
  2564.  
  2565.         if (ShowThumb)
  2566.         {
  2567.             G.FillRectangle(B1, Thumb);
  2568.             G.DrawRectangle(P1, Thumb);
  2569.             G.DrawRectangle(P2, Thumb.X + 1, Thumb.Y + 1, Thumb.Width - 2, Thumb.Height - 2);
  2570.  
  2571.             int Y = 0;
  2572.             int LY = Thumb.Y + (Thumb.Height / 2) - 3;
  2573.  
  2574.             for (int I = 0; I <= 2; I++)
  2575.             {
  2576.                 Y = LY + (I * 3);
  2577.  
  2578.                 G.DrawLine(P1, Thumb.X + 5, Y, Thumb.Right - 5, Y);
  2579.                 G.DrawLine(P2, Thumb.X + 5, Y + 1, Thumb.Right - 5, Y + 1);
  2580.             }
  2581.         }
  2582.  
  2583.         G.DrawRectangle(P3, 0, 0, Width - 1, Height - 1);
  2584.         G.DrawRectangle(P4, 1, 1, Width - 3, Height - 3);
  2585.     }
  2586.  
  2587.     private GraphicsPath DrawArrow(int x, int y, bool flip)
  2588.     {
  2589.         GraphicsPath GP = new GraphicsPath();
  2590.  
  2591.         int W = 9;
  2592.         int H = 5;
  2593.  
  2594.         if (flip)
  2595.         {
  2596.             GP.AddLine(x + 1, y, x + W + 1, y);
  2597.             GP.AddLine(x + W, y, x + H, y + H - 1);
  2598.         }
  2599.         else
  2600.         {
  2601.             GP.AddLine(x, y + H, x + W, y + H);
  2602.             GP.AddLine(x + W, y + H, x + H, y);
  2603.         }
  2604.  
  2605.         GP.CloseFigure();
  2606.         return GP;
  2607.     }
  2608.  
  2609.     protected override void OnSizeChanged(EventArgs e)
  2610.     {
  2611.         InvalidateLayout();
  2612.     }
  2613.  
  2614.     private void InvalidateLayout()
  2615.     {
  2616.         TSA = new Rectangle(0, 0, Width, ButtonSize);
  2617.         BSA = new Rectangle(0, Height - ButtonSize, Width, ButtonSize);
  2618.         Shaft = new Rectangle(0, TSA.Bottom + 1, Width, Height - (ButtonSize * 2) - 1);
  2619.  
  2620.         ShowThumb = ((_Maximum - _Minimum) > Shaft.Height);
  2621.  
  2622.         if (ShowThumb)
  2623.         {
  2624.             //ThumbSize = Math.Max(0, 14) 'TODO: Implement this.
  2625.             Thumb = new Rectangle(1, 0, Width - 3, ThumbSize);
  2626.         }
  2627.  
  2628.         if (Scroll != null)
  2629.         {
  2630.             Scroll(this);
  2631.         }
  2632.         InvalidatePosition();
  2633.     }
  2634.  
  2635.     private void InvalidatePosition()
  2636.     {
  2637.         Thumb.Y = Convert.ToInt32(GetProgress() * (Shaft.Height - ThumbSize)) + TSA.Height;
  2638.         Invalidate();
  2639.     }
  2640.  
  2641.     protected override void OnMouseDown(MouseEventArgs e)
  2642.     {
  2643.         if (e.Button == System.Windows.Forms.MouseButtons.Left && ShowThumb)
  2644.         {
  2645.             if (TSA.Contains(e.Location))
  2646.             {
  2647.                 I1 = _Value - _SmallChange;
  2648.             }
  2649.             else if (BSA.Contains(e.Location))
  2650.             {
  2651.                 I1 = _Value + _SmallChange;
  2652.             }
  2653.             else
  2654.             {
  2655.                 if (Thumb.Contains(e.Location))
  2656.                 {
  2657.                     ThumbDown = true;
  2658.                     base.OnMouseDown(e);
  2659.                     return;
  2660.                 }
  2661.                 else
  2662.                 {
  2663.                     if (e.Y < Thumb.Y)
  2664.                     {
  2665.                         I1 = _Value - _LargeChange;
  2666.                     }
  2667.                     else
  2668.                     {
  2669.                         I1 = _Value + _LargeChange;
  2670.                     }
  2671.                 }
  2672.             }
  2673.  
  2674.             Value = Math.Min(Math.Max(I1, _Minimum), _Maximum);
  2675.             InvalidatePosition();
  2676.         }
  2677.  
  2678.         base.OnMouseDown(e);
  2679.     }
  2680.  
  2681.     protected override void OnMouseMove(MouseEventArgs e)
  2682.     {
  2683.         if (ThumbDown && ShowThumb)
  2684.         {
  2685.             int ThumbPosition = e.Y - TSA.Height - (ThumbSize / 2);
  2686.             int ThumbBounds = Shaft.Height - ThumbSize;
  2687.  
  2688.             I1 = Convert.ToInt32(((double)ThumbPosition / (double)ThumbBounds) * (_Maximum - _Minimum)) + _Minimum;
  2689.  
  2690.             Value = Math.Min(Math.Max(I1, _Minimum), _Maximum);
  2691.             InvalidatePosition();
  2692.         }
  2693.  
  2694.         base.OnMouseMove(e);
  2695.     }
  2696.  
  2697.     protected override void OnMouseUp(MouseEventArgs e)
  2698.     {
  2699.         ThumbDown = false;
  2700.         base.OnMouseUp(e);
  2701.     }
  2702.  
  2703.     private double GetProgress()
  2704.     {
  2705.         return (double)(_Value - _Minimum) / (double)(_Maximum - _Minimum);
  2706.     }
  2707.  
  2708. }
  2709.  
  2710. [DefaultEvent("Scroll")]
  2711. class NSHScrollBar : Control
  2712. {
  2713.  
  2714.     public event ScrollEventHandler Scroll;
  2715.     public delegate void ScrollEventHandler(object sender);
  2716.  
  2717.     private int _Minimum;
  2718.     public int Minimum
  2719.     {
  2720.         get { return _Minimum; }
  2721.         set
  2722.         {
  2723.             if (value < 0)
  2724.             {
  2725.                 throw new Exception("Property value is not valid.");
  2726.             }
  2727.  
  2728.             _Minimum = value;
  2729.             if (value > _Value)
  2730.                 _Value = value;
  2731.             if (value > _Maximum)
  2732.                 _Maximum = value;
  2733.  
  2734.             InvalidateLayout();
  2735.         }
  2736.     }
  2737.  
  2738.     private int _Maximum = 100;
  2739.     public int Maximum
  2740.     {
  2741.         get { return _Maximum; }
  2742.         set
  2743.         {
  2744.             if (value < 0)
  2745.             {
  2746.                 throw new Exception("Property value is not valid.");
  2747.             }
  2748.  
  2749.             _Maximum = value;
  2750.             if (value < _Value)
  2751.                 _Value = value;
  2752.             if (value < _Minimum)
  2753.                 _Minimum = value;
  2754.  
  2755.             InvalidateLayout();
  2756.         }
  2757.     }
  2758.  
  2759.     private int _Value;
  2760.     public int Value
  2761.     {
  2762.         get
  2763.         {
  2764.             if (!ShowThumb)
  2765.                 return _Minimum;
  2766.             return _Value;
  2767.         }
  2768.         set
  2769.         {
  2770.             if (value == _Value)
  2771.                 return;
  2772.  
  2773.             if (value > _Maximum || value < _Minimum)
  2774.             {
  2775.                 throw new Exception("Property value is not valid.");
  2776.             }
  2777.  
  2778.             _Value = value;
  2779.             InvalidatePosition();
  2780.  
  2781.             if (Scroll != null)
  2782.             {
  2783.                 Scroll(this);
  2784.             }
  2785.         }
  2786.     }
  2787.  
  2788.     private int _SmallChange = 1;
  2789.     public int SmallChange
  2790.     {
  2791.         get { return _SmallChange; }
  2792.         set
  2793.         {
  2794.             if (value < 1)
  2795.             {
  2796.                 throw new Exception("Property value is not valid.");
  2797.             }
  2798.  
  2799.             _SmallChange = value;
  2800.         }
  2801.     }
  2802.  
  2803.     private int _LargeChange = 10;
  2804.     public int LargeChange
  2805.     {
  2806.         get { return _LargeChange; }
  2807.         set
  2808.         {
  2809.             if (value < 1)
  2810.             {
  2811.                 throw new Exception("Property value is not valid.");
  2812.             }
  2813.  
  2814.             _LargeChange = value;
  2815.         }
  2816.     }
  2817.  
  2818.     private int ButtonSize = 16;
  2819.     // 14 minimum
  2820.     private int ThumbSize = 24;
  2821.  
  2822.     private Rectangle LSA;
  2823.     private Rectangle RSA;
  2824.     private Rectangle Shaft;
  2825.  
  2826.     private Rectangle Thumb;
  2827.     private bool ShowThumb;
  2828.  
  2829.     private bool ThumbDown;
  2830.     public NSHScrollBar()
  2831.     {
  2832.         SetStyle((ControlStyles)139286, true);
  2833.         SetStyle(ControlStyles.Selectable, false);
  2834.  
  2835.         Height = 18;
  2836.  
  2837.         B1 = new SolidBrush(Color.FromArgb(55, 55, 55));
  2838.         B2 = new SolidBrush(Color.FromArgb(35, 35, 35));
  2839.  
  2840.         P1 = new Pen(Color.FromArgb(35, 35, 35));
  2841.         P2 = new Pen(Color.FromArgb(65, 65, 65));
  2842.         P3 = new Pen(Color.FromArgb(55, 55, 55));
  2843.         P4 = new Pen(Color.FromArgb(40, 40, 40));
  2844.     }
  2845.  
  2846.     private GraphicsPath GP1;
  2847.     private GraphicsPath GP2;
  2848.     private GraphicsPath GP3;
  2849.  
  2850.     private GraphicsPath GP4;
  2851.     private Pen P1;
  2852.     private Pen P2;
  2853.     private Pen P3;
  2854.     private Pen P4;
  2855.     private SolidBrush B1;
  2856.  
  2857.     private SolidBrush B2;
  2858.  
  2859.     int I1;
  2860.     private Graphics G;
  2861.     protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
  2862.     {
  2863.         G = e.Graphics;
  2864.         G.Clear(BackColor);
  2865.  
  2866.         GP1 = DrawArrow(6, 4, false);
  2867.         GP2 = DrawArrow(7, 5, false);
  2868.  
  2869.         G.FillPath(B1, GP2);
  2870.         G.FillPath(B2, GP1);
  2871.  
  2872.         GP3 = DrawArrow(Width - 11, 4, true);
  2873.         GP4 = DrawArrow(Width - 10, 5, true);
  2874.  
  2875.         G.FillPath(B1, GP4);
  2876.         G.FillPath(B2, GP3);
  2877.  
  2878.         if (ShowThumb)
  2879.         {
  2880.             G.FillRectangle(B1, Thumb);
  2881.             G.DrawRectangle(P1, Thumb);
  2882.             G.DrawRectangle(P2, Thumb.X + 1, Thumb.Y + 1, Thumb.Width - 2, Thumb.Height - 2);
  2883.  
  2884.             int X = 0;
  2885.             int LX = Thumb.X + (Thumb.Width / 2) - 3;
  2886.  
  2887.             for (int I = 0; I <= 2; I++)
  2888.             {
  2889.                 X = LX + (I * 3);
  2890.  
  2891.                 G.DrawLine(P1, X, Thumb.Y + 5, X, Thumb.Bottom - 5);
  2892.                 G.DrawLine(P2, X + 1, Thumb.Y + 5, X + 1, Thumb.Bottom - 5);
  2893.             }
  2894.         }
  2895.  
  2896.         G.DrawRectangle(P3, 0, 0, Width - 1, Height - 1);
  2897.         G.DrawRectangle(P4, 1, 1, Width - 3, Height - 3);
  2898.     }
  2899.  
  2900.     private GraphicsPath DrawArrow(int x, int y, bool flip)
  2901.     {
  2902.         GraphicsPath GP = new GraphicsPath();
  2903.  
  2904.         int W = 5;
  2905.         int H = 9;
  2906.  
  2907.         if (flip)
  2908.         {
  2909.             GP.AddLine(x, y + 1, x, y + H + 1);
  2910.             GP.AddLine(x, y + H, x + W - 1, y + W);
  2911.         }
  2912.         else
  2913.         {
  2914.             GP.AddLine(x + W, y, x + W, y + H);
  2915.             GP.AddLine(x + W, y + H, x + 1, y + W);
  2916.         }
  2917.  
  2918.         GP.CloseFigure();
  2919.         return GP;
  2920.     }
  2921.  
  2922.     protected override void OnSizeChanged(EventArgs e)
  2923.     {
  2924.         InvalidateLayout();
  2925.     }
  2926.  
  2927.     private void InvalidateLayout()
  2928.     {
  2929.         LSA = new Rectangle(0, 0, ButtonSize, Height);
  2930.         RSA = new Rectangle(Width - ButtonSize, 0, ButtonSize, Height);
  2931.         Shaft = new Rectangle(LSA.Right + 1, 0, Width - (ButtonSize * 2) - 1, Height);
  2932.  
  2933.         ShowThumb = ((_Maximum - _Minimum) > Shaft.Width);
  2934.  
  2935.         if (ShowThumb)
  2936.         {
  2937.             //ThumbSize = Math.Max(0, 14) 'TODO: Implement this.
  2938.             Thumb = new Rectangle(0, 1, ThumbSize, Height - 3);
  2939.         }
  2940.  
  2941.         if (Scroll != null)
  2942.         {
  2943.             Scroll(this);
  2944.         }
  2945.         InvalidatePosition();
  2946.     }
  2947.  
  2948.     private void InvalidatePosition()
  2949.     {
  2950.         Thumb.X = Convert.ToInt32(GetProgress() * (Shaft.Width - ThumbSize)) + LSA.Width;
  2951.         Invalidate();
  2952.     }
  2953.  
  2954.     protected override void OnMouseDown(MouseEventArgs e)
  2955.     {
  2956.         if (e.Button == System.Windows.Forms.MouseButtons.Left && ShowThumb)
  2957.         {
  2958.             if (LSA.Contains(e.Location))
  2959.             {
  2960.                 I1 = _Value - _SmallChange;
  2961.             }
  2962.             else if (RSA.Contains(e.Location))
  2963.             {
  2964.                 I1 = _Value + _SmallChange;
  2965.             }
  2966.             else
  2967.             {
  2968.                 if (Thumb.Contains(e.Location))
  2969.                 {
  2970.                     ThumbDown = true;
  2971.                     base.OnMouseDown(e);
  2972.                     return;
  2973.                 }
  2974.                 else
  2975.                 {
  2976.                     if (e.X < Thumb.X)
  2977.                     {
  2978.                         I1 = _Value - _LargeChange;
  2979.                     }
  2980.                     else
  2981.                     {
  2982.                         I1 = _Value + _LargeChange;
  2983.                     }
  2984.                 }
  2985.             }
  2986.  
  2987.             Value = Math.Min(Math.Max(I1, _Minimum), _Maximum);
  2988.             InvalidatePosition();
  2989.         }
  2990.  
  2991.         base.OnMouseDown(e);
  2992.     }
  2993.  
  2994.     protected override void OnMouseMove(MouseEventArgs e)
  2995.     {
  2996.         if (ThumbDown && ShowThumb)
  2997.         {
  2998.             int ThumbPosition = e.X - LSA.Width - (ThumbSize / 2);
  2999.             int ThumbBounds = Shaft.Width - ThumbSize;
  3000.  
  3001.             I1 = Convert.ToInt32(((double)ThumbPosition / (double)ThumbBounds) * (_Maximum - _Minimum)) + _Minimum;
  3002.  
  3003.             Value = Math.Min(Math.Max(I1, _Minimum), _Maximum);
  3004.             InvalidatePosition();
  3005.         }
  3006.  
  3007.         base.OnMouseMove(e);
  3008.     }
  3009.  
  3010.     protected override void OnMouseUp(MouseEventArgs e)
  3011.     {
  3012.         ThumbDown = false;
  3013.         base.OnMouseUp(e);
  3014.     }
  3015.  
  3016.     private double GetProgress()
  3017.     {
  3018.         return (double)(_Value - _Minimum) / (double)(_Maximum - _Minimum);
  3019.     }
  3020.  
  3021. }
  3022.  
  3023. class NSContextMenu : ContextMenuStrip
  3024. {
  3025.  
  3026.     public NSContextMenu()
  3027.     {
  3028.         Renderer = new ToolStripProfessionalRenderer(new NSColorTable());
  3029.         ForeColor = Color.White;
  3030.     }
  3031.  
  3032.     protected override void OnPaint(PaintEventArgs e)
  3033.     {
  3034.         e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
  3035.         base.OnPaint(e);
  3036.     }
  3037.  
  3038. }
  3039.  
  3040. class NSColorTable : ProfessionalColorTable
  3041. {
  3042.  
  3043.  
  3044.     private Color BackColor = Color.FromArgb(55, 55, 55);
  3045.     public override Color ButtonSelectedBorder
  3046.     {
  3047.         get { return BackColor; }
  3048.     }
  3049.  
  3050.     public override Color CheckBackground
  3051.     {
  3052.         get { return BackColor; }
  3053.     }
  3054.  
  3055.     public override Color CheckPressedBackground
  3056.     {
  3057.         get { return BackColor; }
  3058.     }
  3059.  
  3060.     public override Color CheckSelectedBackground
  3061.     {
  3062.         get { return BackColor; }
  3063.     }
  3064.  
  3065.     public override Color ImageMarginGradientBegin
  3066.     {
  3067.         get { return BackColor; }
  3068.     }
  3069.  
  3070.     public override Color ImageMarginGradientEnd
  3071.     {
  3072.         get { return BackColor; }
  3073.     }
  3074.  
  3075.     public override Color ImageMarginGradientMiddle
  3076.     {
  3077.         get { return BackColor; }
  3078.     }
  3079.  
  3080.     public override Color MenuBorder
  3081.     {
  3082.         get { return Color.FromArgb(25, 25, 25); }
  3083.     }
  3084.  
  3085.     public override Color MenuItemBorder
  3086.     {
  3087.         get { return BackColor; }
  3088.     }
  3089.  
  3090.     public override Color MenuItemSelected
  3091.     {
  3092.         get { return Color.FromArgb(65, 65, 65); }
  3093.     }
  3094.  
  3095.     public override Color SeparatorDark
  3096.     {
  3097.         get { return Color.FromArgb(35, 35, 35); }
  3098.     }
  3099.  
  3100.     public override Color ToolStripDropDownBackground
  3101.     {
  3102.         get { return BackColor; }
  3103.     }
  3104.  
  3105. }
  3106.  
  3107. //If you have made it this far it's not too late to turn back, you must not continue on! If you are trying to fullfill some
  3108. //sick act of masochism by studying the source of the ListView then, may god have mercy on your soul.
  3109. class NSListView : Control
  3110. {
  3111.  
  3112.     public class NSListViewItem
  3113.     {
  3114.         public string Text { get; set; }
  3115.         [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  3116.         public List<NSListViewSubItem> SubItems { get; set; }
  3117.  
  3118.  
  3119.         protected Guid UniqueId;
  3120.         public NSListViewItem()
  3121.         {
  3122.             UniqueId = Guid.NewGuid();
  3123.         }
  3124.  
  3125.         public override string ToString()
  3126.         {
  3127.             return Text;
  3128.         }
  3129.  
  3130.         public override bool Equals(object obj)
  3131.         {
  3132.             if (obj is NSListViewItem)
  3133.             {
  3134.                 return (((NSListViewItem)obj).UniqueId == UniqueId);
  3135.             }
  3136.  
  3137.             return false;
  3138.         }
  3139.  
  3140.         public override int GetHashCode()
  3141.         {
  3142.             return base.GetHashCode();
  3143.         }
  3144.  
  3145.     }
  3146.  
  3147.     public class NSListViewSubItem
  3148.     {
  3149.         public string Text { get; set; }
  3150.  
  3151.         public override string ToString()
  3152.         {
  3153.             return Text;
  3154.         }
  3155.     }
  3156.  
  3157.     public class NSListViewColumnHeader
  3158.     {
  3159.         public string Text { get; set; }
  3160.         public int Width { get; set; }
  3161.  
  3162.         public override string ToString()
  3163.         {
  3164.             return Text;
  3165.         }
  3166.     }
  3167.  
  3168.     private List<NSListViewItem> _Items = new List<NSListViewItem>();
  3169.     [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  3170.     public NSListViewItem[] Items
  3171.     {
  3172.         get { return _Items.ToArray(); }
  3173.         set
  3174.         {
  3175.             _Items = new List<NSListViewItem>(value);
  3176.             InvalidateScroll();
  3177.         }
  3178.     }
  3179.  
  3180.     private List<NSListViewItem> _SelectedItems = new List<NSListViewItem>();
  3181.     public NSListViewItem[] SelectedItems
  3182.     {
  3183.         get { return _SelectedItems.ToArray(); }
  3184.     }
  3185.  
  3186.     private List<NSListViewColumnHeader> _Columns = new List<NSListViewColumnHeader>();
  3187.     [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  3188.     public NSListViewColumnHeader[] Columns
  3189.     {
  3190.         get { return _Columns.ToArray(); }
  3191.         set
  3192.         {
  3193.             _Columns = new List<NSListViewColumnHeader>(value);
  3194.             InvalidateColumns();
  3195.         }
  3196.     }
  3197.  
  3198.     private bool _MultiSelect = true;
  3199.     public bool MultiSelect
  3200.     {
  3201.         get { return _MultiSelect; }
  3202.         set
  3203.         {
  3204.             _MultiSelect = value;
  3205.  
  3206.             if (_SelectedItems.Count > 1)
  3207.             {
  3208.                 _SelectedItems.RemoveRange(1, _SelectedItems.Count - 1);
  3209.             }
  3210.  
  3211.             Invalidate();
  3212.         }
  3213.     }
  3214.  
  3215.     private int ItemHeight = 24;
  3216.     public override Font Font
  3217.     {
  3218.         get { return base.Font; }
  3219.         set
  3220.         {
  3221.             ItemHeight = Convert.ToInt32(Graphics.FromHwnd(Handle).MeasureString("@", Font).Height) + 6;
  3222.  
  3223.             if (VS != null)
  3224.             {
  3225.                 VS.SmallChange = ItemHeight;
  3226.                 VS.LargeChange = ItemHeight;
  3227.             }
  3228.  
  3229.             base.Font = value;
  3230.             InvalidateLayout();
  3231.         }
  3232.     }
  3233.  
  3234.     #region " Item Helper Methods "
  3235.  
  3236.     //Ok, you've seen everything of importance at this point; I am begging you to spare yourself. You must not read any further!
  3237.  
  3238.     public void AddItem(string text, params string[] subItems)
  3239.     {
  3240.         List<NSListViewSubItem> Items = new List<NSListViewSubItem>();
  3241.         foreach (string I in subItems)
  3242.         {
  3243.             NSListViewSubItem SubItem = new NSListViewSubItem();
  3244.             SubItem.Text = I;
  3245.             Items.Add(SubItem);
  3246.         }
  3247.  
  3248.         NSListViewItem Item = new NSListViewItem();
  3249.         Item.Text = text;
  3250.         Item.SubItems = Items;
  3251.  
  3252.         _Items.Add(Item);
  3253.         InvalidateScroll();
  3254.     }
  3255.  
  3256.     public void RemoveItemAt(int index)
  3257.     {
  3258.         _Items.RemoveAt(index);
  3259.         InvalidateScroll();
  3260.     }
  3261.  
  3262.     public void RemoveItem(NSListViewItem item)
  3263.     {
  3264.         _Items.Remove(item);
  3265.         InvalidateScroll();
  3266.     }
  3267.  
  3268.     public void RemoveItems(NSListViewItem[] items)
  3269.     {
  3270.         foreach (NSListViewItem I in items)
  3271.         {
  3272.             _Items.Remove(I);
  3273.         }
  3274.  
  3275.         InvalidateScroll();
  3276.     }
  3277.  
  3278.     #endregion
  3279.  
  3280.  
  3281.     private NSVScrollBar VS;
  3282.     public NSListView()
  3283.     {
  3284.         SetStyle((ControlStyles)139286, true);
  3285.         SetStyle(ControlStyles.Selectable, true);
  3286.  
  3287.         P1 = new Pen(Color.FromArgb(55, 55, 55));
  3288.         P2 = new Pen(Color.FromArgb(35, 35, 35));
  3289.         P3 = new Pen(Color.FromArgb(65, 65, 65));
  3290.  
  3291.         B1 = new SolidBrush(Color.FromArgb(62, 62, 62));
  3292.         B2 = new SolidBrush(Color.FromArgb(65, 65, 65));
  3293.         B3 = new SolidBrush(Color.FromArgb(47, 47, 47));
  3294.         B4 = new SolidBrush(Color.FromArgb(50, 50, 50));
  3295.  
  3296.         VS = new NSVScrollBar();
  3297.         VS.SmallChange = ItemHeight;
  3298.         VS.LargeChange = ItemHeight;
  3299.  
  3300.         VS.Scroll += HandleScroll;
  3301.         VS.MouseDown += VS_MouseDown;
  3302.         Controls.Add(VS);
  3303.  
  3304.         InvalidateLayout();
  3305.     }
  3306.  
  3307.     protected override void OnSizeChanged(EventArgs e)
  3308.     {
  3309.         InvalidateLayout();
  3310.         base.OnSizeChanged(e);
  3311.     }
  3312.  
  3313.     private void HandleScroll(object sender)
  3314.     {
  3315.         Invalidate();
  3316.     }
  3317.  
  3318.     private void InvalidateScroll()
  3319.     {
  3320.         VS.Maximum = (_Items.Count * ItemHeight);
  3321.         Invalidate();
  3322.     }
  3323.  
  3324.     private void InvalidateLayout()
  3325.     {
  3326.         VS.Location = new Point(Width - VS.Width - 1, 1);
  3327.         VS.Size = new Size(18, Height - 2);
  3328.  
  3329.         Invalidate();
  3330.     }
  3331.  
  3332.     private int[] ColumnOffsets;
  3333.     private void InvalidateColumns()
  3334.     {
  3335.         int Width = 3;
  3336.         ColumnOffsets = new int[_Columns.Count];
  3337.  
  3338.         for (int I = 0; I <= _Columns.Count - 1; I++)
  3339.         {
  3340.             ColumnOffsets[I] = Width;
  3341.             Width += Columns[I].Width;
  3342.         }
  3343.  
  3344.         Invalidate();
  3345.     }
  3346.  
  3347.     private void VS_MouseDown(object sender, MouseEventArgs e)
  3348.     {
  3349.         Focus();
  3350.     }
  3351.  
  3352.     protected override void OnMouseDown(MouseEventArgs e)
  3353.     {
  3354.         Focus();
  3355.  
  3356.         if (e.Button == System.Windows.Forms.MouseButtons.Left)
  3357.         {
  3358.             int Offset = Convert.ToInt32(VS.Percent * (VS.Maximum - (Height - (ItemHeight * 2))));
  3359.             int Index = ((e.Y + Offset - ItemHeight) / ItemHeight);
  3360.  
  3361.             if (Index > _Items.Count - 1)
  3362.                 Index = -1;
  3363.  
  3364.             if (!(Index == -1))
  3365.             {
  3366.                 //TODO: Handle Shift key
  3367.  
  3368.                 if (ModifierKeys == Keys.Control && _MultiSelect)
  3369.                 {
  3370.                     if (_SelectedItems.Contains(_Items[Index]))
  3371.                     {
  3372.                         _SelectedItems.Remove(_Items[Index]);
  3373.                     }
  3374.                     else
  3375.                     {
  3376.                         _SelectedItems.Add(_Items[Index]);
  3377.                     }
  3378.                 }
  3379.                 else
  3380.                 {
  3381.                     _SelectedItems.Clear();
  3382.                     _SelectedItems.Add(_Items[Index]);
  3383.                 }
  3384.             }
  3385.  
  3386.             Invalidate();
  3387.         }
  3388.  
  3389.         base.OnMouseDown(e);
  3390.     }
  3391.  
  3392.     private Pen P1;
  3393.     private Pen P2;
  3394.     private Pen P3;
  3395.     private SolidBrush B1;
  3396.     private SolidBrush B2;
  3397.     private SolidBrush B3;
  3398.     private SolidBrush B4;
  3399.  
  3400.     private LinearGradientBrush GB1;
  3401.     //I am so sorry you have to witness this. I tried warning you. ;.;
  3402.  
  3403.     private Graphics G;
  3404.     protected override void OnPaint(PaintEventArgs e)
  3405.     {
  3406.         G = e.Graphics;
  3407.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
  3408.  
  3409.         G.Clear(BackColor);
  3410.  
  3411.         int X = 0;
  3412.         int Y = 0;
  3413.         float H = 0;
  3414.  
  3415.         G.DrawRectangle(P1, 1, 1, Width - 3, Height - 3);
  3416.  
  3417.         Rectangle R1 = default(Rectangle);
  3418.         NSListViewItem CI = null;
  3419.  
  3420.         int Offset = Convert.ToInt32(VS.Percent * (VS.Maximum - (Height - (ItemHeight * 2))));
  3421.  
  3422.         int StartIndex = 0;
  3423.         if (Offset == 0)
  3424.             StartIndex = 0;
  3425.         else
  3426.             StartIndex = (Offset / ItemHeight);
  3427.  
  3428.         int EndIndex = Math.Min(StartIndex + (Height / ItemHeight), _Items.Count - 1);
  3429.  
  3430.         for (int I = StartIndex; I <= EndIndex; I++)
  3431.         {
  3432.             CI = Items[I];
  3433.  
  3434.             R1 = new Rectangle(0, ItemHeight + (I * ItemHeight) + 1 - Offset, Width, ItemHeight - 1);
  3435.  
  3436.             H = G.MeasureString(CI.Text, Font).Height;
  3437.             Y = R1.Y + Convert.ToInt32((ItemHeight / 2) - (H / 2));
  3438.  
  3439.             if (_SelectedItems.Contains(CI))
  3440.             {
  3441.                 if (I % 2 == 0)
  3442.                 {
  3443.                     G.FillRectangle(B1, R1);
  3444.                 }
  3445.                 else
  3446.                 {
  3447.                     G.FillRectangle(B2, R1);
  3448.                 }
  3449.             }
  3450.             else
  3451.             {
  3452.                 if (I % 2 == 0)
  3453.                 {
  3454.                     G.FillRectangle(B3, R1);
  3455.                 }
  3456.                 else
  3457.                 {
  3458.                     G.FillRectangle(B4, R1);
  3459.                 }
  3460.             }
  3461.  
  3462.             G.DrawLine(P2, 0, R1.Bottom, Width, R1.Bottom);
  3463.  
  3464.             if (Columns.Length > 0)
  3465.             {
  3466.                 R1.Width = Columns[0].Width;
  3467.                 G.SetClip(R1);
  3468.             }
  3469.  
  3470.             //TODO: Ellipse text that overhangs seperators.
  3471.             G.DrawString(CI.Text, Font, Brushes.Black, 10, Y + 1);
  3472.             G.DrawString(CI.Text, Font, Brushes.White, 9, Y);
  3473.  
  3474.             if (CI.SubItems != null)
  3475.             {
  3476.                 for (int I2 = 0; I2 <= Math.Min(CI.SubItems.Count, _Columns.Count) - 1; I2++)
  3477.                 {
  3478.                     X = ColumnOffsets[I2 + 1] + 4;
  3479.  
  3480.                     R1.X = X;
  3481.                     R1.Width = Columns[I2].Width;
  3482.                     G.SetClip(R1);
  3483.  
  3484.                     G.DrawString(CI.SubItems[I2].Text, Font, Brushes.Black, X + 1, Y + 1);
  3485.                     G.DrawString(CI.SubItems[I2].Text, Font, Brushes.White, X, Y);
  3486.                 }
  3487.             }
  3488.  
  3489.             G.ResetClip();
  3490.         }
  3491.  
  3492.         R1 = new Rectangle(0, 0, Width, ItemHeight);
  3493.  
  3494.         GB1 = new LinearGradientBrush(R1, Color.FromArgb(60, 60, 60), Color.FromArgb(55, 55, 55), 90f);
  3495.         G.FillRectangle(GB1, R1);
  3496.         G.DrawRectangle(P3, 1, 1, Width - 22, ItemHeight - 2);
  3497.  
  3498.         int LH = Math.Min(VS.Maximum + ItemHeight - Offset, Height);
  3499.  
  3500.         NSListViewColumnHeader CC = null;
  3501.         for (int I = 0; I <= _Columns.Count - 1; I++)
  3502.         {
  3503.             CC = Columns[I];
  3504.  
  3505.             H = G.MeasureString(CC.Text, Font).Height;
  3506.             Y = Convert.ToInt32((ItemHeight / 2) - (H / 2));
  3507.             X = ColumnOffsets[I];
  3508.  
  3509.             G.DrawString(CC.Text, Font, Brushes.Black, X + 1, Y + 1);
  3510.             G.DrawString(CC.Text, Font, Brushes.White, X, Y);
  3511.  
  3512.             G.DrawLine(P2, X - 3, 0, X - 3, LH);
  3513.             G.DrawLine(P3, X - 2, 0, X - 2, ItemHeight);
  3514.         }
  3515.  
  3516.         G.DrawRectangle(P2, 0, 0, Width - 1, Height - 1);
  3517.  
  3518.         G.DrawLine(P2, 0, ItemHeight, Width, ItemHeight);
  3519.         G.DrawLine(P2, VS.Location.X - 1, 0, VS.Location.X - 1, Height);
  3520.     }
  3521.  
  3522.     protected override void OnMouseWheel(MouseEventArgs e)
  3523.     {
  3524.         int Move = -((e.Delta * SystemInformation.MouseWheelScrollLines / 120) * (ItemHeight / 2));
  3525.  
  3526.         int Value = Math.Max(Math.Min(VS.Value + Move, VS.Maximum), VS.Minimum);
  3527.         VS.Value = Value;
  3528.  
  3529.         base.OnMouseWheel(e);
  3530.     }
  3531.  
  3532. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement