[COLOR=#000000]using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Windows.Forms;[/COLOR]
[COLOR=#000000]enum MouseState
{
None = 0,
Over = 1,
Down = 2
}[/COLOR]
[COLOR=#000000]class SimpleButton : Control[/COLOR]
[COLOR=#000000]{[/COLOR]
[COLOR=#000000]
[/COLOR]
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]#region Declarations[/COLOR]
[COLOR=#000000] private MouseState _State;[/COLOR]
[COLOR=#000000] #endregion[/COLOR]
[COLOR=#000000]#region MouseStates[/COLOR]
[COLOR=#000000] protected override void OnMouseEnter(EventArgs e)[/COLOR]
[COLOR=#000000] {[/COLOR]
[COLOR=#000000] base.OnMouseEnter(e);[/COLOR]
[COLOR=#000000] _State = MouseState.Over;[/COLOR]
[COLOR=#000000] Invalidate();[/COLOR]
[COLOR=#000000] }[/COLOR]
[COLOR=#000000]
[/COLOR]
[COLOR=#000000]
[/COLOR]
[COLOR=#000000] protected override void OnMouseLeave(EventArgs e)[/COLOR]
[COLOR=#000000] {[/COLOR]
[COLOR=#000000] base.OnMouseLeave(e);[/COLOR]
[COLOR=#000000] _State = MouseState.None;[/COLOR]
[COLOR=#000000] Invalidate();[/COLOR]
[COLOR=#000000] }[/COLOR]
[COLOR=#000000]
[/COLOR]
[COLOR=#000000]
[/COLOR]
[COLOR=#000000] protected override void OnMouseDown(MouseEventArgs e)[/COLOR]
[COLOR=#000000] {[/COLOR]
[COLOR=#000000] base.OnMouseDown(e);[/COLOR]
[COLOR=#000000] _State = MouseState.Down;[/COLOR]
[COLOR=#000000] Invalidate();[/COLOR]
[COLOR=#000000] }[/COLOR]
[COLOR=#000000]
[/COLOR]
[COLOR=#000000]
[/COLOR]
[COLOR=#000000] protected override void OnMouseUp(MouseEventArgs e)[/COLOR]
[COLOR=#000000] {[/COLOR]
[COLOR=#000000] base.OnMouseUp(e);[/COLOR]
[COLOR=#000000] _State = MouseState.Over;[/COLOR]
[COLOR=#000000] Invalidate();[/COLOR]
[COLOR=#000000] }[/COLOR]
[COLOR=#000000] #endregion[/COLOR]
[COLOR=#000000]public SimpleButton()
{
Size = new Size(90, 30);
}[/COLOR]
[COLOR=#000000] #region Properties[/COLOR]
[COLOR=#000000]
//Edit the ARGB to whichever color you wish[/COLOR]
[COLOR=#000000] private Color _BaseColor = Color.FromArgb(37, 37, 37);[/COLOR]
[COLOR=#000000] public Color BaseColor[/COLOR]
[COLOR=#000000] {[/COLOR]
[COLOR=#000000] get { return _BaseColor; }[/COLOR]
[COLOR=#000000] set { _BaseColor = value; }[/COLOR]
[COLOR=#000000] }[/COLOR]
[COLOR=#000000]
[/COLOR]
[COLOR=#000000]
[/COLOR]
[COLOR=#000000] #endregion[/COLOR]
[COLOR=#000000] protected override void OnPaint(PaintEventArgs e)[/COLOR]
[COLOR=#000000] {[/COLOR]
[COLOR=#000000] base.OnPaint(e);[/COLOR]
[COLOR=#000000] dynamic G = e.Graphics;[/COLOR]
[COLOR=#000000] G.Clear(_BaseColor);[/COLOR]
[COLOR=#000000]
[/COLOR]
[COLOR=#000000] switch (_State)[/COLOR]
[COLOR=#000000] {[/COLOR]
[COLOR=#000000] case MouseState.Over:[/COLOR]
[COLOR=#000000] G.FillRectangle(new SolidBrush(Color.FromArgb(20, Color.White)), new Rectangle(0, 0, Width, Height));[/COLOR]
[COLOR=#000000] break;[/COLOR]
[COLOR=#000000]
[/COLOR]
[COLOR=#000000] case MouseState.Down:[/COLOR]
[COLOR=#000000] G.FillRectangle(new SolidBrush(Color.FromArgb(30, Color.Black)), new Rectangle(0, 0, Width, Height));[/COLOR]
[COLOR=#000000] break;[/COLOR]
[COLOR=#000000] }[/COLOR]
[COLOR=#000000]
[/COLOR]
[COLOR=#000000] StringFormat _StringF = new StringFormat();[/COLOR]
[COLOR=#000000] _StringF.Alignment = StringAlignment.Center;[/COLOR]
[COLOR=#000000] _StringF.LineAlignment = StringAlignment.Center;[/COLOR]
[COLOR=#000000] G.DrawString(Text, new Font("Arial", 9), Brushes.White, new RectangleF(0, 0, Width, Height), _StringF);[/COLOR]
[COLOR=#000000]
[/COLOR]
[COLOR=#000000] }[/COLOR]
class SimpleTextBox : Control
{
}
[DefaultEvent("TextChanged")]
#region Variables
private System.Windows.Forms.TextBox _TextBox;
#endregion
#region " Properties"
private HorizontalAlignment _TextAlign = HorizontalAlignment.Left;
[Category("Options")]
public HorizontalAlignment TextAlign
{
get { return _TextAlign; }
set
{
_TextAlign = value;
if (_TextBox != null)
{
_TextBox.TextAlign = value;
}
}
}
private int _MaxLength = 32767;
[Category("Options")]
public int MaxLength
{
get { return _MaxLength; }
set
{
_MaxLength = value;
if (_TextBox != null)
{
_TextBox.MaxLength = value;
}
}
}
private bool _ReadOnly;
[Category("Options")]
public bool ReadOnly
{
get { return _ReadOnly; }
set
{
_ReadOnly = value;
if (_TextBox != null)
{
_TextBox.ReadOnly = value;
}
}
}
private bool _UseSystemPasswordChar;
[Category("Options")]
public bool UseSystemPasswordChar
{
get { return _UseSystemPasswordChar; }
set
{
_UseSystemPasswordChar = value;
if (_TextBox != null)
{
_TextBox.UseSystemPasswordChar = value;
}
}
}
private bool _Multiline;
[Category("Options")]
public bool Multiline
{
get { return _Multiline; }
set
{
_Multiline = value;
if (_TextBox != null)
{
_TextBox.Multiline = value;
if (value)
{
_TextBox.Height = Height - 11;
}
else
{
Height = _TextBox.Height + 11;
}
}
}
}
[Category("Options")]
public override string Text
{
get { return base.Text; }
set
{
base.Text = value;
if (_TextBox != null)
{
_TextBox.Text = value;
}
}
}
[Category("Options")]
public override Font Font
{
get { return base.Font; }
set
{
base.Font = value;
if (_TextBox != null)
{
_TextBox.Font = value;
_TextBox.Location = new Point(3, 5);
_TextBox.Width = Width - 6;
if (!_Multiline)
{
Height = _TextBox.Height + 11;
}
}
}
}
//Change this ARGB color to change the border of the TextBox
private Color _BorderColor = Color.FromArgb(32, 32, 32);
public Color BorderColor
{
get { return _BorderColor; }
set { _BorderColor = value; }
}
#endregion
#region " Events "
protected override void OnCreateControl()
{
base.OnCreateControl();
if (!Controls.Contains(_TextBox))
{
Controls.Add(_TextBox);
}
}
private void OnBaseTextChanged(object s, EventArgs e)
{
Text = _TextBox.Text;
}
private void OnBaseKeyDown(object s, KeyEventArgs e)
{
if (e.Control && e.KeyCode == Keys.A)
{
_TextBox.SelectAll();
e.SuppressKeyPress = true;
}
if (e.Control && e.KeyCode == Keys.C)
{
_TextBox.Copy();
e.SuppressKeyPress = true;
}
}
protected override void OnResize(EventArgs e)
{
_TextBox.Location = new Point(5, 5);
_TextBox.Width = Width - 10;
if (_Multiline)
{
_TextBox.Height = Height - 11;
}
else
{
Height = _TextBox.Height + 11;
}
base.OnResize(e);
}
#endregion
public SimpleTextBox()
{
SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor, true);
DoubleBuffered = true;
BackColor = Color.Transparent;
_TextBox = new System.Windows.Forms.TextBox();
_TextBox.Font = new Font("Segoe UI", 10);
_TextBox.Text = Text;
_TextBox.BackColor = Color.FromArgb(255, 255, 255);
_TextBox.ForeColor = Color.Black;
_TextBox.MaxLength = _MaxLength;
_TextBox.Multiline = _Multiline;
_TextBox.ReadOnly = _ReadOnly;
_TextBox.UseSystemPasswordChar = _UseSystemPasswordChar;
_TextBox.BorderStyle = BorderStyle.None;
_TextBox.Location = new Point(5, 5);
_TextBox.Width = Width - 10;
_TextBox.Cursor = Cursors.IBeam;
if (_Multiline)
{
_TextBox.Height = Height - 11;
}
else
{
Height = _TextBox.Height + 11;
}
_TextBox.TextChanged += OnBaseTextChanged;
_TextBox.KeyDown += OnBaseKeyDown;
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
dynamic G = e.Graphics;
G.Clear(Color.FromArgb(255, 255, 255));
G.DrawRectangle(new Pen(_BorderColor), new Rectangle(0, 0, Width - 1, Height - 1));
}
class SimpleClose : Control
{
}
#region Declarations
private MouseState _State;
#endregion
#region MouseStates
protected override void OnMouseEnter(EventArgs e)
{
base.OnMouseEnter(e);
_State = MouseState.Over;
Invalidate();
}
protected override void OnMouseLeave(EventArgs e)
{
base.OnMouseLeave(e);
_State = MouseState.None;
Invalidate();
}
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
_State = MouseState.Down;
Invalidate();
}
protected override void OnMouseUp(MouseEventArgs e)
{
base.OnMouseUp(e);
_State = MouseState.Over;
Invalidate();
}
protected override void OnClick(EventArgs e)
{
base.OnClick(e);
//This call below ask the program to exit up click the button
Environment.Exit(0);
}
#endregion
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
Size = new Size(12, 12);
}
public SimpleClose()
{
SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true);
DoubleBuffered = true;
Size = new Size(12, 12);
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
dynamic G = e.Graphics;
//This is the background color
G.Clear(Color.FromArgb(32, 32, 32));
StringFormat _StringF = new StringFormat();
_StringF.Alignment = StringAlignment.Center;
_StringF.LineAlignment = StringAlignment.Center;
//This controls the font size and color of the X normally
G.DrawString("r", new Font("Marlett", 11), Brushes.White, new RectangleF(0, 0, Width, Height), _StringF);
switch (_State)
{
case MouseState.Over:
//This controls the font size and color of the X on hover
G.DrawString("r", new Font("Marlett", 11), new SolidBrush(Color.FromArgb(25, Color.White)), new RectangleF(0, 0, Width, Height), _StringF);
break;
case MouseState.Down:
//This controls the font size and color of the X on press
G.DrawString("r", new Font("Marlett", 11), new SolidBrush(Color.FromArgb(40, Color.Black)), new RectangleF(0, 0, Width, Height), _StringF);
break;
}
}
Copyright © 2024, NextGenUpdate.
All Rights Reserved.