Guest User

Untitled

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