コード例 #1
0
        public void SetItemCalibState(List <string> itemArr, bool bCalibrated)
        {
            int index = -1;

            foreach (var val in itemArr)
            {
                index = _gpBtnArr.FindIndex(r => r.Text == val);
                if (index != -1)
                {
                    ItemButton itemBtn = _gpBtnArr[index] as ItemButton;
                    itemBtn.IsCalibrated = bCalibrated;
                }
            }
        }
コード例 #2
0
        public List <string> GetDownloadItem()
        {
            List <string> itemArr = new List <string>();

            foreach (var val in _gpBtnArr)
            {
                ItemButton itemBtn = val as ItemButton;
                if (itemBtn.Download)
                {
                    itemArr.Add(val.Text);
                }
            }

            return(itemArr);
        }
コード例 #3
0
        public List <string> GetCheckedItem()
        {
            List <string> itemArr = new List <string>();

            foreach (var val in _gpBtnArr)
            {
                ItemButton itemBtn = val as ItemButton;
                if (itemBtn.Selected && !itemBtn.Download && itemBtn.Enabled)
                {
                    itemArr.Add(val.Text);
                }
            }

            return(itemArr);
        }
コード例 #4
0
        public void SetItemDownloadState(List <string> itemArr, bool download)
        {
            int index = -1;

            foreach (var val in itemArr)
            {
                index = _gpBtnArr.FindIndex(r => r.Text == val);
                if (index != -1)
                {
                    ItemButton itemBtn = _gpBtnArr[index] as ItemButton;
                    itemBtn.Download = download;
                }
            }

            this.Invalidate();
        }
コード例 #5
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            g.SmoothingMode      = SmoothingMode.HighQuality;
            g.PixelOffsetMode    = PixelOffsetMode.HighQuality;          //高像素偏移质量
            g.InterpolationMode  = InterpolationMode.HighQualityBicubic;
            g.CompositingQuality = CompositingQuality.HighQuality;

            g.Clear(this.BackColor);

            Color bkColor = Color.White;

            if (!this.Enabled)
            {
                bkColor = Color.FromArgb(244, 244, 244);
            }
            using (SolidBrush backBsh = new SolidBrush(bkColor))
            {
                g.FillRectangle(backBsh, this.ClientRectangle);
            }

            using (Pen pen = new Pen(Color.Black))
            {
                g.DrawRectangle(pen, this.ClientRectangle);
            }

            g.TranslateTransform(this.AutoScrollPosition.X, this.AutoScrollPosition.Y);

            if (_gpBtnArr.Count > 0)
            {
                for (int i = 0; i < _gpBtnArr.Count; i++)
                {
                    ItemButton itemBtn = _gpBtnArr[i] as ItemButton;

                    Color     txtColor = Color.Black;
                    Rectangle txtRect  = Rectangle.Round(itemBtn.BtnRect);
                    txtRect.Offset(this.AutoScrollPosition);

                    Pen borderPen = new Pen(Color.Black, 1f);

                    if (itemBtn.Enabled)
                    {
                        if (itemBtn.Download)
                        {
                            txtColor = BackColor;

                            using (SolidBrush btnbsh = new SolidBrush(DownloadColor))
                            {
                                g.FillPath(btnbsh, _gpBtnArr[i].BtnPath);
                            }
                        }
                        else
                        {
                            if (itemBtn.Selected)
                            {
                                txtColor = BackColor;

                                using (SolidBrush btnbsh = new SolidBrush(SelectedColor))
                                {
                                    g.FillPath(btnbsh, _gpBtnArr[i].BtnPath);
                                }
                            }
                            else if (_gpBtnArr[i].MouseHover)
                            {
                                borderPen.Color = Color.Green;
                                borderPen.Width = 2f;
                            }
                        }
                    }
                    else
                    {
                        using (SolidBrush btnbsh = new SolidBrush(Color.LightGray))
                        {
                            g.FillPath(btnbsh, _gpBtnArr[i].BtnPath);
                        }
                    }

                    CommonGraphic.DrawRectangle(g, borderPen,
                                                _gpBtnArr[i].BtnRect.X,
                                                _gpBtnArr[i].BtnRect.Y,
                                                _gpBtnArr[i].BtnRect.Width,
                                                _gpBtnArr[i].BtnRect.Height);

                    if (IsShowCalibStatus)
                    {
                        if (itemBtn.IsCalibrated && CalibrateImage != null)
                        {
                            g.DrawImage(CalibrateImage, itemBtn.CalibImageRect);
                        }
                        else if (!itemBtn.IsCalibrated && UnCalibrateImage != null)
                        {
                            g.DrawImage(UnCalibrateImage, itemBtn.CalibImageRect);
                        }
                    }

                    TextRenderer.DrawText(g,
                                          _gpBtnArr[i].Text,
                                          this.Font,
                                          txtRect,
                                          txtColor,
                                          TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter);
                }
            }

            g.ResetTransform();
        }