55 lines
1.4 KiB
C#
55 lines
1.4 KiB
C#
using System;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
|
|
namespace RyzStudio.Windows.Forms
|
|
{
|
|
public class TImageBox : System.Windows.Forms.PictureBox
|
|
{
|
|
public TImageBox() : base()
|
|
{
|
|
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)]
|
|
public new Image Image { get => base.Image; set => base.Image = value; }
|
|
|
|
[Category("Appearance"), Browsable(true)]
|
|
public Image NormalImage { get; set; }
|
|
|
|
[Category("Appearance"), Browsable(true)]
|
|
public Image HighlightImage { get; set; }
|
|
|
|
protected override void OnMouseEnter(EventArgs e)
|
|
{
|
|
this.Image = this.HighlightImage;
|
|
|
|
base.OnMouseEnter(e);
|
|
}
|
|
|
|
protected override void OnMouseLeave(EventArgs e)
|
|
{
|
|
this.Image = this.NormalImage;
|
|
|
|
base.OnMouseLeave(e);
|
|
}
|
|
|
|
protected override void OnLostFocus(EventArgs e)
|
|
{
|
|
this.Image = this.NormalImage;
|
|
|
|
base.OnLostFocus(e);
|
|
}
|
|
}
|
|
}
|