168 lines
4.5 KiB
C#
168 lines
4.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
|
|
namespace ryControls
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
[DefaultEvent("Click")]
|
|
public partial class PicButton : UserControl
|
|
{
|
|
private bool Mouse_Enter = false;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public PicButton()
|
|
{
|
|
InitializeComponent();
|
|
SetEvent(this);
|
|
SetEvent(pictureBox1);
|
|
SetEvent(label1);
|
|
SetEvent(zhLoading1);
|
|
void SetEvent(Control ct)
|
|
{
|
|
ct.Click+= Button_Click;
|
|
ct.MouseDown += Ct_MouseDown;
|
|
ct.MouseEnter += Button_MouseEnter;
|
|
ct.MouseLeave += Button_MouseLeave;
|
|
ct.MouseMove += Button_MouseMove;
|
|
}
|
|
}
|
|
|
|
private void Ct_MouseDown(object sender, MouseEventArgs e)
|
|
{
|
|
if (!(sender is UserControl))
|
|
{
|
|
base.OnMouseDown(e);
|
|
}
|
|
}
|
|
|
|
private void Button_MouseMove(object sender, MouseEventArgs e)
|
|
{
|
|
if (!Mouse_Enter)
|
|
{
|
|
Mouse_Enter = true;
|
|
zhLoading1.Location = new Point(0, 0);
|
|
zhLoading1.Size = new Size(this.Width, this.Height);
|
|
zhLoading1.ShowLoad();
|
|
}
|
|
}
|
|
|
|
private void Button_MouseEnter(object sender, EventArgs e)
|
|
{
|
|
//if (this.Bounds.Contains(MousePosition.X, MousePosition.Y);
|
|
{
|
|
zhLoading1.Location = new Point(0, 0);
|
|
zhLoading1.Size = new Size(this.Width, this.Height);
|
|
zhLoading1.ShowLoad();
|
|
}
|
|
}
|
|
|
|
private void Button_MouseLeave(object sender, EventArgs e)
|
|
{
|
|
switch (sender)
|
|
{
|
|
case ryControls.ZhLoading k:
|
|
if (Mouse_Enter)
|
|
{
|
|
Mouse_Enter = false;
|
|
zhLoading1.HideLoad();
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
private void Button_Click(object sender, EventArgs e)
|
|
{
|
|
if (!(sender is UserControl))
|
|
{
|
|
base.OnClick(e);
|
|
}
|
|
Selected = !Selected;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 图标
|
|
/// </summary>
|
|
public Image Image
|
|
{
|
|
get { return pictureBox1.Image; }
|
|
set { pictureBox1.Image = value; }
|
|
}
|
|
/// <summary>
|
|
/// 标题
|
|
/// </summary>
|
|
public string Title
|
|
{
|
|
get { return label1.Text; }
|
|
set { label1.Text = value; }
|
|
}
|
|
private string _ToolTip = "";
|
|
/// <summary>
|
|
/// 悬浮提示
|
|
/// </summary>
|
|
public string ToolTip
|
|
{
|
|
get { return _ToolTip; }
|
|
set
|
|
{
|
|
_ToolTip = value;
|
|
toolTip1.SetToolTip(pictureBox1, value);
|
|
toolTip1.SetToolTip(this, value);
|
|
toolTip1.SetToolTip(label1, value);
|
|
toolTip1.SetToolTip(zhLoading1, value);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 标题颜色
|
|
/// </summary>
|
|
public Color TitleColor
|
|
{
|
|
get { return label1.ForeColor; }
|
|
set { label1.ForeColor = value; }
|
|
}
|
|
/// <summary>
|
|
/// 设置按钮
|
|
/// </summary>
|
|
/// <param name="title"></param>
|
|
/// <param name="img"></param>
|
|
public void SetButton(string title,Image img)
|
|
{
|
|
Title = title;
|
|
Image = img;
|
|
}
|
|
private bool _selected = false;
|
|
/// <summary>
|
|
/// 判断和设置是否选择
|
|
/// </summary>
|
|
public bool Selected
|
|
{
|
|
get { return _selected; }
|
|
set
|
|
{
|
|
if (_selected != value)
|
|
{
|
|
_selected = value;
|
|
if (_selected)
|
|
{
|
|
zhLoading1.Location = new Point(0, 0);
|
|
zhLoading1.Size = new Size(this.Width, this.Height);
|
|
zhLoading1.ShowLoad();
|
|
}
|
|
else
|
|
{
|
|
zhLoading1.HideLoad();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|