Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Complex Theme
- //By: FoSho
- //ThemeBase: Aeonhack
- using System;
- using System.IO;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Windows.Forms;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- abstract class ThemeContainer151 : ContainerControl
- {
- protected Graphics G;
- ThemeContainer151()
- {
- SetStyle((ControlStyles)139270, true);
- _ImageSize = Size.Empty;
- MeasureBitmap = new Bitmap(1, 1);
- MeasureGraphics = Graphics.FromImage(MeasureBitmap);
- Font = new Font("Verdana", 8);
- InvalidateCustimization();
- }
- protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)
- {
- if (!_LockWidth == 0) width = _LockWidth;
- if (!_LockHeight == 0) height = _LockHeight;
- base.SetBoundsCore(x, y, width, height, specified);
- }
- private Rectangle Header;
- protected override sealed void OnSizeChanged(EventArgs e)
- {
- base.OnSizeChanged(e);
- if (_Movable && !_ControlMode) Header = new Rectangle(7, 7, Width - 14, _MoveHeight - 7);
- Invalidate();
- }
- protected override sealed void OnPaint(PaintEventArgs e)
- {
- if (Width == 0 || Height == 0) return;
- G = e.Graphics;
- PaintHook();
- }
- protected override sealed void OnHandleCreated(EventArgs e)
- {
- InitializeMessages();
- InvalidateCustimization();
- ColorHook();
- _IsParentForm = Parent is Form;
- if (!_ControlMode) Dock = DockStyle.Fill;
- if (!_LockWidth == 0) Width = _LockWidth;
- if (!_LockHeight == 0) Height = _LockHeight;
- if (!BackColorWait == null) BackColor = BackColorWait;
- if (_IsParentForm && !_ControlMode) {
- ParentForm.FormBorderStyle = _BorderStyle;
- ParentForm.TransparencyKey = _TransparencyKey;
- }
- OnCreation();
- base.OnHandleCreated(e);
- }
- protected virtual void OnCreation()
- {
- }
- protected MouseState State;
- private void SetState(MouseState current)
- {
- State = current;
- Invalidate();
- }
- protected override void OnMouseMove(MouseEventArgs e)
- {
- if (_Sizable && !_ControlMode) InvalidateMouse();
- base.OnMouseMove(e);
- }
- protected override void OnEnabledChanged(EventArgs e)
- {
- if (Enabled) SetState(MouseState.None); else SetState(MouseState.Block);
- base.OnEnabledChanged(e);
- }
- protected override void OnMouseEnter(EventArgs e)
- {
- SetState(MouseState.Over);
- base.OnMouseEnter(e);
- }
- protected override void OnMouseUp(MouseEventArgs e)
- {
- SetState(MouseState.Over);
- base.OnMouseUp(e);
- }
- protected override void OnMouseLeave(EventArgs e)
- {
- SetState(MouseState.None);
- if (_Sizable && !_ControlMode && GetChildAtPoint(PointToClient(MousePosition)) != null) {
- Cursor = Cursors.Default;
- Previous = 0;
- }
- base.OnMouseLeave(e);
- }
- protected override void OnMouseDown(MouseEventArgs e)
- {
- base.OnMouseDown(e);
- if (!e.Button == Windows.Forms.MouseButtons.Left) return;
- SetState(MouseState.Down);
- if (_IsParentForm && ParentForm.WindowState == FormWindowState.Maximized || _ControlMode) return;
- if (_Movable && Header.Contains(e.Location)) {
- Capture = false;
- DefWndProc(Messages(0));
- }
- else if (_Sizable && !Previous == 0) {
- Capture = false;
- DefWndProc(Messages(Previous));
- }
- }
- private Point GetIndexPoint;
- private bool B1;
- private bool B2;
- private bool B3;
- private bool B4;
- private int GetIndex()
- {
- GetIndexPoint = PointToClient(MousePosition);
- B1 = GetIndexPoint.X < 7;
- B2 = GetIndexPoint.X > Width - 7;
- B3 = GetIndexPoint.Y < 7;
- B4 = GetIndexPoint.Y > Height - 7;
- if (B1 && B3) return 4;
- if (B1 && B4) return 7;
- if (B2 && B3) return 5;
- if (B2 && B4) return 8;
- if (B1) return 1;
- if (B2) return 2;
- if (B3) return 3;
- if (B4) return 6;
- return 0;
- }
- private int Current;
- private int Previous;
- private void InvalidateMouse()
- {
- Current = GetIndex();
- if (Current == Previous) return;
- Previous = Current;
- switch (Previous) {
- case 0:
- Cursor = Cursors.Default;
- case 1:
- case 2:
- Cursor = Cursors.SizeWE;
- case 3:
- case 6:
- Cursor = Cursors.SizeNS;
- case 4:
- case 8:
- Cursor = Cursors.SizeNWSE;
- case 5:
- case 7:
- Cursor = Cursors.SizeNESW;
- }
- }
- private Message[] Messages = new Message[8];
- private void InitializeMessages()
- {
- Messages(0) = Message.Create(Parent.Handle, 161, new IntPtr(2), IntPtr.Zero);
- for (int I = 1; I <= 8; I++) {
- Messages(I) = Message.Create(Parent.Handle, 161, new IntPtr(I + 9), IntPtr.Zero);
- }
- }
- private Color BackColorWait;
- override Color BackColor {
- get { return base.BackColor; }
- set {
- if (IsHandleCreated) {
- if (!_ControlMode) Parent.BackColor = value;
- base.BackColor = value;
- }
- else {
- BackColorWait = value;
- }
- }
- }
- [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- override Color ForeColor {
- get { return Color.Empty; }
- set { }
- }
- [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- override Image BackgroundImage {
- get { return null; }
- set { }
- }
- [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- override ImageLayout BackgroundImageLayout {
- get { return ImageLayout.None; }
- set { }
- }
- override string Text {
- get { return base.Text; }
- set {
- base.Text = value;
- Invalidate();
- }
- }
- override Font Font {
- get { return base.Font; }
- set {
- base.Font = value;
- Invalidate();
- }
- }
- private bool _Movable = true;
- bool Movable {
- get { return _Movable; }
- set { _Movable = value; }
- }
- private bool _Sizable = true;
- bool Sizable {
- get { return _Sizable; }
- set { _Sizable = value; }
- }
- private int _MoveHeight = 24;
- protected int MoveHeight {
- get { return _MoveHeight; }
- set {
- if (v < 8) return;
- Header = new Rectangle(7, 7, Width - 14, v - 7);
- _MoveHeight = v;
- Invalidate();
- }
- }
- private bool _ControlMode;
- protected bool ControlMode {
- get { return _ControlMode; }
- set { _ControlMode = v; }
- }
- private Color _TransparencyKey;
- Color TransparencyKey {
- get {
- if (_IsParentForm && !_ControlMode) return ParentForm.TransparencyKey; else return _TransparencyKey;
- }
- set {
- if (_IsParentForm && !_ControlMode) ParentForm.TransparencyKey = value;
- _TransparencyKey = value;
- }
- }
- private FormBorderStyle _BorderStyle;
- FormBorderStyle BorderStyle {
- get {
- if (_IsParentForm && !_ControlMode) return ParentForm.FormBorderStyle; else return _BorderStyle;
- }
- set {
- if (_IsParentForm && !_ControlMode) ParentForm.FormBorderStyle = value;
- _BorderStyle = value;
- }
- }
- private bool _NoRounding;
- bool NoRounding {
- get { return _NoRounding; }
- set {
- _NoRounding = v;
- Invalidate();
- }
- }
- private Image _Image;
- Image Image {
- get { return _Image; }
- set {
- if (value == null) {
- _ImageSize = Size.Empty;
- }
- else {
- _ImageSize = value.Size;
- }
- _Image = value;
- Invalidate();
- }
- }
- private Size _ImageSize;
- protected Size ImageSize {
- get { return _ImageSize; }
- }
- private bool _IsParentForm;
- protected bool IsParentForm {
- get { return _IsParentForm; }
- }
- private int _LockWidth;
- protected int LockWidth {
- get { return _LockWidth; }
- set {
- _LockWidth = value;
- if (!LockWidth == 0 && IsHandleCreated) Width = LockWidth;
- }
- }
- private int _LockHeight;
- protected int LockHeight {
- get { return _LockHeight; }
- set {
- _LockHeight = value;
- if (!LockHeight == 0 && IsHandleCreated) Height = LockHeight;
- }
- }
- private Dictionary<string, Color> Items = new Dictionary<string, Color>();
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
- Bloom[] Colors {
- get {
- List<Bloom> T = new List<Bloom>();
- Dictionary<string, Color>.Enumerator E = Items.GetEnumerator;
- while (E.MoveNext) {
- T.Add(new Bloom(E.Current.Key, E.Current.Value));
- }
- return T.ToArray;
- }
- set {
- foreach (Bloom B in value) {
- if (Items.ContainsKey(B.Name)) Items(B.Name) = B.Value;
- }
- InvalidateCustimization();
- ColorHook();
- Invalidate();
- }
- }
- private string _Customization;
- string Customization {
- get { return _Customization; }
- set {
- if (value == _Customization) return;
- byte[] Data;
- Bloom[] Items = Colors;
- try {
- Data = Convert.FromBase64String(value);
- for (int I = 0; I <= Items.Length - 1; I++) {
- Items(I).Value = Color.FromArgb(BitConverter.ToInt32(Data, I * 4));
- }
- }
- catch {
- return;
- }
- _Customization = value;
- Colors = Items;
- ColorHook();
- Invalidate();
- }
- }
- protected Color GetColor(string name)
- {
- return Items(name);
- }
- protected void SetColor(string name, Color color)
- {
- if (Items.ContainsKey(name)) Items(name) = color; else Items.Add(name, color);
- }
- protected void SetColor(string name, byte r, byte g, byte b)
- {
- SetColor(name, Color.FromArgb(r, g, b));
- }
- protected void SetColor(string name, byte a, byte r, byte g, byte b)
- {
- SetColor(name, Color.FromArgb(a, r, g, b));
- }
- protected void SetColor(string name, byte a, Color color)
- {
- SetColor(name, color.FromArgb(a, color));
- }
- private void InvalidateCustimization()
- {
- MemoryStream M = new MemoryStream(Items.Count * 4);
- foreach (Bloom B in Colors) {
- M.Write(BitConverter.GetBytes(B.Value.ToArgb), 0, 4);
- }
- M.Close();
- _Customization = Convert.ToBase64String(M.ToArray);
- }
- protected abstract void ColorHook();
- protected abstract void PaintHook();
- private Point CenterReturn;
- protected Point Center(Rectangle r1, Size s1)
- {
- CenterReturn = new Point((r1.Width / 2 - s1.Width / 2) + r1.X, (r1.Height / 2 - s1.Height / 2) + r1.Y);
- return CenterReturn;
- }
- protected Point Center(Rectangle r1, Rectangle r2)
- {
- return Center(r1, r2.Size);
- }
- protected Point Center(int w1, int h1, int w2, int h2)
- {
- CenterReturn = new Point(w1 / 2 - w2 / 2, h1 / 2 - h2 / 2);
- return CenterReturn;
- }
- protected Point Center(Size s1, Size s2)
- {
- return Center(s1.Width, s1.Height, s2.Width, s2.Height);
- }
- protected Point Center(Rectangle r1)
- {
- return Center(ClientRectangle.Width, ClientRectangle.Height, r1.Width, r1.Height);
- }
- protected Point Center(Size s1)
- {
- return Center(Width, Height, s1.Width, s1.Height);
- }
- protected Point Center(int w1, int h1)
- {
- return Center(Width, Height, w1, h1);
- }
- private Bitmap MeasureBitmap;
- private Graphics MeasureGraphics;
- protected Size Measure(string text)
- {
- return MeasureGraphics.MeasureString(text, Font, Width).ToSize;
- }
- protected Size Measure()
- {
- return MeasureGraphics.MeasureString(Text, Font).ToSize;
- }
- private SolidBrush DrawCornersBrush;
- protected void DrawCorners(Color c1)
- {
- DrawCorners(c1, 0, 0, Width, Height);
- }
- protected void DrawCorners(Color c1, Rectangle r1)
- {
- DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height);
- }
- protected void DrawCorners(Color c1, int x, int y, int width, int height)
- {
- if (_NoRounding) return;
- DrawCornersBrush = new SolidBrush(c1);
- G.FillRectangle(DrawCornersBrush, x, y, 1, 1);
- G.FillRectangle(DrawCornersBrush, x + (width - 1), y, 1, 1);
- G.FillRectangle(DrawCornersBrush, x, y + (height - 1), 1, 1);
- G.FillRectangle(DrawCornersBrush, x + (width - 1), y + (height - 1), 1, 1);
- }
- protected void DrawBorders(Pen p1, int x, int y, int width, int height, int offset)
- {
- DrawBorders(p1, x + offset, y + offset, width - (offset * 2), height - (offset * 2));
- }
- protected void DrawBorders(Pen p1, int offset)
- {
- DrawBorders(p1, 0, 0, Width, Height, offset);
- }
- protected void DrawBorders(Pen p1, Rectangle r, int offset)
- {
- DrawBorders(p1, r.X, r.Y, r.Width, r.Height, offset);
- }
- protected void DrawBorders(Pen p1, int x, int y, int width, int height)
- {
- G.DrawRectangle(p1, x, y, width - 1, height - 1);
- }
- protected void DrawBorders(Pen p1)
- {
- DrawBorders(p1, 0, 0, Width, Height);
- }
- protected void DrawBorders(Pen p1, Rectangle r)
- {
- DrawBorders(p1, r.X, r.Y, r.Width, r.Height);
- }
- private Point DrawTextPoint;
- private Size DrawTextSize;
- protected void DrawText(Brush b1, HorizontalAlignment a, int x, int y)
- {
- DrawText(b1, Text, a, x, y);
- }
- protected void DrawText(Brush b1, Point p1)
- {
- DrawText(b1, Text, p1.X, p1.Y);
- }
- protected void DrawText(Brush b1, int x, int y)
- {
- DrawText(b1, Text, x, y);
- }
- protected void DrawText(Brush b1, string text, HorizontalAlignment a, int x, int y)
- {
- if (text.Length == 0) return;
- DrawTextSize = Measure(text);
- DrawTextPoint = new Point(Width / 2 - DrawTextSize.Width / 2, MoveHeight / 2 - DrawTextSize.Height / 2);
- switch (a) {
- case HorizontalAlignment.Left:
- DrawText(b1, text, x, DrawTextPoint.Y + y);
- case HorizontalAlignment.Center:
- DrawText(b1, text, DrawTextPoint.X + x, DrawTextPoint.Y + y);
- case HorizontalAlignment.Right:
- DrawText(b1, text, Width - DrawTextSize.Width - x, DrawTextPoint.Y + y);
- }
- }
- protected void DrawText(Brush b1, string text, Point p1)
- {
- DrawText(b1, text, p1.X, p1.Y);
- }
- protected void DrawText(Brush b1, string text, int x, int y)
- {
- if (text.Length == 0) return;
- G.DrawString(text, Font, b1, x, y);
- }
- private Point DrawImagePoint;
- protected void DrawImage(HorizontalAlignment a, int x, int y)
- {
- DrawImage(_Image, a, x, y);
- }
- protected void DrawImage(Point p1)
- {
- DrawImage(_Image, p1.X, p1.Y);
- }
- protected void DrawImage(int x, int y)
- {
- DrawImage(_Image, x, y);
- }
- protected void DrawImage(Image image, HorizontalAlignment a, int x, int y)
- {
- if (image == null) return;
- DrawImagePoint = new Point(Width / 2 - image.Width / 2, MoveHeight / 2 - image.Height / 2);
- switch (a) {
- case HorizontalAlignment.Left:
- DrawImage(image, x, DrawImagePoint.Y + y);
- case HorizontalAlignment.Center:
- DrawImage(image, DrawImagePoint.X + x, DrawImagePoint.Y + y);
- case HorizontalAlignment.Right:
- DrawImage(image, Width - image.Width - x, DrawImagePoint.Y + y);
- }
- }
- protected void DrawImage(Image image, Point p1)
- {
- DrawImage(image, p1.X, p1.Y);
- }
- protected void DrawImage(Image image, int x, int y)
- {
- if (image == null) return;
- G.DrawImage(image, x, y, image.Width, image.Height);
- }
- private LinearGradientBrush DrawGradientBrush;
- private Rectangle DrawGradientRectangle;
- protected void DrawGradient(ColorBlend blend, int x, int y, int width, int height)
- {
- DrawGradient(blend, x, y, width, height, 90);
- }
- protected void DrawGradient(Color c1, Color c2, int x, int y, int width, int height)
- {
- DrawGradient(c1, c2, x, y, width, height, 90);
- }
- protected void DrawGradient(ColorBlend blend, int x, int y, int width, int height, float angle)
- {
- DrawGradientRectangle = new Rectangle(x, y, width, height);
- DrawGradient(blend, DrawGradientRectangle, angle);
- }
- protected void DrawGradient(Color c1, Color c2, int x, int y, int width, int height, float angle)
- {
- DrawGradientRectangle = new Rectangle(x, y, width, height);
- DrawGradient(c1, c2, DrawGradientRectangle, angle);
- }
- protected void DrawGradient(ColorBlend blend, Rectangle r, float angle)
- {
- DrawGradientBrush = new LinearGradientBrush(r, Color.Empty, Color.Empty, angle);
- DrawGradientBrush.InterpolationColors = blend;
- G.FillRectangle(DrawGradientBrush, r);
- }
- protected void DrawGradient(Color c1, Color c2, Rectangle r, float angle)
- {
- DrawGradientBrush = new LinearGradientBrush(r, c1, c2, angle);
- G.FillRectangle(DrawGradientBrush, r);
- }
- }
- abstract class ThemeControl151 : Control
- {
- protected Graphics G;
- protected Bitmap B;
- ThemeControl151()
- {
- SetStyle((ControlStyles)139270, true);
- _ImageSize = Size.Empty;
- MeasureBitmap = new Bitmap(1, 1);
- MeasureGraphics = Graphics.FromImage(MeasureBitmap);
- Font = new Font("Verdana", 8);
- InvalidateCustimization();
- }
- protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)
- {
- if (!_LockWidth == 0) width = _LockWidth;
- if (!_LockHeight == 0) height = _LockHeight;
- base.SetBoundsCore(x, y, width, height, specified);
- }
- protected override sealed void OnSizeChanged(EventArgs e)
- {
- if (_Transparent && !(Width == 0 || Height == 0)) {
- B = new Bitmap(Width, Height);
- G = Graphics.FromImage(B);
- }
- Invalidate();
- base.OnSizeChanged(e);
- }
- protected override sealed void OnPaint(PaintEventArgs e)
- {
- if (Width == 0 || Height == 0) return;
- if (_Transparent) {
- PaintHook();
- e.Graphics.DrawImage(B, 0, 0);
- }
- else {
- G = e.Graphics;
- PaintHook();
- }
- }
- protected override void OnHandleCreated(EventArgs e)
- {
- InvalidateCustimization();
- ColorHook();
- if (!_LockWidth == 0) Width = _LockWidth;
- if (!_LockHeight == 0) Height = _LockHeight;
- if (!BackColorWait == null) BackColor = BackColorWait;
- OnCreation();
- base.OnHandleCreated(e);
- }
- protected virtual void OnCreation()
- {
- }
- protected override void OnMouseEnter(EventArgs e)
- {
- SetState(MouseState.Over);
- base.OnMouseEnter(e);
- }
- protected override void OnMouseUp(MouseEventArgs e)
- {
- SetState(MouseState.Over);
- base.OnMouseUp(e);
- }
- protected override void OnMouseDown(MouseEventArgs e)
- {
- if (e.Button == Windows.Forms.MouseButtons.Left) SetState(MouseState.Down);
- base.OnMouseDown(e);
- }
- protected override void OnMouseLeave(EventArgs e)
- {
- SetState(MouseState.None);
- base.OnMouseLeave(e);
- }
- protected override void OnEnabledChanged(EventArgs e)
- {
- if (Enabled) SetState(MouseState.None); else SetState(MouseState.Block);
- base.OnEnabledChanged(e);
- }
- protected MouseState State;
- private void SetState(MouseState current)
- {
- State = current;
- Invalidate();
- }
- private Color BackColorWait;
- override Color BackColor {
- get { return base.BackColor; }
- set {
- if (IsHandleCreated) {
- base.BackColor = value;
- }
- else {
- BackColorWait = value;
- }
- }
- }
- [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- override Color ForeColor {
- get { return Color.Empty; }
- set { }
- }
- [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- override Image BackgroundImage {
- get { return null; }
- set { }
- }
- [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- override ImageLayout BackgroundImageLayout {
- get { return ImageLayout.None; }
- set { }
- }
- override string Text {
- get { return base.Text; }
- set {
- base.Text = value;
- Invalidate();
- }
- }
- override Font Font {
- get { return base.Font; }
- set {
- base.Font = value;
- Invalidate();
- }
- }
- private bool _NoRounding;
- bool NoRounding {
- get { return _NoRounding; }
- set {
- _NoRounding = v;
- Invalidate();
- }
- }
- private Image _Image;
- Image Image {
- get { return _Image; }
- set {
- if (value == null) {
- _ImageSize = Size.Empty;
- }
- else {
- _ImageSize = value.Size;
- }
- _Image = value;
- Invalidate();
- }
- }
- private Size _ImageSize;
- protected Size ImageSize {
- get { return _ImageSize; }
- }
- private int _LockWidth;
- protected int LockWidth {
- get { return _LockWidth; }
- set {
- _LockWidth = value;
- if (!LockWidth == 0 && IsHandleCreated) Width = LockWidth;
- }
- }
- private int _LockHeight;
- protected int LockHeight {
- get { return _LockHeight; }
- set {
- _LockHeight = value;
- if (!LockHeight == 0 && IsHandleCreated) Height = LockHeight;
- }
- }
- private bool _Transparent;
- bool Transparent {
- get { return _Transparent; }
- set {
- if (!value && !BackColor.A == 255) {
- throw new Exception("Unable to change value to false while a transparent BackColor is in use.");
- }
- SetStyle(ControlStyles.Opaque, !value);
- SetStyle(ControlStyles.SupportsTransparentBackColor, value);
- if (value) InvalidateBitmap(); else B = null;
- _Transparent = value;
- Invalidate();
- }
- }
- private Dictionary<string, Color> Items = new Dictionary<string, Color>();
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
- Bloom[] Colors {
- get {
- List<Bloom> T = new List<Bloom>();
- Dictionary<string, Color>.Enumerator E = Items.GetEnumerator;
- while (E.MoveNext) {
- T.Add(new Bloom(E.Current.Key, E.Current.Value));
- }
- return T.ToArray;
- }
- set {
- foreach (Bloom B in value) {
- if (Items.ContainsKey(B.Name)) Items(B.Name) = B.Value;
- }
- InvalidateCustimization();
- ColorHook();
- Invalidate();
- }
- }
- private string _Customization;
- string Customization {
- get { return _Customization; }
- set {
- if (value == _Customization) return;
- byte[] Data;
- Bloom[] Items = Colors;
- try {
- Data = Convert.FromBase64String(value);
- for (int I = 0; I <= Items.Length - 1; I++) {
- Items(I).Value = Color.FromArgb(BitConverter.ToInt32(Data, I * 4));
- }
- }
- catch {
- return;
- }
- _Customization = value;
- Colors = Items;
- ColorHook();
- Invalidate();
- }
- }
- private void InvalidateBitmap()
- {
- if (Width == 0 || Height == 0) return;
- B = new Bitmap(Width, Height);
- G = Graphics.FromImage(B);
- }
- protected Color GetColor(string name)
- {
- return Items(name);
- }
- protected void SetColor(string name, Color color)
- {
- if (Items.ContainsKey(name)) Items(name) = color; else Items.Add(name, color);
- }
- protected void SetColor(string name, byte r, byte g, byte b)
- {
- SetColor(name, Color.FromArgb(r, g, b));
- }
- protected void SetColor(string name, byte a, byte r, byte g, byte b)
- {
- SetColor(name, Color.FromArgb(a, r, g, b));
- }
- protected void SetColor(string name, byte a, Color color)
- {
- SetColor(name, color.FromArgb(a, color));
- }
- private void InvalidateCustimization()
- {
- MemoryStream M = new MemoryStream(Items.Count * 4);
- foreach (Bloom B in Colors) {
- M.Write(BitConverter.GetBytes(B.Value.ToArgb), 0, 4);
- }
- M.Close();
- _Customization = Convert.ToBase64String(M.ToArray);
- }
- protected abstract void ColorHook();
- protected abstract void PaintHook();
- private Point CenterReturn;
- protected Point Center(Rectangle r1, Size s1)
- {
- CenterReturn = new Point((r1.Width / 2 - s1.Width / 2) + r1.X, (r1.Height / 2 - s1.Height / 2) + r1.Y);
- return CenterReturn;
- }
- protected Point Center(Rectangle r1, Rectangle r2)
- {
- return Center(r1, r2.Size);
- }
- protected Point Center(int w1, int h1, int w2, int h2)
- {
- CenterReturn = new Point(w1 / 2 - w2 / 2, h1 / 2 - h2 / 2);
- return CenterReturn;
- }
- protected Point Center(Size s1, Size s2)
- {
- return Center(s1.Width, s1.Height, s2.Width, s2.Height);
- }
- protected Point Center(Rectangle r1)
- {
- return Center(ClientRectangle.Width, ClientRectangle.Height, r1.Width, r1.Height);
- }
- protected Point Center(Size s1)
- {
- return Center(Width, Height, s1.Width, s1.Height);
- }
- protected Point Center(int w1, int h1)
- {
- return Center(Width, Height, w1, h1);
- }
- private Bitmap MeasureBitmap;
- private Graphics MeasureGraphics;
- protected Size Measure(string text)
- {
- return MeasureGraphics.MeasureString(text, Font, Width).ToSize;
- }
- protected Size Measure()
- {
- return MeasureGraphics.MeasureString(Text, Font, Width).ToSize;
- }
- private SolidBrush DrawCornersBrush;
- protected void DrawCorners(Color c1)
- {
- DrawCorners(c1, 0, 0, Width, Height);
- }
- protected void DrawCorners(Color c1, Rectangle r1)
- {
- DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height);
- }
- protected void DrawCorners(Color c1, int x, int y, int width, int height)
- {
- if (_NoRounding) return;
- if (_Transparent) {
- B.SetPixel(x, y, c1);
- B.SetPixel(x + (width - 1), y, c1);
- B.SetPixel(x, y + (height - 1), c1);
- B.SetPixel(x + (width - 1), y + (height - 1), c1);
- }
- else {
- DrawCornersBrush = new SolidBrush(c1);
- G.FillRectangle(DrawCornersBrush, x, y, 1, 1);
- G.FillRectangle(DrawCornersBrush, x + (width - 1), y, 1, 1);
- G.FillRectangle(DrawCornersBrush, x, y + (height - 1), 1, 1);
- G.FillRectangle(DrawCornersBrush, x + (width - 1), y + (height - 1), 1, 1);
- }
- }
- protected void DrawBorders(Pen p1, int x, int y, int width, int height, int offset)
- {
- DrawBorders(p1, x + offset, y + offset, width - (offset * 2), height - (offset * 2));
- }
- protected void DrawBorders(Pen p1, int offset)
- {
- DrawBorders(p1, 0, 0, Width, Height, offset);
- }
- protected void DrawBorders(Pen p1, Rectangle r, int offset)
- {
- DrawBorders(p1, r.X, r.Y, r.Width, r.Height, offset);
- }
- protected void DrawBorders(Pen p1, int x, int y, int width, int height)
- {
- G.DrawRectangle(p1, x, y, width - 1, height - 1);
- }
- protected void DrawBorders(Pen p1)
- {
- DrawBorders(p1, 0, 0, Width, Height);
- }
- protected void DrawBorders(Pen p1, Rectangle r)
- {
- DrawBorders(p1, r.X, r.Y, r.Width, r.Height);
- }
- private Point DrawTextPoint;
- private Size DrawTextSize;
- protected void DrawText(Brush b1, HorizontalAlignment a, int x, int y)
- {
- DrawText(b1, Text, a, x, y);
- }
- protected void DrawText(Brush b1, Point p1)
- {
- DrawText(b1, Text, p1.X, p1.Y);
- }
- protected void DrawText(Brush b1, int x, int y)
- {
- DrawText(b1, Text, x, y);
- }
- protected void DrawText(Brush b1, string text, HorizontalAlignment a, int x, int y)
- {
- if (text.Length == 0) return;
- DrawTextSize = Measure(text);
- DrawTextPoint = Center(DrawTextSize);
- switch (a) {
- case HorizontalAlignment.Left:
- DrawText(b1, text, x, DrawTextPoint.Y + y);
- case HorizontalAlignment.Center:
- DrawText(b1, text, DrawTextPoint.X + x, DrawTextPoint.Y + y);
- case HorizontalAlignment.Right:
- DrawText(b1, text, Width - DrawTextSize.Width - x, DrawTextPoint.Y + y);
- }
- }
- protected void DrawText(Brush b1, string text, Point p1)
- {
- DrawText(b1, text, p1.X, p1.Y);
- }
- protected void DrawText(Brush b1, string text, int x, int y)
- {
- if (text.Length == 0) return;
- G.DrawString(text, Font, b1, x, y);
- }
- private Point DrawImagePoint;
- protected void DrawImage(HorizontalAlignment a, int x, int y)
- {
- DrawImage(_Image, a, x, y);
- }
- protected void DrawImage(Point p1)
- {
- DrawImage(_Image, p1.X, p1.Y);
- }
- protected void DrawImage(int x, int y)
- {
- DrawImage(_Image, x, y);
- }
- protected void DrawImage(Image image, HorizontalAlignment a, int x, int y)
- {
- if (image == null) return;
- DrawImagePoint = Center(image.Size);
- switch (a) {
- case HorizontalAlignment.Left:
- DrawImage(image, x, DrawImagePoint.Y + y);
- case HorizontalAlignment.Center:
- DrawImage(image, DrawImagePoint.X + x, DrawImagePoint.Y + y);
- case HorizontalAlignment.Right:
- DrawImage(image, Width - image.Width - x, DrawImagePoint.Y + y);
- }
- }
- protected void DrawImage(Image image, Point p1)
- {
- DrawImage(image, p1.X, p1.Y);
- }
- protected void DrawImage(Image image, int x, int y)
- {
- if (image == null) return;
- G.DrawImage(image, x, y, image.Width, image.Height);
- }
- private LinearGradientBrush DrawGradientBrush;
- private Rectangle DrawGradientRectangle;
- protected void DrawGradient(ColorBlend blend, int x, int y, int width, int height)
- {
- DrawGradient(blend, x, y, width, height, 90);
- }
- protected void DrawGradient(Color c1, Color c2, int x, int y, int width, int height)
- {
- DrawGradient(c1, c2, x, y, width, height, 90);
- }
- protected void DrawGradient(ColorBlend blend, int x, int y, int width, int height, float angle)
- {
- DrawGradientRectangle = new Rectangle(x, y, width, height);
- DrawGradient(blend, DrawGradientRectangle, angle);
- }
- protected void DrawGradient(Color c1, Color c2, int x, int y, int width, int height, float angle)
- {
- DrawGradientRectangle = new Rectangle(x, y, width, height);
- DrawGradient(c1, c2, DrawGradientRectangle, angle);
- }
- protected void DrawGradient(ColorBlend blend, Rectangle r, float angle)
- {
- DrawGradientBrush = new LinearGradientBrush(r, Color.Empty, Color.Empty, angle);
- DrawGradientBrush.InterpolationColors = blend;
- G.FillRectangle(DrawGradientBrush, r);
- }
- protected void DrawGradient(Color c1, Color c2, Rectangle r, float angle)
- {
- DrawGradientBrush = new LinearGradientBrush(r, c1, c2, angle);
- G.FillRectangle(DrawGradientBrush, r);
- }
- }
- class ComplexTheme : ThemeContainer151
- {
- protected override void ColorHook()
- {
- }
- ComplexTheme()
- {
- MoveHeight = 28;
- }
- protected override void PaintHook()
- {
- Drawing2D.HatchBrush hb2 = new Drawing2D.HatchBrush(Drawing2D.HatchStyle.Trellis, Color.FromArgb(15, 15, 15));
- SolidBrush sb1 = new SolidBrush(Color.LightGray);
- SolidBrush sb3 = new SolidBrush(Color.White);
- SolidBrush sb2 = new SolidBrush(Color.FromArgb(35, 35, 35));
- G.Clear(Color.LightGray);
- G.DrawRectangle(new Pen(new SolidBrush(Color.LightGray)), new Rectangle(0, 0, Width, 28));
- G.FillRectangle(sb1, new Rectangle(0, 0, Width, 28));
- G.DrawString(Text, Font, Brushes.Black, new Point(5, 8));
- Font SubFont = new Font(DefaultFont.FontFamily, Font.Size - 1);
- G.DrawRectangle(Pens.LightGray, new Rectangle(0, 0, Width - 1, Height - 1));
- G.FillRectangle(sb3, new Rectangle(8, 28, Width - 16, Height - 35));
- DrawCorners(Color.White);
- }
- }
- class ComplexButton : ThemeControl151
- {
- protected override void ColorHook()
- {
- }
- private Brush B1;
- private Brush B2;
- private Brush B3;
- protected override void PaintHook()
- {
- B1 = new SolidBrush(Color.FromArgb(50, Color.Gray));
- B2 = new SolidBrush(Color.FromArgb(50, Color.LightGray));
- B3 = new SolidBrush(Color.FromArgb(50, Color.DarkGray));
- G.Clear(BackColor);
- switch (State) {
- case MouseState.None:
- G.FillRectangle(B1, ClientRectangle);
- case MouseState.Over:
- G.FillRectangle(B2, ClientRectangle);
- case MouseState.Down:
- G.FillRectangle(B3, ClientRectangle);
- }
- G.DrawString(Text, Font, Brushes.Black, new Point((int)(this.Width / 2) - (Measure(Text).Width / 2), (int)(this.Height / 2) - (Measure(Text).Height / 2)));
- G.DrawRectangle(Pens.LightGray, new Rectangle(0, 0, Width - 1, Height - 1));
- DrawCorners(Color.White);
- }
- }
- class ComplexTopButton : ThemeControl151
- {
- protected override void ColorHook()
- {
- }
- private Brush B1;
- private Brush B2;
- private Brush B3;
- protected override void PaintHook()
- {
- B1 = new SolidBrush(Color.FromArgb(50, Color.Gray));
- B2 = new SolidBrush(Color.FromArgb(50, Color.LightGray));
- B3 = new SolidBrush(Color.FromArgb(50, Color.DarkGray));
- G.Clear(BackColor);
- switch (State) {
- case MouseState.None:
- G.FillRectangle(B1, ClientRectangle);
- case MouseState.Over:
- G.FillRectangle(B2, ClientRectangle);
- case MouseState.Down:
- G.FillRectangle(B3, ClientRectangle);
- }
- G.DrawString(Text, Font, Brushes.Black, new Point((int)(this.Width / 2) - (Measure(Text).Width / 2), (int)(this.Height / 2) - (Measure(Text).Height / 2)));
- G.DrawRectangle(Pens.LightGray, new Rectangle(0, 0, Width - 1, Height - 1));
- }
- }
- class ComplexProgressBar : ThemeControl151
- {
- private int _Maximum = 100;
- public int Maximum {
- get { return _Maximum; }
- set {
- if (value < 1) value = 1;
- if (value < _Value) _Value = value;
- _Maximum = value;
- Invalidate();
- }
- }
- private int _Value = 50;
- public int Value {
- get { return _Value; }
- set {
- if (value > _Maximum) value = _Maximum;
- _Value = value;
- Invalidate();
- }
- }
- private Color C2;
- private Pen P1;
- private Brush B1;
- private Brush B2;
- private Brush B3;
- ComplexProgressBar()
- {
- Size = new Size(75, 18);
- }
- protected override void ColorHook()
- {
- C2 = Color.LightGray;
- P1 = Pens.LightGray;
- }
- protected override void PaintHook()
- {
- B1 = new SolidBrush(Color.FromArgb(50, Color.Gray));
- B2 = new SolidBrush(Color.FromArgb(50, Color.LightGray));
- B3 = new SolidBrush(Color.FromArgb(50, Color.DarkGray));
- G.Clear(C2);
- if ((_Value > 0)) {
- G.FillRectangle(B3, 0, 0, (int)(_Value / _Maximum) * Width, Height);
- }
- DrawBorders(P1, 0, 0, Width, Height);
- DrawCorners(Color.White);
- }
- }
- class ComplexGroupBox : ThemeContainer151
- {
- private Color C1;
- private Color C2;
- private Color C3;
- private Pen P1;
- private Brush B1;
- private Brush B2;
- private Brush B3;
- private Brush B0;
- private Brush B8;
- private Brush HB1;
- ComplexGroupBox()
- {
- ControlMode = true;
- Size = new Size(205, 95);
- }
- protected override void ColorHook()
- {
- C1 = Color.White;
- C2 = Color.FromArgb(50, 50, 50);
- C3 = Color.FromArgb(0, 0, 0);
- P1 = Pens.LightGray;
- B0 = new SolidBrush(Color.FromArgb(60, Color.White));
- B8 = new SolidBrush(Color.Black);
- B2 = new SolidBrush(Color.White);
- }
- protected override void PaintHook()
- {
- B1 = new SolidBrush(Color.FromArgb(50, Color.Gray));
- B2 = new SolidBrush(Color.FromArgb(50, Color.LightGray));
- B3 = new SolidBrush(Color.FromArgb(50, Color.DarkGray));
- G.Clear(C1);
- G.FillRectangle(B0, 0, 0, Width, Height);
- G.FillRectangle(B0, 0, 0, Width, 15);
- G.DrawRectangle(P1, 0, 15, Width - 1, (int)Height - 16);
- G.FillRectangle(B3, 0, 15, Width, 20);
- G.FillRectangle(B3, 0, 15, Width, 20);
- DrawText(B8, HorizontalAlignment.Left, 3, 13);
- DrawCorners(Color.White);
- }
- }
- enum MouseState : byte
- {
- None = 0,
- Over = 1,
- Down = 2,
- Block = 3
- }
- class Bloom
- {
- private string _Name;
- string Name {
- get { return _Name; }
- set { _Name = value; }
- }
- private Color _Value;
- Color Value {
- get { return _Value; }
- set { _Value = value; }
- }
- Bloom()
- {
- }
- Bloom(string name, Color value)
- {
- _Name = name;
- _Value = value;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment