←Select platform

CanGroup Property

Summary

Gets a value indicating whether this AnnAutomation is in a state where objects can be grouped together.

Syntax

C#
VB
C++
public virtual bool CanGroup {get;}
Public Overridable ReadOnly Property CanGroup As Boolean
public: 
virtual property bool CanGroup { 
   bool get(); 
} 

Property Value

true if this AnnAutomation is in a state where objects can be grouped together; false otherwise.

Remarks

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 IsTemporary value is set to true.

For more information about grouping and ungrouping, refer to Grouping and Ungrouping WPF Annotation Objects.

Example

This example will add two objects into the automation and then group them together.

C#
VB
Silverlight C#
Silverlight VB
Imports Leadtools.Windows.Controls 
Imports Leadtools.Windows.Annotations 
 
Private Sub AnnAutomation_CanGroup(ByVal automation As AnnAutomation) 
   ShowStatus(automation) 
   ' first, add two objects to the automation 
   Dim rectObj As AnnRectangleObject = New AnnRectangleObject() 
   rectObj.Rect = New Rect(100, 100, 200, 200) 
 
   rectObj.Stroke = Colors.Blue 
   rectObj.StrokeThickness = 1.0 
   rectObj.Fill = Nothing 
   automation.Container.Children.Add(rectObj) 
 
   ShowStatus(automation) 
 
   Dim lineObj As AnnLineObject = New AnnLineObject() 
   lineObj.Start = New Point(100, 100) 
   lineObj.End = New Point(200, 200) 
 
   lineObj.Stroke = Colors.Red 
   lineObj.StrokeThickness = 1.0 
   automation.Container.Children.Add(lineObj) 
 
   ShowStatus(automation) 
 
   ' "select" both objects 
   automation.StartEditing(rectObj, False) 
   ShowStatus(automation) 
 
   automation.StartEditing(lineObj, True) 
   ShowStatus(automation) 
 
   ' make this group object a true group 
   If automation.CanGroup Then 
      automation.Group() 
      ShowStatus(automation) 
   End If 
 
   ' ungroup to again to the origina 2 objects 
   If automation.CanUngroup Then 
      automation.Ungroup() 
      ShowStatus(automation) 
   End If 
End Sub 
 
Private 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.Children.Count) 
   sb.Append(Environment.NewLine) 
 
   sb.Append("Object currently being edited: ") 
   If Not automation.CurrentEditObject Is Nothing Then 
      sb.Append(automation.CurrentEditObject.GetType().Name) 
      If TypeOf automation.CurrentEditObject Is AnnGroupObject Then 
         sb.Append(", Temporary: ") 
         Dim group As AnnGroupObject = DirectCast(automation.CurrentEditObject, AnnGroupObject) 
         sb.Append(group.IsTemporary) 
      End If 
   Else 
      sb.Append("None") 
   End If 
 
   sb.Append(Environment.NewLine) 
 
   sb.Append("CanGroup: ") 
   sb.Append(automation.CanGroup) 
   sb.Append(", CanUngroup: ") 
   sb.Append(automation.CanUngroup) 
 
   MessageBox.Show(sb.ToString()) 
End Sub 
using Leadtools.Windows.Controls; 
using Leadtools.Windows.Annotations; 
using Leadtools.Demos; 
using Leadtools.Help; 
 
private void AnnAutomation_CanGroup(AnnAutomation automation) 
{ 
   ShowStatus(automation); 
   // first, add two objects to the automation 
   AnnRectangleObject rectObj = new AnnRectangleObject(); 
   rectObj.Rect = new Rect(100, 100, 200, 200); 
 
   rectObj.Stroke = Colors.Blue; 
   rectObj.Fill = Colors.Transparent; 
   rectObj.StrokeThickness = 1.0; 
   automation.Container.Children.Add(rectObj); 
 
   ShowStatus(automation); 
 
   AnnLineObject lineObj = new AnnLineObject(); 
   lineObj.Start = new Point(100, 100); 
   lineObj.End = new Point(200, 200); 
 
   lineObj.Stroke = Colors.Red; 
   lineObj.StrokeThickness = 1.0; 
   automation.Container.Children.Add(lineObj); 
 
   ShowStatus(automation); 
 
   // "select" both objects 
   automation.StartEditing(rectObj, false); 
   ShowStatus(automation); 
 
   automation.StartEditing(lineObj, true); 
   ShowStatus(automation); 
 
   // make this group object a true group 
   if(automation.CanGroup) 
   { 
      automation.Group(); 
      ShowStatus(automation); 
   } 
 
   // ungroup to again to the origina 2 objects 
   if(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.Children.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.IsTemporary); 
      } 
   } 
   else 
      sb.Append("None"); 
 
   sb.Append(Environment.NewLine); 
 
   sb.Append("CanGroup: "); 
   sb.Append(automation.CanGroup); 
   sb.Append(", CanUngroup: "); 
   sb.Append(automation.CanUngroup); 
 
   MessageBox.Show(sb.ToString()); 
} 
using Leadtools.Windows.Controls; 
using Leadtools.Windows.Annotations; 
using Leadtools.Examples; 
using Leadtools.Silverlight.Demos; 
 
private void AnnAutomation_CanGroup(AnnAutomation automation) 
{ 
   ShowStatus(automation); 
   // first, add two objects to the automation 
   AnnRectangleObject rectObj = new AnnRectangleObject(); 
   rectObj.Rect = new Rect(100, 100, 200, 200); 
 
   rectObj.Stroke = Colors.Blue; 
   rectObj.Fill = Colors.Transparent; 
   rectObj.StrokeThickness = 1.0; 
   automation.Container.Children.Add(rectObj); 
 
   ShowStatus(automation); 
 
   AnnLineObject lineObj = new AnnLineObject(); 
   lineObj.Start = new Point(100, 100); 
   lineObj.End = new Point(200, 200); 
 
   lineObj.Stroke = Colors.Red; 
   lineObj.StrokeThickness = 1.0; 
   automation.Container.Children.Add(lineObj); 
 
   ShowStatus(automation); 
 
   // "select" both objects 
   automation.StartEditing(rectObj, false); 
   ShowStatus(automation); 
 
   automation.StartEditing(lineObj, true); 
   ShowStatus(automation); 
 
   // make this group object a true group 
   if(automation.CanGroup) 
   { 
      automation.Group(); 
      ShowStatus(automation); 
   } 
 
   // ungroup to again to the origina 2 objects 
   if(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.Children.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.IsTemporary); 
      } 
   } 
   else 
      sb.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 Leadtools.Windows.Controls 
Imports Leadtools.Windows.Annotations 
Imports Leadtools.Silverlight.Demos 
 
Private Sub AnnAutomation_CanGroup(ByVal automation As AnnAutomation) 
   ShowStatus(automation) 
   ' first, add two objects to the automation 
   Dim rectObj As AnnRectangleObject = New AnnRectangleObject() 
   rectObj.Rect = New Rect(100, 100, 200, 200) 
 
   rectObj.Stroke = Colors.Blue 
   rectObj.Fill = Colors.Transparent 
   rectObj.StrokeThickness = 1.0 
   automation.Container.Children.Add(rectObj) 
 
   ShowStatus(automation) 
 
   Dim lineObj As AnnLineObject = New AnnLineObject() 
   lineObj.Start = New Point(100, 100) 
   lineObj.End = New Point(200, 200) 
 
   lineObj.Stroke = Colors.Red 
   lineObj.StrokeThickness = 1.0 
   automation.Container.Children.Add(lineObj) 
 
   ShowStatus(automation) 
 
   ' "select" both objects 
   automation.StartEditing(rectObj, False) 
   ShowStatus(automation) 
 
   automation.StartEditing(lineObj, True) 
   ShowStatus(automation) 
 
   ' make this group object a true group 
   If automation.CanGroup Then 
      automation.Group() 
      ShowStatus(automation) 
   End If 
 
   ' ungroup to again to the origina 2 objects 
   If automation.CanUngroup Then 
      automation.Ungroup() 
      ShowStatus(automation) 
   End If 
End Sub 
 
Private 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.Children.Count) 
   sb.Append(Environment.NewLine) 
 
   sb.Append("Object currently being edited: ") 
   If Not automation.CurrentEditObject Is Nothing Then 
      sb.Append(automation.CurrentEditObject.GetType().Name) 
      If TypeOf automation.CurrentEditObject Is AnnGroupObject Then 
         sb.Append(", Temporary: ") 
         Dim group As AnnGroupObject = TryCast(automation.CurrentEditObject, AnnGroupObject) 
         sb.Append(group.IsTemporary) 
      End If 
   Else 
      sb.Append("None") 
   End If 
 
   sb.Append(Environment.NewLine) 
 
   sb.Append("CanGroup: ") 
   sb.Append(automation.CanGroup) 
   sb.Append(", CanUngroup: ") 
   sb.Append(automation.CanUngroup) 
 
   MessageBox.Show(sb.ToString()) 
End Sub 

Requirements

Target Platforms

Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
Leadtools.Windows.Annotations Assembly
Click or drag to resize