public RequestImageAsync ( ImageBinder binder, |
||
binder | ImageBinder | |
imgRun | ||
requestFrom | object | |
return | void |
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); } }
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 }
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 }
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 }