Advertisement
Guest User

Fusion Theme by AeonHack, converted by Chuiby

a guest
Apr 25th, 2011
2,172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 14.06 KB | None | 0 0
  1. class Pigment
  2. {
  3.     public string Name { get; set; }
  4.     public Color Value { get; set; }
  5.  
  6.     public Pigment()
  7.     {
  8.     }
  9.  
  10.     public Pigment(string n, Color v)
  11.     {
  12.         Name = n;
  13.         Value = v;
  14.     }
  15.  
  16.     public Pigment(string n, byte a, byte r, byte g, byte b)
  17.     {
  18.         Name = n;
  19.         Value = Color.FromArgb(a, r, g, b);
  20.     }
  21.  
  22.     public Pigment(string n, byte r, byte g, byte b)
  23.     {
  24.         Name = n;
  25.         Value = Color.FromArgb(r, g, b);
  26.     }
  27. }
  28.  
  29. class FTheme : ContainerControl
  30. {
  31.  
  32.     public bool Resizeable { get; set; }
  33.  
  34.     public FTheme()
  35.     {
  36.         SetStyle((ControlStyles)8198, true);
  37.         Pigment[] C = new Pigment[]{
  38.             new Pigment("Border", Color.Black),
  39.             new Pigment("Frame", 47, 47, 50),
  40.             new Pigment("Border Highlight", 15, 255, 255, 255),
  41.             new Pigment("Side Highlight", 6, 255, 255, 255),
  42.             new Pigment("Shine", 20, 255, 255, 255),
  43.             new Pigment("Shadow", 38, 38, 40),
  44.             new Pigment("Backcolor", 247, 247, 251),
  45.             new Pigment("Transparency", Color.Fuchsia)
  46.         };
  47.     }
  48.  
  49.     protected override void OnHandleCreated(EventArgs e)
  50.     {
  51.         Dock = DockStyle.Fill;
  52.         if (Parent is Form)
  53.             ((Form)Parent).FormBorderStyle = FormBorderStyle.None;
  54.         Colors = C;
  55.         base.OnHandleCreated(e);
  56.     }
  57.  
  58.     const byte Count = 8;
  59.     private Pigment[] C = new Pigment[]{
  60.             new Pigment("Border", Color.Black),
  61.             new Pigment("Frame", 47, 47, 50),
  62.             new Pigment("Border Highlight", 15, 255, 255, 255),
  63.             new Pigment("Side Highlight", 6, 255, 255, 255),
  64.             new Pigment("Shine", 20, 255, 255, 255),
  65.             new Pigment("Shadow", 38, 38, 40),
  66.             new Pigment("Backcolor", 247, 247, 251),
  67.             new Pigment("Transparency", Color.Fuchsia)
  68.         };
  69.     public Pigment[] Colors
  70.     {
  71.         get { return C; }
  72.         set
  73.         {
  74.             if (value.Length != Count)
  75.                 throw new IndexOutOfRangeException();
  76.  
  77.             P1 = new Pen(value[0].Value);
  78.             P2 = new Pen(value[2].Value);
  79.  
  80.             B1 = new SolidBrush(value[6].Value);
  81.             B2 = new SolidBrush(value[7].Value);
  82.  
  83.             if (Parent != null)
  84.             {
  85.                 Parent.BackColor = value[6].Value;
  86.                 if (Parent is Form)
  87.                     ((Form)Parent).TransparencyKey = value[7].Value;
  88.             }
  89.  
  90.             CB = new ColorBlend();
  91.             CB.Colors = new Color[]{
  92.                 Color.Transparent,
  93.                 value[4].Value,
  94.                 Color.Transparent
  95.             };
  96.             CB.Positions = new float[] {
  97.                 0,
  98.                 (float)0.5,
  99.                 1
  100.             };
  101.  
  102.             C = value;
  103.  
  104.             Invalidate();
  105.         }
  106.     }
  107.  
  108.     private Pen P1;
  109.     private Pen P2;
  110.     private Pen P3;
  111.     private SolidBrush B1;
  112.     private SolidBrush B2;
  113.     private LinearGradientBrush B3;
  114.     private LinearGradientBrush B4;
  115.     private Rectangle R1;
  116.     private Rectangle R2;
  117.  
  118.     private ColorBlend CB;
  119.     private Graphics G;
  120.     private Bitmap B;
  121.     protected override void OnPaint(PaintEventArgs e)
  122.     {
  123.         B = new Bitmap(Width, Height);
  124.         G = Graphics.FromImage(B);
  125.  
  126.         G.Clear(C[1].Value);
  127.  
  128.         G.DrawRectangle(P2, new Rectangle(1, 1, Width - 3, Height - 3));
  129.         G.DrawRectangle(P2, new Rectangle(12, 40, Width - 24, Height - 52));
  130.  
  131.         R1 = new Rectangle(1, 0, 15, Height);
  132.         B3 = new LinearGradientBrush(R1, C[3].Value, Color.Transparent, 90f);
  133.         G.FillRectangle(B3, R1);
  134.         G.FillRectangle(B3, new Rectangle(Width - 16, 0, 15, Height));
  135.  
  136.         G.FillRectangle(B1, new Rectangle(13, 41, Width - 26, Height - 54));
  137.  
  138.         R2 = new Rectangle(0, 2, Width, 2);
  139.         B4 = new LinearGradientBrush(R2, Color.Empty, Color.Empty, 0F);
  140.         B4.InterpolationColors = CB;
  141.         G.FillRectangle(B4, R2);
  142.  
  143.         G.DrawRectangle(P1, new Rectangle(13, 41, Width - 26, Height - 54));
  144.         G.DrawRectangle(P1, new Rectangle(0, 0, Width - 1, Height - 1));
  145.  
  146.         G.FillRectangle(B2, new Rectangle(0, 0, 2, 2));
  147.         G.FillRectangle(B2, new Rectangle(Width - 2, 0, 2, 2));
  148.         G.FillRectangle(B2, new Rectangle(Width - 2, Height - 2, 2, 2));
  149.         G.FillRectangle(B2, new Rectangle(0, Height - 2, 2, 2));
  150.  
  151.         B.SetPixel(1, 1, Color.Black);
  152.         B.SetPixel(Width - 2, 1, Color.Black);
  153.         B.SetPixel(Width - 2, Height - 2, Color.Black);
  154.         B.SetPixel(1, Height - 2, Color.Black);
  155.  
  156.         e.Graphics.DrawImage(B, 0, 0);
  157.         B3.Dispose();
  158.         B4.Dispose();
  159.         G.Dispose();
  160.         B.Dispose();
  161.     }
  162.  
  163.     public enum Direction : int
  164.     {
  165.         NONE = 0,
  166.         LEFT = 10,
  167.         RIGHT = 11,
  168.         TOP = 12,
  169.         TOPLEFT = 13,
  170.         TOPRIGHT = 14,
  171.         BOTTOM = 15,
  172.         BOTTOMLEFT = 16,
  173.         BOTTOMRIGHT = 17
  174.     }
  175.     private Direction Current;
  176.     public void SetCurrent()
  177.     {
  178.         Point T = PointToClient(MousePosition);
  179.         if (T.X < 7 & T.Y < 7)
  180.         {
  181.             Current = Direction.TOPLEFT;
  182.             Cursor = Cursors.SizeNWSE;
  183.         }
  184.         else if (T.X < 7 & T.Y > Height - 7)
  185.         {
  186.             Current = Direction.BOTTOMLEFT;
  187.             Cursor = Cursors.SizeNESW;
  188.         }
  189.         else if (T.X > Width - 7 & T.Y > Height - 7)
  190.         {
  191.             Current = Direction.BOTTOMRIGHT;
  192.             Cursor = Cursors.SizeNWSE;
  193.         }
  194.         else if (T.X > Width - 7 & T.Y < 7)
  195.         {
  196.             Current = Direction.TOPRIGHT;
  197.             Cursor = Cursors.SizeNESW;
  198.         }
  199.         else if (T.X < 7)
  200.         {
  201.             Current = Direction.LEFT;
  202.             Cursor = Cursors.SizeWE;
  203.         }
  204.         else if (T.X > Width - 7)
  205.         {
  206.             Current = Direction.RIGHT;
  207.             Cursor = Cursors.SizeWE;
  208.         }
  209.         else if (T.Y < 7)
  210.         {
  211.             Current = Direction.TOP;
  212.             Cursor = Cursors.SizeNS;
  213.         }
  214.         else if (T.Y > Height - 7)
  215.         {
  216.             Current = Direction.BOTTOM;
  217.             Cursor = Cursors.SizeNS;
  218.         }
  219.         else
  220.         {
  221.             Current = Direction.NONE;
  222.             Cursor = Cursors.Default;
  223.         }
  224.     }
  225.     protected override void OnMouseDown(MouseEventArgs e)
  226.     {
  227.         if (e.Button == MouseButtons.Left)
  228.         {
  229.             if (Parent is Form)
  230.             {
  231.                 if (((Form)Parent).WindowState == FormWindowState.Maximized)
  232.                     return;
  233.             }
  234.             if (Drag.Contains(e.Location))
  235.             {
  236.                 Capture = false;
  237.                 IntPtr Val = new IntPtr(2);
  238.                 IntPtr NULL = IntPtr.Zero;
  239.                 Message msg = Message.Create(Parent.Handle, 161, Val, NULL);
  240.                 DefWndProc(ref msg);
  241.             }
  242.             else
  243.             {
  244.                 if (Current != Direction.NONE & Resizeable)
  245.                 {
  246.                     Capture = false;
  247.                     IntPtr Val = new IntPtr(Convert.ToInt32(Current));
  248.                     IntPtr NULL = IntPtr.Zero;
  249.                     Message msg = Message.Create(Parent.Handle, 161, Val, NULL);
  250.                     DefWndProc(ref msg);
  251.                 }
  252.             }
  253.         }
  254.         base.OnMouseDown(e);
  255.     }
  256.     protected override void OnMouseMove(MouseEventArgs e)
  257.     {
  258.         if (Resizeable)
  259.             SetCurrent();
  260.         base.OnMouseMove(e);
  261.     }
  262.     protected override void OnSizeChanged(System.EventArgs e)
  263.     {
  264.         Invalidate();
  265.         base.OnSizeChanged(e);
  266.     }
  267.     private Rectangle Drag
  268.     {
  269.         get { return new Rectangle(7, 7, Width - 14, 35); }
  270.     }
  271.  
  272. }
  273. class FButton : Control
  274. {
  275.  
  276.     private bool Shadow_ = true;
  277.     public bool Shadow
  278.     {
  279.         get { return Shadow_; }
  280.         set
  281.         {
  282.             Shadow_ = value;
  283.             Invalidate();
  284.         }
  285.     }
  286.  
  287.     public FButton()
  288.     {
  289.         SetStyle((ControlStyles)8198, true);
  290.         Colors = new Pigment[] {
  291.             new Pigment("Border", 254, 133, 0),
  292.             new Pigment("Backcolor", 247, 247, 251),
  293.             new Pigment("Highlight", 255, 197, 19),
  294.             new Pigment("Gradient1", 255, 175, 12),
  295.             new Pigment("Gradient2", 255, 127, 1),
  296.             new Pigment("Text Color", Color.White),
  297.             new Pigment("Text Shadow", 30, 0, 0, 0)
  298.         };
  299.         Font = new Font("Verdana", 8);
  300.     }
  301.  
  302.     const byte Count = 7;
  303.     private Pigment[] C;
  304.     public Pigment[] Colors
  305.     {
  306.         get { return C; }
  307.         set
  308.         {
  309.             if (value.Length != Count)
  310.                 throw new IndexOutOfRangeException();
  311.  
  312.             P1 = new Pen(value[0].Value);
  313.             P2 = new Pen(value[2].Value);
  314.  
  315.             B1 = new SolidBrush(value[6].Value);
  316.             B2 = new SolidBrush(value[5].Value);
  317.  
  318.             C = value;
  319.             Invalidate();
  320.         }
  321.     }
  322.  
  323.     private Pen P1;
  324.     private Pen P2;
  325.     private SolidBrush B1;
  326.     private SolidBrush B2;
  327.     private LinearGradientBrush B3;
  328.     private Size SZ;
  329.  
  330.     private Point PT;
  331.     private Graphics G;
  332.     private Bitmap B;
  333.     protected override void OnPaint(PaintEventArgs e)
  334.     {
  335.         B = new Bitmap(Width, Height);
  336.         G = Graphics.FromImage(B);
  337.  
  338.         if (Down)
  339.         {
  340.             B3 = new LinearGradientBrush(ClientRectangle, C[4].Value, C[3].Value, 90f);
  341.         }
  342.         else
  343.         {
  344.             B3 = new LinearGradientBrush(ClientRectangle, C[3].Value, C[4].Value, 90f);
  345.         }
  346.         G.FillRectangle(B3, ClientRectangle);
  347.  
  348.         if (!string.IsNullOrEmpty(Text))
  349.         {
  350.             SZ = G.MeasureString(Text, Font).ToSize();
  351.             PT = new Point(Convert.ToInt32(Width / 2 - SZ.Width / 2), Convert.ToInt32(Height / 2 - SZ.Height / 2));
  352.             if (Shadow_)
  353.                 G.DrawString(Text, Font, B1, PT.X + 1, PT.Y + 1);
  354.             G.DrawString(Text, Font, B2, PT);
  355.         }
  356.  
  357.         G.DrawRectangle(P1, new Rectangle(0, 0, Width - 1, Height - 1));
  358.         G.DrawRectangle(P2, new Rectangle(1, 1, Width - 3, Height - 3));
  359.  
  360.         B.SetPixel(0, 0, C[1].Value);
  361.         B.SetPixel(Width - 1, 0, C[1].Value);
  362.         B.SetPixel(Width - 1, Height - 1, C[1].Value);
  363.         B.SetPixel(0, Height - 1, C[1].Value);
  364.  
  365.         e.Graphics.DrawImage(B, 0, 0);
  366.         B3.Dispose();
  367.         G.Dispose();
  368.         B.Dispose();
  369.     }
  370.  
  371.     private bool Down;
  372.     protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
  373.     {
  374.         if (e.Button == MouseButtons.Left)
  375.         {
  376.             Down = true;
  377.             Invalidate();
  378.         }
  379.         base.OnMouseDown(e);
  380.     }
  381.     protected override void OnMouseUp(System.Windows.Forms.MouseEventArgs e)
  382.     {
  383.         Down = false;
  384.         Invalidate();
  385.         base.OnMouseUp(e);
  386.     }
  387.  
  388. }
  389. class FProgressBar : Control
  390. {
  391.  
  392.     private double _Maximum = 100;
  393.     public double Maximum
  394.     {
  395.         get { return _Maximum; }
  396.         set
  397.         {
  398.             _Maximum = value;
  399.             Progress = _Current / value * 100;
  400.         }
  401.     }
  402.     private double _Current;
  403.     public double Current
  404.     {
  405.         get { return _Current; }
  406.         set { Progress = value / _Maximum * 100; }
  407.     }
  408.     private double _Progress;
  409.     public double Progress
  410.     {
  411.         get { return _Progress; }
  412.         set
  413.         {
  414.             if (value < 0)
  415.                 value = 0;
  416.             else
  417.                 if (value > 100)
  418.                     value = 100;
  419.             _Progress = value;
  420.             _Current = value * 0.01 * _Maximum;
  421.             Invalidate();
  422.         }
  423.     }
  424.  
  425.     public FProgressBar()
  426.     {
  427.         SetStyle((ControlStyles)8198, true);
  428.         Colors = new Pigment[] {
  429.             new Pigment("Border", 214, 214, 216),
  430.             new Pigment("Backcolor1", 247, 247, 251),
  431.             new Pigment("Backcolor2", 239, 239, 242),
  432.             new Pigment("Highlight", 100, 255, 255, 255),
  433.             new Pigment("Forecolor", 224, 224, 224),
  434.             new Pigment("Gloss", 130, 255, 255, 255)
  435.         };
  436.     }
  437.  
  438.     const byte Count = 6;
  439.     private Pigment[] C;
  440.     public Pigment[] Colors
  441.     {
  442.         get { return C; }
  443.         set
  444.         {
  445.             if (value.Length != Count)
  446.                 throw new IndexOutOfRangeException();
  447.  
  448.             P1 = new Pen(value[0].Value);
  449.             P2 = new Pen(value[3].Value);
  450.  
  451.             B1 = new SolidBrush(value[4].Value);
  452.  
  453.             CB = new ColorBlend();
  454.             CB.Colors = new Color[] {
  455.                 value[5].Value,
  456.                 Color.Transparent,
  457.                 Color.Transparent
  458.             };
  459.             CB.Positions = new float[]{
  460.                 0,
  461.                 0.3F,
  462.                 1
  463.             };
  464.  
  465.             C = value;
  466.             Invalidate();
  467.         }
  468.     }
  469.  
  470.     private Pen P1;
  471.     private Pen P2;
  472.     private SolidBrush B1;
  473.     private LinearGradientBrush B2;
  474.  
  475.     private ColorBlend CB;
  476.     private Graphics G;
  477.     private Bitmap B;
  478.     protected override void OnPaint(PaintEventArgs e)
  479.     {
  480.         B = new Bitmap(Width, Height);
  481.         G = Graphics.FromImage(B);
  482.  
  483.         G.Clear(C[2].Value);
  484.  
  485.         G.FillRectangle(B1, new Rectangle(1, 1, Convert.ToInt32((Width * _Progress * 0.01) - 2), Height - 2));
  486.  
  487.         B2 = new LinearGradientBrush(ClientRectangle, Color.Empty, Color.Empty, 90f);
  488.         B2.InterpolationColors = CB;
  489.         G.FillRectangle(B2, ClientRectangle);
  490.  
  491.         G.DrawRectangle(P1, new Rectangle(0, 0, Width - 1, Height - 1));
  492.         G.DrawRectangle(P2, new Rectangle(1, 1, Width - 3, Height - 3));
  493.  
  494.         B.SetPixel(0, 0, C[1].Value);
  495.         B.SetPixel(Width - 1, 0, C[1].Value);
  496.         B.SetPixel(Width - 1, Height - 1, C[1].Value);
  497.         B.SetPixel(0, Height - 1, C[1].Value);
  498.  
  499.         e.Graphics.DrawImage(B, 0, 0);
  500.         B2.Dispose();
  501.         G.Dispose();
  502.         B.Dispose();
  503.     }
  504.  
  505.     protected override void OnSizeChanged(EventArgs e)
  506.     {
  507.         Invalidate();
  508.         base.OnSizeChanged(e);
  509.     }
  510. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement