VintaSoft Imaging .NET SDK v8.7
Vintasoft.Imaging.UI.VisualTools Namespace / CropSelectionTool Class
Members Example



In This Topic
    CropSelectionTool Class
    In This Topic
    A visual tool for cropping an image in image viewer.
    Object Model
    CropSelectionTool ClassIInteractionController InterfaceImageViewer ClassIInteractionController InterfaceRectangularObjectTransformer Class
    Syntax
    Remarks
    Rectangular region of image in image viewer can be cropped as follows:
    • place the mouse to the desired position
    • press the action button (VisualTool.ActionButton) and select the "crop" region by holding the action button
    • press the action button inside the "crop" region for cropping of image; press any mouse button outside of the "crop" region for canceling cropping of image

    If VisualTool.ActionButton is set to right mouse button, context menu during action can be disabled with the VisualTool.DisableContextMenu property.
    Example
    This example shows how to programmatically crop an image.
    Class CropSelectionToolExample
    	''' <summary>
    	''' Programmatically crops an image in image viewer.
    	''' </summary>
    	''' <param name="viewer">Image viewer.</param>
    	Public Sub ProgrammaticallyCropImageInViewer(viewer As Vintasoft.Imaging.UI.ImageViewer)
    		' create an instance of CropSelectionTool class
    		Dim cropSelectionTool As New Vintasoft.Imaging.UI.VisualTools.CropSelectionTool()
                
    		' set the tool as the current tool of the ImageViewer
    		viewer.VisualTool = cropSelectionTool
                
    		' set the region of interest on image
    		cropSelectionTool.Rectangle = New System.Drawing.Rectangle(50, 50, 250, 150)
    		' crop an image
    		cropSelectionTool.Crop()
    	End Sub
    End Class
    class CropSelectionToolExample
    {
        /// <summary>
        /// Programmatically crops an image in image viewer.
        /// </summary>
        /// <param name="viewer">Image viewer.</param>
        public void ProgrammaticallyCropImageInViewer(Vintasoft.Imaging.UI.ImageViewer viewer)
        {
            // create an instance of CropSelectionTool class
            Vintasoft.Imaging.UI.VisualTools.CropSelectionTool cropSelectionTool = 
                new Vintasoft.Imaging.UI.VisualTools.CropSelectionTool();
                
            // set the tool as the current tool of the ImageViewer
            viewer.VisualTool = cropSelectionTool;
            
            // set the region of interest on image
            cropSelectionTool.Rectangle = new System.Drawing.Rectangle(50, 50, 250, 150);
            // crop an image
            cropSelectionTool.Crop();
        }
    }
    Inheritance Hierarchy
    Requirements

    Target Platforms: Windows 10, Windows 8, Windows 7, Windows Vista, Windows XP, Windows Server 2012, Windows Server 2008, Windows Server 2003

    See Also