/******************************
* 说明:自定义功能模块
* 创建人:龚宇超
* 创建日期:2017-08-16
* 修改人:
* 修改日期:
* 修改备注:
* 版本:1.0.0.0
******************************/
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;
using Lskj.Business.Impl;
using Lskj.Control;
namespace Lskj.Main.Control
{
///
/// 自定义功能模块
///
public partial class Menu_Item : UserControl
{
///
/// 圆角
///
private int _radius;
private Image _defaultImg, _hoverImg;
///
/// 所在行数
///
public int menuRow;
///
/// 所在分组
///
public int menuGroup;
///
/// 所在子菜单
///
public string menuNode;
public Menu_Item()
{
InitializeComponent();
}
public Button GetButton()
{
return this.btn_item_img;
}
///
/// 说明:设置模块显示名称
/// 创建人:龚宇超
/// 创建日期:2017-08-16
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The text.
public void SetMenuCaption(string text)
{
this.btn_item_title.Text = text;
this.toolTip1.SetToolTip(this.btn_item_title, text);
}
///
/// 说明:设置背景图标
/// 创建人:龚宇超
/// 创建日期:2017-08-16
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The img.
public void SetMenuImg(Image img)
{
this._defaultImg = img;
this.btn_item_img.BackgroundImage = img;
this.btn_item_img.BackgroundImageLayout = ImageLayout.Center;
}
///
/// 说明:设置选中背景图标
/// 创建人:龚宇超
/// 创建日期:2017-08-16
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The img.
public void SetMenuHoverImg(Image img)
{
this._hoverImg = img;
}
public void SetMenuNum(int num)
{
if (Business.SystemInfo.Instance.DisableShowNotify)//角标禁显
{
this.cb_mark.Visible = false;
}
else
{
if (num < 1)
{
this.cb_mark.Visible = false;
}
else
{
this.cb_mark.Visible = true;
this.cb_mark.SetMenuNum(num);
}
}
}
///
/// 说明:选中背景图片
/// 创建人:龚宇超
/// 创建日期:2017-08-16
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
private void btn_item_img_MouseMove(object sender, MouseEventArgs e)
{
//(sender as Button).BackgroundImage = hoverImg;
//(sender as Button).BackgroundImageLayout = ImageLayout.Center;
try
{
this.BackColor = Color.FromArgb(240, 240, 240);
this.Cursor = Cursors.Hand;
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
///
/// 说明:还原背景
/// 创建人:龚宇超
/// 创建日期:2017-08-16
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
private void btn_item_img_MouseLeave(object sender, EventArgs e)
{
try
{
this.BackColor = Color.White;
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
[Browsable(true)]
[Description("圆角弧度(0为不要圆角)")]
public int SetRoundRadius
{
get
{
return _radius;
}
set
{
if (value < 0) { _radius = 0; }
else { _radius = value; }
base.Refresh();
}
}
///
/// 说明:重绘圆角
/// 创建人:龚宇超
/// 创建日期:2017-08-16
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
private void MenuItem_Paint(object sender, PaintEventArgs e)
{
try
{
System.Drawing.Drawing2D.GraphicsPath oPath = new System.Drawing.Drawing2D.GraphicsPath();
int x = 0;
int y = 0;
int thisWidth = this.Width;
int thisHeight = this.Height;
int angle = _radius;
if (angle > 0)
{
System.Drawing.Graphics g = CreateGraphics();
oPath.AddArc(x, y, angle, angle, 180, 90); // 左上角
oPath.AddArc(thisWidth - angle, y, angle, angle, 270, 90); // 右上角
oPath.AddArc(thisWidth - angle, thisHeight - angle, angle, angle, 0, 90); // 右下角
oPath.AddArc(x, thisHeight - angle, angle, angle, 90, 90); // 左下角
oPath.CloseAllFigures();
Region = new System.Drawing.Region(oPath);
}
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
}
}