예제 #1
0
        /// <summary>
        /// 比较
        /// </summary>
        /// <param name="x">对象X</param>
        /// <param name="y">对象Y</param>
        /// <returns>数值</returns>
        public int Compare(ControlA x, ControlA y)
        {
            FoldMenuItemA itemLeft  = x as FoldMenuItemA;
            FoldMenuItemA itemRight = y as FoldMenuItemA;

            return(itemLeft.OrderNum.CompareTo(itemRight.OrderNum));
        }
예제 #2
0
        /// <summary>
        /// 获取App功能
        /// </summary>
        public void GetApps(List <UserAppsTable> type1List, List <UserAppsTable> type2List,
                            List <UserAppsTable> type3List, List <UserAppsTable> type4List)
        {
            PADDING margin1 = new PADDING(5, 5, 5, 5);
            PADDING padding = new PADDING(5, 5, 5, 5);
            PADDING margin2 = new PADDING(5, 5, 5, 5);
            Dictionary <String, FoldSubMenuA> menuCaches = new Dictionary <String, FoldSubMenuA>();

            if (type1List != null && type1List.Count > 0)
            {
                int          num             = type1List.Count;
                FoldSubMenuA menuItemAccount = new FoldSubMenuA();
                m_foldMenu.AddSubMenu(menuItemAccount);
                menuItemAccount.Name              = "TYPE1";
                menuCaches[menuItemAccount.Name]  = menuItemAccount;
                menuItemAccount.TitleLabel.Text   = "员工管理(" + num + ")";
                menuItemAccount.ShrinkButton.Text = "收缩";
                menuItemAccount.ShrinkButton.Name = "shrink";
                menuItemAccount.LayoutDiv.Margin  = margin1;
                menuItemAccount.Padding           = padding;
                menuItemAccount.Margin            = margin2;
                menuItemAccount.TitleLabel.Size   = new SIZE(150, 20);
                menuItemAccount.ShrinkButton.Size = new SIZE(80, 20);
                foreach (UserAppsTable userApp in type1List)
                {
                    FoldMenuItemA menuButtonAddUser = new FoldMenuItemA();
                    menuButtonAddUser.Text      = userApp.m_appName;
                    menuButtonAddUser.Name      = userApp.m_appID;
                    menuButtonAddUser.BackImage = "file='images\\" + userApp.m_appID + ".jpg'";
                    menuButtonAddUser.Margin    = margin2;
                    menuItemAccount.LayoutDiv.AddControl(menuButtonAddUser);
                }
            }
            if (type2List != null && type2List.Count > 0)
            {
                int          num = type2List.Count;
                FoldSubMenuA menuItemFundTrade = new FoldSubMenuA();
                m_foldMenu.AddSubMenu(menuItemFundTrade);
                menuItemFundTrade.Name              = "TYPE2";
                menuCaches[menuItemFundTrade.Name]  = menuItemFundTrade;
                menuItemFundTrade.TitleLabel.Text   = "项目管理(" + num + ")";
                menuItemFundTrade.ShrinkButton.Text = "收缩";
                menuItemFundTrade.ShrinkButton.Name = "shrink";
                menuItemFundTrade.LayoutDiv.Margin  = margin1;
                menuItemFundTrade.Padding           = padding;
                menuItemFundTrade.Margin            = margin2;
                menuItemFundTrade.TitleLabel.Size   = new SIZE(150, 20);
                menuItemFundTrade.ShrinkButton.Size = new SIZE(80, 20);
                foreach (UserAppsTable userApp in type2List)
                {
                    FoldMenuItemA menuButtonAddUser = new FoldMenuItemA();
                    menuButtonAddUser.Text      = userApp.m_appName;
                    menuButtonAddUser.Name      = userApp.m_appID;
                    menuButtonAddUser.BackImage = "file='images\\" + userApp.m_appID + ".jpg'";
                    menuButtonAddUser.Margin    = margin2;
                    menuItemFundTrade.LayoutDiv.AddControl(menuButtonAddUser);
                }
            }
            if (type3List != null && type3List.Count > 0)
            {
                int          num            = type3List.Count;
                FoldSubMenuA menuItemSystem = new FoldSubMenuA();
                menuItemSystem.Name             = "TYPE3";
                menuCaches[menuItemSystem.Name] = menuItemSystem;
                m_foldMenu.AddSubMenu(menuItemSystem);
                menuItemSystem.TitleLabel.Text   = "个人管理(" + num + ")";
                menuItemSystem.ShrinkButton.Text = "收缩";
                menuItemSystem.ShrinkButton.Name = "shrink";
                menuItemSystem.LayoutDiv.Margin  = margin1;
                menuItemSystem.Padding           = padding;
                menuItemSystem.Margin            = margin2;
                menuItemSystem.TitleLabel.Size   = new SIZE(150, 20);
                menuItemSystem.ShrinkButton.Size = new SIZE(80, 20);
                foreach (UserAppsTable userApp in type3List)
                {
                    FoldMenuItemA menuButtonAddUser = new FoldMenuItemA();
                    menuButtonAddUser.Text      = userApp.m_appName;
                    menuButtonAddUser.Name      = userApp.m_appID;
                    menuButtonAddUser.BackImage = "file='images\\" + userApp.m_appID + ".jpg'";
                    menuButtonAddUser.Margin    = margin2;
                    menuItemSystem.LayoutDiv.AddControl(menuButtonAddUser);
                }
            }
            if (type4List != null && type4List.Count > 0)
            {
                int          num          = type4List.Count;
                FoldSubMenuA menuItemRisk = new FoldSubMenuA();
                menuItemRisk.Name             = "TYPE4";
                menuCaches[menuItemRisk.Name] = menuItemRisk;
                m_foldMenu.AddSubMenu(menuItemRisk);
                menuItemRisk.TitleLabel.Text   = "情报管理(" + num + ")";
                menuItemRisk.ShrinkButton.Text = "收缩";
                menuItemRisk.ShrinkButton.Name = "shrink";
                menuItemRisk.LayoutDiv.Margin  = margin1;
                menuItemRisk.Padding           = padding;
                menuItemRisk.Margin            = margin2;
                menuItemRisk.TitleLabel.Size   = new SIZE(150, 20);
                menuItemRisk.ShrinkButton.Size = new SIZE(80, 20);
                foreach (UserAppsTable userApp in type4List)
                {
                    FoldMenuItemA menuButtonAddUser = new FoldMenuItemA();
                    menuButtonAddUser.Text      = userApp.m_appName;
                    menuButtonAddUser.Name      = userApp.m_appID;
                    menuButtonAddUser.BackImage = "file='images\\" + userApp.m_appID + ".jpg'";
                    menuButtonAddUser.Margin    = margin2;
                    menuItemRisk.LayoutDiv.AddControl(menuButtonAddUser);
                }
            }
            //读取布局信息
            UserCookie cookie = new UserCookie();

            cookie.m_key    = "MENULAYOUT" + DataCenter.UserID.ToString();
            cookie.m_userID = DataCenter.UserID;
            if (DataCenter.UserCookieService.GetCookie(cookie.m_key, ref cookie) > 0)
            {
                String   value    = cookie.m_value;
                String[] strs     = value.Split(new String[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                int      strsSize = strs.Length;
                for (int i = 0; i < strsSize; i++)
                {
                    String[] subStrs  = strs[i].Split(new String[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                    String   foldName = subStrs[0];
                    bool     visible  = subStrs[1] == "1";
                    if (menuCaches.ContainsKey(foldName))
                    {
                        FoldSubMenuA foldSubMenu = menuCaches[foldName];
                        foldSubMenu.LayoutDiv.Visible = visible;
                        int subStrsSize = subStrs.Length;
                        int orderNum    = 0;
                        for (int j = 2; j < subStrsSize; j++)
                        {
                            List <ControlA> subControls     = foldSubMenu.LayoutDiv.m_controls;
                            int             subControlsSize = subControls.Count;
                            for (int m = 0; m < subControlsSize; m++)
                            {
                                ControlA subControl = subControls[m];
                                if (subControl.Name == subStrs[j])
                                {
                                    (subControl as FoldMenuItemA).OrderNum = orderNum;
                                    orderNum++;
                                    break;
                                }
                            }
                        }
                        foldSubMenu.LayoutDiv.m_controls.Sort(new FoldMenuItemOrderNumCompare());
                    }
                }
            }
            menuCaches.Clear();
            m_foldMenu.Update();
            Native.Update();
            ControlPaintEvent paintLayoutEvent = new ControlPaintEvent(PaintLayoutDiv);

            m_foldMenu.RegisterEvent(paintLayoutEvent, EVENTID.PAINT);
        }