VintaSoft Imaging .NET SDK 12.4: Documentation for .NET developer
Vintasoft.Imaging.UI.VisualTools.GraphicObjects Namespace / GraphicObjectTool Class
Members Object Syntax Example Hierarchy Requirements SeeAlso
In This Topic
    GraphicObjectTool Class
    In This Topic
    Visual tool for displaying static graphic objects in an image viewer.
    Object Model
    IObjectClipboard IInteractionController ImageViewer GraphicObjectTool
    Syntax
    Example

    This C#/VB.NET code shows how to draw two graphic object on viewer: first object - rectangle (red) that uses coordinate system of current image, second object - ellipse (green) that uses coordinate system of image viewer:

    
    ''' <summary>
    ''' Tests the graphics objects on image viewer.
    ''' </summary>
    ''' <param name="viewer">The viewer.</param>
    Public Shared Sub TestGraphicsObjects(viewer As Vintasoft.Imaging.UI.ImageViewer)
        ' objects location and size
        Dim objectBBox As New System.Drawing.RectangleF(40, 60, 80, 100)
    
        ' object fill brush
        Dim brush As System.Drawing.Brush = New System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(128, System.Drawing.Color.White))
    
        ' create Rectangular Graphic Object
        Dim rect As New Vintasoft.Imaging.UI.VisualTools.GraphicObjects.RectangularGraphicObject(objectBBox, New System.Drawing.Pen(System.Drawing.Color.Red, 10), brush)
        ' use current image coordinate space for rectange
        rect.PointTransform = New Vintasoft.Imaging.UI.VisualTools.PixelsToImageViewerPointFTransform()
    
        ' create Elliptical Graphic Object
        Dim ellipse As New Vintasoft.Imaging.UI.VisualTools.GraphicObjects.EllipticalGraphicObject(objectBBox, New System.Drawing.Pen(System.Drawing.Color.Green, 10), brush)
        ' use image viewer coordinate space for ellipse
        ellipse.PointTransform = Nothing
    
        ' create GraphicObjectTool
        Dim graphicObjects As New Vintasoft.Imaging.UI.VisualTools.GraphicObjects.GraphicObjectTool()
        graphicObjects.GraphicObjectCollection.Add(rect)
        graphicObjects.GraphicObjectCollection.Add(ellipse)
    
        ' set GraphicObjectTool as current tool of ImageViewer
        viewer.VisualTool = graphicObjects
    End Sub
    
    
    
    /// <summary>
    /// Tests the graphics objects on image viewer.
    /// </summary>
    /// <param name="viewer">The viewer.</param>
    public static void TestGraphicsObjects(Vintasoft.Imaging.UI.ImageViewer viewer)
    {
        // objects location and size
        System.Drawing.RectangleF objectBBox = new System.Drawing.RectangleF(40, 60, 80, 100);
    
        // object fill brush
        System.Drawing.Brush brush = new System.Drawing.SolidBrush(
            System.Drawing.Color.FromArgb(128, System.Drawing.Color.White));
    
        // create Rectangular Graphic Object
        Vintasoft.Imaging.UI.VisualTools.GraphicObjects.RectangularGraphicObject rect = 
            new Vintasoft.Imaging.UI.VisualTools.GraphicObjects.RectangularGraphicObject(
                objectBBox, 
                new System.Drawing.Pen(System.Drawing.Color.Red, 10), 
                brush);
        // use current image coordinate space for rectange
        rect.PointTransform = 
            new Vintasoft.Imaging.UI.VisualTools.PixelsToImageViewerPointFTransform();
    
        // create Elliptical Graphic Object
        Vintasoft.Imaging.UI.VisualTools.GraphicObjects.EllipticalGraphicObject ellipse = 
            new Vintasoft.Imaging.UI.VisualTools.GraphicObjects.EllipticalGraphicObject(
                objectBBox, 
                new System.Drawing.Pen(System.Drawing.Color.Green, 10), 
                brush);
        // use image viewer coordinate space for ellipse
        ellipse.PointTransform = null;
    
        // create GraphicObjectTool
        Vintasoft.Imaging.UI.VisualTools.GraphicObjects.GraphicObjectTool graphicObjects = 
            new Vintasoft.Imaging.UI.VisualTools.GraphicObjects.GraphicObjectTool();
        graphicObjects.GraphicObjectCollection.Add(rect);
        graphicObjects.GraphicObjectCollection.Add(ellipse);
    
        // set GraphicObjectTool as current tool of ImageViewer
        viewer.VisualTool = graphicObjects;
    }
    
    

    Inheritance Hierarchy

    System.Object
       Vintasoft.Imaging.UI.VisualTools.VisualTool
          Vintasoft.Imaging.UI.VisualTools.UserInteraction.UserInteractionVisualTool
             Vintasoft.Imaging.UI.VisualTools.GraphicObjects.GraphicObjectTool
                Vintasoft.Imaging.UI.VisualTools.TextOverlayTool

    Requirements

    Target Platforms: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    See Also