Пример #1
0
 //初始化菜单
 private void InitMenu()
 {
     //   MainMenuStrip.AutoSize = false;
     //初始化datatable
     //MainMenu.Items.Clear();
     string menuGroupName = string.Empty;
     string funcationName = string.Empty;
     string frmName = string.Empty;
     int icoIndex;
     Common.DataProces dp = new Common.DataProces();
     DataTable dt_role = dp.GetMenuDt(Common.MenuData.RoleTable);
     //遍历datatable增加菜单项
     for (int i = 0; i < dt_role.Rows.Count; i++)
     {
         DataRow dr = dt_role.Rows[i];
         menuGroupName = dr["MenuGroupName"].ToString();
         funcationName = dr["FunctionName"].ToString();
         frmName = dr["FrmName"].ToString();
         icoIndex = int.Parse(dr["ICO"].ToString());
         //创建二级子菜单
         ToolStripMenuItem tsi = new ToolStripMenuItem(funcationName, icoLargeList.Images[icoIndex]);
         tsi.Tag = frmName;
         tsi.Click += new EventHandler(tsi_Click);
         //创建工具栏
         ToolStripButton tsb = new ToolStripButton(funcationName, icoLargeList.Images[icoIndex]);
         tsb.Tag = frmName;
         tsb.ToolTipText = funcationName;
         tsb.Click += new EventHandler(tsb_Click);
         tsb.TextImageRelation = TextImageRelation.ImageAboveText;
         MainToolStrip.Items.Add(tsb);
         MainToolStrip.Items.Add(new ToolStripSeparator());
         MenuAddNewFunction(menuGroupName, tsi);
     }
 }
Пример #2
0
 private void frmTools_Load(object sender, EventArgs e)
 {
     //dt_role = new BLL.sys_SetRoleManager().GetUserRoleByUserID(allensingleton.UserID);
     _outlookBar = new LumiSoft.UI.Controls.WOutlookBar.WOutlookBar();
     //_outlookBar.BorderStyle = BorderStyle.FixedSingle;
     _outlookBar.ImageList = singleton.m_FrmMain.icoLargeList;
     _outlookBar.ImageListSmall = singleton.m_FrmMain.icoLargeList;
     _outlookBar.Dock = DockStyle.Fill;
     _outlookBar.ItemClicked += wOutlookBar_ItemClicked;
     _outlookBar.BarClicked += wOutlookBar_BarClicked;
     _outlookBar.ViewStyle.BarClientAreaColor = Color.Wheat;//工具箱的背影颜色
     _outlookBar.ViewStyle.BarItemHotTextColor = Color.Blue;//鼠标悬浮在菜单上面的时候菜单的文字前景色
     _outlookBar.ViewStyle.BarItemTextColor = Color.Black;//菜单的文字前景色
     _outlookBar.ViewStyle.BarColor = Color.CadetBlue;//主菜单名称的背景颜色
     //_outlookBar.ViewStyle.BarClientAreaColor = Color.LightBlue;//工具箱的背影颜色
     _outlookBar.ViewStyle.BarItemHotTextColor = Color.Red;//鼠标悬浮在菜单上面的时候菜单的文字前景色
     //_outlookBar.ViewStyle.BarItemTextColor = Color.Black;//菜单的文字前景色
     //_outlookBar.ViewStyle.BarColor = Color.Violet;//主菜单名称的背景颜色
     Item it = null;
     Bar bar = null;
     string strMenu = string.Empty;
     Common.DataProces dp = new Common.DataProces();
     DataTable dt_role = dp.GetMenuDt(Common.MenuData.RoleTable);
     for (int i = 0; i < dt_role.Rows.Count; i++)
     {
         if (string.IsNullOrEmpty(strMenu) || strMenu != dt_role.Rows[i]["MenuGroupName"].ToString())
         {
             //处理快捷键如“系统设置(&M)”
             string str = dt_role.Rows[i]["MenuGroupName"].ToString();
             int index = str.IndexOf("(");
             if (index != -1)
                 str = str.Remove(index);
             bar = _outlookBar.Bars.Add(str);
             bar.ItemsStyle = ItemsStyle.IconSelect;
             strMenu = dt_role.Rows[i]["MenuGroupName"].ToString();
         }
         it = bar.Items.Add(dt_role.Rows[i]["FunctionName"].ToString(), dt_role.Rows[i]["FrmName"].ToString(),
                            int.Parse(dt_role.Rows[i]["ICO"].ToString()), true, dt_role.Rows[i]["FrmName"].ToString());
         it.AllowStuck = false;
     }
     //_outlookBar.BackColor = Color.Red;
     ploutlookBar.Controls.AddRange(new Control[] { _outlookBar });
 }