コード例 #1
0
 private void FillBackground(Graphics graphics, int imageWidth, TabStateType tabState)
 {
     Brush brush = new SolidBrush((tabState == TabStateType.Normal) ? _tabColor : _selectedColor);
     graphics.FillRectangle(brush, 0, 0, imageWidth, _tabHeight);
 }
コード例 #2
0
        private Bitmap CreateTabRightImage(TabStateType tabState)
        {
            int cornerHeight = 0;
            int cornerWidth = 0;

            if (_tabType == TabType.LeftLean || _tabType == TabType.Symetrical)
            {
                cornerHeight = _cornerHeight;
                cornerWidth = _cornerWidth;
            }

            int imageWidth = _tabWidth - (_cornerWidth / 2) - 1;

            Bitmap tabRightImage = new Bitmap(imageWidth, _tabHeight, PixelFormat.Format32bppArgb);
            Graphics graphics = Graphics.FromImage(tabRightImage);

            this.FillBackground(graphics, imageWidth, tabState);
            Pen pen = this.GetPen();

            if (cornerWidth > 0 && cornerHeight > 0)
            {
                if (_cornerType == CornerType.Rounded)
                    this.DrawCornerArc(graphics, pen, CornerSideType.Right);
                else
                    this.DrawCornerLine(graphics, pen, CornerSideType.Right, imageWidth);
            }

            // draw right image vertical line
            Point pointA = new Point();
            Point pointB = new Point();

            int penWidth = Convert.ToInt32(pen.Width);

            pointA.X = imageWidth - (1 + penWidth / 2);
            pointA.Y = cornerHeight / 2;
            pointB.X = imageWidth - (1 + penWidth / 2);
            pointB.Y = _tabHeight;

            graphics.DrawLine(pen, pointA, pointB);

            // draw right image horizontal line
            pointA.X = 0;
            pointA.Y = penWidth / 2;
            pointB.X = (imageWidth - cornerWidth + (cornerWidth / 2)) - 1;
            pointB.Y = penWidth / 2;

            graphics.DrawLine(pen, pointA, pointB);

            Color currentTabColor = (tabState == TabStateType.Normal) ? _tabColor : _selectedColor;

            for (int y = 0; y < cornerHeight / 2; y++)
            {
                for (int x = imageWidth - 1; x > pointB.X; x--)
                {
                    if (!this.ClearPixel(tabRightImage, currentTabColor, x, y))
                        break;
                }
            }

            return tabRightImage;
        }