LEADTOOLS Annotations for WPF and Silverlight (Leadtools.Windows.Annotations assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.31
Ungroup Method
See Also 
Leadtools.Windows.Annotations Namespace > AnnGroupObject Class : Ungroup Method



Ungroups this AnnGroupObject object. Supported in Silverlight, Windows Phone 7

Syntax

Visual Basic (Declaration) 
Public Sub Ungroup() 
Visual Basic (Usage)Copy Code
Dim instance As AnnGroupObject
 
instance.Ungroup()
C# 
public void Ungroup()
C++/CLI 
public:
void Ungroup(); 

Example

This example groups/ungroups objects.

Visual BasicCopy Code
Private Sub AnnGroupObject_Ungroup()
   Dim container As AnnContainer = New AnnContainer()
   ' adds a few objects to the container
   Dim line As AnnLineObject = New AnnLineObject()
   container.Children.Add(line)

   Dim rect As AnnRectangleObject = New AnnRectangleObject()
   container.Children.Add(rect)

   ' show the number of objects in this container (should be 2: line and rectangle)
   Dim s As String = String.Format("There are {0} objects in the container", container.Children.Count)

   MessageBox.Show(s)

   ' move all objects from the container to a group
   Dim group As AnnGroupObject = New AnnGroupObject()

   Do While container.Children.Count > 0
      Dim obj As AnnObject = DirectCast(container.Children(0), AnnObject)
      container.Children.Remove(obj)
      group.Children.Add(obj)
   Loop

   ' show the number of objects in this container (should be 0)
   s = String.Format("There are {0} objects in the container", container.Children.Count)
   MessageBox.Show(s)

   ' add the group to the container
   container.Children.Add(group)

   ' show the number of objects in this container (should be 1: group)
   s = String.Format("There are {0} objects in the container", container.Children.Count)
   MessageBox.Show(s)

   ' ungroup the group object
   group.Ungroup()

   ' show the number of objects in this container (should be 3: group, line and rectangle)
   s = String.Format("There are {0} objects in the container", container.Children.Count)
   MessageBox.Show(s)

   ' remove the group from the container
   container.Children.Remove(group)

   ' show the number of objects in this container (should be 2: line and rectangle)
   s = String.Format("There are {0} objects in the container", container.Children.Count)
   MessageBox.Show(s)
End Sub
C#Copy Code
private void AnnGroupObject_Ungroup()
{
   AnnContainer container = new AnnContainer();
   // adds a few objects to the container
   AnnLineObject line = new AnnLineObject();
   container.Children.Add(line);

   AnnRectangleObject rect = new AnnRectangleObject();
   container.Children.Add(rect);

   // show the number of objects in this container (should be 2: line and rectangle)
   string s = string.Format("There are {0} objects in the container", container.Children.Count);
   ;
   MessageBox.Show(s);

   // move all objects from the container to a group
   AnnGroupObject group = new AnnGroupObject();

   while(container.Children.Count > 0)
   {
      AnnObject obj = container.Children[0] as AnnObject;
      container.Children.Remove(obj);
      group.Children.Add(obj);
   }

   // show the number of objects in this container (should be 0)
   s = string.Format("There are {0} objects in the container", container.Children.Count);
   MessageBox.Show(s);

   // add the group to the container
   container.Children.Add(group);

   // show the number of objects in this container (should be 1: group)
   s = string.Format("There are {0} objects in the container", container.Children.Count);
   MessageBox.Show(s);

   // ungroup the group object
   group.Ungroup();

   // show the number of objects in this container (should be 3: group, line and rectangle)
   s = string.Format("There are {0} objects in the container", container.Children.Count);
   MessageBox.Show(s);

   // remove the group from the container
   container.Children.Remove(group);

   // show the number of objects in this container (should be 2: line and rectangle)
   s = string.Format("There are {0} objects in the container", container.Children.Count);
   MessageBox.Show(s);
}
SilverlightCSharpCopy Code
private void AnnGroupObject_Ungroup()
{
   AnnContainer container = new AnnContainer();
   // adds a few objects to the container
   AnnLineObject line = new AnnLineObject();
   container.Children.Add(line);

   AnnRectangleObject rect = new AnnRectangleObject();
   container.Children.Add(rect);

   // show the number of objects in this container (should be 2: line and rectangle)
   string s = string.Format("There are {0} objects in the container", container.Children.Count);
   ;
   MessageBox.Show(s);

   // move all objects from the container to a group
   AnnGroupObject group = new AnnGroupObject();

   while(container.Children.Count > 0)
   {
      AnnObject obj = container.Children[0] as AnnObject;
      container.Children.Remove(obj);
      group.Children.Add(obj);
   }

   // show the number of objects in this container (should be 0)
   s = string.Format("There are {0} objects in the container", container.Children.Count);
   MessageBox.Show(s);

   // add the group to the container
   container.Children.Add(group);

   // show the number of objects in this container (should be 1: group)
   s = string.Format("There are {0} objects in the container", container.Children.Count);
   MessageBox.Show(s);

   // ungroup the group object
   group.Ungroup();

   // show the number of objects in this container (should be 3: group, line and rectangle)
   s = string.Format("There are {0} objects in the container", container.Children.Count);
   MessageBox.Show(s);

   // remove the group from the container
   container.Children.Remove(group);

   // show the number of objects in this container (should be 2: line and rectangle)
   s = string.Format("There are {0} objects in the container", container.Children.Count);
   MessageBox.Show(s);
}
SilverlightVBCopy Code
Private Sub AnnGroupObject_Ungroup()
   Dim container As AnnContainer = New AnnContainer()
   ' adds a few objects to the container
   Dim line As AnnLineObject = New AnnLineObject()
   container.Children.Add(line)

   Dim rect As AnnRectangleObject = New AnnRectangleObject()
   container.Children.Add(rect)

   ' show the number of objects in this container (should be 2: line and rectangle)
   Dim s As String = String.Format("There are {0} objects in the container", container.Children.Count)

   MessageBox.Show(s)

   ' move all objects from the container to a group
   Dim group As AnnGroupObject = New AnnGroupObject()

   Do While container.Children.Count > 0
      Dim obj As AnnObject = TryCast(container.Children(0), AnnObject)
      container.Children.Remove(obj)
      group.Children.Add(obj)
   Loop

   ' show the number of objects in this container (should be 0)
   s = String.Format("There are {0} objects in the container", container.Children.Count)
   MessageBox.Show(s)

   ' add the group to the container
   container.Children.Add(group)

   ' show the number of objects in this container (should be 1: group)
   s = String.Format("There are {0} objects in the container", container.Children.Count)
   MessageBox.Show(s)

   ' ungroup the group object
   group.Ungroup()

   ' show the number of objects in this container (should be 3: group, line and rectangle)
   s = String.Format("There are {0} objects in the container", container.Children.Count)
   MessageBox.Show(s)

   ' remove the group from the container
   container.Children.Remove(group)

   ' show the number of objects in this container (should be 2: line and rectangle)
   s = String.Format("There are {0} objects in the container", container.Children.Count)
   MessageBox.Show(s)
End Sub

Remarks

Ungrouping an AnnGroupObject object moves all the objects in this group to the group's System.ComponentModel.Container. After ungrouping is done, the group's Children collection will be empty. This method does not remove this AnnGroupObject object from the System.ComponentModel.Container.

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

Requirements

Target Platforms: Silverlight 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7, MAC OS/X (Intel Only)

See Also

Ungroup requires a Document/Medical product license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features and Unlocking Special LEAD Features.