233 lines
7.5 KiB
C#
233 lines
7.5 KiB
C#
/******************************
|
|
* 说明:自定义功能模块
|
|
* 创建人:龚宇超
|
|
* 创建日期: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
|
|
{
|
|
/// <summary>
|
|
/// 自定义功能模块
|
|
/// </summary>
|
|
public partial class Menu_Item : UserControl
|
|
{
|
|
/// <summary>
|
|
/// 圆角
|
|
/// </summary>
|
|
private int _radius;
|
|
private Image _defaultImg, _hoverImg;
|
|
|
|
/// <summary>
|
|
/// 所在行数
|
|
/// </summary>
|
|
public int menuRow;
|
|
/// <summary>
|
|
/// 所在分组
|
|
/// </summary>
|
|
public int menuGroup;
|
|
/// <summary>
|
|
/// 所在子菜单
|
|
/// </summary>
|
|
public string menuNode;
|
|
|
|
|
|
public Menu_Item()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public Button GetButton()
|
|
{
|
|
return this.btn_item_img;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置模块显示名称</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-08-16 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="text">The text.</param>
|
|
public void SetMenuCaption(string text)
|
|
{
|
|
this.btn_item_title.Text = text;
|
|
this.toolTip1.SetToolTip(this.btn_item_title, text);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置背景图标</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-08-16 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="img">The img.</param>
|
|
public void SetMenuImg(Image img)
|
|
{
|
|
this._defaultImg = img;
|
|
this.btn_item_img.BackgroundImage = img;
|
|
this.btn_item_img.BackgroundImageLayout = ImageLayout.Center;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置选中背景图标</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-08-16 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="img">The img.</param>
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:选中背景图片</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-08-16 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The source of the event.</param>
|
|
/// <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param>
|
|
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);
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:还原背景</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-08-16 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The source of the event.</param>
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
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();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:重绘圆角</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-08-16 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The source of the event.</param>
|
|
/// <param name="e">The <see cref="PaintEventArgs"/> instance containing the event data.</param>
|
|
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);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|