public override RectangleF MeasureContentBoundsF(ContentDrawArgs args) { var image = this.FoldedImage; if (image == null) { return Miscs.GetInternalContactRectF(args.ViewBoundsF, new SizeF(1, 1)); } else { return Miscs.GetInternalContactRectF(args.ViewBoundsF, image.Size); } }
public override void DrawContent(ContentDrawArgs args) { // base.DrawContent(args); using (var lockObj = _foldedImage.Lock()) { var image = _foldedImage.Data; if (image == null) return; var srcRect = new Rectangle(0, 0, image.Width, image.Height); var destRect = Miscs.GetInternalContactRect(args.ViewBoundsI, srcRect.Size); args.Graphics.DrawImage(image, destRect, srcRect, GraphicsUnit.Pixel); } }
/// <summary>サムネイルを描画する</summary> public virtual void DrawThumbnail(ContentDrawArgs args) { if (_thumbnailCacheEnabled) { if (_thumbnailImage == null) { PrepareThumbnail(); } var srcRect = _thumbnailSourceRect; RectangleF destRect = Miscs.GetExternalContactRectF(args.ViewBoundsF, srcRect.Size); args.Graphics.DrawImage(_thumbnailImage, destRect, srcRect, GraphicsUnit.Pixel); } else { DrawContent(args); } }
/// <summary>サムネイルのキャッシュを準備する</summary> public void PrepareThumbnail() { if (!ThumbnailCacheEnabled) return; this.InvalidateThumbnail(); // 描画 _thumbnailImage = new Bitmap(ThumbnailSize, ThumbnailSize); using (var g = Graphics.FromImage(_thumbnailImage)) { var drawArgs = new ContentDrawArgs(); drawArgs.Graphics = g; drawArgs.ViewBoundsF = new RectangleF(0, 0, _thumbnailImage.Width, _thumbnailImage.Height); _thumbnailSourceRect = MeasureContentBoundsF(drawArgs); DrawContent(drawArgs); } }
/// <summary>描画されるコンテンツの矩形領域を返す</summary> public virtual RectangleF MeasureContentBoundsF(ContentDrawArgs args) { return args.ViewBoundsF; }
/// <summary>コンテンツを描画する</summary> public virtual void DrawContent(ContentDrawArgs args) { args.Graphics.DrawString(this.Name, SystemFonts.DefaultFont, SystemBrushes.WindowText, args.ViewBoundsF); }