コード例 #1
0
        public override bool Populate(cmnGroupData data)
        {
            if (!base.Populate(data) || data.GetType() != typeof(CMNBtnGroupData))
            {
                return(false);
            }
            CMNBtnGroupData calcBtnGroupData = (CMNBtnGroupData)data;

            if (calcBtnGroupData.mButtons == null || calcBtnGroupData.mButtons.Length == 0)
            {
                return(true);
            }
            this.mButtons = new GroupButton[calcBtnGroupData.mButtons.Length];
            this.mRows    = 0;
            this.mColumns = 0;
            foreach (cmnBtnData mButton in calcBtnGroupData.mButtons)
            {
                if (mButton.mVIndex >= this.mRows)
                {
                    ++this.mRows;
                }
                if (mButton.mHIndex >= this.mColumns)
                {
                    ++this.mColumns;
                }
            }
            if (this.mRows == 0 || this.mColumns == 0)
            {
                return(true);
            }
            this.mHeight = ButtonGroupCtrl.GROUP_TOP_PADDING + this.mRows * (calcBtnGroupData.mBtnSize.Height + ButtonGroupCtrl.BUTTON_V_SPACE) - ButtonGroupCtrl.BUTTON_V_SPACE + ButtonGroupCtrl.GROUP_BOTTOM_PADDING;
            FlatStyle btnStyle = ButtonGroupCtrl.GetBtnStyle();

            for (int index = 0; index < calcBtnGroupData.mButtons.Length; ++index)
            {
                cmnBtnData  data1       = (cmnBtnData)calcBtnGroupData.mButtons.GetValue(index);
                GroupButton groupButton = new GroupButton(data1);
                groupButton.FlatStyle = btnStyle;
                groupButton.ForeColor = Color.FromName(data1.msColor);
                groupButton.Location  = new Point(ButtonGroupCtrl.GROUP_LEFT_PADDING + data1.mHIndex * (calcBtnGroupData.mBtnSize.Width + ButtonGroupCtrl.BUTTON_H_SPACE), ButtonGroupCtrl.GROUP_TOP_PADDING + data1.mVIndex * (calcBtnGroupData.mBtnSize.Height + ButtonGroupCtrl.BUTTON_V_SPACE));
                groupButton.Size      = calcBtnGroupData.mBtnSize;
                groupButton.Name      = data1.msExpression;
                groupButton.TabIndex  = index;
                groupButton.Text      = ResHandler.GetResStringByName(data1.msLabel);
                string msToolTip = data1.msToolTip;
                if (msToolTip != null && !msToolTip.Equals(""))
                {
                    groupButton.ToolTip = ResHandler.GetResStringByName(data1.msToolTip);
                }
                groupButton.Click += new EventHandler(this.OnButton_Click);
                this.mButtons.SetValue((object)groupButton, index);
                this.Controls.Add((Control)groupButton);
            }
            return(true);
        }
コード例 #2
0
        public override void ThemeChanged()
        {
            base.ThemeChanged();
            FlatStyle btnStyle = ButtonGroupCtrl.GetBtnStyle();

            foreach (GroupButton mButton in this.mButtons)
            {
                if (mButton.FlatStyle != btnStyle)
                {
                    mButton.FlatStyle = btnStyle;
                }
            }
        }