internal void DrawInternal(Graphics g, RectangleF rect, float zoom, StiAdvancedBorder border)
        {
            using (var pen = new Pen(this.Color))
            {
                pen.DashStyle = StiPenUtils.GetPenStyle(style);
                pen.Width     = (int)(this.Size * zoom);
                pen.StartCap  = LineCap.NoAnchor;
                pen.EndCap    = LineCap.NoAnchor;

                rect = GetAdvancedBorderRectangle(g, rect, zoom, border);

                switch (side)
                {
                case StiBorderSides.Top:
                    if (border.IsTopBorderSidePresent)
                    {
                        g.DrawLine(pen, rect.Left, rect.Top, rect.Right, rect.Top);
                    }
                    break;

                case StiBorderSides.Bottom:
                    if (border.IsBottomBorderSidePresent)
                    {
                        g.DrawLine(pen, rect.Left, rect.Bottom, rect.Right, rect.Bottom);
                    }
                    break;

                case StiBorderSides.Left:
                    if (border.IsLeftBorderSidePresent)
                    {
                        g.DrawLine(pen, rect.Left, rect.Top, rect.Left, rect.Bottom);
                    }
                    break;

                case StiBorderSides.Right:
                    if (border.IsRightBorderSidePresent)
                    {
                        g.DrawLine(pen, rect.Right, rect.Top, rect.Right, rect.Bottom);
                    }
                    break;
                }
            }
        }
        internal void DrawSolidInternal(Graphics g, RectangleF rect, float zoom, StiAdvancedBorder border)
        {
            using (var brush = new SolidBrush(this.Color))
            {
                var size = Math.Max(1, (int)(this.Size * zoom));

                rect = GetAdvancedBorderRectangle(g, rect, zoom, border);

                switch (side)
                {
                case StiBorderSides.Top:
                    if (border.IsTopBorderSidePresent)
                    {
                        g.FillRectangle(brush, rect.Left, rect.Top, rect.Width, size);
                    }
                    break;

                case StiBorderSides.Bottom:
                    if (border.IsBottomBorderSidePresent)
                    {
                        g.FillRectangle(brush, rect.Left, rect.Bottom - size, rect.Width, size);
                    }
                    break;

                case StiBorderSides.Left:
                    if (border.IsLeftBorderSidePresent)
                    {
                        g.FillRectangle(brush, rect.Left, rect.Top, size, rect.Height);
                    }
                    break;

                case StiBorderSides.Right:
                    if (border.IsRightBorderSidePresent)
                    {
                        g.FillRectangle(brush, rect.Right - size, rect.Top, size, rect.Height);
                    }
                    break;
                }
            }
        }
        private RectangleF GetAdvancedBorderRectangle(Graphics g, RectangleF rect, float zoom, StiAdvancedBorder border)
        {
            if (border.IsTopBorderSidePresent)
            {
                var size = (int)(border.TopSide.Size * zoom * .5);
                rect.Y      -= size;
                rect.Height += size;
            }

            if (border.IsBottomBorderSidePresent)
            {
                var size = (int)(border.BottomSide.Size * zoom * .5);
                rect.Height = rect.Height + size;
            }

            if (border.IsLeftBorderSidePresent)
            {
                var size = (int)(border.LeftSide.Size * zoom * .5);
                rect.X     -= size;
                rect.Width += size;
            }

            if (border.IsRightBorderSidePresent)
            {
                var size = (int)(border.RightSide.Size * zoom * .5);
                rect.Width = rect.Width + size;
            }

            return(rect);
        }
        private void DrawDoubleInternal(Graphics g, RectangleF rect, float zoom, Color emptyColor, StiAdvancedBorder border)
        {
            using (var emptyPen = new Pen(emptyColor))
                using (var pen = new Pen(this.Color, 1))
                {
                    pen.DashStyle = StiPenUtils.GetPenStyle(style);
                    pen.StartCap  = LineCap.Square;
                    pen.EndCap    = LineCap.Square;

                    var rectIn  = rect;
                    var rectOut = rect;

                    rectIn.Inflate(-1, -1);
                    rectOut.Inflate(1, 1);

                    var left   = 0f;
                    var right  = 0f;
                    var top    = 0f;
                    var bottom = 0f;

                    switch (side)
                    {
                        #region Top
                    case StiBorderSides.Top:
                        if (border.IsTopBorderSidePresent)
                        {
                            left  = rectIn.Left;
                            right = rectIn.Right;

                            if (!border.IsLeftBorderSidePresent)
                            {
                                left = rectOut.Left;
                            }
                            if (!border.IsRightBorderSidePresent)
                            {
                                right = rectOut.Right;
                            }

                            g.DrawLine(emptyPen, rect.Left, rect.Top, rect.Right, rect.Top);
                            g.DrawLine(pen, left, rectIn.Top, right, rectIn.Top);
                            g.DrawLine(pen, rectOut.Left, rectOut.Top, rectOut.Right, rectOut.Top);
                        }
                        break;
                        #endregion

                        #region Bottom
                    case StiBorderSides.Bottom:
                        if (border.IsBottomBorderSidePresent)
                        {
                            left  = rectIn.Left;
                            right = rectIn.Right;

                            if (!border.IsLeftBorderSidePresent)
                            {
                                left = rectOut.Left;
                            }
                            if (!border.IsRightBorderSidePresent)
                            {
                                right = rectOut.Right;
                            }

                            g.DrawLine(emptyPen, rect.Left, rect.Bottom, rect.Right, rect.Bottom);
                            g.DrawLine(pen, left, rectIn.Bottom, right, rectIn.Bottom);
                            g.DrawLine(pen, rectOut.Left, rectOut.Bottom, rectOut.Right, rectOut.Bottom);
                        }
                        break;
                        #endregion

                        #region Left
                    case StiBorderSides.Left:
                        if (border.IsLeftBorderSidePresent)
                        {
                            top    = rectIn.Top;
                            bottom = rectIn.Bottom;

                            if (!border.IsTopBorderSidePresent)
                            {
                                top = rectOut.Top;
                            }
                            if (!border.IsBottomBorderSidePresent)
                            {
                                bottom = rectOut.Bottom;
                            }

                            g.DrawLine(emptyPen, rect.Left, rect.Top, rect.Left, rect.Bottom);
                            g.DrawLine(pen, rectIn.Left, top, rectIn.Left, bottom);
                            g.DrawLine(pen, rectOut.Left, rectOut.Top, rectOut.Left, rectOut.Bottom);
                        }
                        break;
                        #endregion

                        #region Right
                    case StiBorderSides.Right:
                        if (border.IsRightBorderSidePresent)
                        {
                            top    = rectIn.Top;
                            bottom = rectIn.Bottom;

                            if (!border.IsTopBorderSidePresent)
                            {
                                top = rectOut.Top;
                            }
                            if (!border.IsBottomBorderSidePresent)
                            {
                                bottom = rectOut.Bottom;
                            }

                            g.DrawLine(emptyPen, rect.Right, rect.Top, rect.Right, rect.Bottom);
                            g.DrawLine(pen, rectIn.Right, top, rectIn.Right, bottom);
                            g.DrawLine(pen, rectOut.Right, rectOut.Top, rectOut.Right, rectOut.Bottom);
                        }
                        break;
                        #endregion
                    }
                }
        }
 internal void Draw(Graphics g, RectangleF rect, float zoom, Color emptyColor, StiAdvancedBorder border)
 {
     if (this.Style == StiPenStyle.None)
     {
         return;
     }
     else if (this.Style == StiPenStyle.Double)
     {
         DrawDoubleInternal(g, rect, zoom, emptyColor, border);
     }
     else if (this.Style == StiPenStyle.Solid && Size >= 1)
     {
         DrawSolidInternal(g, rect, zoom, border);
     }
     else
     {
         DrawInternal(g, rect, zoom, border);
     }
 }
示例#6
0
 protected bool Equals(StiAdvancedBorder other)
 {
     return(base.Equals(other) && Equals(bottomSide, other.bottomSide) && Equals(topSide, other.topSide) && Equals(leftSide, other.leftSide) && Equals(rightSide, other.rightSide));
 }