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



In This Topic
    CustomSelectionTool Class
    In This Topic
    Visual tool that allows to select the custom image region in an image viewer.
    Object Model
    CustomSelectionTool ClassIInteractionController InterfaceImageViewer ClassSelectionRegionBase Class
    Syntax
    Example
    This example shows how to execute image processing command on the custom image region.
    Class CustomSelectionToolProcessingExample
    	Public Sub RunExample(viewer As Vintasoft.Imaging.UI.ImageViewer)
    		' create the CustomSelectionTool object
    		Dim selectionTool As New Vintasoft.Imaging.UI.VisualTools.CustomSelectionTool()
    		' set the created tool as the current tool of the ImageViewer
    		viewer.VisualTool = selectionTool
    		' set current selection to curvilinear selection
    		selectionTool.Selection = New Vintasoft.Imaging.UI.VisualTools.CurvilinearSelectionRegion(New System.Drawing.PointF() {New System.Drawing.PointF(100, 100), New System.Drawing.PointF(100, 200), New System.Drawing.PointF(200, 200), New System.Drawing.PointF(200, 100)})
                
    		' execute blur command using selection
    		ExecuteProcessing(viewer.Image, selectionTool.Selection, New Vintasoft.Imaging.ImageProcessing.Effects.MotionBlurCommand())
                
    		' create point-based object transformer
    		Dim transformer As New Vintasoft.Imaging.UI.VisualTools.UserInteraction.PointBasedObjectPointTransformer(selectionTool.Selection)
    		' set point-based object transformer as transformer of current selection 
    		selectionTool.Selection.TransformInteractionController = transformer
                
    		' insert point to selection
    		transformer.InsertPoint(New System.Drawing.PointF(150, 150), 0)
                
    		' translate selection points
    		transformer.TranslatePoints(100, 100)
                
    		' execute invert command using selection
    		ExecuteProcessing(viewer.Image, selectionTool.Selection, New Vintasoft.Imaging.ImageProcessing.Color.InvertCommand())
                
    		' clear selection
    		selectionTool.Selection = Nothing
    	End Sub
                
    	' Executes image processing command using selection region.
    	Private Sub ExecuteProcessing(image As Vintasoft.Imaging.VintasoftImage, selectionRegion As Vintasoft.Imaging.UI.VisualTools.SelectionRegionBase, command As Vintasoft.Imaging.ImageProcessing.ProcessingCommandBase)
    		Using path As System.Drawing.Drawing2D.GraphicsPath = selectionRegion.GetAsGraphicsPath()
    			Dim processPath As New Vintasoft.Imaging.ImageProcessing.ProcessPathCommand(command, path)
    			processPath.ExecuteInPlace(image)
    		End Using
    	End Sub
                
    End Class
    class CustomSelectionToolProcessingExample
    {
        public void RunExample(Vintasoft.Imaging.UI.ImageViewer viewer)
        {
            // create the CustomSelectionTool object
            Vintasoft.Imaging.UI.VisualTools.CustomSelectionTool selectionTool = 
                new Vintasoft.Imaging.UI.VisualTools.CustomSelectionTool();
            // set the created tool as the current tool of the ImageViewer
            viewer.VisualTool = selectionTool;
            // set current selection to curvilinear selection
            selectionTool.Selection = new Vintasoft.Imaging.UI.VisualTools.CurvilinearSelectionRegion(
                new System.Drawing.PointF[] { 
                new System.Drawing.PointF(100, 100), new System.Drawing.PointF(100, 200),
                new System.Drawing.PointF(200, 200), new System.Drawing.PointF(200, 100) });
                
            // execute blur command using selection
            ExecuteProcessing(viewer.Image, selectionTool.Selection, 
                new Vintasoft.Imaging.ImageProcessing.Effects.MotionBlurCommand());
                
            // create point-based object transformer
            Vintasoft.Imaging.UI.VisualTools.UserInteraction.PointBasedObjectPointTransformer transformer =
                new Vintasoft.Imaging.UI.VisualTools.UserInteraction.PointBasedObjectPointTransformer(
                    selectionTool.Selection);
            // set point-based object transformer as transformer of current selection 
            selectionTool.Selection.TransformInteractionController = transformer;
                
            // insert point to selection
            transformer.InsertPoint(new System.Drawing.PointF(150, 150), 0);
                
            // translate selection points
            transformer.TranslatePoints(100, 100);
                
            // execute invert command using selection
            ExecuteProcessing(viewer.Image, selectionTool.Selection, 
                new Vintasoft.Imaging.ImageProcessing.Color.InvertCommand());
                
            // clear selection
            selectionTool.Selection = null;
        }
                
        // Executes image processing command using selection region.
        private void ExecuteProcessing(
            Vintasoft.Imaging.VintasoftImage image,
            Vintasoft.Imaging.UI.VisualTools.SelectionRegionBase selectionRegion,
            Vintasoft.Imaging.ImageProcessing.ProcessingCommandBase command)
        {
            using (System.Drawing.Drawing2D.GraphicsPath path = selectionRegion.GetAsGraphicsPath())
            {
                Vintasoft.Imaging.ImageProcessing.ProcessPathCommand processPath = 
                    new Vintasoft.Imaging.ImageProcessing.ProcessPathCommand(command, path);
                processPath.ExecuteInPlace(image);
            }
        }
                
    }
    Inheritance Hierarchy

    System.Object
       Vintasoft.Imaging.UI.VisualTools.VisualTool
          Vintasoft.Imaging.UI.VisualTools.UserInteraction.UserInteractionVisualTool
             Vintasoft.Imaging.UI.VisualTools.CustomSelectionTool

    Requirements

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

    See Also