PaintEventArgs Property (original) (raw)

Summary

Native paint event arguments associated with this object

Syntax

public PaintEventArgs PaintEventArgs { get; set; } 

public: property System::Windows::Forms::PaintEventArgs^ PaintEventArgs { System::Windows::Forms::PaintEventArgs^ get() void set(System::Windows::Forms::PaintEventArgs^ value) }

Property Value

The native event arguments associated with this object. Default value is null.

Example

using Leadtools; using Leadtools.Controls; using Leadtools.Codecs; using Leadtools.Drawing; using Leadtools.ImageProcessing; using Leadtools.ImageProcessing.Color; public void ImageViewerPostRender_Example() { // Clear all the images already the viewer _imageViewer.Items.Clear(); // Use vertical view layout _imageViewer.ViewLayout = new ImageViewerVerticalViewLayout(); // Make sure the item size is larger than the image size (thumbnails mode) _imageViewer.ItemSize = LeadSize.Create(200, 200); _imageViewer.ItemPadding = new Padding(8, 8, 8, 20); _imageViewer.ImageBorderThickness = 1; // Add 4 items to the viewer using (var codecs = new RasterCodecs()) { for (var page = 1; page <= 4; page++) { var item = new ImageViewerItem(); var fileName = Path.Combine(LEAD_VARS.ImagesDir, string.Format("ocr{0}.tif", page)); // Create a thumbnail from the image using (var image = codecs.Load(fileName, page)) { item.Image = image.CreateThumbnail(180, 180, 24, RasterViewPerspective.TopLeft, RasterSizeFlags.Resample); } item.Text = string.Format("Item {0}", page - 1); _imageViewer.Items.Add(item); } } // Render on the view _imageViewer.PostRender += (sender, e) => { // Rendering the whole view var graphics = e.PaintEventArgs.Graphics; // Blue ellipse at fixed position. This will stay the same and will not scroll or zoom using (var brush = new SolidBrush(Color.FromArgb(128, Color.Blue))) graphics.FillEllipse(brush, new Rectangle(0, 0, 100, 100)); // Red ellipse at relative position, this will scroll and zoom with the view var gstate = graphics.Save(); var transform = _imageViewer.ViewTransform; using (var matrix = new System.Drawing.Drawing2D.Matrix( (float)transform.M11, (float)transform.M12, (float)transform.M21, (float)transform.M22, (float)transform.OffsetX, (float)transform.OffsetY)) graphics.MultiplyTransform(matrix); graphics.FillEllipse(Brushes.Red, new Rectangle(0, 0, 100, 100)); graphics.Restore(gstate); }; // Render on each item _imageViewer.PostRenderItem += (sender, e) => { var item = e.Item; var graphics = e.PaintEventArgs.Graphics; var gstate = graphics.Save(); // Get the bounding rectangle for the image var bounds = LeadRectD.Create(0, 0, item.Image.ImageWidth, item.Image.ImageHeight); // Add the image transform to the graphics var transform = _imageViewer.GetItemImageTransform(item); using (var matrix = new System.Drawing.Drawing2D.Matrix( (float)transform.M11, (float)transform.M12, (float)transform.M21, (float)transform.M22, (float)transform.OffsetX, (float)transform.OffsetY)) graphics.MultiplyTransform(matrix); // Red hilight on top of each item image using (var brush = new SolidBrush(Color.FromArgb(128, Color.Red))) graphics.FillRectangle(brush, (float)bounds.X, (float)bounds.Y, (float)bounds.Width, (float)bounds.Height); graphics.Restore(gstate); }; } static class LEAD_VARS { public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; }