示例#1
0
        private void InitUI()
        {
            MainViewManage.MainView = this.mainPanel;
            //添加按钮列
            List <HomePageNodeModel> modelList = XMLDataManage.GetNodesXML();

            for (int i = modelList.Count - 1; i >= 0; i--)
            {
                HomePageNodeModel nodeModel = modelList[i];
                SimpleButton      button    = new SimpleButton();
                button.Text                 = nodeModel.nodeName;
                button.ButtonStyle          = DevExpress.XtraEditors.Controls.BorderStyles.UltraFlat;
                button.Appearance.BackColor = NOR_BACK_COLOR;
                button.Size                 = new Size(50, 40);
                button.ForeColor            = Color.White;
                button.Font                 = new Font("宋体", 12, GraphicsUnit.Pixel);
                button.Margin               = new Padding(0);
                button.Padding              = new Padding(0);
                button.Dock                 = DockStyle.Top;
                button.AllowFocus           = false;
                button.ShowFocusRectangle   = DevExpress.Utils.DefaultBoolean.False;
                //button.ImageToTextAlignment = ImageAlignToText.LeftCenter;
                button.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Near;
                button.Click += Button_Click;
                button.Tag    = nodeModel;
                button.Paint += Button_Paint;
                if (nodeModel.imgName == null || nodeModel.imgName == "")
                {
                    button.Image = Imgs.icon_huiyuan;
                }
                else
                {
                    button.Image = Imgs.GetBitImg(nodeModel.imgName);
                }
                this.functionPanel.Controls.Add(button);
                Image img = Imgs.GetBitImg(nodeModel.imgName);
            }
            ////添加首页视图
            AddHomePageView();
            //添加系统消息监听
            AddMsgDelegate();
        }
示例#2
0
        private void Button_Click(object sender, EventArgs e)
        {
            HomePageNodeModel nodeModel = (HomePageNodeModel)(((SimpleButton)sender).Tag);
            //列表类型
            bool isList = nodeModel.childNodes.Count > 0;


            if (selectButton == sender && !isList)
            {
                return;
            }

            //设置回原来的样子
            if (selectButton != null)
            {
                HomePageNodeModel selectNodeModel = (HomePageNodeModel)(selectButton.Tag);
                selectButton.ForeColor            = Color.White;
                selectButton.Appearance.BackColor = NOR_BACK_COLOR;
                if (selectNodeModel.imgName == null || selectNodeModel.imgName == "")
                {
                    selectButton.Image = Imgs.icon_huiyuan;
                }
                else
                {
                    selectButton.Image = Imgs.GetBitImg(selectNodeModel.imgName);
                }
            }

            //设置成选择状态
            selectButton                      = sender as SimpleButton;
            selectButton.ForeColor            = Color.FromArgb(108, 140, 190);
            selectButton.Appearance.BackColor = SEL_BACK_COLOR;
            if (nodeModel.selName == null || nodeModel.selName == "")
            {
                selectButton.Image = Imgs.icon_huiyuan2;
            }
            else
            {
                selectButton.Image = Imgs.GetBitImg(nodeModel.selName);
            }
            //判断是否有子菜单
            //设置右键弹出框
            if (isList)
            {
                this.popupMenu1.ClearLinks();
                foreach (HomePageNodeModel model in nodeModel.childNodes)
                {
                    BarButtonItem item = new BarButtonItem();
                    item.Caption    = model.nodeName;
                    item.Tag        = model.nodeid;
                    item.ItemClick += Item_ItemClick;
                    this.popupMenu1.AddItem(item);
                }

                Point screenPoint = selectButton.PointToScreen(new Point(selectButton.Width, 0));
                popupMenu1.ShowPopup(screenPoint);
            }
            else
            {
                //显示右侧内容列表
                ShowView(nodeModel);
            }
        }