111 lines
3.1 KiB
C#
111 lines
3.1 KiB
C#
|
namespace RyzStudio.Windows.ThemedForms
|
|||
|
{
|
|||
|
using System;
|
|||
|
using System.ComponentModel;
|
|||
|
using System.Drawing;
|
|||
|
|
|||
|
public partial class LeftButton : RyzStudio.Windows.ThemedForms.LeftUserControl
|
|||
|
{
|
|||
|
protected ButtonState buttonState = ButtonState.Normal;
|
|||
|
|
|||
|
public LeftButton() : base()
|
|||
|
{
|
|||
|
InitializeComponent();
|
|||
|
|
|||
|
label1.ImageAlign = ContentAlignment.MiddleCenter;
|
|||
|
|
|||
|
label1.Click += delegate { this.OnClick(null); };
|
|||
|
label1.MouseEnter += delegate { this.VisualState = ButtonState.Hover; };
|
|||
|
label1.MouseLeave += delegate { this.VisualState = ButtonState.Normal; };
|
|||
|
label1.MouseDown += delegate { this.VisualState = ButtonState.Down; };
|
|||
|
label1.MouseUp += delegate { this.VisualState = ButtonState.Normal; };
|
|||
|
}
|
|||
|
|
|||
|
protected override void OnLoad(EventArgs e)
|
|||
|
{
|
|||
|
base.OnLoad(e);
|
|||
|
|
|||
|
// customise
|
|||
|
this.StyleOver = new ButtonStyle(Color.FromArgb(0, 152, 167), Color.White, this.OverImage);
|
|||
|
this.StyleDown = new ButtonStyle(Color.FromArgb(179, 179, 179), Color.Black, this.DownImage);
|
|||
|
this.StyleDefault = new ButtonStyle(Color.White, Color.Black, this.DefaultImage);
|
|||
|
|
|||
|
//this.StyleOver.ForeImage = this.OverImage;
|
|||
|
//this.StyleDown.ForeImage = this.DownImage;
|
|||
|
//this.StyleDefault.ForeImage = this.DefaultImage;
|
|||
|
|
|||
|
this.VisualState = ButtonState.Normal;
|
|||
|
}
|
|||
|
|
|||
|
protected ButtonState VisualState
|
|||
|
{
|
|||
|
get { return buttonState; }
|
|||
|
set
|
|||
|
{
|
|||
|
switch (value)
|
|||
|
{
|
|||
|
case ButtonState.Normal:
|
|||
|
if (this.VisualState == ButtonState.Down)
|
|||
|
{
|
|||
|
updateButton(StyleOver);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
updateButton(StyleDefault);
|
|||
|
}
|
|||
|
|
|||
|
break;
|
|||
|
case ButtonState.Hover:
|
|||
|
updateButton(StyleOver);
|
|||
|
break;
|
|||
|
case ButtonState.Down:
|
|||
|
updateButton(StyleDown);
|
|||
|
break;
|
|||
|
default:
|
|||
|
updateButton(StyleDefault);
|
|||
|
break;
|
|||
|
}
|
|||
|
|
|||
|
buttonState = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
protected void updateButton(ButtonStyle style)
|
|||
|
{
|
|||
|
label1.ForeColor = style.PenColour;
|
|||
|
label1.BackColor = style.BackColour;
|
|||
|
label1.Image = style.ForeImage;
|
|||
|
}
|
|||
|
|
|||
|
[Browsable(true)]
|
|||
|
[Category("Appearance")]
|
|||
|
public string LabelText { get => label1.Text; set => label1.Text = value; }
|
|||
|
|
|||
|
[Browsable(true)]
|
|||
|
[Category("Appearance")]
|
|||
|
public System.Windows.Forms.Label Label { get => label1; set => label1 = value; }
|
|||
|
|
|||
|
[Browsable(true)]
|
|||
|
[Category("Appearance")]
|
|||
|
public Image OverImage { get; set; } = null;
|
|||
|
|
|||
|
[Browsable(true)]
|
|||
|
[Category("Appearance")]
|
|||
|
public Image DownImage { get; set; } = null;
|
|||
|
|
|||
|
[Browsable(true)]
|
|||
|
[Category("Appearance")]
|
|||
|
public Image DefaultImage { get; set; } = null;
|
|||
|
|
|||
|
[Browsable(false)]
|
|||
|
public ButtonStyle StyleOver { get; set; } = new ButtonStyle(Color.FromArgb(71, 142, 203), Color.FromArgb(250, 250, 250));
|
|||
|
|
|||
|
[Browsable(false)]
|
|||
|
public ButtonStyle StyleDown { get; set; } = new ButtonStyle(Color.FromArgb(61, 132, 193), Color.FromArgb(250, 250, 250));
|
|||
|
|
|||
|
[Browsable(false)]
|
|||
|
public ButtonStyle StyleDefault { get; set; } = new ButtonStyle(Color.FromArgb(51, 122, 183), Color.FromArgb(250, 250, 250));
|
|||
|
|
|||
|
public void PerformClick() => this.OnClick(null);
|
|||
|
}
|
|||
|
}
|