Gets a value indicating whether this AnnAutomation is in a state where objects can be grouped together.
public virtual bool CanGroup { get; } Public Overridable ReadOnly Property CanGroup As Boolean
public:virtual property bool CanGroup {bool get();}
true if this AnnAutomation is in a state where objects can be grouped together, otherwise; false.
The AnnAutomation is in a state where objects can be grouped together when 2 or more objects are in an edit state.
Call the Group method to group the objects currently being edited together.
Note, when you select one or more objects in this AnnAutomation through the user interface, an AnnGroupObject will be created and the selected objects are moved from the Container to this AnnGroupObject. This AnnGroupObject is a temporary group and will be ungrouped (by calling AnnGroupObject.Ungroup) and added back to the Container when the objects are not selected anymore (for example, by clicking somewhere in the container outside the group or by calling the user interface or by calling SelectNone). To check if the current editing object is the temporary group, first check if the CurrentEditObject is an AnnGroupObject, then check if the AnnGroupObject.Temporary value is set to true.
For more information about grouping and ungrouping, refer to Grouping and Ungrouping Annotation Objects (Deprecated).
This example will add two objects into the automation and then group them together.
using Leadtools;using Leadtools.Annotations;using Leadtools.WinForms;using Leadtools.Drawing;public void AnnAutomation_CanGroup(AnnAutomation automation){ShowStatus(automation);// first, add two objects to the automationAnnRectangleObject rectObj = new AnnRectangleObject();rectObj.Bounds = new AnnRectangle(100, 100, 100, 100, AnnUnit.Pixel);rectObj.Pen = new AnnPen(Color.Blue, new AnnLength(1, AnnUnit.Pixel));rectObj.Brush = null;automation.Container.Objects.Add(rectObj);automation.Viewer.Invalidate(rectObj.InvalidRectangle);ShowStatus(automation);AnnLineObject lineObj = new AnnLineObject();lineObj.StartPoint = new AnnPoint(100, 100, AnnUnit.Pixel);lineObj.EndPoint = new AnnPoint(200, 200, AnnUnit.Pixel);lineObj.Pen = new AnnPen(Color.Red, new AnnLength(1, AnnUnit.Pixel));automation.Container.Objects.Add(lineObj);automation.Viewer.Invalidate(lineObj.InvalidRectangle);ShowStatus(automation);// "select" both objectsautomation.StartEditing(rectObj, false);ShowStatus(automation);automation.StartEditing(lineObj, true);ShowStatus(automation);// make this group object a true groupif (automation.CanGroup){automation.Group();ShowStatus(automation);}// ungroup to again to the origina 2 objectsif (automation.CanUngroup){automation.Ungroup();ShowStatus(automation);}}private void ShowStatus(AnnAutomation automation){System.Text.StringBuilder sb = new System.Text.StringBuilder();sb.Append("Number of objects: ");sb.Append(automation.Container.Objects.Count);sb.Append(Environment.NewLine);sb.Append("Object currently being edited: ");if (automation.CurrentEditObject != null){sb.Append(automation.CurrentEditObject.GetType().Name);if (automation.CurrentEditObject is AnnGroupObject){sb.Append(", Temporary: ");AnnGroupObject group = automation.CurrentEditObject as AnnGroupObject;sb.Append(group.Temporary);}}elsesb.Append("None");sb.Append(Environment.NewLine);sb.Append("CanGroup: ");sb.Append(automation.CanGroup);sb.Append(", CanUngroup: ");sb.Append(automation.CanUngroup);MessageBox.Show(sb.ToString());}
Imports LeadtoolsImports Leadtools.AnnotationsImports Leadtools.WinFormsImports Leadtools.DrawingPublic Sub AnnAutomation_CanGroup(ByVal automation As AnnAutomation)ShowStatus(automation)' first, add two objects to the automationDim rectObj As AnnRectangleObject = New AnnRectangleObject()rectObj.Bounds = New AnnRectangle(100, 100, 100, 100, AnnUnit.Pixel)rectObj.Pen = New AnnPen(Color.Blue, New AnnLength(1, AnnUnit.Pixel))rectObj.Brush = Nothingautomation.Container.Objects.Add(rectObj)automation.Viewer.Invalidate(rectObj.InvalidRectangle)ShowStatus(automation)Dim lineObj As AnnLineObject = New AnnLineObject()lineObj.StartPoint = New AnnPoint(100, 100, AnnUnit.Pixel)lineObj.EndPoint = New AnnPoint(200, 200, AnnUnit.Pixel)lineObj.Pen = New AnnPen(Color.Red, New AnnLength(1, AnnUnit.Pixel))automation.Container.Objects.Add(lineObj)automation.Viewer.Invalidate(lineObj.InvalidRectangle)ShowStatus(automation)' "select" both objectsautomation.StartEditing(rectObj, False)ShowStatus(automation)automation.StartEditing(lineObj, True)ShowStatus(automation)' make this group object a true groupIf automation.CanGroup Thenautomation.Group()ShowStatus(automation)End If' ungroup to again to the origina 2 objectsIf automation.CanUngroup Thenautomation.Ungroup()ShowStatus(automation)End IfEnd SubPrivate Sub ShowStatus(ByVal automation As AnnAutomation)Dim sb As System.Text.StringBuilder = New System.Text.StringBuilder()sb.Append("Number of objects: ")sb.Append(automation.Container.Objects.Count)sb.Append(Environment.NewLine)sb.Append("Object currently being edited: ")If Not automation.CurrentEditObject Is Nothing Thensb.Append(automation.CurrentEditObject.GetType().Name)If TypeOf automation.CurrentEditObject Is AnnGroupObject Thensb.Append(", Temporary: ")Dim group As AnnGroupObject = CType(IIf(TypeOf automation.CurrentEditObject Is AnnGroupObject, automation.CurrentEditObject, Nothing), AnnGroupObject)sb.Append(group.Temporary)End IfElsesb.Append("None")End Ifsb.Append(Environment.NewLine)sb.Append("CanGroup: ")sb.Append(automation.CanGroup)sb.Append(", CanUngroup: ")sb.Append(automation.CanUngroup)MessageBox.Show(sb.ToString())End Sub
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
