Advertisement
Guest User

Bullion Theme by AeonHack, converted by Chuiby

a guest
Apr 25th, 2011
1,559
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 10.28 KB | None | 0 0
  1. internal class BullionTheme : Control
  2. {
  3.  
  4.     protected override void OnHandleCreated(EventArgs e)
  5.     {
  6.         Dock = DockStyle.Fill;
  7.         if (Parent is Form)
  8.         {
  9.             Form tempWith1 = (Form)Parent;
  10.             tempWith1.FormBorderStyle = 0;
  11.             tempWith1.BackColor = C1;
  12.             tempWith1.ForeColor = Color.FromArgb(170, 170, 170);
  13.         }
  14.         base.OnHandleCreated(e);
  15.     }
  16.     protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
  17.     {
  18.         if (new Rectangle(Parent.Location.X, Parent.Location.Y, Width, 22).IntersectsWith(new Rectangle(MousePosition.X, MousePosition.Y, 1, 1)))
  19.         {
  20.             Capture = false;
  21.             Message M = Message.Create(Parent.Handle, 161, new IntPtr(2), IntPtr.Zero);
  22.             DefWndProc(ref M);
  23.         }
  24.         base.OnMouseDown(e);
  25.     }
  26.  
  27.     private Graphics G;
  28.     private Bitmap B;
  29.     private Rectangle R1;
  30.     private Rectangle R2;
  31.     private Color C1;
  32.     private Color C2;
  33.     private Color C3;
  34.     private Pen P1;
  35.     private Pen P2;
  36.     private Pen P3;
  37.     private Pen P4;
  38.     private SolidBrush B1;
  39.     private LinearGradientBrush B2;
  40.     private LinearGradientBrush B3;
  41.  
  42.     public BullionTheme()
  43.     {
  44.  
  45.         SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
  46.         C1 = Color.FromArgb(248, 248, 248); //Background
  47.         C2 = Color.FromArgb(255, 255, 255); //Highlight
  48.         C3 = Color.FromArgb(235, 235, 235); //Shadow
  49.         P1 = new Pen(Color.FromArgb(215, 215, 215)); //Border
  50.         P4 = new Pen(Color.FromArgb(230, 230, 230)); //Diagnol Lines
  51.         P2 = new Pen(C1);
  52.         P3 = new Pen(C2);
  53.         B1 = new SolidBrush(Color.FromArgb(170, 170, 170));
  54.         Font = new Font("Verdana", 7.0F);
  55.  
  56.     }
  57.  
  58.     protected override void OnSizeChanged(EventArgs e)
  59.     {
  60.         if (Height > 0)
  61.         {
  62.             R1 = new Rectangle(0, 2, Width, 18);
  63.             R2 = new Rectangle(0, 21, Width, 10);
  64.             B2 = new LinearGradientBrush(R1, C1, C3, 90.0F);
  65.             B3 = new LinearGradientBrush(R2, Color.FromArgb(18, 0, 0, 0), Color.Transparent, 90.0F);
  66.             Invalidate();
  67.         }
  68.         base.OnSizeChanged(e);
  69.     }
  70.  
  71.     protected override void OnPaintBackground(PaintEventArgs pevent)
  72.     {
  73.     }
  74.  
  75.     protected override void OnPaint(PaintEventArgs e)
  76.     {
  77.         B = new Bitmap(Width, Height);
  78.         G = Graphics.FromImage(B);
  79.  
  80.         G.Clear(C1);
  81.  
  82.         for (int I = 0; I <= Width + 17; I += 4)
  83.         {
  84.             G.DrawLine(P4, I, 21, I - 17, 37);
  85.             G.DrawLine(P4, I - 1, 21, I - 16, 37);
  86.         }
  87.         G.FillRectangle(B3, R2);
  88.  
  89.         G.FillRectangle(B2, R1);
  90.         G.DrawString(Text, Font, B1, 5, 5);
  91.  
  92.         G.DrawRectangle(P2, 1, 1, Width - 3, 19);
  93.         G.DrawRectangle(P3, 1, 39, Width - 3, Height - 41);
  94.  
  95.         G.DrawRectangle(P1, 0, 0, Width - 1, Height - 1);
  96.         G.DrawLine(P1, 0, 21, Width, 21);
  97.         G.DrawLine(P1, 0, 38, Width, 38);
  98.  
  99.         e.Graphics.DrawImage(B, 0, 0);
  100.         G.Dispose();
  101.         B.Dispose();
  102.     }
  103.  
  104. }
  105. internal class BullionButton : Control
  106. {
  107.  
  108.  
  109.     private Image _Image;
  110.     private bool ImageSet;
  111.     public Image Image
  112.     {
  113.         get
  114.         {
  115.             return _Image;
  116.         }
  117.         set
  118.         {
  119.             _Image = value;
  120.             ImageSet = value != null;
  121.         }
  122.     }
  123.  
  124.  
  125.     private Bitmap B;
  126.     private Graphics G;
  127.     private Rectangle R1;
  128.     private Color C1;
  129.     private Color C2;
  130.     private Color C3;
  131.     private Color C4;
  132.     private Pen P1;
  133.     private Pen P2;
  134.     private Pen P3;
  135.     private Pen P4;
  136.     private Brush B1;
  137.     private Brush B2;
  138.     private Brush B5;
  139.     private LinearGradientBrush B3;
  140.     private LinearGradientBrush B4;
  141.  
  142.     public BullionButton()
  143.     {
  144.         SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
  145.         C1 = Color.FromArgb(244, 244, 244); //Background
  146.         C2 = Color.FromArgb(220, 220, 220); //Highlight
  147.         C3 = Color.FromArgb(248, 248, 248); //Lesser Highlight
  148.         C4 = Color.FromArgb(24, Color.Black);
  149.         P1 = new Pen(Color.FromArgb(255, 255, 255)); //Shadow
  150.         P2 = new Pen(Color.FromArgb(40, Color.White));
  151.         P3 = new Pen(Color.FromArgb(20, Color.White));
  152.         P4 = new Pen(Color.FromArgb(10, Color.Black)); //Down-Left
  153.         B1 = new SolidBrush(C1);
  154.         B2 = new SolidBrush(C3);
  155.         B5 = new SolidBrush(Color.FromArgb(170, 170, 170)); //Text Color
  156.         Font = new Font("Verdana", 8.0F);
  157.     }
  158.  
  159.     private int State;
  160.     protected override void OnMouseLeave(EventArgs e)
  161.     {
  162.         State = 0;
  163.         Invalidate();
  164.     }
  165.     protected override void OnMouseUp(MouseEventArgs e)
  166.     {
  167.         State = 1;
  168.         Invalidate();
  169.     }
  170.     protected override void OnMouseEnter(EventArgs e)
  171.     {
  172.         State = 1;
  173.         Invalidate();
  174.     }
  175.     protected override void OnMouseDown(MouseEventArgs e)
  176.     {
  177.         State = 2;
  178.         Invalidate();
  179.     }
  180.  
  181.     protected override void OnResize(EventArgs e)
  182.     {
  183.         R1 = new Rectangle(2, 2, Width - 4, 4);
  184.         B3 = new LinearGradientBrush(ClientRectangle, C3, C2, 90.0F);
  185.         B4 = new LinearGradientBrush(R1, C4, Color.Transparent, 90.0F);
  186.         Invalidate();
  187.     }
  188.  
  189.     protected override void OnPaint(PaintEventArgs e)
  190.     {
  191.         B = new Bitmap(Width, Height);
  192.         G = Graphics.FromImage(B);
  193.  
  194.         G.FillRectangle(B3, ClientRectangle);
  195.  
  196.         switch (State)
  197.         {
  198.             case 0: //Up
  199.                 G.FillRectangle(B2, 1, 1, Width - 2, Height - 2);
  200.                 G.DrawRectangle(P4, 2, 2, Width - 5, Height - 5);
  201.                 break;
  202.             case 1: //Over
  203.                 G.FillRectangle(B1, 1, 1, Width - 2, Height - 2);
  204.                 G.DrawRectangle(P4, 2, 2, Width - 5, Height - 5);
  205.                 break;
  206.             case 2: //Down
  207.                 G.FillRectangle(B1, 1, 1, Width - 2, Height - 2);
  208.                 G.FillRectangle(B4, R1);
  209.                 G.DrawLine(P4, 2, 2, 2, Height - 3);
  210.                 break;
  211.         }
  212.  
  213.         SizeF S = G.MeasureString(Text, Font);
  214.         G.DrawString(Text, Font, B5, Convert.ToInt32(Width / 2 - S.Width / 2.0), Convert.ToInt32(Height / 2 - S.Height / 2.0));
  215.  
  216.         G.DrawRectangle(P1, 1, 1, Width - 3, Height - 3);
  217.  
  218.         if (ImageSet)
  219.         {
  220.             G.DrawImage(_Image, 5, System.Convert.ToInt32(Height / 2 - _Image.Height / 2.0), _Image.Width, _Image.Height);
  221.         }
  222.  
  223.         e.Graphics.DrawImage(B, 0, 0);
  224.         G.Dispose();
  225.         B.Dispose();
  226.     }
  227.  
  228.     protected override void OnPaintBackground(PaintEventArgs e)
  229.     {
  230.     }
  231.  
  232. }
  233. internal class BullionProgressBar : Control
  234. {
  235.  
  236. #region  Properties
  237.     private double _Maximum = 100;
  238.     public double Maximum
  239.     {
  240.         get
  241.         {
  242.             return _Maximum;
  243.         }
  244.         set
  245.         {
  246.             _Maximum = value;
  247.             Progress = _Current / value * 100;
  248.             Invalidate();
  249.         }
  250.     }
  251.     private double _Current;
  252.     public double Current
  253.     {
  254.         get
  255.         {
  256.             return _Current;
  257.         }
  258.         set
  259.         {
  260.             _Current = value;
  261.             Progress = value / _Maximum * 100;
  262.             Invalidate();
  263.         }
  264.     }
  265.     private int _Progress;
  266.     public double Progress
  267.     {
  268.         get
  269.         {
  270.             return _Progress;
  271.         }
  272.         set
  273.         {
  274.             if (value < 0)
  275.             {
  276.                 value = 0;
  277.             }
  278.             else if (value > 100)
  279.             {
  280.                 value = 100;
  281.             }
  282.             _Progress = Convert.ToInt32(value);
  283.             _Current = value * 0.01 * _Maximum;
  284.             if (Width > 0)
  285.             {
  286.                 UpdateProgress();
  287.             }
  288.             Invalidate();
  289.         }
  290.     }
  291.  
  292.     private Color C2 = Color.PaleTurquoise; //Dark Color
  293.     public Color Color1
  294.     {
  295.         get
  296.         {
  297.             return C2;
  298.         }
  299.         set
  300.         {
  301.             C2 = value;
  302.             UpdateColors();
  303.             Invalidate();
  304.         }
  305.     }
  306.     private Color C3 = Color.AliceBlue; //Light color
  307.     public Color Color2
  308.     {
  309.         get
  310.         {
  311.             return C3;
  312.         }
  313.         set
  314.         {
  315.             C3 = value;
  316.             UpdateColors();
  317.             Invalidate();
  318.         }
  319.     }
  320.  
  321. #endregion
  322.  
  323.     protected override void OnPaintBackground(PaintEventArgs pevent)
  324.     {
  325.     }
  326.  
  327.     private Graphics G;
  328.     private Bitmap B;
  329.     private Rectangle R1;
  330.     private Rectangle R2;
  331.     private ColorBlend X;
  332.     private Color C1;
  333.     private Pen P1;
  334.     private Pen P2;
  335.     private Pen P3;
  336.     private LinearGradientBrush B1;
  337.     private LinearGradientBrush B2;
  338.     private SolidBrush B3;
  339.     public BullionProgressBar()
  340.     {
  341.  
  342.         C1 = Color.FromArgb(246, 246, 246); //Background
  343.         P1 = new Pen(Color.FromArgb(70, Color.White), 2F);
  344.         P2 = new Pen(C2);
  345.         P3 = new Pen(Color.FromArgb(255, 255, 255)); //Highlight
  346.         B3 = new SolidBrush(Color.FromArgb(100, Color.White));
  347.         X = new ColorBlend(4);
  348.         X.Colors = new Color[]{C2, C3, C3, C2};
  349.         X.Positions = new float[]{0.0F, 0.1F, 0.9F, 1.0F};
  350.         R2 = new Rectangle(2, 2, 2, 2);
  351.         B2 = new LinearGradientBrush(R2, Color.Transparent, Color.Transparent, 180.0F);
  352.         B2.InterpolationColors = X;
  353.  
  354.     }
  355.  
  356.     public void UpdateColors()
  357.     {
  358.         P2.Color = C2;
  359.         X.Colors = new Color[]{C2, C3, C3, C2};
  360.         B2.InterpolationColors = X;
  361.     }
  362.  
  363.     protected override void OnSizeChanged(System.EventArgs e)
  364.     {
  365.         R1 = new Rectangle(0, 1, Width, 4);
  366.         B1 = new LinearGradientBrush(R1, Color.FromArgb(24, Color.Black), Color.Transparent, 90.0F);
  367.         UpdateProgress();
  368.         Invalidate();
  369.         base.OnSizeChanged(e);
  370.     }
  371.  
  372.     public void UpdateProgress()
  373.     {
  374.         if (_Progress == 0)
  375.         {
  376.             return;
  377.         }
  378.         R2 = new Rectangle(2, 2, Convert.ToInt32((Width - 4) * (_Progress * 0.01)), Height - 4);
  379.         B2 = new LinearGradientBrush(R2, Color.Transparent, Color.Transparent, 180.0F);
  380.         B2.InterpolationColors = X;
  381.     }
  382.  
  383.     protected override void OnPaint(PaintEventArgs e)
  384.     {
  385.         B = new Bitmap(Width, Height);
  386.         G = Graphics.FromImage(B);
  387.  
  388.         G.Clear(C1);
  389.  
  390.         G.FillRectangle(B1, R1);
  391.  
  392.         if (_Progress > 0)
  393.         {
  394.             G.FillRectangle(B2, R2);
  395.  
  396.             G.FillRectangle(B3, 2, 3, R2.Width, 4);
  397.             G.DrawRectangle(P1, 4, 4, R2.Width - 4, Height - 8);
  398.  
  399.             G.DrawRectangle(P2, 2, 2, R2.Width - 1, Height - 5);
  400.         }
  401.  
  402.         G.DrawRectangle(P3, 0, 0, Width - 1, Height - 1);
  403.  
  404.         e.Graphics.DrawImage(B, 0, 0);
  405.         G.Dispose();
  406.         B.Dispose();
  407.     }
  408.  
  409. }
  410. internal class BullionSeperator : Control
  411. {
  412.  
  413.     private Orientation _Orientation;
  414.     public Orientation Orientation
  415.     {
  416.         get
  417.         {
  418.             return _Orientation;
  419.         }
  420.         set
  421.         {
  422.             _Orientation = value;
  423.             UpdateOffset();
  424.             Invalidate();
  425.         }
  426.     }
  427.  
  428.     private Graphics G;
  429.     private Bitmap B;
  430.     private int I;
  431.     private Color C1;
  432.     private Pen P1;
  433.     private Pen P2;
  434.     public BullionSeperator()
  435.     {
  436.         SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
  437.         C1 = Color.FromArgb(248, 248, 248); //Background
  438.         P1 = new Pen(Color.FromArgb(230, 230, 230)); //Shadow
  439.         P2 = new Pen(Color.FromArgb(255, 255, 255)); //Highlight
  440.     }
  441.  
  442.     protected override void OnSizeChanged(EventArgs e)
  443.     {
  444.         UpdateOffset();
  445.         base.OnSizeChanged(e);
  446.     }
  447.  
  448.     public void UpdateOffset()
  449.     {
  450.         I = Convert.ToInt32(((_Orientation == 0) ? Height / 2 - 1 : Width / 2 - 1));
  451.     }
  452.  
  453.     protected override void OnPaint(PaintEventArgs e)
  454.     {
  455.         B = new Bitmap(Width, Height);
  456.         G = Graphics.FromImage(B);
  457.  
  458.         G.Clear(C1);
  459.  
  460.         if (_Orientation == 0)
  461.         {
  462.             G.DrawLine(P1, 0, I, Width, I);
  463.             G.DrawLine(P2, 0, I + 1, Width, I + 1);
  464.         }
  465.         else
  466.         {
  467.             G.DrawLine(P2, I, 0, I, Height);
  468.             G.DrawLine(P1, I + 1, 0, I + 1, Height);
  469.         }
  470.  
  471.         e.Graphics.DrawImage(B, 0, 0);
  472.         G.Dispose();
  473.         B.Dispose();
  474.     }
  475.  
  476.     protected override void OnPaintBackground(PaintEventArgs pevent)
  477.     {
  478.     }
  479.  
  480. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement