예제 #1
0
        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;
                        }
                    }
                }
            }
        }
예제 #2
0
        void _rasterImageViewer_PostRender(object sender, Leadtools.Controls.ImageViewerRenderEventArgs e)
        {
            PDFDocumentPage page = _document.Pages[_currentPageNumber - 1];

            if (_selectedText != null && _selectedText[_currentPageNumber] != null)
            {
                HighlightSelectedWords(e.PaintEventArgs.Graphics);
            }

            if (HighlightObjects && _document != null)
            {
                HighlightObjectsData data = new HighlightObjectsData();
                data.TextBrush         = new SolidBrush(Color.FromArgb(128, Color.Yellow));
                data.RetangleBrush     = new SolidBrush(Color.FromArgb(128, Color.Black));
                data.ImageBrush        = new SolidBrush(Color.FromArgb(128, Color.Red));
                data.HyperlinkBrush    = new SolidBrush(Color.FromArgb(128, Color.Blue));
                data.InternalLinkBrush = new SolidBrush(Color.FromArgb(128, Color.Green));

                DrawHighlightObjects(e.PaintEventArgs.Graphics, data, page);
                DrawLegends(e.PaintEventArgs.Graphics, data);

                data.TextBrush.Dispose();
                data.RetangleBrush.Dispose();
                data.ImageBrush.Dispose();
                data.HyperlinkBrush.Dispose();
                data.InternalLinkBrush.Dispose();
            }

            if (_highlightSelectedImageObject && !HighlightObjects)
            {
                using (Brush imageBrush = new SolidBrush(Color.FromArgb(128, Color.Red)))
                {
                    DrawHighlightImageObject(e.PaintEventArgs.Graphics, imageBrush, page);
                }
            }
        }