94 lines
2.5 KiB
C#
94 lines
2.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.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using DevExpress.XtraEditors;
|
|
|
|
namespace Lskj.Main
|
|
{
|
|
public partial class Sub_Item : UserControl
|
|
{
|
|
public string DefaultColor;
|
|
public string MoveColor;
|
|
public Boolean isUsed;
|
|
public string SubName;
|
|
|
|
// 鼠标划过控件
|
|
private HoverEventHandler hoverEvent = null;
|
|
public delegate void HoverEventHandler(Sub_Item sender);
|
|
|
|
// 鼠标点击控件
|
|
private MouseClickEventHanlder clickEvent = null;
|
|
public delegate void MouseClickEventHanlder(Sub_Item sender);
|
|
|
|
public Sub_Item()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
/// <summary>
|
|
/// label对象
|
|
/// </summary>
|
|
public Label GetLabel { get { return lblTitle; } }
|
|
/// <summary>
|
|
/// pic对象
|
|
/// </summary>
|
|
public PictureBox GetPictureBox { get { return picImage; } }
|
|
|
|
/// <summary>
|
|
/// 注册设置事件
|
|
/// </summary>
|
|
/// <param name="hoverEvent"></param>
|
|
public void SetHoverEvent(HoverEventHandler hoverEvent)
|
|
{
|
|
this.hoverEvent = hoverEvent;
|
|
}
|
|
/// <summary>
|
|
/// 注册设置事件
|
|
/// </summary>
|
|
/// <param name="hoverEvent"></param>
|
|
public void SetClickEvent(MouseClickEventHanlder clickEvent)
|
|
{
|
|
this.clickEvent = clickEvent;
|
|
}
|
|
|
|
#region 改变背景色
|
|
private void plTop_MouseMove(object sender, MouseEventArgs e)
|
|
{
|
|
this.BackColor = ColorTranslator.FromHtml(MoveColor);
|
|
this.Cursor = Cursors.Hand;
|
|
if (hoverEvent != null)
|
|
{
|
|
this.hoverEvent(this);
|
|
}
|
|
}
|
|
private void plCenter_MouseLeave(object sender, EventArgs e)
|
|
{
|
|
this.BackColor = ColorTranslator.FromHtml(DefaultColor);
|
|
}
|
|
#endregion
|
|
|
|
#region 点击事件
|
|
private void plTop_MouseClick(object sender, MouseEventArgs e)
|
|
{
|
|
if (clickEvent != null)
|
|
{
|
|
if (isUsed)
|
|
{
|
|
clickEvent(this);
|
|
}
|
|
else
|
|
{
|
|
XtraMessageBox.Show(SubName + "子系统不可用.");
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|