Gets a value indicating whether this
AnnAutomation is in a state where objects can be grouped together.
Syntax
Visual Basic (Declaration) | |
---|
Public Overridable ReadOnly Property CanGroup As Boolean |
Visual Basic (Usage) | Copy Code |
---|
Dim instance As AnnAutomation
Dim value As Boolean
value = instance.CanGroup
|
C# | |
---|
public virtual bool CanGroup {get;} |
C++/CLI | |
---|
public:
virtual property bool CanGroup {
bool get();
} |
XAML Syntax | |
---|
You cannot use this property in XAML. |
XAML Syntax | |
---|
You cannot use this property in XAML. |
Return Value
true if this
AnnAutomation is in a state where objects can be grouped together; false otherwise.
Example
This example will add two objects into the automation and then group them together.
Visual Basic | Copy Code |
---|
Private Sub AnnAutomation_CanGroup(ByVal automation As AnnAutomation)
ShowStatus(automation)
Dim rectObj As AnnRectangleObject = New AnnRectangleObject()
rectObj.Left = 100
rectObj.Top = 100
rectObj.Width = 200
rectObj.Height = 200
rectObj.Stroke = Brushes.Blue
rectObj.StrokeThickness = 1.0
rectObj.Fill = Nothing
automation.Container.Children.Add(rectObj)
ShowStatus(automation)
Dim lineObj As AnnLineObject = New AnnLineObject()
lineObj.X1 = 100
lineObj.Y1 = 100
lineObj.X2 = 200
lineObj.Y2 = 200
lineObj.Stroke = Brushes.Red
lineObj.StrokeThickness = 1.0
automation.Container.Children.Add(lineObj)
ShowStatus(automation)
automation.StartEditing(rectObj, False)
ShowStatus(automation)
automation.StartEditing(lineObj, True)
ShowStatus(automation)
If automation.CanGroup Then
automation.Group()
ShowStatus(automation)
End If
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 = CType(IIf(TypeOf automation.CurrentEditObject Is AnnGroupObject, automation.CurrentEditObject, Nothing), 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 |
C# | Copy Code |
---|
private void AnnAutomation_CanGroup(AnnAutomation automation) { ShowStatus(automation); // first, add two objects to the automation AnnRectangleObject rectObj = new AnnRectangleObject(); rectObj.Left = 100; rectObj.Top = 100; rectObj.Width = 200; rectObj.Height = 200; rectObj.Stroke = Brushes.Blue; rectObj.StrokeThickness = 1.0; rectObj.Fill = null; automation.Container.Children.Add(rectObj); ShowStatus(automation); AnnLineObject lineObj = new AnnLineObject(); lineObj.X1 = 100; lineObj.Y1 = 100; lineObj.X2 = 200; lineObj.Y2 = 200; lineObj.Stroke = Brushes.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()); } |
Remarks
Requirements
Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Vista, and Windows Server 2003 family
See Also