Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Pearl Theme
- public class PTheme : Control
- {
- private int _TitleHeight = 25;
- 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();
- }
- }
- protected override void OnHandleCreated(System.EventArgs e)
- {
- Dock = (DockStyle)5;
- if (Parent is Form)
- {
- ((Form)Parent).FormBorderStyle = 0;
- }
- 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, new IntPtr(2), new IntPtr(0));
- DefWndProc(ref M);
- }
- base.OnMouseDown(e);
- }
- private Color C1 = Color.FromArgb(240, 240, 240);
- private Color C2 = Color.FromArgb(230, 230, 230);
- private Color C3 = Color.FromArgb(190, 190, 190);
- 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))
- {
- G.Clear(Color.FromArgb(245, 245, 245));
- Draw.Blend(G, Color.White, C2, C1, 0.7F, 1, 0, 0, Width, _TitleHeight);
- G.FillRectangle(new SolidBrush(Color.FromArgb(80, 255, 255, 255)), 0, 0, Width, System.Convert.ToInt32(_TitleHeight / 2.0));
- G.DrawRectangle(new Pen(Color.FromArgb(100, 255, 255, 255)), 1, 1, Width - 3, _TitleHeight - 2);
- 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(C3), O, System.Convert.ToInt32(_TitleHeight / 2.0 - S.Height / 2.0));
- G.DrawLine(new Pen(C3), 0, _TitleHeight, Width, _TitleHeight);
- G.DrawLine(Pens.White, 0, _TitleHeight + 1, Width, _TitleHeight + 1);
- G.DrawRectangle(new Pen(C3), 0, 0, Width - 1, Height - 1);
- e.Graphics.DrawImage((Image)B.Clone(), 0, 0);
- }
- }
- }
- }
- public class PButton : Control
- {
- public PButton()
- {
- 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(240, 240, 240);
- private Color C2 = Color.FromArgb(230, 230, 230);
- private Color C3 = Color.FromArgb(190, 190, 190);
- 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, Color.WhiteSmoke, 1, 1, Width, Height);
- }
- else
- {
- Draw.Gradient(G, Color.WhiteSmoke, C2, 1, 1, Width, Height);
- }
- if (State < 2)
- {
- G.FillRectangle(new SolidBrush(Color.FromArgb(80, 255, 255, 255)), 0, 0, Width, System.Convert.ToInt32(Height * 0.3));
- }
- 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(C3), 0, 0, Width - 1, Height - 1);
- e.Graphics.DrawImage((Image)B.Clone(), 0, 0);
- }
- }
- }
- }
- public class PProgress : Control
- {
- private int _Value;
- public int Value
- {
- get
- {
- return _Value;
- }
- set
- {
- _Value = value;
- Invalidate();
- }
- }
- private int _Maximum = 100;
- public int Maximum
- {
- get
- {
- return _Maximum;
- }
- set
- {
- if (value == 0)
- {
- value = 1;
- }
- _Maximum = value;
- Invalidate();
- }
- }
- private Color C1 = Color.FromArgb(240, 240, 240);
- private Color C2 = Color.FromArgb(230, 230, 230);
- private Color C3 = Color.FromArgb(190, 190, 190);
- protected override void OnPaintBackground(System.Windows.Forms.PaintEventArgs pevent)
- {
- }
- protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
- {
- int V = Width * _Value / _Maximum;
- using (Bitmap B = new Bitmap(Width, Height))
- {
- using (var G = Graphics.FromImage(B))
- {
- Draw.Gradient(G, C2, C1, 1, 1, Width - 2, Height - 2);
- G.DrawRectangle(new Pen(C2), 1, 1, V - 3, Height - 3);
- Draw.Gradient(G, C1, C2, 2, 2, V - 4, Height - 4);
- G.FillRectangle(new SolidBrush(Color.FromArgb(50, 255, 255, 255)), 2, 2, V - 4, System.Convert.ToInt32(Height / 2) - 2);
- G.DrawRectangle(new Pen(C3), 0, 0, Width - 1, Height - 1);
- e.Graphics.DrawImage((Image)B.Clone(), (float)0, (float)0);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement