2020-04-27 12:17:13 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
|
|
|
|
|
namespace RyzStudio.Windows.Forms
|
|
|
|
|
{
|
2020-05-15 00:19:09 +00:00
|
|
|
|
public class TImageBox : System.Windows.Forms.PictureBox
|
2020-04-27 12:17:13 +00:00
|
|
|
|
{
|
2020-05-15 00:19:09 +00:00
|
|
|
|
public TImageBox() : base()
|
2020-04-27 12:17:13 +00:00
|
|
|
|
{
|
|
|
|
|
this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
|
|
|
|
|
this.ErrorImage = null;
|
|
|
|
|
this.InitialImage = null;
|
|
|
|
|
this.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnCreateControl()
|
|
|
|
|
{
|
|
|
|
|
OnMouseLeave(null);
|
|
|
|
|
|
|
|
|
|
base.OnCreateControl();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
2020-05-15 00:19:09 +00:00
|
|
|
|
public new Image Image { get => base.Image; set => base.Image = value; }
|
2020-04-27 12:17:13 +00:00
|
|
|
|
|
|
|
|
|
[Category("Appearance"), Browsable(true)]
|
2020-05-17 11:28:21 +00:00
|
|
|
|
public Image ImageNormal { get; set; }
|
2020-04-27 12:17:13 +00:00
|
|
|
|
|
|
|
|
|
[Category("Appearance"), Browsable(true)]
|
2020-05-17 11:28:21 +00:00
|
|
|
|
public Image ImageHover { get; set; }
|
|
|
|
|
|
|
|
|
|
[Category("Appearance"), Browsable(true)]
|
|
|
|
|
public Image ImageSelected { get; set; }
|
|
|
|
|
|
|
|
|
|
public bool IsSelected { get; set; } = false;
|
2020-04-27 12:17:13 +00:00
|
|
|
|
|
|
|
|
|
protected override void OnMouseEnter(EventArgs e)
|
|
|
|
|
{
|
2020-05-17 11:28:21 +00:00
|
|
|
|
this.Image = this.ImageHover;
|
2020-04-27 12:17:13 +00:00
|
|
|
|
|
|
|
|
|
base.OnMouseEnter(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnMouseLeave(EventArgs e)
|
|
|
|
|
{
|
2020-05-17 11:28:21 +00:00
|
|
|
|
this.Image = (this.IsSelected ? this.ImageSelected : this.ImageNormal);
|
2020-04-27 12:17:13 +00:00
|
|
|
|
|
|
|
|
|
base.OnMouseLeave(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnLostFocus(EventArgs e)
|
|
|
|
|
{
|
2020-05-17 11:28:21 +00:00
|
|
|
|
this.Image = (this.IsSelected ? this.ImageSelected : this.ImageNormal);
|
2020-04-27 12:17:13 +00:00
|
|
|
|
|
|
|
|
|
base.OnLostFocus(e);
|
|
|
|
|
}
|
2020-05-17 11:28:21 +00:00
|
|
|
|
|
2020-04-27 12:17:13 +00:00
|
|
|
|
}
|
|
|
|
|
}
|