Esempio n. 1
0
        public void InitCtrl(List <TitleBtnItem> items)
        {
            _gpBtnArr.Clear();

            foreach (var item in items)
            {
                GraphicButton gpBtn = new GraphicButton();
                gpBtn.Text            = item.Text;
                gpBtn.BackgroundImage = item.BackgroundImage;
                gpBtn.SelectedBKImage = item.SelectedBKImage;

                _gpBtnArr.Add(gpBtn);
            }

            if (_gpBtnArr.Count > 0)
            {
                float width = (float)ClientRectangle.Width / _gpBtnArr.Count;

                for (int i = 0; i < _gpBtnArr.Count; i++)
                {
                    RectangleF rect = new RectangleF();
                    rect.X      = i * width;
                    rect.Width  = width;
                    rect.Y      = (float)ClientRectangle.Top;
                    rect.Height = (float)ClientRectangle.Height;

                    _gpBtnArr[i].BtnRect = rect;

                    _gpBtnArr[i].BtnPath = new GraphicsPath();
                    _gpBtnArr[i].BtnPath.AddRectangle(rect);

                    _gpBtnArr[i].BtnRegion = new Region(_gpBtnArr[i].BtnPath);
                }
            }
        }
Esempio n. 2
0
        public void InitCtrl(List <TitleBtnItem> items)
        {
            //SelectedColor = Color.FromArgb(0, 0, 64);

            SelectedColor = Color.FromArgb(0, 0, 84);

            _gpBtnArr.Clear();

            foreach (var item in items)
            {
                GraphicButton gpBtn = new GraphicButton();
                gpBtn.Text            = item.Text;
                gpBtn.BackgroundImage = item.BackgroundImage;
                gpBtn.SelectedBKImage = item.SelectedBKImage;

                _gpBtnArr.Add(gpBtn);
            }

            if (_gpBtnArr.Count > 0)
            {
                float width  = (float)ClientRectangle.Width;
                float height = width / 3f;

                for (int i = 0; i < _gpBtnArr.Count; i++)
                {
                    RectangleF rect = new RectangleF();
                    rect.X      = 0;
                    rect.Width  = width;
                    rect.Y      = i * height;
                    rect.Height = height;

                    _gpBtnArr[i].BtnRect = rect;

                    _gpBtnArr[i].BtnPath = new GraphicsPath();
                    _gpBtnArr[i].BtnPath.AddRectangle(rect);

                    _gpBtnArr[i].BtnRegion = new Region(_gpBtnArr[i].BtnPath);
                }
            }

            if (EnableDisplayTime)
            {
                _timeRect = new Rectangle(0, this.Height - 80, this.Width, 80);

                _timer.Elapsed  += OntimerElapsed;
                _timer.AutoReset = true;
                _timer.Enabled   = true;
            }
        }
        public void InitCtrl(uint btnNums)
        {
            Debug.Assert(btnNums > 0);

            _gpBtnArr.Clear();

            float startHeight = ClientRectangle.Bottom * 0.7f;
            float k           = (startHeight - ClientRectangle.Top) / (float)(ClientRectangle.Left - ClientRectangle.Right);

            _txtRect         = ClientRectangle;
            _txtRect.Height /= 3;

            float btnWidth = this.Width / (float)btnNums;

            for (int i = 0; i < btnNums; i++)
            {
                RectangleF rect = new RectangleF();
                rect.X     = i * btnWidth;
                rect.Width = btnWidth;

                rect.Y      = (rect.X - ClientRectangle.Left) * k + startHeight;
                rect.Height = ClientRectangle.Height - rect.Y;

                rect.Inflate(-2f, 0);
                CommonGraphic.ConvertRect(ref rect);

                if (rect.Bottom > ClientRectangle.Bottom)
                {
                    rect.Height -= 1f;
                }

                GraphicButton gpBtn = new GraphicButton();
                gpBtn.BtnRect = rect;
                gpBtn.BtnPath = new GraphicsPath();
                gpBtn.BtnPath.AddRectangle(rect);
                gpBtn.BtnRegion = new Region(gpBtn.BtnPath);

                _gpBtnArr.Add(gpBtn);
            }
        }