基线 SVN r240
SVN-Revision: r240
This commit is contained in:
@@ -0,0 +1,237 @@
|
||||
using Lskj.Business.Impl;
|
||||
using Lskj.Control;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Lskj.Main3.Control
|
||||
{
|
||||
public partial class NewMenuBar : UserControl
|
||||
{
|
||||
public NewMenuBar()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.panelImg.BackgroundImageLayout = ImageLayout.Stretch;//设置背景图片自动适应
|
||||
}
|
||||
|
||||
|
||||
private PanelHoverEventHandler hoverEvent;
|
||||
public delegate void PanelHoverEventHandler(NewMenuBar before, NewMenuBar after);
|
||||
|
||||
|
||||
private static NewMenuBar defaultMenuBar;
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:获取主体panel</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-08-16 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <returns>Button.</returns>
|
||||
public NewMenuBar GetNewMenuBar()
|
||||
{
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:设置默认选中的Panel</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-08-16 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
public void SetDefaultSelectMenu(NewMenuBar item)
|
||||
{
|
||||
defaultMenuBar = item;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:设置菜单状态状态</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-08-16 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="state">The state.</param>
|
||||
public void SetButtonState(MenuButtonState state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case MenuButtonState.defaultState:
|
||||
this.labelTitle.BackColor = Color.White;
|
||||
this.labelTitle.ForeColor = Color.FromArgb(151, 162, 194);
|
||||
|
||||
break;
|
||||
case MenuButtonState.selectState:
|
||||
this.labelTitle.BackColor = Color.FromArgb(0, 131, 232);
|
||||
this.labelTitle.ForeColor = Color.FromArgb(195, 219, 255);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:注册鼠标划过事件</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-08-16 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="hoverEvent">The hover event.</param>
|
||||
/// <param name="eventType">Type of the event.</param>
|
||||
public void SetHoverEvent(PanelHoverEventHandler hoverEvent, MenuEventType eventType)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.hoverEvent = hoverEvent;
|
||||
switch (eventType)
|
||||
{
|
||||
case MenuEventType.MouseClickEvent:
|
||||
//this.btn_item_title.MouseMove += new MouseEventHandler(btnDesktop_MouseMove);
|
||||
//this.btn_item_title.MouseClick += new MouseEventHandler(this.btnDesktio_MouseEvent);
|
||||
this.panelImg.MouseMove += new MouseEventHandler(this.btnDesktio_MouseEvent);
|
||||
this.labelTitle.MouseMove += new MouseEventHandler(this.btnDesktio_MouseEvent);
|
||||
this.panel1.MouseMove += new MouseEventHandler(this.btnDesktio_MouseEvent);
|
||||
this.panelImg.MouseClick += new MouseEventHandler(this.btnDesktio_MouseEvent);
|
||||
this.labelTitle.MouseClick += new MouseEventHandler(this.btnDesktio_MouseEvent);
|
||||
this.panel1.MouseClick += new MouseEventHandler(this.btnDesktio_MouseEvent);
|
||||
break;
|
||||
case MenuEventType.MouseHoverEvent:
|
||||
default:
|
||||
this.panelImg.MouseMove += new MouseEventHandler(this.btnDesktio_MouseEvent);
|
||||
this.labelTitle.MouseMove += new MouseEventHandler(this.btnDesktio_MouseEvent);
|
||||
this.panel1.MouseMove += new MouseEventHandler(this.btnDesktio_MouseEvent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
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="MouseEventArgs"/> instance containing the event data.</param>
|
||||
private void btnDesktop_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
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="MouseEventArgs"/> instance containing the event data.</param>
|
||||
private void btnDesktio_MouseEvent(object sender, MouseEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
NewMenuBar item = null;
|
||||
if (sender is Panel)
|
||||
{
|
||||
item = (sender as Panel).Parent.Parent as NewMenuBar;
|
||||
if (item == null)
|
||||
{
|
||||
item = (sender as Panel).Parent.Parent.Parent as NewMenuBar;
|
||||
}
|
||||
}
|
||||
if (sender is Label)
|
||||
{
|
||||
item = (sender as Label).Parent.Parent as NewMenuBar;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
if (defaultMenuBar != null)
|
||||
{
|
||||
defaultMenuBar.labelTitle.BackColor = Color.White;
|
||||
defaultMenuBar.panel1.BackColor = Color.White;
|
||||
defaultMenuBar.labelTitle.ForeColor = Color.FromArgb(151, 162, 194);
|
||||
}
|
||||
|
||||
item.labelTitle.BackColor = Color.FromArgb(0, 131, 232);
|
||||
item.panel1.BackColor = Color.FromArgb(0, 131, 232);
|
||||
item.labelTitle.ForeColor = Color.FromArgb(195, 219, 255);
|
||||
}
|
||||
|
||||
|
||||
if (defaultMenuBar != item)
|
||||
{
|
||||
if (hoverEvent != null)
|
||||
{
|
||||
this.hoverEvent(defaultMenuBar, item);
|
||||
}
|
||||
defaultMenuBar = item;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||||
MessageUtil.Show(Message, ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 菜单状态
|
||||
/// </summary>
|
||||
public enum MenuButtonState
|
||||
{
|
||||
defaultState,
|
||||
selectState
|
||||
}
|
||||
/// <summary>
|
||||
/// 菜单事件
|
||||
/// </summary>
|
||||
public enum MenuEventType
|
||||
{
|
||||
MouseHoverEvent = 0,
|
||||
MouseClickEvent = 1
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user