public override void Paint(PaintVisitor p)
 {
     if (fillColor.A > 0)
     {
         p.FillPath(myCachedPath, this.fillColor);
     }
     if (this.strokeColor.A > 0 && this.ActualStrokeWidth > 0)
     {
         p.DrawPath(myCachedPath, this.StrokeColor, this.ActualStrokeWidth);
     }
 }
示例#2
0
        public override void Paint(PaintVisitor p)
        {
            if (Vxs != null)
            {
                //1.
                //convert vxs to bitmap
                //then render with bitmap cache**
                //or
                //2. convert vxs to path data

                if (backimg == null)
                {
                    var svgPart = new SvgPart(SvgRenderVxKind.Path);
                    svgPart.FillColor = fillColor;

                    svgPart.SetVxsAsOriginal(Vxs);
                    var svgVx = new SvgRenderVx(new SvgPart[] { svgPart });

                    if (svgVx != null && !svgVx.HasBitmapSnapshot)
                    {
                        var bounds = svgVx.GetBounds();
                        //create
                        backimg = new ActualBitmap((int)bounds.Width, (int)bounds.Height);
                        AggRenderSurface renderSurface = new AggRenderSurface(backimg);
                        AggPainter       painter       = new AggPainter(renderSurface);
                        svgVx.Render(painter);
                        svgVx.SetBitmapSnapshot(backimg);
                        //***
                    }
                }


                if (backimg != null)
                {
                    p.InnerCanvas.DrawImage(backimg, new RectangleF(0, 0, backimg.Width, backimg.Height));
                    return;
                }
            }

            if (fillColor.A > 0)
            {
                p.FillPath(this.myCachedPath, this.fillColor);
            }
            if (this.strokeColor.A > 0)
            {
                p.DrawPath(this.myCachedPath, this.strokeColor, this.ActualStrokeWidth);
            }
        }
示例#3
0
        public override void Paint(PaintVisitor p)
        {
            //DrawBoard 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)
                        {
                            p.DrawImage(img, r);
                        }
                        else
                        {
                            //
                            p.DrawImage(img, _imgRun.ImageRectangle);
                        }
                    }
                    else
                    {
                        RenderUtils.DrawImageLoadingIcon(p, r);
                        if (r.Width > 19 && r.Height > 19)
                        {
                            p.DrawImage(img, _imgRun.ImageRectangle);
                            p.DrawRectangle(Color.LightGray, r.X, r.Y, r.Width, r.Height);
                        }
                    }
                }
                break;

                case ImageBinderState.NoImage:
                {
                }
                break;

                case ImageBinderState.Error:
                {
                    RenderUtils.DrawImageErrorIcon(p, r);
                }
                break;
                }
            }
            //---------------------------------------------------------
            if (this.strokeColor.A > 0 &&
                this.ActualStrokeWidth > 0)
            {
                p.DrawPath(_path, strokeColor, ActualStrokeWidth);
            }
        }