Options for annotation snap to grid behavior in annotation automation design mode.
public class AnnSnapToGridOptions
Public Class AnnSnapToGridOptions
public ref class AnnSnapToGridOptions
The AnnSnapToGridOptions class is used with the AnnContainer.SnapToGridOptions property to get or set the annotation snap to grid behavior in annotation automation design mode. You can then enable or disable snapping to grid by using the AnnContainer.EnableSnapToGrid property.
The snap-to-grid feature is used in annotation automation design mode to allow the user to precisely draw, locate, and align annotation objects. When snap-to-grid is enabled (AnnContainer.EnableSnapToGrid is set to true), a grid pattern consisting of dots and lines is overlayed on the image beging annotated. When creating annotations in design mode, each point snaps to the nearest grid point. This beavior holds for creating any annotation object except the freehand annotation. When creating a freehand annotation, the individual points do not snap to the nearest grid point because this would adversely affect the behavior of the freehand. The snap-to-grid feature affects the moving of all annotations object types in design mode, in that the bounding box of the annotation object snaps to the nearest grid point.
The grid that is overlayed can be customized by color (GridColor), grid spacing (GridLength), and line frequency (LineSpacing). For example, to display a red grid that has a dot pattern every 20 pixels, and solid lines every 100 pixels, you would set:
GridColor = Color.Red
LineSpacing = 20
LineStyle = DashStyle.Solid
The lines of the grid can be removed completely by setting GridColor to be Color.Transparent. The lines of the grid can be drawn in any style (LineStyle). The grid itself can be hidden by setting ShowGrid to false so that the snap-to-grid feature is still on without the grid being overlaid on the image. Conversely, the grid can be displayed by setting ShowGrid to true while disabling the snap-to-grid-behavior by setting AnnContainer.EnableSnapToGrid to true.
Setting AutoChangeGridLength to true affects the grid density when zooming. The effect is that when zooming to 200, the density of the dot pattern doubles. When zooming to 400, the density doubles again The density doubles at 200, 400, 800, 1600 and so on as long as it is meaningful to double the density. In other words, if doubling the dot density would create a dot where no pixel exists when viewing at 100, then the dot density will not change. The following examples illustrate this.
The dot density doubles at 200 because 10 is evenly divisible by 2.
The dot density does not double again at 400 because 10 do not evenly divide 4.
The dot density doubles at 200, and doubles again at 400.
The dot density does not double again at 800 because 20 does not divide 8 evenly.
The dot density doubles at 200, and doubles again at 400.
The dot density never changes because 21 is a prime number.
The snap-to-grid behavior can be turned on our off in annotation automation mode by right-clicking on a part of the image that does not contain an annotation, and selecting the Snap To Grid option from the context menu. The snap-to-grid behavior can be customized in annotation automation mode by:
Right-clicking on a part of the image that does not contain an annotation
Selecting Default Properties
Clicking on the "Snap to Grid..." menu option
This example:
Gets the current state of the snap-to-grid
Changes the snap to grid to grid size of 10, lines every ten row of dots, solid red lines
Enables the snap to grid
Imports Leadtools.Windows.Controls
Imports Leadtools.Windows.Annotations
Private Shared Sub SnapToGridExample(ByVal automation As AnnAutomation)
' First use default
automation.Container.EnableSnapToGrid = True
automation.EnableSnapToGrid = True
DisplaySnapToGrid(automation, "Original settings")
' Change snap-to-grid to grid size of 10, lines every ten row of dots, solid red lines, and enable it
Dim options As New AnnSnapToGridOptions()
options.AutoChangeGridLength = True
options.EnableSnap = True
options.ShowGrid = True
options.GridColor = Colors.Red
options.GridLength = 10
options.LineSpacing = 10
options.LineStyle = DashStyles.Solid
automation.Container.SnapToGridOptions = options
DisplaySnapToGrid(automation, "New settings")
End Sub
Private Shared Sub DisplaySnapToGrid(ByVal automation As AnnAutomation, ByVal title As String)
Dim options As AnnSnapToGridOptions = automation.Container.SnapToGridOptions
Dim sb As New StringBuilder()
sb.AppendLine("Grid color: " + options.GridColor.ToString())
sb.AppendLine("Grid length: " + options.GridLength.ToString())
sb.AppendLine("Line spacing: " + options.LineSpacing.ToString())
sb.AppendLine("Line style: " + options.LineStyle.ToString())
sb.AppendLine("Enable snap: " + options.EnableSnap.ToString())
sb.AppendLine("Show grid: " + options.ShowGrid.ToString())
sb.AppendLine("Auto-change grid length: " + options.AutoChangeGridLength.ToString())
MessageBox.Show(sb.ToString(), title)
End Sub
using Leadtools.Windows.Controls;
using Leadtools.Windows.Annotations;
using Leadtools.Demos;
using Leadtools.Help;
private static void SnapToGridExample(AnnAutomation automation)
{
// First use default
automation.Container.EnableSnapToGrid = true;
automation.EnableSnapToGrid = true;
DisplaySnapToGrid(automation, "Original settings");
// Change snap-to-grid to grid size of 10, lines every ten row of dots, solid red lines, and enable it
AnnSnapToGridOptions options = new AnnSnapToGridOptions();
options.AutoChangeGridLength = true;
options.EnableSnap = true;
options.ShowGrid = true;
options.GridColor = Colors.Red;
options.GridLength = 10;
options.LineSpacing = 10;
options.LineStyle = DashStyles.Solid;
automation.Container.SnapToGridOptions = options;
DisplaySnapToGrid(automation, "New settings");
}
private static void DisplaySnapToGrid(AnnAutomation automation, string title)
{
AnnSnapToGridOptions options = automation.Container.SnapToGridOptions;
StringBuilder sb = new StringBuilder();
sb.AppendLine("Grid color: " + options.GridColor);
sb.AppendLine("Grid length: " + options.GridLength);
sb.AppendLine("Line spacing: " + options.LineSpacing);
sb.AppendLine("Line style: " + options.LineStyle);
sb.AppendLine("Enable snap: " + options.EnableSnap);
sb.AppendLine("Show grid: " + options.ShowGrid);
sb.AppendLine("Auto-change grid length: " + options.AutoChangeGridLength);
MessageBox.Show(sb.ToString(), title);
}
Products |
Support |
Feedback: AnnSnapToGridOptions Class - Leadtools.Windows.Annotations |
Introduction |
Help Version 19.0.2017.3.22
|
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.