DrawPath() 공개 메소드

public DrawPath ( GraphicsPath path, Color strokeColor, float strokeW ) : void
path PixelFarm.Drawing.GraphicsPath
strokeColor Color
strokeW float
리턴 void
        /// <summary>
        /// Draw specific border (top/bottom/left/right) with the box data (style/width/rounded).<br/>
        /// </summary>
        /// <param name="borderSide">desired border to draw</param>
        /// <param name="box">the box to draw its borders, contain the borders data</param>
        /// <param name="g">the device to draw into</param>
        /// <param name="rect">the rectangle the border is enclosing</param>
        /// <param name="isLineStart">Specifies if the border is for a starting line (no bevel on left)</param>
        /// <param name="isLineEnd">Specifies if the border is for an ending line (no bevel on right)</param>
        static void DrawBorder(CssSide borderSide, CssBox box,
                               PaintVisitor p, RectangleF rect, bool isLineStart, bool isLineEnd)
        {
            float          actualBorderWidth;
            Color          borderColor;
            CssBorderStyle style;

            GetBorderBorderDrawingInfo(box, borderSide, out style, out borderColor, out actualBorderWidth);
            DrawBoard g = p.InnerDrawBoard;

            if (box.HasSomeRoundCorner)
            {
                GraphicsPath borderPath = GetRoundedBorderPath(p, borderSide, box, rect);
                if (borderPath != null)
                {
                    // rounded border need special path
                    var smooth = g.SmoothingMode;
                    if (!p.AvoidGeometryAntialias && box.HasSomeRoundCorner)
                    {
                        g.SmoothingMode = SmoothingMode.AntiAlias;
                    }


                    p.DrawPath(borderPath, borderColor, actualBorderWidth);
                    //using (var pen = GetPen(p.Platform, style, borderColor, actualBorderWidth))
                    //using (borderPath)
                    //{
                    //    g.DrawPath(pen, borderPath);
                    //}
                    g.SmoothingMode = smooth;
                }
            }
            else
            {
                // non rounded border
                switch (style)
                {
                case CssBorderStyle.Inset:
                case CssBorderStyle.Outset:
                {
                    // inset/outset border needs special rectangle
                    PointF[] borderPnts = new PointF[4];
                    SetInOutsetRectanglePoints(borderSide, box, rect, isLineStart, isLineEnd, borderPnts);
                    g.FillPolygon(borderColor, borderPnts);
                }
                break;

                default:
                {
                    // solid/dotted/dashed border draw as simple line


                    //using (var pen = GetPen(p.Platform, style, borderColor, actualBorderWidth))
                    //{
                    var prevColor = g.StrokeColor;
                    g.StrokeColor = borderColor;
                    float prevStrokeW = g.StrokeWidth;
                    g.StrokeWidth = actualBorderWidth;


                    //s_simpleRectBorderBuilder.SetBorderWidth(
                    //     box.ActualBorderLeftWidth,
                    //     box.ActualBorderTopWidth,
                    //     box.ActualBorderRightWidth,
                    //     box.ActualBorderBottomWidth
                    //    );


                    //s_simpleRectBorderBuilder.BuildOverRefBounds(
                    //    rect.Left,
                    //    rect.Top,
                    //    rect.Width,
                    //    rect.Height,
                    //    s_reusableBorderCoords);

                    switch (borderSide)
                    {
                    case CssSide.Top:
                        g.DrawLine((float)Math.Ceiling(rect.Left), rect.Top + box.ActualBorderTopWidth / 2, rect.Right - 1, rect.Top + box.ActualBorderTopWidth / 2);
                        break;

                    case CssSide.Left:
                        g.DrawLine(rect.Left + box.ActualBorderLeftWidth / 2, (float)Math.Ceiling(rect.Top), rect.Left + box.ActualBorderLeftWidth / 2, (float)Math.Floor(rect.Bottom));
                        break;

                    case CssSide.Bottom:
                        g.DrawLine((float)Math.Ceiling(rect.Left), rect.Bottom - box.ActualBorderBottomWidth / 2, rect.Right - 1, rect.Bottom - box.ActualBorderBottomWidth / 2);
                        break;

                    case CssSide.Right:
                        g.DrawLine(rect.Right - box.ActualBorderRightWidth / 2, (float)Math.Ceiling(rect.Top), rect.Right - box.ActualBorderRightWidth / 2, (float)Math.Floor(rect.Bottom));
                        break;
                    }

                    g.StrokeWidth = prevStrokeW;
                    g.StrokeColor = prevColor;
                }
                break;
                }
            }
        }
예제 #2
0
        public override void Paint(PaintVisitor p)
        {
            Canvas g = p.InnerCanvas;
            if (fillColor.A > 0)
            {
                p.FillPath(_path, this.fillColor);
            }
            //---------------------------------------------------------  
            if (this.ImageBinder != null)
            {
                //---------------------------------------------------------  
                //Because we need external image resource , so ...
                //use render technique like CssBoxImage ****
                //---------------------------------------------------------  

                RectangleF r = new RectangleF(this.ActualX, this.ActualY, this.ActualWidth, this.ActualHeight);
                bool tryLoadOnce = false;
            EVAL_STATE:
                switch (this.ImageBinder.State)
                {
                    case ImageBinderState.Unload:
                        {
                            //async request image
                            if (!tryLoadOnce)
                            {
                                p.RequestImageAsync(_imgRun.ImageBinder, this._imgRun, this);
                                //retry again
                                tryLoadOnce = true;
                                goto EVAL_STATE;
                            }
                        }
                        break;
                    case ImageBinderState.Loading:
                        {
                            //RenderUtils.DrawImageLoadingIcon(g, r);
                        }
                        break;
                    case ImageBinderState.Loaded:
                        {
                            Image img;
                            if ((img = _imgRun.ImageBinder.Image) != null)
                            {
                                if (_imgRun.ImageRectangle == Rectangle.Empty)
                                {
                                    g.DrawImage(img, r);
                                }
                                else
                                {
                                    //
                                    g.DrawImage(img, _imgRun.ImageRectangle);
                                }
                            }
                            else
                            {
                                RenderUtils.DrawImageLoadingIcon(g, r);
                                if (r.Width > 19 && r.Height > 19)
                                {
                                    g.DrawRectangle(Color.LightGray, r.X, r.Y, r.Width, r.Height);
                                }
                            }
                        }
                        break;
                    case ImageBinderState.NoImage:
                        {
                        }
                        break;
                    case ImageBinderState.Error:
                        {
                            RenderUtils.DrawImageErrorIcon(g, r);
                        }
                        break;
                }
            }
            //--------------------------------------------------------- 
            if (this.strokeColor.A > 0
                && this.ActualStrokeWidth > 0)
            {
                p.DrawPath(_path, strokeColor, ActualStrokeWidth);
            }
        }
예제 #3
0
        /// <summary>
        /// Draw specific border (top/bottom/left/right) with the box data (style/width/rounded).<br/>
        /// </summary>
        /// <param name="borderSide">desired border to draw</param>
        /// <param name="box">the box to draw its borders, contain the borders data</param>
        /// <param name="g">the device to draw into</param>
        /// <param name="rect">the rectangle the border is enclosing</param>
        /// <param name="isLineStart">Specifies if the border is for a starting line (no bevel on left)</param>
        /// <param name="isLineEnd">Specifies if the border is for an ending line (no bevel on right)</param>
        static void DrawBorder(CssSide borderSide, CssBox box,
            PaintVisitor p, RectangleF rect, bool isLineStart, bool isLineEnd)
        {
            float actualBorderWidth;
            Color borderColor;
            CssBorderStyle style;
            GetBorderBorderDrawingInfo(box, borderSide, out style, out borderColor, out actualBorderWidth);
            Canvas g = p.InnerCanvas;
            if (box.HasSomeRoundCorner)
            {
                GraphicsPath borderPath = GetRoundedBorderPath(p, borderSide, box, rect);
                if (borderPath != null)
                {
                    // rounded border need special path 
                    var smooth = g.SmoothingMode;
                    if (!p.AvoidGeometryAntialias && box.HasSomeRoundCorner)
                    {
                        g.SmoothingMode = SmoothingMode.AntiAlias;
                    }


                    p.DrawPath(borderPath, borderColor, actualBorderWidth);
                    //using (var pen = GetPen(p.Platform, style, borderColor, actualBorderWidth))
                    //using (borderPath)
                    //{
                    //    g.DrawPath(pen, borderPath);
                    //}
                    g.SmoothingMode = smooth;
                }
            }
            else
            {
                // non rounded border 
                switch (style)
                {
                    case CssBorderStyle.Inset:
                    case CssBorderStyle.Outset:
                        {
                            // inset/outset border needs special rectangle
                            PointF[] borderPnts = new PointF[4];
                            SetInOutsetRectanglePoints(borderSide, box, rect, isLineStart, isLineEnd, borderPnts);
                            g.FillPolygon(borderColor, borderPnts);
                        }
                        break;
                    default:
                        {
                            // solid/dotted/dashed border draw as simple line


                            //using (var pen = GetPen(p.Platform, style, borderColor, actualBorderWidth))
                            //{
                            var prevColor = g.StrokeColor;
                            g.StrokeColor = borderColor;
                            float prevStrokeW = g.StrokeWidth;
                            g.StrokeWidth = actualBorderWidth;
                            switch (borderSide)
                            {
                                case CssSide.Top:
                                    g.DrawLine((float)Math.Ceiling(rect.Left), rect.Top + box.ActualBorderTopWidth / 2, rect.Right - 1, rect.Top + box.ActualBorderTopWidth / 2);
                                    break;
                                case CssSide.Left:
                                    g.DrawLine(rect.Left + box.ActualBorderLeftWidth / 2, (float)Math.Ceiling(rect.Top), rect.Left + box.ActualBorderLeftWidth / 2, (float)Math.Floor(rect.Bottom));
                                    break;
                                case CssSide.Bottom:
                                    g.DrawLine((float)Math.Ceiling(rect.Left), rect.Bottom - box.ActualBorderBottomWidth / 2, rect.Right - 1, rect.Bottom - box.ActualBorderBottomWidth / 2);
                                    break;
                                case CssSide.Right:
                                    g.DrawLine(rect.Right - box.ActualBorderRightWidth / 2, (float)Math.Ceiling(rect.Top), rect.Right - box.ActualBorderRightWidth / 2, (float)Math.Floor(rect.Bottom));
                                    break;
                            }

                            g.StrokeWidth = prevStrokeW;
                            g.StrokeColor = prevColor;
                        }
                        break;
                }
            }
        }
예제 #4
0
 public override void Paint(PaintVisitor p)
 {
     if (fillColor.A > 0)
     {
         p.FillPath(this.myCachedPath, this.fillColor);
     }
     if (this.strokeColor.A > 0)
     {
         p.DrawPath(this.myCachedPath, this.strokeColor, this.ActualStrokeWidth);
     }
 }
예제 #5
0
 public override void Paint(PaintVisitor p)
 {
     if (this.strokeColor.A > 0
         && this.ActualStrokeWidth > 0)
     {
         p.DrawPath(myCachedPath, this.strokeColor, this.ActualStrokeWidth);
     }
 }