/// <summary>
/// 定义菜单中的通用按钮事件
/// </summary>
public interface IMenuAction
{
/// <summary>
/// 更新按钮事件
/// </summary>
event EventHandler Refresh_MenuEvent;
/// <summary>
/// 是否包含更新事件
/// </summary>
bool HasEventRefresh { get; }
/// <summary>
/// 更新操作
/// </summary>
void ProcessRefresh(object sender, EventArgs e);
/// <summary>
/// 定义菜单中的通用按钮事件
/// </summary>
public interface IMenuAction
{
/// <summary>
/// 更新按钮事件
/// </summary>
event EventHandler Refresh_MenuEvent;
/// <summary>
/// 新建按钮事件
/// </summary>
event EventHandler Add_MenuEvent;
/// <summary>
/// 编辑按钮事件
/// </summary>
event EventHandler Edit_MenuEvent;
/// <summary>
/// 删除按钮事件
/// </summary>
event EventHandler Delete_MenuEvent;
/// <summary>
/// 导入按钮事件
/// </summary>
event EventHandler Import_MenuEvent;
/// <summary>
/// 导出按钮事件
/// </summary>
event EventHandler Export_MenuEvent;
/// <summary>
/// 是否包含更新事件
/// </summary>
bool HasEventRefresh { get; }
/// <summary>
/// 是否包含增加事件
/// </summary>
bool HasEventAdd { get; }
/// <summary>
/// 是否包含编辑事件
/// </summary>
bool HasEventEdit { get; }
/// <summary>
/// 是否包含删除事件
/// </summary>
bool HasEventDelete { get; }
/// <summary>
/// 是否包含导入事件
/// </summary>
bool HasEventImport { get; }
/// <summary>
/// 是否包含导出事件
/// </summary>
bool HasEventExport { get; }
/// <summary>
/// 更新操作
/// </summary>
void ProcessRefresh(object sender, EventArgs e);
/// <summary>
/// 增加操作
/// </summary>
void ProcessAdd(object sender, EventArgs e);
/// <summary>
/// 编辑操作
/// </summary>
void ProcessEdit(object sender, EventArgs e);
/// <summary>
/// 删除操作
/// </summary>
void ProcessDelete(object sender, EventArgs e);
/// <summary>
/// 导入操作
/// </summary>
void ProcessImport(object sender, EventArgs e);
/// <summary>
/// 导出操作
/// </summary>
void ProcessExport(object sender, EventArgs e);
}
/// <summary> /// 用于一般列表界面的基类 /// </summary> public partial class BaseDock : XtraForm, IMenuAction
#region 通用按钮菜单事件
/// <summary>
/// 更新按钮事件
/// </summary>
public event EventHandler Refresh_MenuEvent;
/// <summary>
/// 根据事件判断是否有
/// </summary>
public bool HasEventRefresh
{
get
{
return Refresh_MenuEvent != null;
}
}
/// <summary>
/// 调用事件定义
/// </summary>
public void ProcessRefresh(object sender, EventArgs e)
{
if (Refresh_MenuEvent != null)
{
Refresh_MenuEvent(sender, e);
}
}
.......................
#endregion
/// <summary> /// 应用菜单管理 /// </summary> public partial class FrmApplicationMenu : BaseDock
/// <summary>
/// 初始化公用菜单按钮的处理
/// </summary>
private void InitMenuAction()
{
this.Refresh_MenuEvent += (s, e) => { btnSearch_Click(s, e); };
this.Add_MenuEvent += (s, e) => { btnAddNew_Click(s, e); };
this.Edit_MenuEvent += (s, e) => { winGridViewPager1_OnEditSelected(s, e); };
this.Delete_MenuEvent += (s, e) => { winGridViewPager1_OnDeleteSelected(s, e); };
this.Import_MenuEvent += (s, e) => { btnImport_Click(s, e); };
this.Export_MenuEvent += (s, e) => { btnExport_Click(s,e);};
}
//处理树形菜单的点击操作,如果TAG存在,则解析并加载对应的页面到多文档里面
treeView.AfterSelect += (sender, e) =>
{
string tag = e.Node.Tag as string;
if (!string.IsNullOrEmpty(tag))
{
LoadPlugInForm(tag);
}
};
var form = LoadMdiForm(this.mainForm, objType, isShowDialog); RefreshButton(form);
/// <summary>
/// 更新按钮状态
/// </summary>
/// <param name="form">当前窗体</param>
public void RefreshButton(Form form)
{
this.CurrentForm = form;
IMenuAction action = form as IMenuAction;
if (action != null)
{
//事件处理后再判断
menuButton.refresh.Enabled = (action.HasEventRefresh);
menuButton.add.Enabled = (action.HasEventAdd);
menuButton.edit.Enabled = (action.HasEventEdit);
menuButton.delete.Enabled = (action.HasEventDelete);
menuButton.import.Enabled = (action.HasEventImport);
menuButton.export.Enabled = (action.HasEventExport);
}
}
/// <summary>
/// 初始化菜单按钮的事件处理
/// </summary>
private void InitMenuEvent()
{
//事件绑定
//先实现事件绑定
menuButton.add.ItemClick += (s, e) =>
{
if (CurrentForm != null)
{
IMenuAction action = CurrentForm as IMenuAction;
if (action != null)
{
action.ProcessAdd(s, e);
}
}
};
menuButton.edit.ItemClick += (s, e) =>
{
if (CurrentForm != null)
{
IMenuAction action = CurrentForm as IMenuAction;
if (action != null)
{
action.ProcessEdit(s, e);
}
}
};
menuButton.delete.ItemClick += (s, e) =>
{
if (CurrentForm != null)
{
IMenuAction action = CurrentForm as IMenuAction;
if (action != null)
{
action.ProcessDelete(s, e);
}
}
};
menuButton.import.ItemClick += (s, e) =>
{
if (CurrentForm != null)
{
IMenuAction action = CurrentForm as IMenuAction;
if (action != null)
{
action.ProcessImport(s, e);
}
}
};
menuButton.export.ItemClick += (s, e) =>
{
if (CurrentForm != null)
{
IMenuAction action = CurrentForm as IMenuAction;
if (action != null)
{
action.ProcessExport(s, e);
}
}
};
menuButton.refresh.ItemClick += (s, e) =>
{
if (CurrentForm != null)
{
IMenuAction action = CurrentForm as IMenuAction;
if (action != null)
{
action.ProcessRefresh(s, e);
}
}
};
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有