コード例 #1
0
        void PaintItem(Graphics g)
        {
            if (paintType == PaintType.Selected || paintType == PaintType.MouseOver)
            {
                NavigateBarHelper.PaintGradientBack(this, g, navigateBar.NavigateBarColorTable, paintType);
            }

            // Draw Arrow Lines

            Pen linePen    = new Pen(navigateBar.NavigateBarColorTable.CaptionTextColor);
            int halfHeight = this.Height / 2;

            if (this.navigateBar.RightToLeft == RightToLeft.Yes)
            {
                if (!isExpandArrow)
                {
                    //
                    g.DrawLine(linePen, new Point(4, 4), new Point(7, halfHeight));
                    g.DrawLine(linePen, new Point(4, Width - 4), new Point(7, halfHeight));
                    //
                    g.DrawLine(linePen, new Point(8, 4), new Point(11, halfHeight));
                    g.DrawLine(linePen, new Point(8, Width - 4), new Point(11, halfHeight));
                }
                else
                {
                    //
                    g.DrawLine(linePen, new Point(4, halfHeight), new Point(7, 4));
                    g.DrawLine(linePen, new Point(4, halfHeight), new Point(7, Width - 4));
                    //
                    g.DrawLine(linePen, new Point(8, halfHeight), new Point(11, 4));
                    g.DrawLine(linePen, new Point(8, halfHeight), new Point(11, Width - 4));
                }
            }
            else
            {
                if (isExpandArrow)
                {
                    //
                    g.DrawLine(linePen, new Point(4, 4), new Point(7, halfHeight));
                    g.DrawLine(linePen, new Point(4, Width - 4), new Point(7, halfHeight));
                    //
                    g.DrawLine(linePen, new Point(8, 4), new Point(11, halfHeight));
                    g.DrawLine(linePen, new Point(8, Width - 4), new Point(11, halfHeight));
                }
                else
                {
                    //
                    g.DrawLine(linePen, new Point(4, halfHeight), new Point(7, 4));
                    g.DrawLine(linePen, new Point(4, halfHeight), new Point(7, Width - 4));
                    //
                    g.DrawLine(linePen, new Point(8, halfHeight), new Point(11, 4));
                    g.DrawLine(linePen, new Point(8, halfHeight), new Point(11, Width - 4));
                }
            }
        }
コード例 #2
0
        protected override void OnPaintBackground(PaintEventArgs e)
        {
            base.OnPaintBackground(e);
            // Gradient olarak boyama işlemi
            // Paint gradient

            NavigateBarHelper.PaintGradientBack(this, e.Graphics, navigateBar.NavigateBarColorTable, PaintType.Normal);

            // Etrafın çizgisi
            // draw rectangle

            e.Graphics.DrawRectangle(new Pen(navigateBar.NavigateBarColorTable.BorderColor), new Rectangle(0, 0, Width - 1, Height - 1));
        }
コード例 #3
0
        void PaintThisControl(Graphics tGraphics)
        {
            Image imageButton = null;

            switch (this.PaintingType)
            {
            case PaintType.Normal:
            {
                imageButton = isSelected ? navigateBarButton.SelectedImage : navigateBarButton.Image;
                break;
            }

            case PaintType.Selected:
            {
                imageButton = navigateBarButton.SelectedImage;
                break;
            }

            case PaintType.MouseOver:
            {
                imageButton = navigateBarButton.MouseOverImage;
                break;
            }

            case PaintType.Pressed:
            {
                imageButton = navigateBarButton.Image;
                break;
            }
            }
            // Gradient olarak boyama işlemi
            // Paint gradient

            NavigateBarHelper.PaintGradientBack(this, tGraphics,
                                                navigateBarButton.NavigateBar.NavigateBarColorTable,
                                                this.PaintingType);

            // Image

            // OverFlowPanelde mutlaka bir image gösterilmeli
            // Image must be on panel
            if (imageButton == null)
            {
                imageButton = Properties.Resources.NoImage;
            }

            if (!this.Enabled)
            {
                imageButton = navigateBarButton.DisableImage;
            }


            if (!this.IsArrowButton) // Draw image
            {
                Size imgSize = new Size(16, 16);
                int  left    = (this.Width - imgSize.Width) / 2;
                int  top     = (this.Height - imgSize.Height) / 2 + 1;

                Rectangle r2 = new Rectangle(new Point(left, top), imgSize);

                tGraphics.DrawImage(imageButton, r2);
            }
            else // Draw Arrow
            {
                int halfHeight = this.Height / 2, halfWidth = this.Width / 2;

                // Office 2007
                if (this.NavigateBarButton.NavigateBar.NavigateBarColorTable.ContextMenuArrowStyle == ContextMenuArrowStyle.Office2007)
                {
                    // Draw triangles
                    SolidBrush brush       = new SolidBrush(navigateBarButton.NavigateBar.NavigateBarColorTable.BorderColor);
                    SolidBrush brushShadow = new SolidBrush(Color.WhiteSmoke);

                    tGraphics.FillPolygon(brushShadow, new Point[] {
                        new Point(halfWidth - ARROW_WIDTH / 2, halfHeight + 1),
                        new Point(halfWidth + (int)Math.Ceiling((float)ARROW_WIDTH / 2), halfHeight + 1),
                        new Point(halfWidth, halfHeight + ARROW_HEIGHT + 1)
                    });

                    tGraphics.FillPolygon(brush, new Point[] {
                        new Point(halfWidth - ARROW_WIDTH / 2, halfHeight),
                        new Point(halfWidth + (int)Math.Ceiling((float)ARROW_WIDTH / 2), halfHeight),
                        new Point(halfWidth, halfHeight + ARROW_HEIGHT)
                    });

                    brush.Dispose();
                    brushShadow.Dispose();
                }
                else // Office 2003
                {
                    SolidBrush brush   = new SolidBrush(Color.Black);
                    Pen        linePen = new Pen(brush, 1.6f);

                    const int ARROW_LINE_WIDTH = 2;
                    halfHeight -= 2;

                    if (this.NavigateBarButton.NavigateBar.RightToLeft == RightToLeft.Yes)
                    {
                        // <<

                        halfWidth -= 2;
                        tGraphics.DrawLine(linePen, new Point(halfWidth - 3, halfHeight), new Point(halfWidth - 1, halfHeight - ARROW_LINE_WIDTH));
                        tGraphics.DrawLine(linePen, new Point(halfWidth - 3, halfHeight), new Point(halfWidth - 1, halfHeight + ARROW_LINE_WIDTH));
                        //
                        tGraphics.DrawLine(linePen, new Point(halfWidth, halfHeight), new Point(halfWidth + ARROW_LINE_WIDTH, halfHeight - ARROW_LINE_WIDTH));
                        tGraphics.DrawLine(linePen, new Point(halfWidth, halfHeight), new Point(halfWidth + ARROW_LINE_WIDTH, halfHeight + ARROW_LINE_WIDTH));
                    }
                    else
                    {
                        // >>

                        tGraphics.DrawLine(linePen, new Point(halfWidth - ARROW_LINE_WIDTH, halfHeight - ARROW_LINE_WIDTH), new Point(halfWidth, halfHeight));
                        tGraphics.DrawLine(linePen, new Point(halfWidth - ARROW_LINE_WIDTH, halfHeight + ARROW_LINE_WIDTH), new Point(halfWidth, halfHeight));
                        //
                        tGraphics.DrawLine(linePen, new Point(halfWidth + 1, halfHeight - ARROW_LINE_WIDTH), new Point(halfWidth + 3, halfHeight));
                        tGraphics.DrawLine(linePen, new Point(halfWidth + 1, halfHeight + ARROW_LINE_WIDTH), new Point(halfWidth + 3, halfHeight));
                    }
                    //
                    halfHeight++;
                    // draw triangle
                    tGraphics.FillPolygon(brush, new Point[] {
                        new Point(halfWidth - ARROW_WIDTH / 2, halfHeight + 5),
                        new Point(halfWidth + (int)Math.Ceiling((float)ARROW_WIDTH / 2), halfHeight + 5),
                        new Point(halfWidth, halfHeight + ARROW_HEIGHT + 5)
                    });

                    brush.Dispose();
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Paint NavigateBarButton
        /// </summary>
        /// <param name="LightColor"></param>
        /// <param name="DarkColor"></param>
        /// <param name="paintType"></param>
        void PaintThisControl(Graphics g)
        {
            Image imageButton = null;

            switch (this.PaintingType)
            {
            case PaintType.Normal:
            {
                imageButton = isSelected ? SelectedImage : Image;
                break;
            }

            case PaintType.Selected:
            {
                imageButton = SelectedImage;
                break;
            }

            case PaintType.MouseOver:
            {
                imageButton = MouseOverImage;
                break;
            }

            case PaintType.Pressed:
            {
                imageButton = Image;
                break;
            }
            }

            // Gradient olarak boyama işlemi
            // Paint gradient

            NavigateBarHelper.PaintGradientBack(this, g, navigateBar.NavigateBarColorTable, this.PaintingType);

            // Yazıyı yazma
            // Draw caption text

            if (!string.IsNullOrEmpty(Caption))
            {
                Brush brushText;
                if (this.Enabled)
                {
                    brushText = new SolidBrush(isSelected ?
                                               navigateBar.NavigateBarColorTable.SelectedTextColor :
                                               navigateBar.NavigateBarColorTable.TextColor);
                }
                else
                {
                    brushText = SystemBrushes.GrayText; // Disable color
                }
                // Caption ifadesini belirle

                int widthCaption = (int)g.MeasureString(caption, Font).Width; // Caption pixel olarak uzunluğunu al

                if (this.Width < (widthCaption + SPLIT_WIDTH * 2 + (Image == null ? SPLIT_WIDTH : Image.Width)))
                {
                    captionString = "..";
                    for (int i = Caption.Length - 1; i >= 0; i--)
                    {
                        string tmpCaption = caption.Trim().Substring(0, i);

                        int widthCaptionTmp = (int)g.MeasureString(tmpCaption + "..", Font).Width; // Caption pixel olarak uzunluğunu al
                        if (this.Width >= (widthCaptionTmp + SPLIT_WIDTH * 2 + (Image == null ? SPLIT_WIDTH : Image.Width)))
                        {
                            captionString = tmpCaption + "..";
                            break;
                        }
                    }
                }
                else
                {
                    captionString = caption;
                }

                //

                string cap = captionString.Equals("..") ? "" : captionString;
                if (this.NavigateBar.RightToLeft == RightToLeft.Yes && this.NavigateBar.IsUseRTLforButtons)
                {
                    int capWidth = (int)g.MeasureString(cap, this.Font).Width;
                    g.DrawString(cap, Font, brushText,
                                 this.Width - capWidth - SPLIT_WIDTH - (imageButton == null ? 0 : imageButton.Width + SPLIT_WIDTH), this.Height / 2 - Font.Height / 2);
                }
                else
                {
                    g.DrawString(cap, Font, brushText,
                                 SPLIT_WIDTH + (imageButton == null ? 0 : imageButton.Width) + (imageButton != null ? SPLIT_WIDTH : 0), this.Height / 2 - Font.Height / 2);
                }
            }

            // Resmi gösterme
            // Draw Image

            if (imageButton != null)
            {
                Image img = null;
                if (this.Enabled) // Orjinal resmi kullan // use orjinal picture
                {
                    img = imageButton;
                }
                else
                {
                    img = image;
                }

                if (!this.Enabled)
                {
                    img = disableImage;
                }

                int leftPos = SPLIT_WIDTH;

                if (this.NavigateBar.RightToLeft == RightToLeft.Yes && this.NavigateBar.IsUseRTLforButtons)
                {
                    leftPos = this.Width - img.Width - SPLIT_WIDTH;
                }

                // Eğer button metni gözükmüyorsa sadece image gözükecek şekilde ortala
                // if cannot display button text then set image position center button
                if (captionString.Equals("..") || string.IsNullOrEmpty(captionString))
                {
                    // Center position
                    leftPos = (int)((Width - img.Width) / 2);
                    leftPos = leftPos <= 0 ? 1 : leftPos;
                }

                g.DrawImage(img,
                            new Rectangle(leftPos, (int)((Height - img.Height + 4) / 2),
                                          img.Width,
                                          img.Height > Height ? Height : img.Height));
            }

            // Dış Çizgi
            // Draw rectangle

            Pen pen = new Pen(navigateBar.NavigateBarColorTable.BorderColor);

            g.DrawRectangle(pen, new Rectangle(0, 0, Width - 1, Height));

            //
        }