Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class VSTheme : Control
- {
- private int _TitleHeight = 23;
- public int TitleHeight
- {
- get
- {
- return _TitleHeight;
- }
- set
- {
- if (value > Height)
- {
- value = Height;
- }
- if (value < 2)
- {
- Height = 1;
- }
- _TitleHeight = value;
- Invalidate();
- }
- }
- private HorizontalAlignment _TitleAlign;
- public HorizontalAlignment TitleAlign
- {
- get
- {
- return _TitleAlign;
- }
- set
- {
- _TitleAlign = value;
- Invalidate();
- }
- }
- public VSTheme()
- {
- using (Bitmap B = new Bitmap(3, 3))
- {
- using (var G = Graphics.FromImage(B))
- {
- G.Clear(Color.FromArgb(53, 67, 88));
- G.DrawLine(new Pen(Color.FromArgb(33, 46, 67)), 0, 0, 2, 2);
- Tile = (Image)B.Clone();
- }
- }
- }
- protected override void OnTextChanged(System.EventArgs e)
- {
- Invalidate();
- base.OnTextChanged(e);
- }
- protected override void OnHandleCreated(System.EventArgs e)
- {
- Dock = (DockStyle)5;
- if (Parent is Form)
- {
- ((Form)Parent).FormBorderStyle = 0;
- ((Form)Parent).TransparencyKey = Color.Fuchsia;
- }
- base.OnHandleCreated(e);
- }
- protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
- {
- if (new Rectangle(Parent.Location.X, Parent.Location.Y, Width - 1, _TitleHeight - 1).IntersectsWith(new Rectangle(MousePosition.X, MousePosition.Y, 1, 1)))
- {
- Capture = false;
- var M = Message.Create(Parent.Handle, 161, (IntPtr)2, (IntPtr)0);
- DefWndProc(ref M);
- }
- base.OnMouseDown(e);
- }
- private Color C1 = Color.FromArgb(249, 245, 226);
- private Color C2 = Color.FromArgb(255, 232, 165);
- private Color C3 = Color.FromArgb(64, 90, 127);
- private Image Tile;
- protected override void OnPaintBackground(System.Windows.Forms.PaintEventArgs pevent)
- {
- }
- protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
- {
- using (Bitmap B = new Bitmap(Width, Height))
- {
- using (var G = Graphics.FromImage(B))
- {
- using (TextureBrush T = new TextureBrush(Tile, 0))
- {
- G.FillRectangle(T, 0, _TitleHeight, Width, Height - _TitleHeight);
- }
- Draw.Blend(G, Color.Transparent, Color.Transparent, C3, 0.1F, 1, 0, 0, Width, Height - _TitleHeight * 2);
- G.FillRectangle(new SolidBrush(C3), 0, Height - _TitleHeight * 2, Width, _TitleHeight * 2);
- Draw.Gradient(G, C1, C2, 0, 0, Width, _TitleHeight);
- G.FillRectangle(new SolidBrush(Color.FromArgb(100, 255, 255, 255)), 0, 0, Width, System.Convert.ToInt32(_TitleHeight / 2.0));
- G.DrawRectangle(new Pen(C2, 2F), 1, _TitleHeight - 1, Width - 2, Height - _TitleHeight);
- G.DrawArc(new Pen(Color.Fuchsia, 2F), -1, -1, 9, 9, 180, 90);
- G.DrawArc(new Pen(Color.Fuchsia, 2F), Width - 9, -1, 9, 9, 270, 90);
- G.TextRenderingHint = (TextRenderingHint)5;
- var S = G.MeasureString(Text, Font);
- var O = 6;
- if ((int)_TitleAlign == 2)
- {
- O = Width / 2 - (int)S.Width / 2;
- }
- if ((int)_TitleAlign == 1)
- {
- O = Width - (int)S.Width - 6;
- }
- G.DrawString(Text, Font, new SolidBrush(Color.FromArgb(111, 88, 38)), O, System.Convert.ToInt32(_TitleHeight / 2.0 - S.Height / 2.0));
- e.Graphics.DrawImage((Image)B.Clone(), 0, 0);
- }
- }
- }
- }
- public class VSButton : Control
- {
- public VSButton()
- {
- ForeColor = C3;
- }
- private int State;
- protected override void OnMouseEnter(System.EventArgs e)
- {
- State = 1;
- Invalidate();
- base.OnMouseEnter(e);
- }
- protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
- {
- State = 2;
- Invalidate();
- base.OnMouseDown(e);
- }
- protected override void OnMouseLeave(System.EventArgs e)
- {
- State = 0;
- Invalidate();
- base.OnMouseLeave(e);
- }
- protected override void OnMouseUp(System.Windows.Forms.MouseEventArgs e)
- {
- State = 1;
- Invalidate();
- base.OnMouseUp(e);
- }
- private Color C1 = Color.FromArgb(249, 245, 226);
- private Color C2 = Color.FromArgb(255, 232, 165);
- private Color C3 = Color.FromArgb(111, 88, 38);
- protected override void OnPaintBackground(System.Windows.Forms.PaintEventArgs pevent)
- {
- }
- protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
- {
- using (Bitmap B = new Bitmap(Width, Height))
- {
- using (var G = Graphics.FromImage(B))
- {
- if (State == 2)
- {
- Draw.Gradient(G, C2, C1, 0, 0, Width, Height);
- }
- else
- {
- Draw.Gradient(G, C1, C2, 0, 0, Width, Height);
- }
- if (State < 2)
- {
- G.FillRectangle(new SolidBrush(Color.FromArgb(100, 255, 255, 255)), 0, 0, Width, System.Convert.ToInt32(Height / 2));
- }
- G.TextRenderingHint = (TextRenderingHint)5;
- var S = G.MeasureString(Text, Font);
- G.DrawString(Text, Font, new SolidBrush(ForeColor), Width / 2 - S.Width / 2, Height / 2 - S.Height / 2);
- G.DrawRectangle(new Pen(C1), 0, 0, Width - 1, Height - 1);
- e.Graphics.DrawImage((Image)B.Clone(), 0, 0);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement