-
Автор темы
- #1
Опубликовал я тут неплохой скин для приложений на C# (Win Forms конечно ), и он достаточно неплохо зашел народу . Увидев такое количество симпатий интересующихся людей, я решил создать еще одну тему с приватным скином для C# и VB.Net (я хз, кому он нужен). В конце темы будет гайд для пастеров низшей категории, у которых так и не получилось добавить тему в проект
P.S.: есть еще один топовый скин, позже сделаю сборник
Прошлая тема: https://yougame.biz/threads/92254/
P.S.: есть еще один топовый скин, позже сделаю сборник
Код:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
#endregion
#region Helper Methods
public class HelperMethods
{
public static System.Drawing.Drawing2D.GraphicsPath GP = null;
public enum MouseMode
{
NormalMode,
Hovered,
Pushed
};
public static void DrawImageFromBase64(Graphics G, string Base64Image, Rectangle Rect)
{
Image IM = null;
using (System.IO.MemoryStream ms = new System.IO.MemoryStream(Convert.FromBase64String(Base64Image)))
{
IM = System.Drawing.Image.FromStream(ms);
}
G.DrawImage(IM, Rect);
}
public static System.Drawing.Drawing2D.GraphicsPath RoundRec(Rectangle r, int Curve)
{
System.Drawing.Drawing2D.GraphicsPath CreateRoundPath = new System.Drawing.Drawing2D.GraphicsPath(System.Drawing.Drawing2D.FillMode.Winding);
CreateRoundPath.AddArc(r.X, r.Y, Curve, Curve, 180f, 90f);
CreateRoundPath.AddArc(r.Right - Curve, r.Y, Curve, Curve, 270f, 90f);
CreateRoundPath.AddArc(r.Right - Curve, r.Bottom - Curve, Curve, Curve, 0f, 90f);
CreateRoundPath.AddArc(r.X, r.Bottom - Curve, Curve, Curve, 90f, 90f);
CreateRoundPath.CloseFigure();
return CreateRoundPath;
}
public static void FillRoundedPath(Graphics G, Color C, Rectangle Rect, int Curve)
{
G.FillPath(new SolidBrush(C), RoundRec(Rect, Curve));
}
public static void FillRoundedPath(Graphics G, Brush B, Rectangle Rect, int Curve)
{
G.FillPath(B, RoundRec(Rect, Curve));
}
public static void DrawRoundedPath(Graphics G, Color C, Single Size, Rectangle Rect, int Curve)
{
G.DrawPath(new Pen(C, Size), RoundRec(Rect, Curve));
}
public static void DrawTriangle(Graphics G, Color C, Single Size, Point P1_0, Point P1_1, Point P2_0, Point P2_1, Point P3_0, Point P3_1)
{
G.DrawLine(new Pen(C, Size), P1_0, P1_1);
G.DrawLine(new Pen(C, Size), P2_0, P2_1);
G.DrawLine(new Pen(C, Size), P3_0, P3_1);
}
public static Pen PenRGBColor(int R, int G, int B, Single size)
{ return new Pen(System.Drawing.Color.FromArgb(R, G, B), size); }
public static Pen PenHTMlColor(String C_WithoutHash, Single size)
{ return new Pen(GetHTMLColor(C_WithoutHash), size); }
public static SolidBrush SolidBrushRGBColor(int R, int G, int B, int A = 0)
{ return new SolidBrush(System.Drawing.Color.FromArgb(A, R, G, B)); }
public static SolidBrush SolidBrushHTMlColor(String C_WithoutHash)
{ return new SolidBrush(GetHTMLColor(C_WithoutHash)); }
public static Color GetHTMLColor(String C_WithoutHash)
{ return ColorTranslator.FromHtml("#" + C_WithoutHash); }
public static String ColorToHTML(Color C)
{ return ColorTranslator.ToHtml(C); }
public static Color SetARGB(int A, int R, int G, int B)
{ return System.Drawing.Color.FromArgb(A, R, G, B); }
public static Color SetRGB(int R, int G, int B)
{ return System.Drawing.Color.FromArgb(R, G, B); }
public static Font FontByName(String NameOfFont, Single size, FontStyle Style)
{ return new Font(NameOfFont, size, Style); }
public static void CentreString(Graphics G, String Text, Font font, Brush brush, Rectangle Rect)
{ G.DrawString(Text, font, brush, new Rectangle(0, Rect.Y + Convert.ToInt32(Rect.Height / 2) - Convert.ToInt32(G.MeasureString(Text, font).Height / 2) + 0, Rect.Width, Rect.Height), new StringFormat() { Alignment = StringAlignment.Center }); }
public static void LeftString(Graphics G, String Text, Font font, Brush brush, Rectangle Rect)
{
G.DrawString(Text, font, brush, new Rectangle(4, Rect.Y + Convert.ToInt32(Rect.Height / 2) - Convert.ToInt32(G.MeasureString(Text, font).Height / 2) + 0, Rect.Width, Rect.Height), new StringFormat { Alignment = StringAlignment.Near });
}
public static void FillRect(Graphics G, Brush Br, Rectangle Rect)
{ G.FillRectangle(Br, Rect); }
}
#endregion
#region Skin
public class EtherealTheme : ContainerControl
{
#region Variables
bool Movable = false;
private TitlePostion _TitleTextPostion = TitlePostion.Left;
static Point MousePoint = new Point(0, 0);
private int MoveHeight = 50;
private bool _ShowIcon = false;
private Color _HeaderColor = HelperMethods.GetHTMLColor("3f2153");
private Color _BackColor = Color.White;
private Color _BorderColor = HelperMethods.GetHTMLColor("3f2153");
#endregion
#region Properties
public bool ShowIcon
{
get { return _ShowIcon; }
set
{
if (value == _ShowIcon) { return; }
FindForm().ShowIcon = value;
Invalidate();
_ShowIcon = value;
}
}
public TitlePostion TitleTextPostion
{
get { return _TitleTextPostion; }
set
{
_TitleTextPostion = value;
Invalidate();
}
}
public enum TitlePostion
{
Left,
Center
};
public Color HeaderColor
{
get
{
return _HeaderColor;
}
set
{
_HeaderColor = value;
Invalidate();
}
}
override public Color BackColor
{
get
{
return _BackColor;
}
set
{
_BackColor = value;
base.BackColor = value;
Invalidate();
}
}
public Color BorderColor
{
get
{
return _BorderColor;
}
set
{
_BorderColor = value;
Invalidate();
}
}
#endregion
#region Initialization
public EtherealTheme()
{
SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor, true);
DoubleBuffered = true;
UpdateStyles();
Font = new Font("Proxima Nova", 14, FontStyle.Bold);
}
#endregion
#region Mouse & other Events
protected override void OnCreateControl()
{
base.OnCreateControl();
ParentForm.FormBorderStyle = FormBorderStyle.None;
ParentForm.TransparencyKey = Color.Fuchsia;
Dock = DockStyle.Fill;
}
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
int x = MousePosition.X;
int y = MousePosition.Y;
int x1 = MousePoint.X;
int y1 = MousePoint.Y;
if (Movable)
Parent.Location = new Point(x - x1, y - y1);
Focus();
}
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
if (e.Button == System.Windows.Forms.MouseButtons.Left && new Rectangle(0, 0, Width, MoveHeight).Contains(e.Location))
{
Movable = true;
MousePoint = e.Location;
}
}
protected override void OnMouseUp(MouseEventArgs e)
{
base.OnMouseUp(e);
Movable = false;
}
#endregion
#region Draw Control
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Rectangle Rect = new Rectangle(1, 1, (int)(Width - 2.5), (int)(Height - 2.5));
Bitmap B = new Bitmap(Width, Height);
using (Graphics G = Graphics.FromImage(B))
{
G.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
HelperMethods.FillRect(G, new SolidBrush(HeaderColor), new Rectangle(0, 0, Width, 50));
G.DrawRectangle(new Pen(BorderColor, 2), new Rectangle(1, 1, Width - 2, Height - 2));
if (FindForm().ShowIcon==true)
{
G.DrawIcon(FindForm().Icon, new Rectangle(5, 13, 20, 20));
switch (TitleTextPostion)
{
case TitlePostion.Left:
G.DrawString(Text, Font, Brushes.White, 27, 10);
break;
case TitlePostion.Center:
HelperMethods.CentreString(G, Text, Font, Brushes.White, new Rectangle(0, 0, Width, 50));
break;
}
}
else
{
switch (TitleTextPostion)
{
case TitlePostion.Left:
G.DrawString(Text, Font, Brushes.White, 5, 10);
break;
case TitlePostion.Center:
HelperMethods.CentreString(G, Text, Font, Brushes.White, new Rectangle(0, 0, Width, 50));
break;
}
}
e.Graphics.DrawImage((Image)(B.Clone()), 0, 0);
G.Dispose();
B.Dispose();
}
}
#endregion
}
#endregion
#region TabControl
public class EtherealTabControl : TabControl
{
#region Variables
private MouseState State;
private Color _TabsColor = HelperMethods.GetHTMLColor("432e58");
private Color _SeletedTabTriangleColor = Color.White;
private Color _LeftColor = HelperMethods.GetHTMLColor("4e3a62");
private Color _RightColor = Color.White;
private Color _LineColor = HelperMethods.GetHTMLColor("3b2551");
private Color _NoneSelectedTabColors = HelperMethods.GetHTMLColor("432e58");
private Color _HoverColor = HelperMethods.GetHTMLColor("3b2551");
private Color _TextColor = Color.White;
private Color _TabPageColor = Color.White;
#endregion
#region Stractures
public struct MouseState
{
public bool Hover;
public Point Coordinates;
};
#endregion
#region Initialization
public EtherealTabControl()
{
SetStyle(ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.SupportsTransparentBackColor, true);
DoubleBuffered = true;
SizeMode = TabSizeMode.Fixed;
Dock = DockStyle.None;
ItemSize = new Size(40, 150);
Alignment = TabAlignment.Left;
}
#endregion
#region Properties
public Color TabsColor
{
get
{
return _TabsColor;
}
set
{
_TabsColor = value;
Invalidate();
}
}
public Color SeletedTabTriangleColor
{
get
{
return _SeletedTabTriangleColor;
}
set
{
_SeletedTabTriangleColor = value;
Invalidate();
}
}
public Color LeftColor
{
get
{
return _LeftColor;
}
set
{
_LeftColor = value;
Invalidate();
}
}
public Color RightColor
{
get
{
return _RightColor;
}
set
{
_RightColor = value;
Invalidate();
}
}
public Color LineColor
{
get
{
return _LineColor;
}
set
{
_LineColor = value;
Invalidate();
}
}
public Color NoneSelectedTabColors
{
get
{
return _NoneSelectedTabColors;
}
set
{
_NoneSelectedTabColors = value;
Invalidate();
}
}
public Color HoverColor
{
get
{
return _HoverColor;
}
set
{
_HoverColor = value;
Invalidate();
}
}
public Color TextColor
{
get
{
return _TextColor;
}
set
{
_TextColor = value;
Invalidate();
}
}
public Color TabPageColor
{
get
{
return _TabPageColor;
}
set
{
_TabPageColor = value;
Invalidate();
}
}
#endregion
#region Events
protected override void OnMouseEnter(EventArgs e)
{
State.Hover = true;
base.OnMouseEnter(e);
}
protected override void OnMouseLeave(EventArgs e)
{
State.Hover = false;
foreach (TabPage Tab in base.TabPages)
{
if (Tab.DisplayRectangle.Contains(State.Coordinates))
{
base.Invalidate();
break;
}
}
base.OnMouseLeave(e);
}
protected override void OnMouseMove(MouseEventArgs e)
{
State.Coordinates = e.Location;
foreach (TabPage Tab in base.TabPages)
{
if (Tab.DisplayRectangle.Contains(e.Location))
{
base.Invalidate();
break;
}
}
base.OnMouseMove(e);
}
protected override void OnCreateControl()
{
base.OnCreateControl();
foreach(TabPage T in TabPages)
{
T.BackColor = TabPageColor;
}
}
#endregion
#region DrawControl
protected override void OnPaint(PaintEventArgs e)
{
Bitmap B = new Bitmap(Width, Height);
using (Graphics G = Graphics.FromImage(B))
{
G.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
G.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
HelperMethods.FillRect(G, new SolidBrush(LeftColor), new Rectangle(0, 1, 150, Height));
for (int i = 0; i <= TabPages.Count - 1; i++)
{
Rectangle R = GetTabRect(i);
HelperMethods.FillRect(G, new SolidBrush(NoneSelectedTabColors), new Rectangle(R.X - 1, R.Y - 1, R.Width - 3, R.Height));
if (i == SelectedIndex)
{
G.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
Point P1 = new Point(ItemSize.Height - 12, R.Location.Y + 20);
Point P2 = new Point(ItemSize.Height + 2, R.Location.Y + 10);
Point P3 = new Point(ItemSize.Height + 2, R.Location.Y + 30);
G.FillPolygon(new SolidBrush(SeletedTabTriangleColor), new Point[] { P1, P2, P3 });
}
else
{
if (State.Hover & R.Contains(State.Coordinates))
{
Cursor = Cursors.Hand;
HelperMethods.FillRect(G, new SolidBrush(HoverColor), new Rectangle(R.X, R.Y, R.Width - 3, R.Height));
}
}
G.DrawString(TabPages[i].Text, new Font("Segoe UI", 8, FontStyle.Bold), new SolidBrush(TextColor), R.X + 28, R.Y + 13);
if (!(ImageList == null))
{ G.DrawImage(ImageList.Images[i], new Rectangle(R.X + 6, R.Y + 11, 16, 16)); }
G.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;
G.DrawLine(new Pen(LineColor, 1), new Point(R.X - 1, R.Bottom - 2), new Point(R.Width - 2, R.Bottom - 2));
}
G.FillRectangle(new SolidBrush(RightColor), new Rectangle(150, Convert.ToInt32(1.3), Width, Height - 2));
G.DrawRectangle(new Pen(LineColor, 1), new Rectangle(0, 0, Width - 1, Height - 1));
e.Graphics.DrawImage((Image)B.Clone(), 0, 0);
G.Dispose();
B.Dispose();
}
}
#endregion
}
#endregion
#region Button
public class EtherealButton : Control
{
#region Variables
private HelperMethods.MouseMode State;
private Style _ButtonStyle ;
private Color NoneColor = HelperMethods.GetHTMLColor("222222");
private int _RoundRadius = 5;
#endregion
#region Properties
public int RoundRadius
{
get
{
return _RoundRadius;
}
set
{
_RoundRadius=value;
Invalidate();
}
}
public Style ButtonStyle
{
get
{
return _ButtonStyle;
}
set
{
_ButtonStyle = value;
Invalidate();
}
}
#endregion
#region Initialization
public EtherealButton()
{
SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint |
ControlStyles.ResizeRedraw | ControlStyles.UserPaint |
ControlStyles.Selectable | ControlStyles.SupportsTransparentBackColor, true);
DoubleBuffered = true;
BackColor = Color.Transparent;
Font = new Font("Segoe UI", 9, FontStyle.Bold);
}
#endregion
#region Enumerators
public enum Style
{
Clear,
DarkClear,
SemiBlack,
DarkPink,
LightPink
};
#endregion
#region Events
protected override void OnMouseEnter(EventArgs e)
{
base.OnMouseEnter(e);
State = HelperMethods.MouseMode.Hovered;
Invalidate();
}
protected override void OnMouseUp(MouseEventArgs e)
{
base.OnMouseUp(e);
State = HelperMethods.MouseMode.Hovered;
Invalidate();
}
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
State = HelperMethods.MouseMode.Pushed;
Invalidate();
}
protected override void OnMouseLeave(EventArgs e)
{
base.OnMouseLeave(e);
State = HelperMethods.MouseMode.NormalMode;
Invalidate();
}
#endregion
#region Draw Control
protected override void OnPaint(PaintEventArgs e)
{
Bitmap B = new Bitmap(Width, Height);
using (Graphics G = Graphics.FromImage(B))
{
Rectangle Rect=new Rectangle(0, 0, Width - 1, Height - 1);
System.Drawing.Drawing2D.GraphicsPath GP = HelperMethods.RoundRec(Rect, RoundRadius);
G.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
G.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
switch(State)
{
case HelperMethods.MouseMode.NormalMode:
switch(ButtonStyle)
{
case Style.Clear:
NoneColor = HelperMethods.GetHTMLColor("ececec");
HelperMethods.DrawRoundedPath(G, NoneColor, 1, Rect, RoundRadius);
HelperMethods.CentreString(G, Text, Font, HelperMethods.SolidBrushHTMlColor("b9b9b9"), Rect);
break;
case Style.DarkClear:
NoneColor = HelperMethods.GetHTMLColor("444444");
HelperMethods.DrawRoundedPath(G, NoneColor, 1, Rect, RoundRadius);
HelperMethods.CentreString(G, Text, Font, HelperMethods.SolidBrushHTMlColor("444444"), Rect);
break;
case Style.SemiBlack:
HelperMethods.FillRoundedPath(G, NoneColor, Rect, RoundRadius);
HelperMethods.DrawRoundedPath(G, HelperMethods.GetHTMLColor("121212"), 1, Rect, RoundRadius);
HelperMethods.CentreString(G, Text, Font, Brushes.White, Rect);
break;
case Style.DarkPink:
NoneColor = HelperMethods.GetHTMLColor("3b2551");
HelperMethods.FillRoundedPath(G, NoneColor, Rect, RoundRadius);
HelperMethods.DrawRoundedPath(G, HelperMethods.GetHTMLColor("6d5980"), 1, Rect, RoundRadius);
HelperMethods.CentreString(G, Text, Font, Brushes.White, Rect);
break;
case Style.LightPink:
NoneColor = HelperMethods.GetHTMLColor("9d92a8");
HelperMethods.FillRoundedPath(G, NoneColor, Rect, RoundRadius);
HelperMethods.DrawRoundedPath(G, HelperMethods.GetHTMLColor("573d71"), 1, Rect, RoundRadius);
HelperMethods.CentreString(G, Text, Font, Brushes.White, Rect);
break;
}
break;
case HelperMethods.MouseMode.Hovered:
NoneColor = HelperMethods.GetHTMLColor("444444");
switch(ButtonStyle)
{
case Style.Clear:
NoneColor = HelperMethods.GetHTMLColor("444444");
HelperMethods.DrawRoundedPath(G, NoneColor, 1, Rect, RoundRadius);
HelperMethods.CentreString(G, Text, Font, HelperMethods.SolidBrushHTMlColor("444444"), Rect);
break;
case Style.DarkClear:
NoneColor = HelperMethods.GetHTMLColor("ececec");
HelperMethods.DrawRoundedPath(G, NoneColor, 1, Rect, RoundRadius);
HelperMethods.CentreString(G, Text, Font, HelperMethods.SolidBrushHTMlColor("b9b9b9"), Rect);
break;
case Style.SemiBlack:
NoneColor = HelperMethods.GetHTMLColor("444444");
HelperMethods.FillRect(G, new SolidBrush(Color.Transparent), Rect);
HelperMethods.DrawRoundedPath(G, NoneColor, 1, Rect, RoundRadius);
HelperMethods.CentreString(G, Text, Font, HelperMethods.SolidBrushHTMlColor("444444"), Rect);
break;
case Style.DarkPink:
NoneColor = HelperMethods.GetHTMLColor("444444");
HelperMethods.FillRect(G, new SolidBrush(Color.Transparent), Rect);
HelperMethods.DrawRoundedPath(G, NoneColor, 1, Rect, RoundRadius);
HelperMethods.CentreString(G, Text, Font, HelperMethods.SolidBrushHTMlColor("444444"), Rect);
break;
case Style.LightPink:
NoneColor = HelperMethods.GetHTMLColor("9d92a8");
HelperMethods.FillRect(G, new SolidBrush(Color.Transparent), Rect);
HelperMethods.DrawRoundedPath(G, NoneColor, 1, Rect, RoundRadius);
HelperMethods.CentreString(G, Text, Font, HelperMethods.SolidBrushHTMlColor("444444"), Rect);
break;
}
break;
case HelperMethods.MouseMode.Pushed:
switch(ButtonStyle)
{
case Style.Clear: case Style.DarkClear:
NoneColor = HelperMethods.GetHTMLColor("444444");
HelperMethods.FillRect(G, new SolidBrush(Color.Transparent), Rect);
HelperMethods.DrawRoundedPath(G, NoneColor, 1, Rect, 5);
HelperMethods.CentreString(G, Text, Font, HelperMethods.SolidBrushHTMlColor("444444"), Rect);
break;
case Style.DarkPink: case Style.LightPink: case Style.SemiBlack:
NoneColor = HelperMethods.GetHTMLColor("ececec");
HelperMethods.DrawRoundedPath(G, NoneColor, 1, Rect, 5);
HelperMethods.CentreString(G, Text, Font, HelperMethods.SolidBrushHTMlColor("b9b9b9"), Rect);
break;
}
break;
}
e.Graphics.DrawImage(B, 0, 0);
G.Dispose() ;
B.Dispose();
}
}
#endregion
}
#endregion
#region CheckBox
[System.ComponentModel.DefaultEvent("CheckedChanged")]
public class EtherealCheckBox : Control
{
#region Variables
static bool _Checked;
public event CheckedChangedEventHandler CheckedChanged;
public delegate void CheckedChangedEventHandler(object sender);
private Color _CheckColor = HelperMethods.GetHTMLColor("746188");
private Color _BorderColor = HelperMethods.GetHTMLColor("746188");
#endregion
#region Properties
public bool Checked
{
get
{
return _Checked;
}
set
{
_Checked = value;
Invalidate();
}
}
public Color CheckColor
{
get
{
return _CheckColor;
}
set
{
_CheckColor = value;
Invalidate();
}
}
public Color BorderColor
{
get
{
return _BorderColor;
}
set
{
_BorderColor = value;
Invalidate();
}
}
#endregion
#region Initialization
public EtherealCheckBox()
{
SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint |
ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer
| ControlStyles.SupportsTransparentBackColor, true);
DoubleBuffered = true;
//UpdateStyles();
Cursor = Cursors.Hand;
Size = new Size(200, 20);
Font = new Font("Proxima Nova", 11, FontStyle.Regular);
BackColor = Color.Transparent;
}
#endregion
#region DrawControl
protected override void OnPaint(PaintEventArgs e)
{
Bitmap B = new Bitmap(Width, Height);
using (Graphics G = Graphics.FromImage(B))
{
G.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
G.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
HelperMethods.DrawRoundedPath(G, BorderColor, 3, new Rectangle(1, 1, 16, 16), 3);
if (Checked)
{
HelperMethods.FillRoundedPath(G, CheckColor, new Rectangle(5, 5, (int)8.5, (int)8.5), 1);
}
G.DrawString(Text, Font, Brushes.Gray, new Rectangle(22,Convert.ToInt32(-1.2), Width, Height - 2));
e.Graphics.DrawImage((Image)(B.Clone()), 0, 0);
G.Dispose();
B.Dispose();
}
}
#endregion
#region Events
protected override void OnResize(EventArgs e)
{
Height = 20;
base.OnResize(e);
Invalidate();
}
protected override void OnClick(EventArgs e)
{
_Checked = !_Checked;
if (CheckedChanged != null)
{
CheckedChanged(this);
}
base.OnClick(e);
Invalidate();
}
#endregion
}
#endregion
#region Textbox
[System.ComponentModel.DefaultEvent("TextChanged")]
public class EtherealTextbox : Control
{
#region Variables
private TextBox T = new TextBox();
private HorizontalAlignment _TextAlign = HorizontalAlignment.Left;
private int _MaxLength = 32767;
private bool _ReadOnly;
private bool _UseSystemPasswordChar = false;
private string _WatermarkText = "";
private Image _SideImage;
private bool _Multiline = false;
protected HelperMethods.MouseMode State = HelperMethods.MouseMode.NormalMode;
private Color _ForeColor = Color.Gray;
private Color _BackColor = Color.White;
private Color _BorderColor = HelperMethods.GetHTMLColor("ececec");
#endregion
#region Native Methods
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern Int32 SendMessage(IntPtr hWnd, int msg, int wParam, [System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr)]
string lParam);
#endregion
#region Initialization
public EtherealTextbox()
{
SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint |
ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer |
ControlStyles.SupportsTransparentBackColor, true);
DoubleBuffered = true;
UpdateStyles();
Font = new Font("Segoe UI", 10, FontStyle.Regular);
Text = WatermarkText;
Size = new Size(135, 30);
T.Multiline = _Multiline;
T.Cursor = Cursors.IBeam;
T.BackColor = Color.White;
T.ForeColor = Color.Gray;
T.Text = WatermarkText;
T.BorderStyle = BorderStyle.None;
T.Location = new Point(7, 7);
T.Font = Font;
T.Size = new Size(Width - 10, 30);
T.UseSystemPasswordChar = _UseSystemPasswordChar;
T.TextChanged += T_TextChanged;
T.KeyDown += T_KeyDown;
}
#endregion
#region Properties
[System.ComponentModel.Browsable(false), System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never), System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public BorderStyle BorderStyle
{
get
{
return BorderStyle.None;
}
}
[System.ComponentModel.Browsable(false), System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never), System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public bool Multiline
{
get
{
return _Multiline;
}
set
{
_Multiline = value;
if (T != null)
{
T.Multiline = value;
}
}
}
public HorizontalAlignment TextAlign
{
get
{
return _TextAlign;
}
set
{
_TextAlign = value;
if (T != null)
{
T.TextAlign = value;
}
}
}
public int MaxLength
{
get
{
return _MaxLength;
}
set
{
_MaxLength = value;
if (T != null)
{
T.MaxLength = value;
}
}
}
public bool ReadOnly
{
get
{
return _ReadOnly;
}
set
{
_ReadOnly = value;
if (T != null)
{
T.ReadOnly = value;
}
}
}
public bool UseSystemPasswordChar
{
get
{
return _UseSystemPasswordChar;
}
set
{
_UseSystemPasswordChar = value;
if (T != null)
{
T.UseSystemPasswordChar = value;
}
}
}
public string WatermarkText
{
get
{
return _WatermarkText;
}
set
{
_WatermarkText = value;
SendMessage(T.Handle, 0x1501, 0, value);
Invalidate();
}
}
public Image SideImage
{
get
{
return _SideImage;
}
set
{
_SideImage = value;
Invalidate();
}
}
[System.ComponentModel.Browsable(false)]
public override Image BackgroundImage
{
get
{
return base.BackgroundImage;
}
set
{
base.BackgroundImage = value;
}
}
[System.ComponentModel.Browsable(false)]
public override ImageLayout BackgroundImageLayout
{
get
{
return base.BackgroundImageLayout;
}
set
{
base.BackgroundImageLayout = value;
}
}
public override string Text
{
get
{
return base.Text;
}
set
{
base.Text = value;
}
}
override public Color BackColor
{
get
{
return _BackColor;
}
set
{
base.BackColor = value;
T.BackColor = value;
_BackColor = value;
Invalidate();
}
}
override public Color ForeColor
{
get
{
return _ForeColor;
}
set
{
base.ForeColor = value;
T.ForeColor = value;
_ForeColor = value;
Invalidate();
}
}
public Color BorderColor
{
get
{
return _BorderColor;
}
set
{
_BorderColor = value;
Invalidate();
}
}
#endregion
#region DrawControl
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Rectangle Rect = new Rectangle(0, 0, Width - 1, Height - 1);
Bitmap B = new Bitmap(Width, Height);
using (Graphics G = Graphics.FromImage(B))
{
G.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
G.Clear(BackColor);
HelperMethods.DrawRoundedPath(G, BorderColor, (int)1.8, new Rectangle(0, 0, Width - 1, Height - 1), 4);
if (SideImage != null)
{
T.Location = new Point(45, 5);
T.Width = Width - 60;
G.DrawRectangle(new Pen(BorderColor, 1), new Rectangle(-1, -1, 35, Height + 1));
G.DrawImage(SideImage, new Rectangle(8, 7, 16, 16));
}
else
{
T.Location = new Point(7, 5);
T.Width = Width - 10;
}
if (ContextMenuStrip != null) { T.ContextMenuStrip = ContextMenuStrip; }
e.Graphics.DrawImage((Image)(B.Clone()), 0, 0);
G.Dispose();
B.Dispose();
}
}
#endregion
#region Events
private void T_MouseHover(object sender, EventArgs e)
{
State = HelperMethods.MouseMode.Hovered;
}
private void T_MouseLeave(object sender, EventArgs e)
{
State = HelperMethods.MouseMode.NormalMode;
}
private void T_MouseUp(object sender, EventArgs e)
{
State = HelperMethods.MouseMode.Pushed;
}
private void T_MouseEnter(object sender, EventArgs e)
{
State = HelperMethods.MouseMode.Pushed;
}
private void T_MouseDown(object sender, EventArgs e)
{
State = HelperMethods.MouseMode.Pushed;
}
private void T_TextChanged(object sender, EventArgs e)
{
Text = T.Text;
}
protected override void OnTextChanged(EventArgs e)
{
base.OnTextChanged(e);
T.Text = Text;
}
private void T_KeyDown(object sender, KeyEventArgs e)
{
if (e.Control && e.KeyCode == Keys.A) { e.SuppressKeyPress = true; }
if (e.Control && e.KeyCode == Keys.C)
{
T.Copy();
e.SuppressKeyPress = true;
}
}
protected override void OnCreateControl()
{
base.OnCreateControl();
if (!Controls.Contains(T))
Controls.Add(T);
if (T.Text == "" && WatermarkText != "")
T.Text = WatermarkText;
}
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
if (_Multiline == false)
Height = 30;
}
#endregion
}
#endregion
#region RadioButton
[System.ComponentModel.DefaultEvent("CheckedChanged")]
public class EtherealRadioButton : Control
{
#region Variables
private bool _Checked;
private int _Group = 1;
public event CheckedChangedEventHandler CheckedChanged;
public delegate void CheckedChangedEventHandler(object sender);
private Color _CheckColor = HelperMethods.GetHTMLColor("746188");
private Color _BorderColor = HelperMethods.GetHTMLColor("746188");
#endregion
#region Properties
public bool Checked
{
get
{ return _Checked;
}
set
{
_Checked = value;
UpdateCheckState();
Invalidate();
}
}
public int Group
{
get
{
return _Group;
}
set
{
_Group = value;
}
}
public Color CheckColor
{
get
{
return _CheckColor;
}
set
{
_CheckColor = value;
Invalidate();
}
}
public Color BorderColor
{
get
{
return _BorderColor;
}
set
{
_BorderColor = value;
Invalidate();
}
}
#endregion
#region Initialization
public EtherealRadioButton()
{
SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint |
ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor , true);
DoubleBuffered = true;
UpdateStyles();
Cursor = Cursors.Hand;
Font = new Font("Proxima Nova", 11, FontStyle.Regular);
}
#endregion
#region DrawControl
protected override void OnPaint(PaintEventArgs e)
{
Bitmap B = new Bitmap(Width, Height);
using (Graphics G = Graphics.FromImage(B))
{
G.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
G.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
G.DrawEllipse(new Pen(BorderColor, Convert.ToInt32(2.5)), 1, 1, 18, 18);
if (Checked)
{
G.FillEllipse(new SolidBrush(CheckColor), new Rectangle(5, 5, 10, 10));
}
G.DrawString(Text, Font, Brushes.Gray, new Rectangle(23,Convert.ToInt32(-0.3), Width, Height));
e.Graphics.DrawImage(B, 0, 0);
G.Dispose();
B.Dispose();
}
}
#endregion
#region Events
protected override void OnTextChanged(EventArgs e)
{
base.OnTextChanged(e);
Invalidate();
}
protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
{
if (!_Checked)
Checked = true;
base.OnMouseDown(e);
}
protected override void OnResize(EventArgs e)
{
Height = 21;
Invalidate();
base.OnResize(e);
}
private void UpdateCheckState()
{
if (!IsHandleCreated || !_Checked)
return;
foreach (Control C in Parent.Controls)
{
if (!object.ReferenceEquals(C, this) && C is EtherealRadioButton && ((EtherealRadioButton)C).Group == _Group)
{
((EtherealRadioButton)C).Checked = false;
}
}
if (CheckedChanged != null)
{
CheckedChanged(this);
}
}
protected override void OnCreateControl()
{
base.OnCreateControl();
}
#endregion
}
#endregion
#region ComboBox
public class EtherealComboBox : ComboBox
{
#region Variables
private int _StartIndex = 0;
private Color _BorderColor = HelperMethods.GetHTMLColor("ececec");
private Color _TextColor = HelperMethods.GetHTMLColor("b8c6d6");
private Color _TriangleColor = HelperMethods.GetHTMLColor("999999");
#endregion
#region Initialization
public EtherealComboBox()
{
SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint |
ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor, true);
DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
Size = new Size(200, 35);
DropDownStyle = ComboBoxStyle.DropDownList;
Font = new Font("Segoe UI", 15);
BackColor = Color.Transparent;
DoubleBuffered = true;
}
#endregion
#region Properties
public int StartIndex
{
get
{
return _StartIndex;
}
set
{
_StartIndex = value;
try
{
base.SelectedIndex = value;
}
catch
{
}
Invalidate();
}
}
public Color BorderColor
{
get
{
return _BorderColor;
}
set
{
_BorderColor = value;
Invalidate();
}
}
public Color TextColor
{
get
{
return _TextColor;
}
set
{
_TextColor = value;
Invalidate();
}
}
public Color TriangleColor
{
get
{
return _TriangleColor;
}
set
{
_TriangleColor = value;
Invalidate();
}
}
#endregion
#region Draw Control
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Bitmap B = new Bitmap(Width, Height);
using (Graphics G =Graphics.FromImage(B))
{
Rectangle Rect = new Rectangle(1, 1, Width - 2, Height - 2);
G.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
G.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
G.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
HelperMethods.DrawTriangle(G, TriangleColor, 2,
new Point(Width - 20, 16), new Point(Width - 16, 20),
new Point(Width - 16, 20), new Point(Width - 12, 16),
new Point(Width - 16, 21), new Point(Width - 16, 20)
);
HelperMethods.DrawRoundedPath(G, BorderColor,(int) 1.5, Rect, 4);
G.DrawString(Text, Font, new SolidBrush(TextColor), new Rectangle(7, 0, Width - 1, Height - 1), new StringFormat {LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Near});
e.Graphics.DrawImage(B, 0, 0);
G.Dispose();
B.Dispose();
}
}
protected override void OnDrawItem(DrawItemEventArgs e)
{
e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
if (System.Convert.ToInt32((e.State & DrawItemState.Selected)) == (int)DrawItemState.Selected)
{
if (!(e.Index == -1))
{
e.Graphics.FillRectangle(HelperMethods.SolidBrushHTMlColor("3b2551"), e.Bounds);
e.Graphics.DrawString(GetItemText(Items[e.Index]), e.Font, new SolidBrush(Color.WhiteSmoke), e.Bounds);
}
}
else
{
if (!(e.Index == -1))
{
e.Graphics.FillRectangle(new SolidBrush(e.BackColor), e.Bounds);
e.Graphics.DrawString(GetItemText(Items[e.Index]), e.Font, HelperMethods.SolidBrushHTMlColor("b8c6d6"), e.Bounds);
}
}
Invalidate();
}
#endregion
#region Events
protected override void OnCreateControl()
{
base.OnCreateControl();
}
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
}
#endregion
}
#endregion
#region Switch
[System.ComponentModel.DefaultEvent("CheckedChanged")]
public class EtherealSwitch : Control
{
#region Variables
protected bool _Switched;
protected HelperMethods.MouseMode State = HelperMethods.MouseMode.NormalMode;
public event CheckedChangedEventHandler CheckedChanged;
public delegate void CheckedChangedEventHandler(object sender);
private Color _SwitchColor = HelperMethods.GetHTMLColor("3f2153");
#endregion
#region Properties
protected override void OnTextChanged(EventArgs e)
{
base.OnTextChanged(e);
Invalidate();
}
public bool Switched
{
get
{
return _Switched;
}
set
{
_Switched = value;
Invalidate();
}
}
public Color SwitchColor
{
get
{
return _SwitchColor;
}
set
{
_SwitchColor = value;
Invalidate();
}
}
#endregion
#region Draw Control
protected override void OnPaint(PaintEventArgs e)
{
Bitmap B = new Bitmap(Width, Height);
using (Graphics G =Graphics.FromImage(B))
{
G.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
if (Switched)
{
HelperMethods.FillRoundedPath(G, new SolidBrush(SwitchColor), new Rectangle(1, 1, 42, 22), 22);
HelperMethods.DrawRoundedPath(G, HelperMethods.GetHTMLColor("ededed"),(Single)1.5, new Rectangle(1, 1, 42, 22), 20);
G.FillEllipse(HelperMethods.SolidBrushHTMlColor("fcfcfc"), new Rectangle(22, Convert.ToInt32(2.6), 19, 18));
G.DrawEllipse(HelperMethods.PenHTMlColor("e9e9e9", (Single)1.5), new Rectangle(22,Convert.ToInt32(2.6), 19, 18));
}
else
{
HelperMethods.FillRoundedPath(G, HelperMethods.GetHTMLColor("f8f8f8"), new Rectangle(1, 1, 42, 22), 22);
HelperMethods.DrawRoundedPath(G, HelperMethods.GetHTMLColor("ededed"), (Single)1.5, new Rectangle(1, 1, 42, 22), 20);
G.FillEllipse(HelperMethods.SolidBrushHTMlColor("fcfcfc"), new Rectangle(3, Convert.ToInt32(2.6), 19, 18));
G.DrawEllipse(HelperMethods.PenHTMlColor("e9e9e9", (Single)1.5), new Rectangle(3, Convert.ToInt32(2.6), 19, 18));
}
e.Graphics.DrawImage(B, 0, 0);
G.Dispose();
B.Dispose();
}
}
#endregion
#region Initialization
public EtherealSwitch()
{
SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint |
ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor, true);
DoubleBuffered = true;
Cursor = Cursors.Hand;
UpdateStyles();
}
#endregion
#region Events
protected override void OnHandleCreated(EventArgs e)
{
base.OnHandleCreated(e);
}
protected override void OnCreateControl()
{
base.OnCreateControl();
}
protected override void OnMouseHover(EventArgs e)
{
base.OnMouseHover(e);
State = HelperMethods.MouseMode.Hovered;
Invalidate();
}
protected override void OnMouseLeave(EventArgs e)
{
base.OnMouseLeave(e);
State = HelperMethods.MouseMode.NormalMode;
Invalidate();
}
protected override void OnClick(EventArgs e)
{
_Switched = !_Switched;
if (CheckedChanged != null)
{
CheckedChanged(this);
}
base.OnClick(e);
Invalidate();
}
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
Size = new Size(46, 25);
}
#endregion
}
#endregion
#region Progress
public class EtherealProgressBar : Control
{
#region Variables
private int _Maximum = 100;
private int _Value;
private int _RoundRadius=8;
int CurrentValue;
private Color _ProgressColor = HelperMethods.GetHTMLColor("4e3a62");
private Color _BaseColor = HelperMethods.GetHTMLColor("f7f7f7");
private Color _BorderColor = HelperMethods.GetHTMLColor("ececec");
#endregion
#region Properties
public int Value
{
get
{
if (_Value < 0)
{
return 0;
}
else
{
return _Value;
}
}
set
{
if (value > Maximum)
{
_Value = Maximum;
}
_Value = value;
RenewCurrentValue();
Invalidate();
if (ValueChanged != null)
ValueChanged(this);
Invalidate();
}
}
public int Maximum
{
get
{
return _Maximum;
}
set
{
if (_Maximum < value)
{
_Value = value;
}
_Maximum = value;
Invalidate();
}
}
public int RoundRadius
{
get
{
return _RoundRadius;
}
set
{
_RoundRadius = value;
Invalidate();
}
}
public Color ProgressColor
{
get
{
return _ProgressColor;
}
set
{
_ProgressColor = value;
Invalidate();
}
}
public Color BaseColor
{
get
{
return _BaseColor;
}
set
{
_BaseColor = value;
Invalidate();
}
}
public Color BorderColor
{
get
{
return _BorderColor;
}
set
{
_BorderColor = value;
Invalidate();
}
}
#endregion
#region Draw Control
protected override void OnPaint(PaintEventArgs e)
{
Bitmap B = new Bitmap(Width, Height);
using (Graphics G =Graphics.FromImage(B))
{
G.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
Rectangle Rect = new Rectangle(0, 0, Width - 1, Height - 1);
HelperMethods.FillRoundedPath(G, new SolidBrush(BaseColor), Rect, RoundRadius);
HelperMethods.DrawRoundedPath(G, BorderColor, 1, Rect, RoundRadius);
if(CurrentValue != 0)
{
HelperMethods.FillRoundedPath(G, ProgressColor, new Rectangle(Rect.X, Rect.Y, CurrentValue, Rect.Height), RoundRadius);
}
e.Graphics.DrawImage(B, 0, 0);
G.Dispose();
B.Dispose();
}
}
#endregion
#region Initialization
public EtherealProgressBar()
{
SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw |
ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor, true);
DoubleBuffered = true;
BackColor = Color.Transparent;
UpdateStyles();
CurrentValue = Convert.ToInt32(_Value / _Maximum * Width);
}
#endregion
#region Events
public event ValueChangedEventHandler ValueChanged;
public delegate void ValueChangedEventHandler(object sender);
public void RenewCurrentValue()
{
CurrentValue = (int)Math.Round((double)(Value) / (double)(Maximum) * (double)(Width));
}
#endregion
}
#endregion
#region Seperator
public class EtherealSeperator : Control
{
#region Variables
private Style _SepStyle = Style.Horizental;
#endregion
#region Initialization
public EtherealSeperator()
{
SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint |
ControlStyles.ResizeRedraw | ControlStyles.UserPaint |
ControlStyles.SupportsTransparentBackColor, true);
DoubleBuffered = true;
UpdateStyles();
BackColor = Color.Transparent;
ForeColor = HelperMethods.GetHTMLColor("3b2551");
}
#endregion
#region Enumerators
public enum Style
{
Horizental,
Vertiacal
};
#endregion
#region Properties
public Style SepStyle
{
get
{
return _SepStyle;
}
set
{
_SepStyle = value;
if (value == Style.Horizental)
{
Height = 4;
}
else
{
Width = 4;
}
Invalidate();
}
}
#endregion
#region DrawControl
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Bitmap B = new Bitmap(Width, Height);
using (Graphics G = Graphics.FromImage(B))
{
G.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
System.Drawing.Drawing2D.ColorBlend BL1 = new System.Drawing.Drawing2D.ColorBlend();
BL1.Positions = new Single[] { 0.0F, 0.15F, 0.85F, 1.0F };
BL1.Colors = new Color[] { Color.Transparent, ForeColor, ForeColor, Color.Transparent };
switch (SepStyle)
{
case Style.Horizental:
using (System.Drawing.Drawing2D.LinearGradientBrush lb1 = new System.Drawing.Drawing2D.LinearGradientBrush(ClientRectangle, Color.Empty, Color.Empty, 0.0F))
{
lb1.InterpolationColors = BL1;
G.DrawLine(new Pen(lb1), 0, Convert.ToInt32(0.7), Width, Convert.ToInt32(0.7));
}
break;
case Style.Vertiacal:
using (System.Drawing.Drawing2D.LinearGradientBrush lb1 = new System.Drawing.Drawing2D.LinearGradientBrush(ClientRectangle, Color.Empty, Color.Empty, 90.0F))
{
lb1.InterpolationColors = BL1;
G.DrawLine(new Pen(lb1), Convert.ToInt32(0.7), 0, Convert.ToInt32(0.7), Height);
}
break;
}
e.Graphics.DrawImage((Image)(B.Clone()), 0, 0);
G.Dispose();
B.Dispose();
}
}
#endregion
}
#endregion
#region Close
public class EtherealClose : Control
{
#region Variables
private HelperMethods.MouseMode State;
private Color _NormalColor = HelperMethods.GetHTMLColor("3f2153");
private Color _HoverColor = HelperMethods.GetHTMLColor("f0f0f0");
private Color _PushedColor = HelperMethods.GetHTMLColor("966bc1");
private Color _TextColor = Color.White;
#endregion
#region Initialization
public EtherealClose()
{
SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint |
ControlStyles.ResizeRedraw | ControlStyles.UserPaint |
ControlStyles.SupportsTransparentBackColor, true);
DoubleBuffered = true;
UpdateStyles();
BackColor = Color.Transparent;
Font = new Font("Marlett", 8);
Size = new Size(20, 20);
}
#endregion
#region Properties
public Color NormalColor
{
get
{
return _NormalColor;
}
set
{
_NormalColor=value;
Invalidate();
}
}
public Color PushedColor
{
get
{
return _PushedColor;
}
set
{
PushedColor=value;
Invalidate();
}
}
public Color HoverColor
{
get
{
return _HoverColor;
}
set
{
_HoverColor=value;
Invalidate();
}
}
public Color TextColor
{
get
{
return _TextColor;
}
set
{
_TextColor=value;
Invalidate();
}
}
#endregion
#region DrawControl
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Rectangle Rect = new Rectangle(0, 0, 22, 22);
Bitmap B = new Bitmap(Width, Height);
using (Graphics G = Graphics.FromImage(B))
{
G.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
G.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
G.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
switch(State)
{
case HelperMethods.MouseMode.NormalMode:
G.FillEllipse(new SolidBrush(NormalColor), 1, 1, 19, 19);
break;
case HelperMethods.MouseMode.Hovered:
Cursor = Cursors.Hand;
G.FillEllipse(new SolidBrush(NormalColor), 1, 1, 19, 19);
G.DrawEllipse(new Pen(HoverColor, 2), 1, 1, 18, 18);
break;
case HelperMethods.MouseMode.Pushed:
G.FillEllipse(new SolidBrush(PushedColor), 1, 1, 19, 19);
break;
}
G.DrawString("r", Font, new SolidBrush(TextColor), new Rectangle(4, 6, 18, 18));
e.Graphics.DrawImage((Image)(B.Clone()), 0, 0);
G.Dispose();
B.Dispose();
}
}
#endregion
#region Events
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
Size = new Size(20, 20);
}
protected override void OnClick(EventArgs e)
{
base.OnClick(e);
Environment.Exit(0);
Application.Exit();
}
protected override void OnMouseEnter(EventArgs e)
{
base.OnMouseEnter(e);
State = HelperMethods.MouseMode.Hovered;
Invalidate();
}
protected override void OnMouseUp(MouseEventArgs e)
{
base.OnMouseUp(e);
State = HelperMethods.MouseMode.Hovered;
Invalidate();
}
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
State = HelperMethods.MouseMode.Pushed;
Invalidate();
}
protected override void OnMouseLeave(EventArgs e)
{
base.OnMouseLeave(e);
State = HelperMethods.MouseMode.NormalMode;
Invalidate();
}
#endregion
}
#endregion
#region Maximize
public class EtherealMaximize : Control
{
#region Variables
private HelperMethods.MouseMode State;
private Color _NormalColor = HelperMethods.GetHTMLColor("3f2153");
private Color _HoverColor = HelperMethods.GetHTMLColor("f0f0f0");
private Color _PushedColor = HelperMethods.GetHTMLColor("966bc1");
private Color _TextColor = Color.White;
#endregion
#region Initialization
public EtherealMaximize()
{
SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint |
ControlStyles.ResizeRedraw | ControlStyles.UserPaint |
ControlStyles.SupportsTransparentBackColor, true);
DoubleBuffered = true;
UpdateStyles();
BackColor = Color.Transparent;
Font = new Font("Marlett", 9);
Size = new Size(20, 20);
}
#endregion
#region Properties
public Color NormalColor
{
get
{
return _NormalColor;
}
set
{
_NormalColor = value;
Invalidate();
}
}
public Color PushedColor
{
get
{
return _PushedColor;
}
set
{
PushedColor = value;
Invalidate();
}
}
public Color HoverColor
{
get
{
return _HoverColor;
}
set
{
_HoverColor = value;
Invalidate();
}
}
public Color TextColor
{
get
{
return _TextColor;
}
set
{
_TextColor = value;
Invalidate();
}
}
#endregion
#region DrawControl
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Rectangle Rect = new Rectangle(0, 0, 22, 22);
Bitmap B = new Bitmap(Width, Height);
using (Graphics G = Graphics.FromImage(B))
{
G.Clear(HelperMethods.GetHTMLColor("3f2153"));
G.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
G.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
G.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
switch (State)
{
case HelperMethods.MouseMode.NormalMode:
G.FillEllipse(new SolidBrush(NormalColor), 1, 1, 19, 19);
break;
case HelperMethods.MouseMode.Hovered:
Cursor = Cursors.Hand;
G.FillEllipse(new SolidBrush(NormalColor), 1, 1, 19, 19);
G.DrawEllipse(new Pen(HoverColor, 2), 1, 1, 18, 18);
break;
case HelperMethods.MouseMode.Pushed:
G.FillEllipse(new SolidBrush(PushedColor), 1, 1, 19, 19);
break;
}
G.DrawString("v", Font, new SolidBrush(TextColor), new Rectangle(Convert.ToInt32(3.4), 5, 18, 18));
e.Graphics.DrawImage((Image)(B.Clone()), 0, 0);
G.Dispose();
B.Dispose();
}
}
#endregion
#region Events
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
Size = new Size(22, 22);
}
protected override void OnClick(EventArgs e)
{
base.OnClick(e);
if (FindForm().WindowState == FormWindowState.Normal)
{
FindForm().WindowState = FormWindowState.Maximized;
}
else
{
FindForm().WindowState = FormWindowState.Normal;
}
}
protected override void OnMouseEnter(EventArgs e)
{
base.OnMouseEnter(e);
State = HelperMethods.MouseMode.Hovered;
Invalidate();
}
protected override void OnMouseUp(MouseEventArgs e)
{
base.OnMouseUp(e);
State = HelperMethods.MouseMode.Hovered;
Invalidate();
}
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
State = HelperMethods.MouseMode.Pushed;
Invalidate();
}
protected override void OnMouseLeave(EventArgs e)
{
base.OnMouseLeave(e);
State = HelperMethods.MouseMode.NormalMode;
Invalidate();
}
#endregion
}
#endregion
#region Minimize
public class EtherealMinimize : Control
{
#region Variables
private HelperMethods.MouseMode State;
private Color _NormalColor = HelperMethods.GetHTMLColor("3f2153");
private Color _HoverColor = HelperMethods.GetHTMLColor("f0f0f0");
private Color _PushedColor = HelperMethods.GetHTMLColor("966bc1");
private Color _TextColor = Color.White;
#endregion
#region Initialization
public EtherealMinimize()
{
SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint |
ControlStyles.ResizeRedraw | ControlStyles.UserPaint |
ControlStyles.SupportsTransparentBackColor, true);
DoubleBuffered = true;
UpdateStyles();
BackColor = Color.Transparent;
Font = new Font("Marlett", 9);
Size = new Size(21, 21);
}
#endregion
#region Properties
public Color NormalColor
{
get
{
return _NormalColor;
}
set
{
_NormalColor = value;
Invalidate();
}
}
public Color PushedColor
{
get
{
return _PushedColor;
}
set
{
PushedColor = value;
Invalidate();
}
}
public Color HoverColor
{
get
{
return _HoverColor;
}
set
{
_HoverColor = value;
Invalidate();
}
}
public Color TextColor
{
get
{
return _TextColor;
}
set
{
_TextColor = value;
Invalidate();
}
}
#endregion
#region DrawControl
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Rectangle Rect = new Rectangle(0, 0, 22, 22);
Bitmap B = new Bitmap(Width, Height);
using (Graphics G = Graphics.FromImage(B))
{
G.Clear(HelperMethods.GetHTMLColor("3f2153"));
G.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
G.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
G.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
switch (State)
{
case HelperMethods.MouseMode.NormalMode:
G.FillEllipse(new SolidBrush(NormalColor), 1, 1, 19, 19);
break;
case HelperMethods.MouseMode.Hovered:
Cursor = Cursors.Hand;
G.FillEllipse(new SolidBrush(NormalColor), 1, 1, 19, 19);
G.DrawEllipse(new Pen(HoverColor, 2), 1, 1, 18, 18);
break;
case HelperMethods.MouseMode.Pushed:
G.FillEllipse(new SolidBrush(PushedColor), 1, 1, 19, 19);
break;
}
G.DrawString("0", Font, new SolidBrush(TextColor), new Rectangle(Convert.ToInt32(4.5), Convert.ToInt32(2.6), 18, 18));
e.Graphics.DrawImage((Image)(B.Clone()), 0, 0);
G.Dispose();
B.Dispose();
}
}
#endregion
#region Events
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
Size = new Size(22, 22);
}
protected override void OnClick(EventArgs e)
{
base.OnClick(e);
if (FindForm().WindowState == FormWindowState.Normal)
{
FindForm().WindowState = FormWindowState.Minimized;
}
}
protected override void OnMouseEnter(EventArgs e)
{
base.OnMouseEnter(e);
State = HelperMethods.MouseMode.Hovered;
Invalidate();
}
protected override void OnMouseUp(MouseEventArgs e)
{
base.OnMouseUp(e);
State = HelperMethods.MouseMode.Hovered;
Invalidate();
}
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
State = HelperMethods.MouseMode.Pushed;
Invalidate();
}
protected override void OnMouseLeave(EventArgs e)
{
base.OnMouseLeave(e);
State = HelperMethods.MouseMode.NormalMode;
Invalidate();
}
#endregion
}
#endregion
#region Label
public class EtherealLabel :Control
{
#region Vaeiables
private Style _ColorStyle=Style.DarkPink;
#endregion
#region Initialization
public EtherealLabel()
{
SetStyle(ControlStyles.SupportsTransparentBackColor | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer, true);
DoubleBuffered = true;
Font = new Font("Montserrat", 10, FontStyle.Bold);
}
#endregion
#region Properties
public Style ColorStyle
{
get
{
return _ColorStyle;
}
set
{
_ColorStyle = value;
Invalidate();
}
}
#endregion
#region Enumerators
public enum Style
{
SemiBlack,
DarkPink,
LightPink
}
#endregion
#region DrawControl
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Rectangle Rect = new Rectangle(0, 0, 22, 22);
Bitmap B = new Bitmap(Width, Height);
using (Graphics G = Graphics.FromImage(B))
{
G.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
switch (ColorStyle)
{
case Style.SemiBlack:
G.DrawString(Text, Font, HelperMethods.SolidBrushHTMlColor("222222"), ClientRectangle);
break;
case Style.DarkPink:
G.DrawString(Text, Font, HelperMethods.SolidBrushHTMlColor("3b2551"), ClientRectangle);
break;
case Style.LightPink:
G.DrawString(Text, Font, HelperMethods.SolidBrushHTMlColor("9d92a8"), ClientRectangle);
break;
}
e.Graphics.DrawImage((Image)(B.Clone()), 0, 0);
G.Dispose();
B.Dispose();
}
}
#endregion
}
Код:
#Region " Namespaces "
Imports System.Drawing.Drawing2D
Imports System.ComponentModel
#End Region
#Region " Helper Methods "
Public Module HelperMethods
Public GP As GraphicsPath
Public Enum MouseMode As Byte
NormalMode
Hovered
Pushed
End Enum
Public Sub DrawImageFromBase64(ByVal G As Graphics, ByVal Base64Image As String, ByVal Rect As Rectangle)
Dim IM As Image = Nothing
With G
Using ms As New System.IO.MemoryStream(Convert.FromBase64String(Base64Image))
IM = Image.FromStream(ms) : ms.Close()
End Using
.DrawImage(IM, Rect)
End With
End Sub
Function RoundRec(ByVal r As Rectangle, ByVal Curve As Integer) As GraphicsPath
Dim CreateRoundPath As New GraphicsPath(FillMode.Winding)
CreateRoundPath.AddArc(r.X, r.Y, Curve, Curve, 180.0F, 90.0F)
CreateRoundPath.AddArc(r.Right - Curve, r.Y, Curve, Curve, 270.0F, 90.0F)
CreateRoundPath.AddArc(r.Right - Curve, r.Bottom - Curve, Curve, Curve, 0.0F, 90.0F)
CreateRoundPath.AddArc(r.X, r.Bottom - Curve, Curve, Curve, 90.0F, 90.0F)
CreateRoundPath.CloseFigure()
Return CreateRoundPath
End Function
Public Sub FillRoundedPath(ByVal G As Graphics, ByVal C As Color, ByVal Rect As Rectangle, ByVal Curve As Integer)
With G
.FillPath(New SolidBrush(C), RoundRec(Rect, Curve))
End With
End Sub
Public Sub FillRoundedPath(ByVal G As Graphics, ByVal B As Brush, ByVal Rect As Rectangle, ByVal Curve As Integer)
With G
.FillPath(B, RoundRec(Rect, Curve))
End With
End Sub
Public Sub DrawRoundedPath(ByVal G As Graphics, ByVal C As Color, ByVal Size As Single, ByVal Rect As Rectangle, ByVal Curve As Integer)
With G
.DrawPath(New Pen(C, Size), RoundRec(Rect, Curve))
End With
End Sub
Public Sub DrawTriangle(ByVal G As Graphics, ByVal C As Color, ByVal Size As Integer, ByVal P1_0 As Point, ByVal P1_1 As Point, ByVal P2_0 As Point, ByVal P2_1 As Point, ByVal P3_0 As Point, ByVal P3_1 As Point)
With G
.DrawLine(New Pen(C, Size), P1_0, P1_1)
.DrawLine(New Pen(C, Size), P2_0, P2_1)
.DrawLine(New Pen(C, Size), P3_0, P3_1)
End With
End Sub
Public Function PenRGBColor(ByVal GR As Graphics, ByVal R As Integer, ByVal G As Integer, ByVal B As Integer, ByVal Size As Single) As Pen
Return New Pen(Color.FromArgb(R, G, B), Size)
End Function
Public Function PenHTMlColor(ByVal C_WithoutHash As String, ByVal Size As Single) As Pen
Return New Pen(GetHTMLColor(C_WithoutHash), Size)
End Function
Public Function SolidBrushRGBColor(ByVal R As Integer, ByVal G As Integer, ByVal B As Integer) As SolidBrush
Return New SolidBrush(Color.FromArgb(R, G, B))
End Function
Public Function SolidBrushHTMlColor(ByVal C_WithoutHash As String) As SolidBrush
Return New SolidBrush(GetHTMLColor(C_WithoutHash))
End Function
Public Function GetHTMLColor(ByVal C_WithoutHash As String) As Color
Return ColorTranslator.FromHtml("#" & C_WithoutHash)
End Function
Public Function ColorToHTML(ByVal C As Color) As String
Return ColorTranslator.ToHtml(C)
End Function
Public Function SetARGB(ByVal A As Integer, ByVal R As Integer, ByVal G As Integer, ByVal B As Integer) As Color
Return Color.FromArgb(A, R, G, B)
End Function
Public Function SetRGB(ByVal R As Integer, ByVal G As Integer, ByVal B As Integer) As Color
Return Color.FromArgb(R, G, B)
End Function
Public Sub CentreString(ByVal G As Graphics, ByVal Text As String, ByVal font As Font, ByVal brush As Brush, ByVal Rect As Rectangle)
G.DrawString(Text, font, brush, New Rectangle(0, Rect.Y + (Rect.Height / 2) - (G.MeasureString(Text, font).Height / 2) + 0, Rect.Width, Rect.Height), New StringFormat With {.Alignment = StringAlignment.Center})
End Sub
Public Sub LeftString(ByVal G As Graphics, ByVal Text As String, ByVal font As Font, ByVal brush As Brush, ByVal Rect As Rectangle)
G.DrawString(Text, font, brush, New Rectangle(4, Rect.Y + (Rect.Height / 2) - (G.MeasureString(Text, font).Height / 2) + 0, Rect.Width, Rect.Height), New StringFormat With {.Alignment = StringAlignment.Near})
End Sub
Public Sub FillRect(ByVal G As Graphics, ByVal Br As Brush, ByVal Rect As Rectangle)
G.FillRectangle(Br, Rect)
End Sub
End Module
#End Region
#Region " Skin "
Public Class EtherealTheme : Inherits ContainerControl
#Region " Variables "
Private Movable As Boolean = False
Private MousePoint As New Point(0, 0)
Private MoveHeight = 50
Private _TitleTextPostion As TitlePostion = TitlePostion.Left
Private _HeaderColor As Color = GetHTMLColor("3f2153")
Private _BackColor As Color = Color.White
Private _BorderColor As Color = GetHTMLColor("3f2153")
Private Property _ShowIcon As Boolean = False
#End Region
#Region " Properties"
Public Property HeaderColor As Color
Get
Return _HeaderColor
End Get
Set(value As Color)
_HeaderColor = value
Invalidate()
End Set
End Property
Public Overridable Shadows Property BackColor As Color
Get
Return _BackColor
End Get
Set(value As Color)
_BackColor = value
MyBase.BackColor = value
Invalidate()
End Set
End Property
Public Property BorderColor As Color
Get
Return _BorderColor
End Get
Set(value As Color)
_BorderColor = value
Invalidate()
End Set
End Property
Public Overridable Shadows Property ShowIcon As Boolean
Get
Return _ShowIcon
End Get
Set(ByVal value As Boolean)
If value = _ShowIcon Then Return
FindForm().ShowIcon = value
Invalidate()
_ShowIcon = value
End Set
End Property
Public Overridable Property TitleTextPostion As TitlePostion
Get
Return _TitleTextPostion
End Get
Set(value As TitlePostion)
_TitleTextPostion = value
End Set
End Property
Enum TitlePostion
Left
Center
End Enum
#End Region
#Region " Initialization "
Sub New()
SetStyle(ControlStyles.UserPaint Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.AllPaintingInWmPaint Or ControlStyles.ResizeRedraw, True)
DoubleBuffered = True
MyBase.Dock = DockStyle.None
Font = New Font("Proxima Nova", 14, FontStyle.Bold)
End Sub
#End Region
#Region " Draw Control "
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
Dim B As New Bitmap(Width, Height), G = Graphics.FromImage(B)
With G
.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
FillRect(G, New SolidBrush(HeaderColor), New Rectangle(0, 0, Width, 50))
.DrawRectangle(New Pen(BorderColor, 2), New Rectangle(1, 1, Width - 2, Height - 2))
If FindForm().ShowIcon = True Then
G.DrawIcon(FindForm().Icon, New Rectangle(5, 13, 20, 20))
Select Case TitleTextPostion
Case TitlePostion.Left
G.DrawString(Text, Font, Brushes.White, 27, 10)
Exit Select
Case TitlePostion.Center
HelperMethods.CentreString(G, Text, Font, Brushes.White, New Rectangle(0, 0, Width, 50))
Exit Select
End Select
Else
Select Case TitleTextPostion
Case TitlePostion.Left
G.DrawString(Text, Font, Brushes.White, 5, 10)
Exit Select
Case TitlePostion.Center
HelperMethods.CentreString(G, Text, Font, Brushes.White, New Rectangle(0, 0, Width, 50))
Exit Select
End Select
End If
End With
MyBase.OnPaint(e)
e.Graphics.DrawImage(B.Clone, 0, 0)
G.Dispose() : B.Dispose()
End Sub
Protected Overrides Sub CreateHandle()
MyBase.CreateHandle()
End Sub
Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
MyBase.OnMouseDown(e)
If e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(0, 0, Width, MoveHeight).Contains(e.Location) Then
Movable = True
MousePoint = e.Location
End If
End Sub
Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
MyBase.OnMouseUp(e) : Movable = False
End Sub
Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
MyBase.OnMouseMove(e)
If Movable Then Parent.Location = MousePosition - MousePoint
End Sub
Protected Overrides Sub OnCreateControl()
MyBase.OnCreateControl()
ParentForm.FormBorderStyle = FormBorderStyle.None
ParentForm.AllowTransparency = False
ParentForm.TransparencyKey = Color.Fuchsia
ParentForm.FindForm.StartPosition = FormStartPosition.CenterScreen
Dock = DockStyle.Fill
Invalidate()
End Sub
#End Region
End Class
#End Region
#Region " TabControl "
Public Class EtherealTabControl : Inherits TabControl
#Region " Variables "
Private State As New MouseMode
Private _TabsColor As Color = GetHTMLColor("432e58")
Private _SeletedTabTriangleColor As Color = Color.White
Private _LeftColor As Color = GetHTMLColor("4e3a62")
Private _RightColor As Color = Color.White
Private _LineColor As Color = GetHTMLColor("3b2551")
Private _NoneSelectedTabColors As Color = GetHTMLColor("432e58")
Private _HoverColor As Color = GetHTMLColor("3b2551")
Private _TextColor As Color = Color.White
Private _TabPageColor As Color = Color.White
#End Region
#Region " Properties "
Public Property TabsColor As Color
Get
Return _TabsColor
End Get
Set(value As Color)
_TabsColor = value
Invalidate()
End Set
End Property
Public Property SeletedTabTriangleColor As Color
Get
Return _SeletedTabTriangleColor
End Get
Set(value As Color)
_SeletedTabTriangleColor = value
Invalidate()
End Set
End Property
Public Property LeftColor As Color
Get
Return _LeftColor
End Get
Set(value As Color)
_LeftColor = value
Invalidate()
End Set
End Property
Public Property RightColor As Color
Get
Return _RightColor
End Get
Set(value As Color)
_RightColor = value
Invalidate()
End Set
End Property
Public Property LineColor As Color
Get
Return _LineColor
End Get
Set(value As Color)
_LineColor = value
Invalidate()
End Set
End Property
Public Property NoneSelectedTabColors As Color
Get
Return _NoneSelectedTabColors
End Get
Set(value As Color)
_NoneSelectedTabColors = value
Invalidate()
End Set
End Property
Public Property TextColor As Color
Get
Return _TextColor
End Get
Set(value As Color)
_TextColor = value
Invalidate()
End Set
End Property
Public Property HoverColor As Color
Get
Return _HoverColor
End Get
Set(value As Color)
_HoverColor = value
Invalidate()
End Set
End Property
Public Property TabPageColor As Color
Get
Return _TabPageColor
End Get
Set(value As Color)
_TabPageColor = value
Invalidate()
End Set
End Property
#End Region
#Region " Stractures "
Private Structure MouseMode
Dim Hover As Boolean
Dim Coordinates As Point
End Structure
#End Region
#Region " Initialization "
Sub New()
SetStyle(ControlStyles.UserPaint Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.AllPaintingInWmPaint Or ControlStyles.SupportsTransparentBackColor, True)
DoubleBuffered = True
SizeMode = TabSizeMode.Fixed
Dock = DockStyle.None
ItemSize = New Size(40, 150)
Alignment = TabAlignment.Left
End Sub
#End Region
#Region " Draw Control "
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
Using B As New Bitmap(Width, Height), G As Graphics = Graphics.FromImage(B)
With G
.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
.InterpolationMode = InterpolationMode.HighQualityBicubic
FillRect(G, New SolidBrush(LeftColor), New Rectangle(0, 1, 150, Height))
For i = 0 To TabCount - 1
Dim R As Rectangle = GetTabRect(i)
FillRect(G, New SolidBrush(NoneSelectedTabColors), New Rectangle(R.X - 1, R.Y - 1, R.Width - 3, R.Height))
If i = SelectedIndex Then
.SmoothingMode = SmoothingMode.AntiAlias
Dim P1 As New Point(ItemSize.Height - 12, R.Location.Y + 20), _
P2 As New Point(ItemSize.Height + 2, R.Location.Y + 10), _
P3 As New Point(ItemSize.Height + 2, R.Location.Y + 30)
.FillPolygon(New SolidBrush(SeletedTabTriangleColor), New Point() {P1, P2, P3})
Else
If State.Hover AndAlso R.Contains(State.Coordinates) Then
Cursor = Cursors.Hand
FillRect(G, New SolidBrush(HoverColor), New Rectangle(R.X, R.Y, R.Width - 3, R.Height))
End If
End If
.DrawString(TabPages(i).Text, New Font("Segoe UI", 8, FontStyle.Bold), New SolidBrush(TextColor), R.X + 28, R.Y + 13)
If ImageList IsNot Nothing Then
.DrawImage(ImageList.Images(i), New Rectangle(R.X + 6, R.Y + 11, 16, 16))
End If
.DrawLine(New Pen(LineColor, 1), New Point(R.X - 1, R.Bottom - 2), New Point(R.Width - 2, R.Bottom - 2))
Next
.FillRectangle(New SolidBrush(RightColor), New Rectangle(150, 1.3, Width, Height - 2))
.DrawRectangle(New Pen(LineColor, 1), New Rectangle(0, 0, Width - 1, Height - 1))
End With
e.Graphics.DrawImage(B, 0, 0)
G.Dispose()
B.Dispose()
End Using
End Sub
#End Region
#Region " Events "
Protected Overrides Sub OnMouseEnter(e As System.EventArgs)
State.Hover = True
MyBase.OnMouseHover(e)
End Sub
Protected Overrides Sub OnMouseLeave(e As System.EventArgs)
State.Hover = False
For Each Tab As TabPage In MyBase.TabPages
If Tab.DisplayRectangle.Contains(State.Coordinates) Then
Invalidate()
Exit For
End If
Next
MyBase.OnMouseHover(e)
End Sub
Protected Overrides Sub OnMouseMove(e As System.Windows.Forms.MouseEventArgs)
State.Coordinates = e.Location
For Each Tab As TabPage In MyBase.TabPages
If Tab.DisplayRectangle.Contains(e.Location) Then
Invalidate()
Exit For
End If
Next
MyBase.OnMouseMove(e)
End Sub
Protected Overrides Sub OnCreateControl()
MyBase.OnCreateControl()
For Each T As TabPage In TabPages
T.BackColor = TabPageColor
Next
End Sub
#End Region
End Class
#End Region
#Region " Button "
Public Class EtherealButton : Inherits Control
#Region " Variables "
Private State As MouseMode
Public Property ButtonStyle As Style
Private NoneColor As Color = GetHTMLColor("222222")
Private _RoundRadius As Integer = 5
#End Region
#Region " Properties "
Public Property RoundRadius As Integer
Get
Return _RoundRadius
End Get
Set(value As Integer)
_RoundRadius = value
Invalidate()
End Set
End Property
#End Region
#Region " Initialization "
Sub New()
SetStyle(ControlStyles.DoubleBuffer Or ControlStyles.AllPaintingInWmPaint Or _
ControlStyles.ResizeRedraw Or ControlStyles.UserPaint Or _
ControlStyles.Selectable Or ControlStyles.SupportsTransparentBackColor, True)
DoubleBuffered = True
BackColor = Color.Transparent
End Sub
#End Region
#Region " Enumerators "
Public Enum Style As Byte
Clear
DarkClear
SemiBlack
DarkPink
LightPink
End Enum
#End Region
#Region " Draw Control "
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
Using B As New Bitmap(Width, Height), G As Graphics = Graphics.FromImage(B)
Dim Rect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
With G
GP = RoundRec(Rect, RoundRadius)
.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
.SmoothingMode = SmoothingMode.HighQuality
Select Case State
Case MouseMode.NormalMode
Select Case ButtonStyle
Case Style.Clear
NoneColor = GetHTMLColor("ececec")
DrawRoundedPath(G, NoneColor, 1, Rect, RoundRadius)
CentreString(G, Text, New Font("Segoe UI", 9, FontStyle.Bold), SolidBrushHTMlColor("b9b9b9"), Rect)
Case Style.DarkClear
NoneColor = GetHTMLColor("444444")
DrawRoundedPath(G, NoneColor, 1, Rect, RoundRadius)
CentreString(G, Text, New Font("Segoe UI", 9, FontStyle.Bold), SolidBrushHTMlColor("444444"), Rect)
Case Style.SemiBlack
NoneColor = GetHTMLColor("222222")
FillRoundedPath(G, NoneColor, Rect, RoundRadius)
DrawRoundedPath(G, GetHTMLColor("121212"), 1, Rect, RoundRadius)
CentreString(G, Text, New Font("Segoe UI", 9, FontStyle.Bold), Brushes.White, Rect)
Case Style.DarkPink
NoneColor = GetHTMLColor("3b2551")
FillRoundedPath(G, NoneColor, Rect, RoundRadius)
DrawRoundedPath(G, GetHTMLColor("6d5980"), 1, Rect, RoundRadius)
CentreString(G, Text, New Font("Segoe UI", 9, FontStyle.Bold), Brushes.White, Rect)
Case Style.LightPink
NoneColor = GetHTMLColor("9d92a8")
FillRoundedPath(G, NoneColor, Rect, RoundRadius)
DrawRoundedPath(G, GetHTMLColor("573d71"), 1, Rect, RoundRadius)
CentreString(G, Text, New Font("Segoe UI", 9, FontStyle.Bold), Brushes.White, Rect)
End Select
Case MouseMode.Hovered
NoneColor = GetHTMLColor("444444")
Select Case ButtonStyle
Case Style.Clear
NoneColor = GetHTMLColor("444444")
DrawRoundedPath(G, NoneColor, 1, Rect, RoundRadius)
CentreString(G, Text, New Font("Segoe UI", 9, FontStyle.Bold), SolidBrushHTMlColor("444444"), Rect)
Case Style.DarkClear
NoneColor = GetHTMLColor("ececec")
DrawRoundedPath(G, NoneColor, 1, Rect, RoundRadius)
CentreString(G, Text, New Font("Segoe UI", 9, FontStyle.Bold), SolidBrushHTMlColor("b9b9b9"), Rect)
Case Style.SemiBlack
NoneColor = GetHTMLColor("444444")
.FillPath(New SolidBrush(Color.Transparent), GP)
DrawRoundedPath(G, NoneColor, 1, Rect, RoundRadius)
CentreString(G, Text, New Font("Segoe UI", 9, FontStyle.Bold), SolidBrushHTMlColor("444444"), Rect)
Case Style.DarkPink
NoneColor = GetHTMLColor("444444")
FillRect(G, New SolidBrush(Color.Transparent), Rect)
DrawRoundedPath(G, NoneColor, 1, Rect, RoundRadius)
CentreString(G, Text, New Font("Segoe UI", 9, FontStyle.Bold), SolidBrushHTMlColor("444444"), Rect)
Case Style.LightPink
NoneColor = GetHTMLColor("9d92a8")
FillRect(G, New SolidBrush(Color.Transparent), Rect)
DrawRoundedPath(G, NoneColor, 1, Rect, RoundRadius)
CentreString(G, Text, New Font("Segoe UI", 9, FontStyle.Bold), SolidBrushHTMlColor("444444"), Rect)
End Select
Case MouseMode.Pushed
Select Case ButtonStyle
Case Style.Clear, Style.DarkClear
NoneColor = GetHTMLColor("444444")
FillRect(G, New SolidBrush(Color.Transparent), Rect)
DrawRoundedPath(G, NoneColor, 1, Rect, 5)
CentreString(G, Text, New Font("Segoe UI", 9, FontStyle.Bold), SolidBrushHTMlColor("444444"), Rect)
Case Style.DarkPink, Style.LightPink, Style.SemiBlack
NoneColor = GetHTMLColor("ececec")
DrawRoundedPath(G, NoneColor, 1, Rect, 5)
CentreString(G, Text, New Font("Segoe UI", 9, FontStyle.Bold), SolidBrushHTMlColor("b9b9b9"), Rect)
End Select
End Select
End With
e.Graphics.DrawImage(B.Clone, 0, 0)
G.Dispose() : B.Dispose()
End Using
End Sub
#End Region
#Region " Events "
Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
MyBase.OnMouseUp(e)
State = MouseMode.Hovered : Invalidate()
End Sub
Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
MyBase.OnMouseUp(e)
State = MouseMode.Pushed : Invalidate()
End Sub
Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
MyBase.OnMouseEnter(e)
State = MouseMode.Hovered : Invalidate()
End Sub
Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
MyBase.OnMouseEnter(e)
State = MouseMode.NormalMode : Invalidate()
End Sub
#End Region
End Class
#End Region
#Region " ComboBox "
Public Class EtherealComboBox : Inherits ComboBox
#Region " Variables "
Private _StartIndex As Integer = 0
Private _BorderColor As Color = GetHTMLColor("ececec")
Private _TextColor As Color = GetHTMLColor("b8c6d6")
Private _TriangleColor As Color = GetHTMLColor("999999")
#End Region
#Region " Properties "
Private Property StartIndex As Integer
Get
Return _StartIndex
End Get
Set(ByVal value As Integer)
_StartIndex = value
Try
MyBase.SelectedIndex = value
Catch
End Try
Invalidate()
End Set
End Property
Public Property BorderColor As Color
Get
Return _BorderColor
End Get
Set(value As Color)
_BorderColor = value
Invalidate()
End Set
End Property
Public Property TextColor As Color
Get
Return _TextColor
End Get
Set(value As Color)
_TextColor = value
Invalidate()
End Set
End Property
Public Property TriangleColor As Color
Get
Return _TriangleColor
End Get
Set(value As Color)
_TriangleColor = value
Invalidate()
End Set
End Property
#End Region
#Region " Initialization "
Sub New()
SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint Or _
ControlStyles.OptimizedDoubleBuffer Or ControlStyles.SupportsTransparentBackColor, True)
DrawMode = Windows.Forms.DrawMode.OwnerDrawFixed
Size = New Size(200, 35)
DropDownStyle = ComboBoxStyle.DropDownList
BackColor = Color.Transparent
Font = New Font("Segoe UI", 15)
DoubleBuffered = True
End Sub
#End Region
#Region " Draw Control "
Sub MyBase_DrawItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles MyBase.DrawItem
Try
With e.Graphics
.SmoothingMode = SmoothingMode.HighQuality
.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
e.DrawBackground()
If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
.FillRectangle(SolidBrushHTMlColor("3b2551"), e.Bounds)
.DrawString(MyBase.GetItemText(MyBase.Items(e.Index)), New Font("Segoe UI", 10, FontStyle.Bold), New SolidBrush(Color.WhiteSmoke), 1, e.Bounds.Top + 5)
Else
.FillRectangle(New SolidBrush(e.BackColor), e.Bounds)
.DrawString(MyBase.GetItemText(MyBase.Items(e.Index)), New Font("Segoe UI", 10, FontStyle.Bold), SolidBrushHTMlColor("b8c6d6"), 1, e.Bounds.Top + 5)
End If
End With
Catch
End Try
Invalidate()
End Sub
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
Using B As New Bitmap(Width, Height), G As Graphics = Graphics.FromImage(B)
Dim Rect As New Rectangle(1, 1, Width - 2, Height - 2)
With G
.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias : .SmoothingMode = SmoothingMode.HighQuality : .PixelOffsetMode = PixelOffsetMode.HighQuality
DrawTriangle(G, TriangleColor, 2, _
New Point(Width - 20, 16), New Point(Width - 16, 20), _
New Point(Width - 16, 20), New Point(Width - 12, 16), _
New Point(Width - 16, 21), New Point(Width - 16, 20) _
)
DrawRoundedPath(G, BorderColor, 1.5, Rect, 4)
.DrawString(Text, Font, New SolidBrush(TextColor), New Rectangle(7, 0, Width - 1, Height - 1), New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Near})
End With
e.Graphics.DrawImage(B, 0, 0)
G.Dispose()
B.Dispose()
End Using
End Sub
#End Region
End Class
#End Region
#Region " Textbox "
Public Class EtherealTextbox : Inherits Control
#Region " Variables "
Private WithEvents T As New TextBox
Private _TextAlign As HorizontalAlignment = HorizontalAlignment.Left
Private _MaxLength As Integer = 32767
Private _ReadOnly As Boolean = False
Private _UseSystemPasswordChar As Boolean = False
Private _WatermarkText As String = String.Empty
Private _SideImage As Image
Private _BackColor As Color = Color.White
Private _BorderColor As Color = GetHTMLColor("ececec")
Private _ForeColor As Color = Color.Gray
#End Region
#Region " Native Methods "
Private Declare Auto Function SendMessage Lib "user32.dll" (hWnd As IntPtr, msg As Integer, wParam As Integer, <System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr)> lParam As String) As Int32
#End Region
#Region " Properties "
<Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
Property BorderStyle As BorderStyle
Get
Return BorderStyle.None
End Get
Set(ByVal value As BorderStyle)
End Set
End Property
Public Property WatermarkText As String
Get
Return _WatermarkText
End Get
Set(value As String)
_WatermarkText = value
SendMessage(T.Handle, &H1501, 0, value)
Invalidate()
End Set
End Property
Public Overridable Shadows Property TextAlign() As HorizontalAlignment
Get
Return _TextAlign
End Get
Set(ByVal value As HorizontalAlignment)
_TextAlign = value
If T IsNot Nothing Then
T.TextAlign = value
End If
End Set
End Property
Public Overridable Shadows Property MaxLength() As Integer
Get
Return _MaxLength
End Get
Set(ByVal value As Integer)
_MaxLength = value
If T IsNot Nothing Then
T.MaxLength = value
End If
End Set
End Property
Public Overridable Shadows Property [ReadOnly]() As Boolean
Get
Return _ReadOnly
End Get
Set(ByVal value As Boolean)
_ReadOnly = value
If T IsNot Nothing Then
T.ReadOnly = value
End If
End Set
End Property
Public Overridable Shadows Property UseSystemPasswordChar() As Boolean
Get
Return _UseSystemPasswordChar
End Get
Set(ByVal value As Boolean)
_UseSystemPasswordChar = value
If T IsNot Nothing Then
T.UseSystemPasswordChar = value
End If
End Set
End Property
Public Overridable Shadows ReadOnly Property Multiline() As Boolean
Get
Return False
End Get
End Property
Public Overridable Shadows Property Text As String
Get
Return MyBase.Text
End Get
Set(ByVal value As String)
MyBase.Text = value
If T IsNot Nothing Then
T.Text = value
End If
End Set
End Property
<Browsable(False)>
Public Overridable Shadows ReadOnly Property Font As Font
Get
Return New Font("Segoe UI", 10, FontStyle.Regular)
End Get
End Property
Public Overridable Shadows Property ForeColor As Color
Get
Return _ForeColor
End Get
Set(value As Color)
MyBase.ForeColor = value
T.ForeColor = value
_ForeColor = value
Invalidate()
End Set
End Property
<Browsable(True)>
Public Property SideImage As Image
Get
Return _SideImage
End Get
Set(value As Image)
_SideImage = value
End Set
End Property
Protected Overrides Sub OnCreateControl()
MyBase.OnCreateControl()
If Not Controls.Contains(T) Then
Controls.Add(T)
End If
End Sub
Private Sub T_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles T.TextChanged
Text = T.Text
End Sub
Private Sub T_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs) Handles T.KeyDown
If e.Control AndAlso e.KeyCode = Keys.A Then e.SuppressKeyPress = True
If e.Control AndAlso e.KeyCode = Keys.C Then
T.Copy()
e.SuppressKeyPress = True
End If
End Sub
Public Overridable Shadows Property BackColor As Color
Get
Return _BackColor
End Get
Set(value As Color)
MyBase.BackColor = value
T.BackColor = value
_BackColor = value
Invalidate()
End Set
End Property
Public Property BorderColor As Color
Get
Return _BorderColor
End Get
Set(value As Color)
_BorderColor = value
Invalidate()
End Set
End Property
#End Region
#Region " Initialization "
Sub New()
SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or _
ControlStyles.SupportsTransparentBackColor, True)
DoubleBuffered = True
With T
.Multiline = False
.Cursor = Cursors.IBeam
.BackColor = BackColor
.ForeColor = ForeColor
.Text = WatermarkText
.BorderStyle = BorderStyle.None
.Location = New Point(7, 7)
.Font = Font
.Size = New Size(Width - 10, 34)
.UseSystemPasswordChar = _UseSystemPasswordChar
Text = WatermarkText
End With
Size = New Size(135, 34)
End Sub
#End Region
#Region " Draw Control "
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
Using B As New Bitmap(Width, Height), G As Graphics = Graphics.FromImage(B)
Height = 34
With G
.SmoothingMode = SmoothingMode.HighQuality
.Clear(BackColor)
DrawRoundedPath(G, BorderColor, 1.8, New Rectangle(0, 0, Width - 1, Height - 1), 4)
If Not SideImage Is Nothing Then
T.Location = New Point(45, 7)
T.Width = Width - 60
.DrawRectangle(New Pen(BorderColor, 1), New Rectangle(-1, -1, 35, Height + 1))
.DrawImage(SideImage, New Rectangle(8, 7, 16, 16))
Else
T.Location = New Point(7, 7)
T.Width = Width - 10
End If
End With
e.Graphics.DrawImage(B.Clone(), 0, 0)
G.Dispose() : B.Dispose()
End Using
End Sub
#End Region
End Class
#End Region
#Region " Seperator "
Public Class EtherealSeperator : Inherits Control
#Region " Variables "
Public Property SepStyle As Style = Style.Horizental
#End Region
#Region " Enumerators "
Enum Style
Horizental
Vertiacal
End Enum
#End Region
#Region " Initialization "
Sub New()
SetStyle(ControlStyles.SupportsTransparentBackColor Or ControlStyles.UserPaint, True)
DoubleBuffered = True
BackColor = Color.Transparent
ForeColor = GetHTMLColor("3b2551")
End Sub
#End Region
#Region " Draw Control "
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
Dim B As New Bitmap(Width, Height), G = e.Graphics
With G
.SmoothingMode = SmoothingMode.HighQuality
Dim BL1, BL2 As New ColorBlend
BL1.Positions = New Single() {0.0F, 0.15F, 0.85F, 1.0F}
BL1.Colors = New Color() {Color.Transparent, ForeColor, ForeColor, Color.Transparent}
Select Case SepStyle
Case Style.Horizental
Dim lb1 As New LinearGradientBrush(ClientRectangle, Color.Empty, Color.Empty, 0.0F)
lb1.InterpolationColors = BL1
.DrawLine(New Pen(lb1), 0, 1, Width, 1)
Case Style.Vertiacal
Dim lb1 As New LinearGradientBrush(ClientRectangle, Color.Empty, Color.Empty, 90.0F)
lb1.InterpolationColors = BL1
.DrawLine(New Pen(lb1), 1, 0, 1, Height)
End Select
End With
End Sub
#End Region
End Class
#End Region
#Region " Radio Button "
<DefaultEvent("CheckedChanged")> Public Class EtherealRadioButton : Inherits Control
#Region " Variables "
Private _Checked As Boolean
Private _Group As Integer = 1
Event CheckedChanged(ByVal sender As Object)
Private _BorderColor As Color = GetHTMLColor("746188")
Private _CheckColor As Color = GetHTMLColor("746188")
#End Region
#Region " Properties "
Property Checked As Boolean
Get
Return _Checked
End Get
Set(ByVal value As Boolean)
_Checked = value
RaiseEvent CheckedChanged(Me)
Invalidate()
End Set
End Property
Public Property CheckColor As Color
Get
Return _CheckColor
End Get
Set(value As Color)
_CheckColor = value
Invalidate()
End Set
End Property
Public Property BorderColor As Color
Get
Return _BorderColor
End Get
Set(value As Color)
_BorderColor = value
Invalidate()
End Set
End Property
Property Group As Integer
Get
Return _Group
End Get
Set(ByVal value As Integer)
_Group = value
End Set
End Property
Private Sub UpdateState()
If Not IsHandleCreated OrElse Not Checked Then Return
For Each C As Control In Parent.Controls
If C IsNot Me AndAlso TypeOf C Is EtherealRadioButton AndAlso DirectCast(C, EtherealRadioButton).Group = _Group Then
DirectCast(C, EtherealRadioButton).Checked = False
End If
Next
End Sub
#End Region
#Region " Initialization "
Sub New()
SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or _
ControlStyles.SupportsTransparentBackColor Or ControlStyles.UserPaint, True)
DoubleBuffered = True
Cursor = Cursors.Hand
Font = New Font("Proxima Nova", 11, FontStyle.Regular)
End Sub
#End Region
#Region " Draw Control "
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
Using B As New Bitmap(Width, Height), G As Graphics = Graphics.FromImage(B)
With G
.SmoothingMode = SmoothingMode.HighQuality
.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
.DrawEllipse(New Pen(BorderColor, 2.5), 1, 1, 18, 18)
.DrawString(Text, Font, Brushes.Gray, New Rectangle(23, -0.3, Width, Height))
If Checked Then .FillEllipse(New SolidBrush(CheckColor), New Rectangle(5, 5, 10, 10))
End With
e.Graphics.DrawImage(B.Clone(), 0, 0)
G.Dispose() : B.Dispose()
End Using
End Sub
#End Region
#Region " Events "
Protected Overrides Sub OnClick(ByVal e As EventArgs)
_Checked = Not Checked
UpdateState()
MyBase.OnClick(e)
Invalidate()
End Sub
Protected Overrides Sub OnCreateControl()
UpdateState()
MyBase.OnCreateControl()
End Sub
Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
Invalidate() : MyBase.OnTextChanged(e)
End Sub
Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
Invalidate()
MyBase.OnResize(e)
Height = 21
End Sub
#End Region
End Class
#End Region
#Region " CheckBox "
<DefaultEvent("CheckedChanged")> _
Public Class EtherealCheckBox : Inherits Control
#Region " Variables "
Private _Checked As Boolean = False
Event CheckedChanged(ByVal sender As Object)
Private _BorderColor As Color = GetHTMLColor("746188")
Private _CheckColor As Color = GetHTMLColor("746188")
#End Region
#Region " Properties "
Property Checked() As Boolean
Get
Return _Checked
End Get
Set(ByVal value As Boolean)
_Checked = value
Invalidate()
End Set
End Property
Public Property CheckColor As Color
Get
Return _CheckColor
End Get
Set(value As Color)
_CheckColor = value
Invalidate()
End Set
End Property
Public Property BorderColor As Color
Get
Return _BorderColor
End Get
Set(value As Color)
_BorderColor = value
Invalidate()
End Set
End Property
#End Region
#Region " Initialization "
Sub New()
SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer _
Or ControlStyles.SupportsTransparentBackColor, True)
DoubleBuffered = True
Cursor = Cursors.Hand
Size = New Size(200, 20)
Font = New Font("Proxima Nova", 11, FontStyle.Regular)
BackColor = Color.Transparent
End Sub
#End Region
#Region " Events "
Protected Overrides Sub OnClick(ByVal e As EventArgs)
_Checked = Not _Checked
RaiseEvent CheckedChanged(Me)
MyBase.OnClick(e)
Invalidate()
End Sub
Protected Overrides Sub OnResize(ByVal e As EventArgs)
MyBase.OnResize(e)
Height = 20
End Sub
#End Region
#Region " Draw Control "
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
Using B As New Bitmap(Width, Height), G As Graphics = Graphics.FromImage(B)
With G
.SmoothingMode = SmoothingMode.AntiAlias
.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
DrawRoundedPath(G, BorderColor, 3, New Rectangle(1, 1, 16, 16), 3)
If Checked Then
FillRoundedPath(G, CheckColor, New Rectangle(5, 5, 8.5, 8.5), 1)
End If
G.DrawString(Text, Font, Brushes.Gray, New Rectangle(22, -1.2, Width, Height - 2))
End With
e.Graphics.DrawImage(B.Clone, 0, 0)
G.Dispose() : B.Dispose()
End Using
End Sub
#End Region
End Class
#End Region
#Region " Switch "
<DefaultEvent("CheckedChanged")> _
Public Class EtherealSwitch : Inherits Control
#Region " Variables "
Private _Switch As Boolean = False
Private State As MouseMode
Private _SwitchColor As Color = GetHTMLColor("3f2153")
#End Region
Event CheckedChanged(ByVal sender As Object)
#Region " Properties "
Public Property Switched() As Boolean
Get
Return _Switch
End Get
Set(ByVal value As Boolean)
_Switch = value
Invalidate()
End Set
End Property
Public Property SwitchColor As Color
Get
Return _SwitchColor
End Get
Set(value As Color)
_SwitchColor = value
Invalidate()
End Set
End Property
#End Region
#Region " Initialization "
Sub New()
SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer _
Or ControlStyles.SupportsTransparentBackColor, True)
DoubleBuffered = True
Cursor = Cursors.Hand
Size = New Size(46, 25)
End Sub
#End Region
#Region " Draw Control "
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
Using B As New Bitmap(Width, Height), G As Graphics = Graphics.FromImage(B)
With G
.SmoothingMode = SmoothingMode.AntiAlias
If Switched Then
FillRoundedPath(G, SwitchColor, New Rectangle(1, 1, 42, 22), 22)
DrawRoundedPath(G, GetHTMLColor("ededed"), 1.5, New Rectangle(1, 1, 42, 22), 20)
G.FillEllipse(SolidBrushHTMlColor("fcfcfc"), New Rectangle(22, 2.6, 19, 18))
G.DrawEllipse(PenHTMlColor("e9e9e9", 1.5), New Rectangle(22, 2.6, 19, 18))
Else
FillRoundedPath(G, GetHTMLColor("f8f8f8"), New Rectangle(1, 1, 42, 22), 22)
DrawRoundedPath(G, GetHTMLColor("ededed"), 1.5, New Rectangle(1, 1, 42, 22), 20)
G.FillEllipse(SolidBrushHTMlColor("fcfcfc"), New Rectangle(3, 2.6, 19, 18))
G.DrawEllipse(PenHTMlColor("e9e9e9", 1.5), New Rectangle(3, 2.6, 19, 18))
End If
End With
e.Graphics.DrawImage(B.Clone(), 0, 0)
G.Dispose() : B.Dispose()
End Using
End Sub
#End Region
#Region " Events "
Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
MyBase.OnMouseDown(e)
State = MouseMode.Pushed : Invalidate()
End Sub
Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
MyBase.OnMouseUp(e)
State = MouseMode.Hovered : Invalidate()
End Sub
Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
MyBase.OnMouseEnter(e)
State = MouseMode.Hovered : Invalidate()
End Sub
Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
MyBase.OnMouseLeave(e)
State = MouseMode.NormalMode : Invalidate()
End Sub
Protected Overrides Sub OnClick(ByVal e As EventArgs)
_Switch = Not _Switch
RaiseEvent CheckedChanged(Me)
MyBase.OnClick(e)
End Sub
Protected Overrides Sub OnResize(ByVal e As EventArgs)
MyBase.OnResize(e)
Size = New Size(46, 25)
End Sub
#End Region
End Class
#End Region
#Region " ProgressBar "
Public Class EtherealProgressBar : Inherits Control
#Region " Variables "
Private _Maximum As Integer = 100
Private _Value As Integer = 0
Private _RoundRadius As Integer = 8
Private _ProgressColor As Color = GetHTMLColor("4e3a62")
Private _BaseColor As Color = GetHTMLColor("f7f7f7")
Private _BorderColor As Color = GetHTMLColor("ececec")
#End Region
#Region " Initialization "
Sub New()
MyBase.New()
DoubleBuffered = True
SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.SupportsTransparentBackColor, True)
BackColor = Color.Transparent
Size = New Size(75, 23)
End Sub
#End Region
#Region " Properties "
Public Property Value() As Integer
Get
If _Value < 0 Then
Return 0
Else
Return _Value
End If
End Get
Set(ByVal Value As Integer)
If Value > Maximum Then
Value = Maximum
End If
_Value = Value
Invalidate()
End Set
End Property
Public Property Maximum() As Integer
Get
Return _Maximum
End Get
Set(ByVal Value As Integer)
Select Case Value
Case Is < _Value
_Value = Value
End Select
_Maximum = Value
Invalidate()
End Set
End Property
Public Property RoundRadius As Integer
Get
Return _RoundRadius
End Get
Set(value As Integer)
_RoundRadius = value
Invalidate()
End Set
End Property
Public Property ProgressColor As Color
Get
Return _ProgressColor
End Get
Set(value As Color)
_ProgressColor = value
Invalidate()
End Set
End Property
Public Property BaseColor As Color
Get
Return _BaseColor
End Get
Set(value As Color)
_BaseColor = value
Invalidate()
End Set
End Property
Public Property BorderColor As Color
Get
Return _BorderColor
End Get
Set(value As Color)
_BorderColor = value
Invalidate()
End Set
End Property
#End Region
#Region " Draw Control "
Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
Using B As New Bitmap(Width, Height), G As Graphics = Graphics.FromImage(B)
G.SmoothingMode = SmoothingMode.HighQuality
Dim CurrentValue As Integer = CInt(Value / Maximum * Width)
Dim Rect As New Rectangle(0, 0, Width - 1, Height - 1)
FillRoundedPath(G, BaseColor, Rect, RoundRadius)
DrawRoundedPath(G, BorderColor, 1, Rect, RoundRadius)
If Not CurrentValue = 0 Then
FillRoundedPath(G, ProgressColor, New Rectangle(Rect.X, Rect.Y, CurrentValue, Rect.Height), RoundRadius)
End If
e.Graphics.DrawImage(B, 0, 0)
G.Dispose()
B.Dispose()
End Using
End Sub
#End Region
End Class
#End Region
#Region " Lable "
Public Class EtherealLabel : Inherits Control
#Region " Variables "
Private _ColorStyle As Style = Style.DarkPink
#End Region
#Region " Properties "
Public Property ColorStyle As Style
Get
Return _ColorStyle
End Get
Set(value As Style)
_ColorStyle = value
Invalidate()
End Set
End Property
#End Region
#Region " Enumerators "
Public Enum Style As Byte
SemiBlack
DarkPink
LightPink
End Enum
#End Region
#Region " Events "
Protected Overrides Sub OnTextChanged(ByVal e As EventArgs)
MyBase.OnTextChanged(e)
Invalidate()
End Sub
#End Region
#Region " Initialization "
Sub New()
SetStyle(ControlStyles.SupportsTransparentBackColor Or ControlStyles.UserPaint Or ControlStyles.OptimizedDoubleBuffer, True)
DoubleBuffered = True
Font = New Font("Montserrat", 10, FontStyle.Bold)
End Sub
#End Region
#Region " Draw Control "
Protected Overrides Sub OnPaint(e As PaintEventArgs)
Dim G As Graphics = e.Graphics
With G
.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
Select Case ColorStyle
Case Style.SemiBlack
.DrawString(Text, Font, SolidBrushHTMlColor("222222"), ClientRectangle)
Case Style.DarkPink
.DrawString(Text, Font, SolidBrushHTMlColor("3b2551"), ClientRectangle)
Case Style.LightPink
.DrawString(Text, Font, SolidBrushHTMlColor("9d92a8"), ClientRectangle)
End Select
End With
End Sub
#End Region
End Class
#End Region
#Region " Close "
Public Class EtherealClose : Inherits Control
#Region " Variable "
Private State As MouseMode
Private _NormalColor As Color = GetHTMLColor("3f2153")
Private _HoverColor As Color = GetHTMLColor("f0f0f0")
Private _PushedColor As Color = GetHTMLColor("966bc1")
Private _TextColor As Color = Color.White
#End Region
#Region " Initialization "
Sub New()
SetStyle(ControlStyles.DoubleBuffer Or ControlStyles.AllPaintingInWmPaint Or _
ControlStyles.ResizeRedraw Or ControlStyles.UserPaint Or _
ControlStyles.SupportsTransparentBackColor, True)
DoubleBuffered = True
BackColor = Color.Transparent
Font = New Font("Marlett", 8)
Size = New Size(20, 20)
End Sub
#End Region
#Region " Properties "
Public Property NormalColor As Color
Get
Return _NormalColor
End Get
Set(value As Color)
_NormalColor = value
Invalidate()
End Set
End Property
Public Property HoverColor As Color
Get
Return _HoverColor
End Get
Set(value As Color)
_HoverColor = value
Invalidate()
End Set
End Property
Public Property PushedColor As Color
Get
Return _PushedColor
End Get
Set(value As Color)
_PushedColor = value
Invalidate()
End Set
End Property
Public Property TextColor As Color
Get
Return _TextColor
End Get
Set(value As Color)
_TextColor = value
Invalidate()
End Set
End Property
#End Region
#Region " Draw Control "
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
Using B As New Bitmap(Width, Height), G As Graphics = Graphics.FromImage(B)
With G
.SmoothingMode = SmoothingMode.HighQuality
.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
.PixelOffsetMode = PixelOffsetMode.HighQuality
Select Case State
Case MouseMode.NormalMode
.FillEllipse(New SolidBrush(NormalColor), 1, 1, 19, 19)
Case MouseMode.Hovered
Cursor = Cursors.Hand
.FillEllipse(New SolidBrush(NormalColor), 1, 1, 19, 19)
.DrawEllipse(New Pen(HoverColor, 2), 1, 1, 18, 18)
Case MouseMode.Pushed
.FillEllipse(New SolidBrush(PushedColor), 1, 1, 19, 19)
End Select
.DrawString("r", Font, New SolidBrush(TextColor), New Rectangle(4, 6, 18, 18))
End With
e.Graphics.DrawImage(B.Clone, 0, 0)
G.Dispose() : B.Dispose()
End Using
End Sub
#End Region
#Region " Events "
Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
MyBase.OnMouseUp(e)
State = MouseMode.Hovered : Invalidate()
End Sub
Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
MyBase.OnMouseUp(e)
State = MouseMode.Pushed : Invalidate()
End Sub
Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
MyBase.OnMouseEnter(e)
State = MouseMode.Hovered : Invalidate()
End Sub
Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
MyBase.OnMouseEnter(e)
State = MouseMode.NormalMode : Invalidate()
End Sub
Protected Overrides Sub OnResize(e As EventArgs)
MyBase.OnResize(e)
Size = New Size(20, 20)
End Sub
Protected Overrides Sub OnClick(e As EventArgs)
MyBase.OnClick(e)
Environment.Exit(0)
Application.Exit()
End Sub
#End Region
End Class
#End Region
#Region " Minimize "
Public Class EtherealMinimize : Inherits Control
#Region " Variables "
Private State As MouseMode
Private _NormalColor As Color = GetHTMLColor("3f2153")
Private _HoverColor As Color = GetHTMLColor("f0f0f0")
Private _PushedColor As Color = GetHTMLColor("966bc1")
Private _TextColor As Color = Color.White
#End Region
#Region " Initialization "
Sub New()
SetStyle(ControlStyles.DoubleBuffer Or ControlStyles.AllPaintingInWmPaint Or _
ControlStyles.ResizeRedraw Or ControlStyles.UserPaint Or _
ControlStyles.Selectable Or ControlStyles.SupportsTransparentBackColor, True)
DoubleBuffered = True
BackColor = Color.Transparent
Font = New Font("Marlett", 8)
Size = New Size(21, 21)
End Sub
#End Region
#Region " Properties "
Public Property NormalColor As Color
Get
Return _NormalColor
End Get
Set(value As Color)
_NormalColor = value
Invalidate()
End Set
End Property
Public Property HoverColor As Color
Get
Return _HoverColor
End Get
Set(value As Color)
_HoverColor = value
Invalidate()
End Set
End Property
Public Property PushedColor As Color
Get
Return _PushedColor
End Get
Set(value As Color)
_PushedColor = value
Invalidate()
End Set
End Property
Public Property TextColor As Color
Get
Return _TextColor
End Get
Set(value As Color)
_TextColor = value
Invalidate()
End Set
End Property
#End Region
#Region " Draw Control "
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
Using B As New Bitmap(Width, Height), G As Graphics = Graphics.FromImage(B)
With G
.SmoothingMode = SmoothingMode.HighQuality
.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
Select Case State
Case MouseMode.NormalMode
.FillEllipse(New SolidBrush(NormalColor), 1, 1, 19, 19)
Case MouseMode.Hovered
Cursor = Cursors.Hand
.FillEllipse(New SolidBrush(NormalColor), 1, 1, 19, 19)
.DrawEllipse(New Pen(HoverColor, 2), 1, 1, 18, 18)
Case MouseMode.Pushed
.FillEllipse(New SolidBrush(PushedColor), 1, 1, 19, 19)
End Select
.DrawString("0", Font, New SolidBrush(TextColor), New Rectangle(4.6, 2.6, 18, 18))
End With
e.Graphics.DrawImage(B, 0, 0)
G.Dispose() : B.Dispose()
End Using
End Sub
#End Region
#Region " Events "
Protected Overrides Sub OnResize(e As EventArgs)
MyBase.OnResize(e)
Size = New Size(21, 21)
End Sub
Protected Overrides Sub OnClick(e As EventArgs)
MyBase.OnClick(e)
If FindForm.WindowState = FormWindowState.Normal Then
FindForm.WindowState = FormWindowState.Minimized
End If
End Sub
Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
MyBase.OnMouseUp(e)
State = MouseMode.Hovered : Invalidate()
End Sub
Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
MyBase.OnMouseUp(e)
State = MouseMode.Pushed : Invalidate()
End Sub
Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
MyBase.OnMouseEnter(e)
State = MouseMode.Hovered : Invalidate()
End Sub
Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
MyBase.OnMouseEnter(e)
State = MouseMode.NormalMode : Invalidate()
End Sub
#End Region
End Class
#End Region
#Region " Maximize "
Public Class EtherealMaximize : Inherits Control
#Region " Variables "
Private State As MouseMode
Private _NormalColor As Color = GetHTMLColor("3f2153")
Private _HoverColor As Color = GetHTMLColor("f0f0f0")
Private _PushedColor As Color = GetHTMLColor("966bc1")
Private _TextColor As Color = Color.White
#End Region
#Region " Initialization "
Sub New()
SetStyle(ControlStyles.DoubleBuffer Or ControlStyles.AllPaintingInWmPaint Or _
ControlStyles.ResizeRedraw Or ControlStyles.UserPaint Or _
ControlStyles.Selectable Or ControlStyles.SupportsTransparentBackColor, True)
DoubleBuffered = True
BackColor = Color.Transparent
Font = New Font("Marlett", 9)
Size = New Size(22, 22)
End Sub
#End Region
#Region " Properties "
Public Property NormalColor As Color
Get
Return _NormalColor
End Get
Set(value As Color)
_NormalColor = value
Invalidate()
End Set
End Property
Public Property HoverColor As Color
Get
Return _HoverColor
End Get
Set(value As Color)
_HoverColor = value
Invalidate()
End Set
End Property
Public Property PushedColor As Color
Get
Return _PushedColor
End Get
Set(value As Color)
_PushedColor = value
Invalidate()
End Set
End Property
Public Property TextColor As Color
Get
Return _TextColor
End Get
Set(value As Color)
_TextColor = value
Invalidate()
End Set
End Property
#End Region
#Region " Draw Control "
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
Using B As New Bitmap(Width, Height), G As Graphics = Graphics.FromImage(B)
With G
.SmoothingMode = SmoothingMode.HighQuality
.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
Select Case State
Case MouseMode.NormalMode
.FillEllipse(New SolidBrush(NormalColor), 1, 1, 19, 19)
Case MouseMode.Hovered
Cursor = Cursors.Hand
.FillEllipse(New SolidBrush(NormalColor), 1, 1, 19, 19)
.DrawEllipse(New Pen(HoverColor, 2), 1, 1, 18, 18)
Case MouseMode.Pushed
.FillEllipse(New SolidBrush(PushedColor), 1, 1, 19, 19)
End Select
.DrawString("v", Font, New SolidBrush(TextColor), New Rectangle(3.4, 5, 18, 18))
End With
e.Graphics.DrawImage(B.Clone, 0, 0)
G.Dispose() : B.Dispose()
End Using
End Sub
#End Region
#Region " Events "
Protected Overrides Sub OnResize(e As EventArgs)
MyBase.OnResize(e)
Size = New Size(22, 22)
End Sub
Protected Overrides Sub OnClick(e As EventArgs)
MyBase.OnClick(e)
If FindForm.WindowState = FormWindowState.Normal Then
FindForm.WindowState = FormWindowState.Maximized
Else
FindForm.WindowState = FormWindowState.Normal
End If
End Sub
Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
MyBase.OnMouseUp(e)
State = MouseMode.Hovered : Invalidate()
End Sub
Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
MyBase.OnMouseUp(e)
State = MouseMode.Pushed : Invalidate()
End Sub
Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
MyBase.OnMouseEnter(e)
State = MouseMode.Hovered : Invalidate()
End Sub
Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
MyBase.OnMouseEnter(e)
State = MouseMode.NormalMode : Invalidate()
End Sub
#End Region
End Class
#End Region
А теперь я покажу вам, мои дорогие дауны начинающие программисты, как же это добавить в ваш топ лоадер!
1) Выбираем нужный язык программирования (VB.Net или C#), узнать ваш язык можно по наличию
2) Открываем нужный спойлер
3) Копируем код из спойлера
4) Заходим в ваш проект
5) Нажимаем Ctrl+Shift+A
6) В vb мы пишем в имени файла
В c# мы пишем в имени файла
7) Вставляем в файл код, который мы скопировали
8) Нажимаем F5
9) Закрываем запустившееся окно
PROFIT, в панели слева появились новые элементы!
1) Выбираем нужный язык программирования (VB.Net или C#), узнать ваш язык можно по наличию
;
в конце строк2) Открываем нужный спойлер
3) Копируем код из спойлера
4) Заходим в ваш проект
5) Нажимаем Ctrl+Shift+A
6) В vb мы пишем в имени файла
zalupa.vb
(название очень важно!!! ), нажимаем ДобавитьВ c# мы пишем в имени файла
chlen.cs
(название очень важно!!! ), нажимаем Добавить7) Вставляем в файл код, который мы скопировали
8) Нажимаем F5
9) Закрываем запустившееся окно
PROFIT, в панели слева появились новые элементы!
Прошлая тема: https://yougame.biz/threads/92254/
Последнее редактирование: