DrawRectangle() public method

public DrawRectangle ( Color c, float x, float y, float w, float h ) : void
c Color
x float
y float
w float
h float
return void
Exemplo n.º 1
0
        internal void dbugPaintRuns(PaintVisitor p)
        {
            if (!PaintVisitor.dbugDrawWireFrame)
            {
                return;
            }
            //linebox
            float x1 = 0;
            float y1 = 0;
            float x2 = x1 + this.CachedLineContentWidth;
            float y2 = y1 + this.CacheLineHeight;

            //draw diagonal
            p.dbugDrawDiagonalBox(Color.Blue, x1, y1, x2, y2);
            //g.DrawRectangle(Pens.Blue,
            //    this.OwnerBox.LocationX,
            //    this.CachedLineTop,
            //    this.CachedLineContentWidth,
            //    this.CacheLineHeight);
            //foreach (var strip in _boxStrips.Values)
            //{
            //    var bound = strip.Bound;
            //    bound.Offset(offset);
            //    dbugDrawDiagnalBox(g, Pens.Green, bound.X, bound.Y, bound.Right, bound.Bottom);
            //}
            //return;
            foreach (CssRun w in _runs)
            {
                p.DrawRectangle(Color.DeepPink, w.Left, w.Top, w.Width, w.Height);
                //p.dbugDrawDiagonalBox(Color.DeepPink, w.Left, w.Top, w.Width, w.Height);
            }

            p.FillRectangle(Color.Red, 0, 0, 5, 5);
        }
Exemplo n.º 2
0
        public override void Paint(PaintVisitor p, RectangleF rect)
        {
            PaintBackground(p, rect, true, true);
            if (this.HasSomeVisibleBorder)
            {
                p.PaintBorders(this, rect, true, true);
            }
            //---------------------------------------------------------
            RectangleF r = _imgRun.Rectangle;

            r.Height -= ActualBorderTopWidth + ActualBorderBottomWidth + ActualPaddingTop + ActualPaddingBottom;
            r.Y      += ActualBorderTopWidth + ActualPaddingTop;
            r.X       = (float)Math.Floor(r.X);
            r.Y       = (float)Math.Floor(r.Y);
            bool tryLoadOnce = false;

EVAL_STATE:
            switch (_imgRun.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 = (Image)_imgRun.ImageBinder.Image) != null)
                {
                    if (_imgRun.ImageRectangle == Rectangle.Empty)
                    {
                        p.DrawImage(img,
                                    r.Left, r.Top,
                                    img.Width, img.Height);
                    }
                    else
                    {
                        p.DrawImage(img, _imgRun.ImageRectangle);
                    }
                }
                else
                {
                    RenderUtils.DrawImageLoadingIcon(p.InnerCanvas, r);
                    if (r.Width > 19 && r.Height > 19)
                    {
                        p.DrawRectangle(Color.LightGray, r.X, r.Y, r.Width, r.Height);
                    }
                }
            }
            break;

            case ImageBinderState.NoImage:
            {
            }
            break;

            case ImageBinderState.Error:
            {
                RenderUtils.DrawImageErrorIcon(p.InnerCanvas, r);
            }
            break;
            }

            //#if DEBUG
            //            p.FillRectangle(Color.Red, rect.X, rect.Y, rect.Width, rect.Height);
            //#endif
        }
Exemplo n.º 3
0
        public override void Paint(PaintVisitor p, RectangleF rect)
        {
            PaintBackground(p, rect, true, true);
            if (this.HasSomeVisibleBorder)
            {
                p.PaintBorders(this, rect, true, true);
            }
            //--------------------------------------------------------- 
            RectangleF r = _imgRun.Rectangle;
            r.Height -= ActualBorderTopWidth + ActualBorderBottomWidth + ActualPaddingTop + ActualPaddingBottom;
            r.Y += ActualBorderTopWidth + ActualPaddingTop;
            r.X = (float)Math.Floor(r.X);
            r.Y = (float)Math.Floor(r.Y);
            bool tryLoadOnce = false;
        EVAL_STATE:
            switch (_imgRun.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 = (Image)_imgRun.ImageBinder.Image) != null)
                        {
                            if (_imgRun.ImageRectangle == Rectangle.Empty)
                            {
                                p.DrawImage(img,
                                      r.Left, r.Top,
                                      img.Width, img.Height);
                            }
                            else
                            {
                                p.DrawImage(img, _imgRun.ImageRectangle);
                            }
                        }
                        else
                        {
                            RenderUtils.DrawImageLoadingIcon(p.InnerCanvas, r);
                            if (r.Width > 19 && r.Height > 19)
                            {
                                p.DrawRectangle(Color.LightGray, r.X, r.Y, r.Width, r.Height);
                            }
                        }
                    }
                    break;
                case ImageBinderState.NoImage:
                    {
                    }
                    break;
                case ImageBinderState.Error:
                    {
                        RenderUtils.DrawImageErrorIcon(p.InnerCanvas, r);
                    }
                    break;
            }

            //#if DEBUG
            //            p.FillRectangle(Color.Red, rect.X, rect.Y, rect.Width, rect.Height);
            //#endif
        }
Exemplo n.º 4
0
        internal void dbugPaintRuns(PaintVisitor p)
        {
            if (!PaintVisitor.dbugDrawWireFrame)
            {
                return;
            }
            //linebox  
            float x1 = 0;
            float y1 = 0;
            float x2 = x1 + this.CachedLineContentWidth;
            float y2 = y1 + this.CacheLineHeight;
            //draw diagonal  
            p.dbugDrawDiagonalBox(Color.Blue, x1, y1, x2, y2);
            //g.DrawRectangle(Pens.Blue,
            //    this.OwnerBox.LocationX,
            //    this.CachedLineTop,
            //    this.CachedLineContentWidth,
            //    this.CacheLineHeight);
            //foreach (var strip in this._boxStrips.Values)
            //{
            //    var bound = strip.Bound;
            //    bound.Offset(offset);
            //    dbugDrawDiagnalBox(g, Pens.Green, bound.X, bound.Y, bound.Right, bound.Bottom);
            //} 
            //return; 
            foreach (CssRun w in this._runs)
            {
                p.DrawRectangle(Color.DeepPink, w.Left, w.Top, w.Width, w.Height);
                //p.dbugDrawDiagonalBox(Color.DeepPink, w.Left, w.Top, w.Width, w.Height);
            }

            p.FillRectangle(Color.Red, 0, 0, 5, 5);
        }
Exemplo n.º 5
0
        public override void Paint(PaintVisitor p, RectangleF rect)
        {
            Color bgColorHint = p.CurrentSolidBackgroundColorHint;//save

            PaintBackground(p, rect, true, true);

            if (this.HasSomeVisibleBorder)
            {
                p.PaintBorders(this, rect, true, true);
            }
            //---------------------------------------------------------
            RectangleF r = _imgRun.Rectangle;

            r.Height  -= ActualBorderTopWidth + ActualBorderBottomWidth + ActualPaddingTop + ActualPaddingBottom;
            r.Location = new PointF((float)Math.Floor(r.Left), (float)Math.Floor(r.Top + ActualBorderTopWidth + ActualPaddingTop));

            bool tryLoadOnce = false;

EVAL_STATE:
            switch (_imgRun.ImageBinder.State)
            {
            case BinderState.Unload:
            {
                if (_tmpTransitionImgBinder != null)
                {
                    DrawWithTempTransitionImage(p, rect);
                }


                //async request image
                if (!tryLoadOnce)
                {
                    p.RequestImageAsync(_imgRun.ImageBinder, _imgRun, this);
                    //retry again
                    tryLoadOnce = true;
                    goto EVAL_STATE;
                }
            }
            break;

            case BinderState.Loading:
            {
                if (_tmpTransitionImgBinder != null)
                {
                    DrawWithTempTransitionImage(p, rect);
                }

                //RenderUtils.DrawImageLoadingIcon(g, r);
            }
            break;

            case BinderState.Loaded:
            {
                if (_tmpTransitionImgBinder != null)
                {
                    //*** clear tmp transition img after new image is loaded
                    _tmpTransitionImgBinder = null;
                }
                Image img;
                if ((img = (Image)_imgRun.ImageBinder.LocalImage) != null)         //assign and test
                {
                    if (this.VisualWidth != 0)
                    {
                        //TODO: review here

                        if (_imgRun.ImageRectangle == Rectangle.Empty)
                        {
                            p.DrawImage(img,
                                        r.Left, r.Top,
                                        this.VisualWidth, this.VisualHeight);
                        }
                        else
                        {
                            p.DrawImage(img, _imgRun.ImageRectangle);
                        }
                    }
                    else
                    {
                        if (_imgRun.ImageRectangle == Rectangle.Empty)
                        {
                            p.DrawImage(img,
                                        r.Left, r.Top,
                                        img.Width, img.Height);
                        }
                        else
                        {
                            p.DrawImage(img, _imgRun.ImageRectangle);
                        }
                    }
                }
                else
                {
                    RenderUtils.DrawImageLoadingIcon(p.InnerDrawBoard, r);
                    if (r.Width > 19 && r.Height > 19)
                    {
                        p.DrawRectangle(KnownColors.LightGray, r.Left, r.Top, r.Width, r.Height);
                    }
                }
            }
            break;

            case BinderState.Blank:
            {
            }
            break;

            case BinderState.Error:
            {
                RenderUtils.DrawImageErrorIcon(p.InnerDrawBoard, r);
            }
            break;
            }

            //#if DEBUG
            //            p.FillRectangle(Color.Red, rect.X, rect.Y, rect.Width, rect.Height);
            //#endif

            p.CurrentSolidBackgroundColorHint = bgColorHint;//restore
        }