/// <summary> /// 菜单单击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SubMenu_Click(object sender, EventArgs e) { ToolStripItem objItem = (ToolStripItem)sender; ToolStripMenuItem objMenuItem; CardManage.Model.Menu objMenuInfo = (CardManage.Model.Menu)objItem.Tag; switch (objMenuInfo.Name.ToLower()) { case "view_tool": objMenuItem = (ToolStripMenuItem)sender; objMenuItem.Checked = !objMenuItem.Checked; this._ToolStrip.Visible = objMenuItem.Checked; break; case "view_status": objMenuItem = (ToolStripMenuItem)sender; objMenuItem.Checked = !objMenuItem.Checked; this._StatusStrip.Visible = objMenuItem.Checked; break; case "window_cascade": //层叠 this._MainForm.LayoutMdi(MdiLayout.Cascade); break; case "window_tilevertical": //垂直平铺 this._MainForm.LayoutMdi(MdiLayout.TileVertical); break; case "window_tilehorizontal": //水平平铺 this._MainForm.LayoutMdi(MdiLayout.TileHorizontal); break; case "window_closeall": //全部关闭 foreach (Form childForm in this._MainForm.MdiChildren) { childForm.Close(); } break; case "window_arrangeicons": //排列图标 this._MainForm.LayoutMdi(MdiLayout.ArrangeIcons); break; case "system_quit": //系统退出 if (MessageBox.Show("确定要退出系统吗?", Config.DialogTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } Application.Exit(); break; default: if (!(string.IsNullOrEmpty(objMenuInfo.FormName) || objMenuInfo.FormName.Equals(""))) { OpenForm(objMenuInfo); } //if (this._OnSubMenuClick != null) this._OnSubMenuClick(sender, e); break; } }
private void OpenForm(CardManage.Model.Menu objMenuInfo) { if (objMenuInfo == null || string.IsNullOrEmpty(objMenuInfo.FormName)) { return; } try { FormBase objForm; string strFormName = string.Format("{0}Form", objMenuInfo.Name); objForm = GetFormByFormName(strFormName); if (objForm != null) { if (objForm.WindowState == FormWindowState.Minimized || objForm.WindowState == FormWindowState.Normal) { objForm.WindowState = FormWindowState.Maximized; } objForm.Activate(); } else { objForm = (FormBase)Activator.CreateInstance(Type.GetType(string.Format("CardManage.Forms.{0}", objMenuInfo.FormName)), new object[] { objMenuInfo.Title, objMenuInfo.IsModal, RunVariable.CurrentUserInfo, objMenuInfo.WindowSize, objMenuInfo.Flag }); objForm.Name = strFormName; if (objMenuInfo.IsModal) { objForm.ShowDialog(); } else { objForm.MdiParent = this._MainForm; objForm.Show(); } } } catch (Exception err) { CMessageBox.ShowError(string.Format("出现异常,异常信息如下:{0}", err.Message), Config.DialogTitle); } }
/// <summary> /// 初始化界面 /// </summary> /// <param name="objForm"></param> public void InitLayout(MDIParent1 objMainForm) { if (objMainForm == null) { return; } this._MainForm = objMainForm; //this._MainForm.ima //2.快捷菜单 _ToolMenu = new Model.Menu("root", "根节点") { ChildList = new List <Model.Menu>() }; this._ToolMenu.ChildList.Add(new CardManage.Model.Menu("Card_Manage", "卡片管理", "CardManageForm", false, null, 1, null, this._MainForm.imageList1.Images[0])); if (!(RunVariable.CurrentUserInfo == null || !RunVariable.CurrentUserInfo.Flag.Equals(0))) { this._ToolMenu.ChildList.Add(new CardManage.Model.Menu("Card_View", "发卡读卡", "CardViewForm", true, (RunVariable.IfDebug ? new WindowSize(801, 596) : new WindowSize(801, 371)), 0, new Flag(CardManage.Forms.FormBase.EAction.Create), this._MainForm.imageList1.Images["CreateCard"])); } this._ToolMenu.ChildList.Add(new CardManage.Model.Menu("CardLog_Manage", "刷卡日志", "CardLogManageForm", false, null, 1, null, this._MainForm.imageList1.Images[1])); //this._ToolMenu.ChildList.Add(new CardManage.Model.Menu("CommLog_Manage", "通讯日志", "CommLogManageForm", false, null, 1, null, this._MainForm.imageList1.Images[2])); this._ToolMenu.ChildList.Add(new CardManage.Model.Menu("SP3", "-")); this._ToolMenu.ChildList.Add(new CardManage.Model.Menu("System_Quit", "退出", "", false, null, 1, null, this._MainForm.imageList1.Images[3])); //创建快捷菜单 if (this._ToolStrip == null) { this._MainForm.Controls.Add(CreateToolStrip()); } //创建菜单 if (this._MenuStrip == null) { this._MainForm.Controls.Add(CreateMenu()); } //创建状态栏 if (this._StatusStrip == null) { this._MainForm.Controls.Add(CreateStatusStrip()); } }
private LayoutManager() { //1.系统菜单 //系统信息 CardManage.Model.Menu SysMenu = new CardManage.Model.Menu("System", "系统信息") { ChildList = new List <Model.Menu> { new CardManage.Model.Menu("System_Set", "系统设置", "SystemSetForm", true, new Model.WindowSize(460, 410)) } }; if (!(RunVariable.CurrentUserInfo == null || !RunVariable.CurrentUserInfo.Flag.Equals(0))) { SysMenu.ChildList.Add(new CardManage.Model.Menu("User_Manage", "账户管理", "UserManageForm", true)); } SysMenu.ChildList.Add(new CardManage.Model.Menu("User_ChangePwd", "密码修改", "ChangePasswordForm", true, new Model.WindowSize(300, 210))); SysMenu.ChildList.Add(new CardManage.Model.Menu("SP1", "-")); SysMenu.ChildList.Add(new CardManage.Model.Menu("System_Quit", "退出")); //基础资料 CardManage.Model.Menu BasicMenu = new CardManage.Model.Menu("BasicData", "基础数据") { ChildList = new List <CardManage.Model.Menu>() }; BasicMenu.ChildList.Add(new CardManage.Model.Menu("Area_Manage", "小区资料管理", "BuildingManageForm", true, null, 1, new Model.Flag("0"))); BasicMenu.ChildList.Add(new CardManage.Model.Menu("Build_Manage", "楼栋资料管理", "BuildingManageForm", true, null, 1, new Model.Flag("1"))); BasicMenu.ChildList.Add(new CardManage.Model.Menu("Unit_Manage", "单元资料管理", "BuildingManageForm", true, null, 1, new Model.Flag("2"))); BasicMenu.ChildList.Add(new CardManage.Model.Menu("Room_Manage", "房间资料管理", "BuildingManageForm", true, null, 1, new Model.Flag("3"))); if (!(RunVariable.CurrentUserInfo == null || !RunVariable.CurrentUserInfo.Flag.Equals(0))) { BasicMenu.ChildList.Add(new CardManage.Model.Menu("SP2", "-")); BasicMenu.ChildList.Add(new CardManage.Model.Menu("Buiding_BatchAdd", "房间批量增加", "BuidingBatchForm", true, new Model.WindowSize(646, 437))); BasicMenu.ChildList.Add(new CardManage.Model.Menu("Data_BatchDelete", "数据批量删除", "DataBatchDeleteForm", true, new Model.WindowSize(532, 463))); } BasicMenu.ChildList.Add(new CardManage.Model.Menu("SP21", "-")); BasicMenu.ChildList.Add(new CardManage.Model.Menu("Card_Manage", "卡片管理", "CardManageForm", false)); //系统日志 CardManage.Model.Menu LogMenu = new CardManage.Model.Menu("Log", "系统日志") { ChildList = new List <CardManage.Model.Menu>() }; LogMenu.ChildList.Add(new CardManage.Model.Menu("CardLog_Manage", "刷卡日志", "CardLogManageForm", false)); //LogMenu.ChildList.Add(new CardManage.Model.Menu("CommLog_Manage", "通讯日志", "CommLogManageForm", false)); //指令监控 CardManage.Model.Menu CommunicationMenu = new CardManage.Model.Menu("Communication", "管理工具") { ChildList = new List <CardManage.Model.Menu>() }; CommunicationMenu.ChildList.Add(new CardManage.Model.Menu("Ping", "Ping(设备检测)", "PingForm", true, new WindowSize(753, 422))); CommunicationMenu.ChildList.Add(new CardManage.Model.Menu("SyncTime", "远程校时", "SyncTimeForm", true, new WindowSize(427, 236))); CommunicationMenu.ChildList.Add(new CardManage.Model.Menu("Communication", "指令监控", "CommunicationForm", false)); CommunicationMenu.ChildList.Add(new CardManage.Model.Menu("CHSSel", "查询空白扇区", "SelChsForm", true, new WindowSize(554, 343))); CommunicationMenu.ChildList.Add(new CardManage.Model.Menu("SP21", "-")); CommunicationMenu.ChildList.Add(new CardManage.Model.Menu("DBBackup", "数据库备份", "SetFormBase", true, new WindowSize(401, 255))); CommunicationMenu.ChildList.Add(new CardManage.Model.Menu("DBRestore", "数据库还原", "SetFormBase", true, new WindowSize(401, 255))); //视图 CardManage.Model.Menu ViewMenu = new Model.Menu("View", "视图") { ChildList = new List <CardManage.Model.Menu>() }; ViewMenu.ChildList.Add(new CardManage.Model.Menu("View_Tool", "工具栏")); ViewMenu.ChildList.Add(new CardManage.Model.Menu("View_Status", "状态栏")); //窗口 CardManage.Model.Menu WindowMenu = new CardManage.Model.Menu("Window", "窗口") { ChildList = new List <CardManage.Model.Menu>() }; WindowMenu.ChildList.Add(new CardManage.Model.Menu("Window_Cascade", "层叠(&C)")); WindowMenu.ChildList.Add(new CardManage.Model.Menu("Window_TileVertical", "垂直平铺(&V)")); WindowMenu.ChildList.Add(new CardManage.Model.Menu("Window_TileHorizontal", "水平平铺(&H)")); WindowMenu.ChildList.Add(new CardManage.Model.Menu("Window_CloseAll", "全部关闭(&L)")); //WindowMenu.ChildList.Add(new CardManage.Model.Menu("Window_ArrangeIcons", "排列图标(&A)")); this._Menu = new CardManage.Model.Menu("root", "根节点"); _Menu.ChildList = new List <Model.Menu> { SysMenu, BasicMenu, LogMenu, CommunicationMenu, ViewMenu, WindowMenu }; }