void _rasterImageList_PostRender(object sender, Leadtools.Controls.ImageViewerRenderEventArgs e) { for (int i = 0; i < _rasterImageList.Items.Count; i++) { ImageViewerItem item = _rasterImageList.Items[i]; LeadRectD itemLeadRect = _rasterImageList.GetItemBounds(item, ImageViewerItemPart.Item); Rectangle itemRect = new Rectangle((int)itemLeadRect.X, (int)itemLeadRect.Y, (int)itemLeadRect.Width, (int)itemLeadRect.Height); LeadSize itemImageSize = _rasterImageList.GetItemImageSize(item, false); LeadRect imageRect = new LeadRect( itemRect.Left + (itemRect.Width - itemImageSize.Width) / 2, itemRect.Top + (itemRect.Height - itemImageSize.Height) / 2, itemImageSize.Width, itemImageSize.Height); itemLeadRect = ImageViewer.GetDestinationRectangle(item.Image.ImageWidth, item.Image.ImageHeight, imageRect, ControlSizeMode.None, ControlAlignment.Near, ControlAlignment.Near).ToLeadRectD(); var destRect = LeadRectD.Create(itemLeadRect.X, itemLeadRect.Y, itemLeadRect.Width * 720.0 / 96.0, itemLeadRect.Height * 720.0 / 96.0); destRect.X = 0.0; destRect.Y = 0.0; //Get the graphic object from the item's image to draw (burn) annotations on it. Leadtools.Drawing.RasterImageGdiPlusGraphicsContainer GdiPlusGraphicsContainer = new RasterImageGdiPlusGraphicsContainer(item.Image); Graphics g = GdiPlusGraphicsContainer.Graphics; // Use anti-aliasing g.SmoothingMode = SmoothingMode.AntiAlias; // Now draw the annotation s on this rectangle if (_automationManager != null && _automation.Containers.Count > 0 && _automation.Containers.Count > i) { AnnContainer container = _automation.Containers[i]; //Clear the old painting g.Clear(Color.White); //Burn the current annotations to the image list item if (container != null) { AnnWinFormsRenderingEngine engine = new AnnWinFormsRenderingEngine(); engine.Resources = _automationManager.Resources; // Save its visible state and set it to true (it is false if viewer is in single mode) bool containerIsVisible = container.IsVisible; container.IsVisible = true; engine.Attach(container, g); engine.BurnToRectWithDpi(destRect, 96, 96, 96, 96); engine.Detach(); if (container.IsVisible != containerIsVisible) { container.IsVisible = containerIsVisible; } } } } }
private void RenderContainer(PaintEventArgs e, AnnWinFormsRenderingEngine engine, AnnContainer container) { // Attach to the current container and graphics. Graphics graphics = e.Graphics; Rectangle clipRectangle = e.ClipRectangle; try { engine.Attach(container, graphics); // Render the annotatirons LeadRectD rc = LeadRectD.Create(clipRectangle.X, clipRectangle.Y, clipRectangle.Width, clipRectangle.Height); rc = container.Mapper.RectToContainerCoordinates(rc); engine.Render(rc, true); } finally { engine.Detach(); } }
private static void RenderContainer(PaintEventArgs e, AnnWinFormsRenderingEngine engine, AnnContainer container, bool runMode) { // Attach to the current container and graphics. var context = e.Graphics; var clipRectangle = e.ClipRectangle; engine.Attach(container, context); try { // Render the annotatirons var rc = LeadRectD.Create(clipRectangle.X, clipRectangle.Y, clipRectangle.Width, clipRectangle.Height); rc = container.Mapper.RectToContainerCoordinates(rc); engine.Render(rc, runMode); } finally { engine.Detach(); } }