Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Drawing;
- using System.Windows.Forms;
- using System.Drawing.Drawing2D;
- public static class Static
- {
- public static Font Font = new Font("Helvetica", 9, FontStyle.Bold);
- public static StringFormat Format = new StringFormat { LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Center };
- public static GraphicsPath RoundRect(Rectangle Rectangle, int Curve)
- {
- var P = new GraphicsPath();
- var ArcRectangleWidth = Curve * 2;
- P.AddArc(new Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90);
- P.AddArc(new Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90);
- P.AddArc(new Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90);
- P.AddArc(new Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90);
- P.AddLine(new Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), new Point(Rectangle.X, Curve + Rectangle.Y));
- return P;
- }
- public static GraphicsPath RoundRect(int X, int Y, int Width, int Height, int Curve)
- {
- var Rectangle = new Rectangle(X, Y, Width, Height);
- var P = new GraphicsPath();
- int ArcRectangleWidth = Curve * 2;
- P.AddArc(new Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90);
- P.AddArc(new Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90);
- P.AddArc(new Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90);
- P.AddArc(new Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90);
- P.AddLine(new Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), new Point(Rectangle.X, Curve + Rectangle.Y));
- return P;
- }
- }
- public class Facebook_WhiteButton : Control
- {
- private bool IsMouseDown = false;
- private SolidBrush TB;
- public Facebook_WhiteButton()
- {
- SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);
- Size = new Size(131, 25);
- Font = Static.Font;
- TB = new SolidBrush(Color.FromArgb(102, 102, 102));
- }
- protected override void OnPaint(PaintEventArgs e)
- {
- var G = e.Graphics;
- G.Clear(Color.White);
- if (IsMouseDown)
- {
- G.FillPath(new SolidBrush(Color.White), Static.RoundRect(new Rectangle(0, 0, Width - 1, Height), 2));
- G.DrawPath(new Pen(Color.FromArgb(225, 226, 228)), Static.RoundRect(new Rectangle(0, 0, Width - 1, Height - 2), 2));
- G.DrawLine(new Pen(Color.FromArgb(202, 203, 205)), new Point(0, Height), new Point(Width, Height));
- G.DrawLine(new Pen(Color.FromArgb(242, 243, 245)), new Point(1, Height - 1), new Point(Width - 2, Height - 1));
- }
- else
- {
- G.FillPath(new SolidBrush(Color.FromArgb(249, 250, 251)), Static.RoundRect(new Rectangle(0, 0, Width - 1, Height), 2));
- G.DrawPath(new Pen(Color.FromArgb(205, 206, 208)), Static.RoundRect(new Rectangle(0, 0, Width - 1, Height - 2), 2));
- G.DrawLine(new Pen(Color.FromArgb(232, 233, 235)), new Point(1, Height - 1), new Point(Width - 2, Height - 1));
- }
- G.DrawString(Text, Font, TB, Bounds, Static.Format);
- }
- protected override void OnMouseDown(MouseEventArgs e)
- {
- IsMouseDown = true;
- Invalidate();
- base.OnMouseDown(e);
- }
- protected override void OnMouseUp(MouseEventArgs e)
- {
- IsMouseDown = false;
- Invalidate();
- base.OnMouseUp(e);
- }
- }
- public class Facebook_BlueButton : Control
- {
- private bool IsMouseDown = false;
- private Color G1, G2;
- private LinearGradientBrush B;
- public Facebook_BlueButton()
- {
- SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);
- Size = new Size(131, 25);
- ForeColor = Color.LightGray;
- Font = Static.Font;
- G1 = Color.FromArgb(99, 123, 173);
- G2 = Color.FromArgb(79, 103, 153);
- }
- protected override void OnPaint(PaintEventArgs e)
- {
- var G = e.Graphics;
- G.Clear(Color.White);
- if (IsMouseDown)
- {
- B = new LinearGradientBrush(new Point(0, 0), new Point(0, Height), G2, G1);
- }
- else
- {
- B = new LinearGradientBrush(new Point(0, 0), new Point(0, Height), G1, G2);
- G.DrawLine(new Pen(Color.FromArgb(119, 142, 193)), new Point(1, 1), new Point(Width - 2, 1));
- }
- G.FillPath(B, Static.RoundRect(new Rectangle(0, 0, Width - 1, Height), 2));
- G.DrawPath(new Pen(Color.FromArgb(29, 56, 113)), Static.RoundRect(new Rectangle(0, 0, Width - 1, Height - 1), 2));
- G.DrawString(Text, Font, Brushes.White, Bounds, Static.Format);
- }
- protected override void OnMouseDown(MouseEventArgs e)
- {
- IsMouseDown = true;
- Invalidate();
- base.OnMouseDown(e);
- }
- protected override void OnMouseUp(MouseEventArgs e)
- {
- IsMouseDown = false;
- Invalidate();
- base.OnMouseUp(e);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement