/// <summary> /// 二级菜单 /// </summary> /// <param name="kj"></param> /// <param name="entityList"></param> private void TreeView_Combination(XPanderPanel kj, IList <SubModule> entityList) { if (entityList.Count > 0) { TreeView treeView1 = new TreeView(); kj.SuspendLayout(); kj.Controls.Add(treeView1); treeView1.Cursor = Cursors.Hand; treeView1.Dock = DockStyle.Fill; treeView1.Location = new Point(1, 25); treeView1.Name = "TreeView1" + Guid.NewGuid().ToString(); treeView1.ShowLines = false; treeView1.Size = new Size(198, 111); treeView1.TabIndex = 0; treeView1.ImageList = LoadImageList(entityList); treeView1.NodeMouseClick += treeView1_NodeMouseClick; treeView1.ItemHeight = 19; for (int i = 0; i < entityList.Count; i++) { TreeNode node = new TreeNode(); node.Text = entityList[i].ModuleName; node.Name = entityList[i].ModuleId; node.ImageIndex = i; node.SelectedImageIndex = i; treeView1.Nodes.Add(node); } kj.ResumeLayout(false); } }
/// <summary> /// 一级菜单--菜单组合 /// </summary> /// <param name="entityList"></param> private void XPanderPanel_Combination(IList <MainModule> entityList) { if (entityList.Count > 0) { xPanderPanelList1.SuspendLayout(); XPanderPanel[] MenuList_XPanderPanel = new XPanderPanel[entityList.Count]; for (int i = 0; i < entityList.Count; i++) { MenuList_XPanderPanel[i] = new XPanderPanel(); MenuList_XPanderPanel[i].CaptionFont = new Font("Microsoft YaHei UI", 8F, FontStyle.Bold); MenuList_XPanderPanel[i].CustomColors.BackColor = SystemColors.Control; MenuList_XPanderPanel[i].CustomColors.BorderColor = Color.FromArgb(184, 184, 184); MenuList_XPanderPanel[i].CustomColors.CaptionCheckedGradientBegin = Color.Empty; MenuList_XPanderPanel[i].CustomColors.CaptionCheckedGradientEnd = Color.Empty; MenuList_XPanderPanel[i].CustomColors.CaptionCheckedGradientMiddle = Color.Empty; MenuList_XPanderPanel[i].CustomColors.CaptionCloseIcon = SystemColors.ControlText; MenuList_XPanderPanel[i].CustomColors.CaptionExpandIcon = SystemColors.ControlText; MenuList_XPanderPanel[i].CustomColors.CaptionGradientBegin = Color.FromArgb(252, 252, 252); MenuList_XPanderPanel[i].CustomColors.CaptionGradientEnd = SystemColors.ButtonFace; MenuList_XPanderPanel[i].CustomColors.CaptionGradientMiddle = Color.FromArgb(248, 248, 248); MenuList_XPanderPanel[i].CustomColors.CaptionPressedGradientBegin = Color.FromArgb(128, 188, 235); MenuList_XPanderPanel[i].CustomColors.CaptionPressedGradientEnd = Color.FromArgb(128, 188, 235); MenuList_XPanderPanel[i].CustomColors.CaptionPressedGradientMiddle = Color.FromArgb(128, 188, 235); MenuList_XPanderPanel[i].CustomColors.CaptionSelectedGradientBegin = Color.FromArgb(179, 215, 243); MenuList_XPanderPanel[i].CustomColors.CaptionSelectedGradientEnd = Color.FromArgb(179, 215, 243); MenuList_XPanderPanel[i].CustomColors.CaptionSelectedGradientMiddle = Color.FromArgb(179, 215, 243); MenuList_XPanderPanel[i].CustomColors.CaptionSelectedText = SystemColors.ControlText; MenuList_XPanderPanel[i].CustomColors.CaptionText = SystemColors.ControlText; MenuList_XPanderPanel[i].CustomColors.FlatCaptionGradientBegin = Color.FromArgb(248, 248, 248); MenuList_XPanderPanel[i].CustomColors.FlatCaptionGradientEnd = Color.FromArgb(252, 252, 252); MenuList_XPanderPanel[i].CustomColors.InnerBorderColor = SystemColors.Window; MenuList_XPanderPanel[i].ForeColor = SystemColors.ControlText; MenuList_XPanderPanel[i].Image = null; MenuList_XPanderPanel[i].Name = entityList[i].MenuId; MenuList_XPanderPanel[i].Size = new Size(200, 382); MenuList_XPanderPanel[i].TabIndex = entityList[i].No; MenuList_XPanderPanel[i].Text = entityList[i].MenuName; MenuList_XPanderPanel[i].ToolTipTextCloseIcon = null; MenuList_XPanderPanel[i].ToolTipTextExpandIconPanelCollapsed = null; MenuList_XPanderPanel[i].ToolTipTextExpandIconPanelExpanded = null; if (i == 0) { MenuList_XPanderPanel[i].Expand = true; } xPanderPanelList1.Controls.Add(MenuList_XPanderPanel[i]); TreeView_Combination(MenuList_XPanderPanel[i], entityList[i].MenuList); } xPanderPanelList1.ResumeLayout(false); } }
public void LoadModuleListFromDb(int ryzbh) { int CardType = -1; string mySQL; DataTable mTable; //XmlDocument mXml = new XmlDocument(); //if (File.Exists("System.xml") == true) //{ // mXml.Load("System.xml"); // XmlNode mCardTypeNode = mXml.SelectSingleNode("/Config/CardType"); // if (mCardTypeNode != null) // { // CardType = Convert.ToInt32(mCardTypeNode.Attributes["Type"].Value); // } //} if (CommonClass.SttUser.blSuperUser) { mySQL = string.Format("select A.MKBH,A.MKMC,A.MKJB,A.MKFCD,A.MKTP,A.MKWJM,A.MKHSM,A.BBH,a.FastStart from PTcd A where cardtype in(-3) or (MKFCD='9800' or A.MKBH='9800') order by A.MKFCD,A.MKBH"); } else { //获取当前卡片类型 mySQL = "select CardMeterTypeId from szIcSysParam"; mTable = SqlHelper.GetData(mySQL); if (mTable.Rows.Count > 0) { CardType = Utils.StrToIntDef(mTable.Rows[0][0].ToString(), -1); CommonClass.SttIC.iCardType = CardType; } if (CardType == -1) {//无卡片类型设置则只加载具有权限中的“系统设置”一级菜单下子菜单 mySQL = string.Format("select A.MKBH,A.MKMC,A.MKJB,A.MKFCD,A.MKTP,A.MKWJM,A.MKHSM,A.BBH,a.FastStart from PTcd A,PTzqx B where A.MKBH=B.MKBH and B.RYZBH={0} and (MKFCD='9800' or A.MKBH='9800') order by A.MKFCD,A.MKBH", ryzbh); } else { mySQL = string.Format("select A.MKBH,A.MKMC,A.MKJB,A.MKFCD,A.MKTP,A.MKWJM,A.MKHSM,A.BBH,a.FastStart from PTcd A,PTzqx B where A.MKBH=B.MKBH and B.RYZBH={0} and cardtype in({1},-1) order by A.MKFCD,A.MKBH", ryzbh, CardType.ToString()); } } mTable = SqlHelper.GetData(mySQL); if (mTable != null) { foreach (DataRow mRow in mTable.Rows) { ModuleList ml = new ModuleList(); ml.MKBH = mRow["MKBH"].ToString().Trim(); ml.MKMC = mRow["MKMC"].ToString().Trim(); ml.MKJB = Convert.ToInt32(mRow["MKJB"]); ml.MKFCD = mRow["MKFCD"].ToString().Trim(); ml.MKTP = mRow.IsNull("MKTP") ? "" : mRow["MKTP"].ToString().Trim(); ml.MKWJM = mRow.IsNull("MKWJM") ? "" : mRow["MKWJM"].ToString().Trim(); ml.MKHSM = mRow.IsNull("MKHSM") ? "" : mRow["MKHSM"].ToString().Trim(); ml.BBH = mRow["BBH"].ToString().Trim(); ml.FastStart = mRow["FastStart"].ToString(); Image tempImage = null; if (File.Exists(ml.MKTP) == true) { tempImage = Image.FromFile(ml.MKTP); } if (Convert.ToBoolean(ml.FastStart) == true && ml.MKJB != 1) { //toolStripFast添加快捷按钮 ToolStripButton tsbFastTemp = new ToolStripButton(ml.MKMC, tempImage, new EventHandler(t2toolStripButton1_Click)); tsbFastTemp.Tag = ml; tsbFastTemp.DisplayStyle = ToolStripItemDisplayStyle.Image; tsbFastTemp.ToolTipText = ml.MKMC; toolStripFast.Items.Add(tsbFastTemp); } if (ml.MKFCD == "0000") { XPanderPanel mxppTemp = new XPanderPanel(); mxppTemp.Text = ml.MKMC; ToolStrip tsTemp = new ToolStrip(); // 新建侧边栏 tsTemp.Name = "ts" + ml.MKMC; tsTemp.ImageScalingSize = new Size(36, 36); tsTemp.BackColor = System.Drawing.Color.FromArgb(192, 220, 255); tsTemp.Dock = DockStyle.Fill; tsTemp.GripStyle = ToolStripGripStyle.Hidden; tsTemp.LayoutStyle = ToolStripLayoutStyle.VerticalStackWithOverflow; tsTemp.Parent = mxppTemp; tsTemp.Tag = ml; ToolStripMenuItem tsmiTemp = new ToolStripMenuItem(ml.MKMC); tsmiTemp.Name = "tsmi" + ml.MKMC; tsmiTemp.Tag = ml; xPanderPanelList1.XPanderPanels.Add(mxppTemp); MenuMain.Items.Insert(MenuMain.Items.Count - 2, tsmiTemp); } else if (ml.MKFCD != "0000" || ml.MKFCD != "9999") { foreach (ToolStripMenuItem mMenuItem in MenuMain.Items) { if (mMenuItem.Tag == null) { continue; } if (((ModuleList)mMenuItem.Tag).MKBH == ml.MKFCD) { ToolStripMenuItem tsmiSubTemp = new ToolStripMenuItem(ml.MKMC, tempImage, new EventHandler(t2toolStripButton1_Click)); tsmiSubTemp.Tag = ml; mMenuItem.DropDownItems.Add(tsmiSubTemp); foreach (Control mCtrl in splitContainer1.Panel1.Controls.Find("ts" + ((ModuleList)mMenuItem.Tag).MKMC, true)) { ToolStripButton tsbTemp = new ToolStripButton(ml.MKMC, tempImage, new EventHandler(t2toolStripButton1_Click), "tsb" + ml.MKMC);//新建业务按钮 tsbTemp.ImageScaling = ToolStripItemImageScaling.SizeToFit; tsbTemp.Name = "tsb" + ml.MKMC; tsbTemp.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText; tsbTemp.TextImageRelation = TextImageRelation.ImageAboveText; tsbTemp.Tag = ml; ((ToolStrip)mCtrl).Items.Add(tsbTemp); //业务按钮添加到控件上 } } } } } } }