Exemple #1
0
 /// <summary>
 /// Related control
 /// </summary>
 /// <param name="tRelatedControl">Related control</param>
 public NavigateBarButton(Control tRelatedControl)
 {
     this.RelatedControl = tRelatedControl;
     this.Caption        = "NavigateBarButton";
     this.Key            = NavigateBarHelper.CreateUniqKey();
     InitNavigateBarButton();
 }
        void PaintThisControl(Graphics g)
        {
            NavigateBarHelper.PaintGradientControl(this, g,
                                                   navigateBar.NavigateBarColorTable.CaptionDescBegin,
                                                   navigateBar.NavigateBarColorTable.CaptionDescEnd,
                                                   navigateBar.NavigateBarColorTable.PaintAngle);

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


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

            int capWidth = (int)g.MeasureString(Caption, SystemFonts.DialogFont).Width;

            g.DrawString(Caption,
                         new Font(SystemFonts.DialogFont.Name, 8, FontStyle.Regular),
                         new SolidBrush(navigateBar.NavigateBarColorTable.TextColor),
                         (this.NavigateBar.RightToLeft == RightToLeft.Yes ? this.Width - capWidth - 8 : 8),
                         (this.Height - SystemFonts.DialogFont.Height) / 2);


            // Etrafın çizgisi
            // Draw rectangle

            g.DrawRectangle(new Pen(navigateBar.NavigateBarColorTable.BorderColor), new Rectangle(0, 0, Width - 1, Height - 1));
        }
Exemple #3
0
 /// <summary>
 /// Caption and Image
 /// </summary>
 /// <param name="tCaption">Caption text</param>
 /// <param name="tImage">Image (24x24 recommended)</param>
 public NavigateBarButton(string tCaption, Image tImage)
 {
     this.Caption = tCaption;
     this.Image   = tImage;
     this.Key     = NavigateBarHelper.CreateUniqKey();
     InitNavigateBarButton();
 }
Exemple #4
0
 /// <summary>
 /// Caption, image and related control
 /// </summary>
 /// <param name="tCaption">Caption text</param>
 /// <param name="tImage">Image (24x24 recommended)</param>
 /// <param name="tRelatedControl">Related control</param>
 public NavigateBarButton(string tCaption, Image tImage, Control tRelatedControl)
 {
     this.Caption        = tCaption;
     this.Image          = tImage;
     this.RelatedControl = tRelatedControl;
     this.Key            = NavigateBarHelper.CreateUniqKey();
     InitNavigateBarButton();
 }
        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));
                }
            }
        }
        protected override void OnPaintBackground(PaintEventArgs e)
        {
            if (this.Controls.Count == 0 && !this.DesignMode)
            {
                base.OnPaintBackground(e);

                NavigateBarHelper.PaintGradientControl(this, e.Graphics,
                                                       navigateBar.NavigateBarColorTable.ButtonNormalBegin,
                                                       navigateBar.NavigateBarColorTable.ButtonNormalEnd,
                                                       navigateBar.NavigateBarColorTable.PaintAngle);
            }
        }
Exemple #7
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));
        }
        /// <summary>
        /// Paint Gradient
        /// </summary>
        /// <param name="tControl">Painting control</param>
        /// <param name="tGraphics">Graphic object</param>
        /// <param name="tColorTable">NavigataBarColorTable inherited object</param>
        /// <param name="tPaintType">Paint type</param>
        public static void PaintGradientBack(Control tControl, Graphics tGraphics, NavigateBarColorTable tColorTable, PaintType tPaintType)
        {
            if (tControl.ClientRectangle.IsEmpty)
            {
                return;
            }

            #region Color Select

            Color cTopColorBegin    = tColorTable.ButtonNormalBegin;
            Color cTopColorEnd      = tColorTable.ButtonNormalMiddleBegin;
            Color cBottomColorBegin = tColorTable.ButtonNormalMiddleEnd;
            Color cBottomColorEnd   = tColorTable.ButtonNormalEnd;

            switch (tPaintType)
            {
            case PaintType.Selected:
            {
                cTopColorBegin    = tColorTable.ButtonSelectedBegin;
                cTopColorEnd      = tColorTable.ButtonSelectedMiddleBegin;
                cBottomColorBegin = tColorTable.ButtonSelectedMiddleEnd;
                cBottomColorEnd   = tColorTable.ButtonSelectedEnd;

                break;
            }

            case PaintType.MouseOver:
            {
                cTopColorBegin    = tColorTable.ButtonMouseOverBegin;
                cTopColorEnd      = tColorTable.ButtonMouseOverMiddleBegin;
                cBottomColorBegin = tColorTable.ButtonMouseOverMiddleEnd;
                cBottomColorEnd   = tColorTable.ButtonMouseOverEnd;

                break;
            }

            case PaintType.Pressed:
            {
                cTopColorBegin    = tColorTable.ButtonSelectedEnd;
                cTopColorEnd      = tColorTable.ButtonSelectedMiddleBegin;
                cBottomColorBegin = tColorTable.ButtonSelectedMiddleEnd;
                cBottomColorEnd   = tColorTable.ButtonSelectedMiddleEnd;

                break;
            }
            }
            #endregion

            NavigateBarHelper.PaintGradientControl(tControl, tGraphics, cTopColorBegin, cTopColorEnd, cBottomColorBegin, cBottomColorEnd, tColorTable.PaintAngle, tColorTable.PaintRatio);
        }
        protected override void OnPaintBackground(PaintEventArgs e)
        {
            base.OnPaintBackground(e);

            // Paint

            if (IsSelected)
            {
                NavigateBarHelper.PaintGradientControl(this, e.Graphics, navigateBar.NavigateBarColorTable.ButtonSelectedBegin, navigateBar.NavigateBarColorTable.ButtonSelectedBegin, navigateBar.NavigateBarColorTable.PaintAngle);
            }
            else if (isMouseOver && !IsSelected)
            {
                NavigateBarHelper.PaintGradientControl(this, e.Graphics, navigateBar.NavigateBarColorTable.ButtonMouseOverBegin, navigateBar.NavigateBarColorTable.ButtonMouseOverBegin, navigateBar.NavigateBarColorTable.PaintAngle);
            }
            else
            {
                NavigateBarHelper.PaintGradientControl(this, e.Graphics, navigateBar.NavigateBarColorTable.ButtonNormalBegin, navigateBar.NavigateBarColorTable.ButtonNormalBegin, navigateBar.NavigateBarColorTable.PaintAngle);
            }

            //if (!(this.IsSelected || isMouseOver))
            //{
            //    Pen pen = new Pen(Color.White);
            //    // |
            //    e.Graphics.DrawLine(pen, new Point(0, 0), new Point(0, this.Height));
            //    // ___
            //    e.Graphics.DrawLine(pen, new Point(0, this.CaptionBand.Height), new Point(this.Width - 1, this.CaptionBand.Height));
            //}

            float leftPoss = 0, rightPoss = 0;

            Font font = new Font(SystemFonts.CaptionFont.FontFamily, 16, FontStyle.Bold);

            // Vertical Text

            e.Graphics.TranslateTransform(0, this.ClientSize.Height);
            e.Graphics.RotateTransform(270F);

            SizeF sf = e.Graphics.MeasureString(this.ContentText, font);

            leftPoss  = (this.ClientSize.Height - sf.Width - CaptionBand.Height) / 2;
            rightPoss = (this.ClientSize.Width - sf.Height) / 2;

            e.Graphics.DrawString(this.ContentText, font,
                                  new SolidBrush(navigateBar.NavigateBarColorTable.CaptionTextColor),
                                  leftPoss, rightPoss);

            //
        }
        protected override void OnPaintBackground(PaintEventArgs e)
        {
            base.OnPaintBackground(e);

            if (navigateBar == null)
            {
                return;
            }

            Rectangle splitRectangle = this.ClientRectangle;
            Brush     darkColor      = new SolidBrush(navigateBar.NavigateBarColorTable.BorderColor);
            Brush     lightColor     = new SolidBrush(navigateBar.NavigateBarColorTable.SeparatorLight);

            NavigateBarHelper.PaintGradientControl(this, e.Graphics,
                                                   navigateBar.NavigateBarColorTable.SeparatorLight,
                                                   navigateBar.NavigateBarColorTable.SeparatorDark,
                                                   navigateBar.NavigateBarColorTable.PaintAngle);

            // Point Position
            int pointWidth = 4, pointHeight = 2;
            int firstPointPos = (splitRectangle.Width - (splitterPointCount * pointWidth + this.splitterPointCount)) / 2;
            int Y             = (int)((splitRectangle.Height - 1) / 2);

            // Draw Points
            for (int i = 0; i < this.splitterPointCount; i++)
            {
                e.Graphics.FillRectangle(darkColor, firstPointPos, Y, pointHeight, pointHeight);
                e.Graphics.FillRectangle(lightColor, firstPointPos + 1, Y + 1, pointHeight, pointHeight);
                e.Graphics.FillRectangle(SystemBrushes.GrayText, firstPointPos + 1, Y, pointHeight, pointHeight);

                firstPointPos += pointWidth + 1;
            }

            splitRectangle.Width--;
            e.Graphics.DrawRectangle(new Pen(navigateBar.NavigateBarColorTable.BorderColor), splitRectangle);
        }
        void PaintThisControl(Graphics g)
        {
            // Gradient olarak boyama işlemi // Paint gradient

            NavigateBarHelper.PaintGradientControl(this, g,
                                                   NavigateBar.NavigateBarColorTable.CaptionBegin,
                                                   NavigateBar.NavigateBarColorTable.CaptionEnd,
                                                   NavigateBar.NavigateBarColorTable.PaintAngle);

            //

            Size imgSize = new Size(16, 16);

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

            // Image

            if (image != null)
            {
                int halfHeight = ((this.Height - imgSize.Height) / 2);
                if (this.NavigateBar.RightToLeft == RightToLeft.Yes)
                {
                    g.DrawImage(image, new Rectangle(new Point(this.Width - imgSize.Width - SPLIT_WIDTH - 2, halfHeight), imgSize));
                }
                else
                {
                    g.DrawImage(image, new Rectangle(new Point(SPLIT_WIDTH + 2, halfHeight), imgSize));
                }
            }

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

            Font  font         = new Font(SystemFonts.CaptionFont.Name, 10, FontStyle.Bold);
            int   capWidth     = (int)g.MeasureString(this.Caption, font).Width;
            Brush captionColor = new SolidBrush(navigateBar.NavigateBarColorTable.CaptionTextColor);

            if (this.NavigateBar.RightToLeft == RightToLeft.Yes)
            {
                g.DrawString(this.Caption, font, captionColor,
                             this.Width - capWidth - SPLIT_WIDTH * 2 - (image == null ? SPLIT_WIDTH * 2 : imgSize.Width + SPLIT_WIDTH), (this.Height - font.GetHeight()) / 2);
            }
            else
            {
                g.DrawString(this.Caption, font, captionColor,
                             image == null ? SPLIT_WIDTH * 2 : imgSize.Width + SPLIT_WIDTH * 2, (this.Height - font.GetHeight()) / 2);
            }

            // Etrafın çizgisi // Draw rectangle

            if (this.CollapseMode) // Sadece başlık durumunda // only caption
            {
                if (navigateBar.SelectedButton != null)
                {
                    g.DrawRectangle(penBorder, new Rectangle(0, 0, Width - 1, Height - (navigateBar.SelectedButton.IsShowCaptionDescription ? 0 : 1)));
                }
                else
                {
                    g.DrawRectangle(penBorder, new Rectangle(0, 0, Width - 1, Height - 1));
                }
            }
            else // Başlık ve Daraltılmış durumda // Collapse and caption
            {
                g.DrawRectangle(penBorder, new Rectangle(-1, 0, Width + 1, Height - 1));
            }
        }
Exemple #12
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();
                }
            }
        }
Exemple #13
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));

            //
        }
Exemple #14
0
 public NavigateBarButton()
 {
     this.Caption = "NavigateBarButton";
     this.Key     = NavigateBarHelper.CreateUniqKey();
     InitNavigateBarButton();
 }