Ejemplo n.º 1
0
 public static void CollectEntitiesInside(Rectangle surfaceRectangle)
 {
     if (surfaceRectangle == Rectangle.Empty)
     {
         return;
     }
     Selection.Clear();
     foreach (IDiagramEntity entity in Selection.Controller.Model.Paintables)
     {
         //if the entity is part of a group we have to look at the bigger picture
         if (mSelectionType == SelectionTypes.Inclusion)
         {
             if (entity.Group != null)
             {
                 //the rectangle must contain the whole group
                 if (surfaceRectangle.Contains(entity.Group.Rectangle))
                 {
                     //add the group if not already present via another group member
                     if (!mSelection.Contains(entity.Group))
                     {
                         mSelection.Add(entity.Group);
                     }
                     continue;
                 }
             }
             else
             {
                 if (surfaceRectangle.Contains(entity.Rectangle))
                 {
                     mSelection.Add(entity);
                     entity.IsSelected = true;
                 }
             }
         }
         else //the selection requires only partial overlap with the rectangle
         {
             if (entity.Group != null)
             {
                 if (surfaceRectangle.IntersectsWith(entity.Group.Rectangle))
                 {
                     if (!mSelection.Contains(entity.Group))
                     {
                         mSelection.Add(entity.Group);
                     }
                     continue;
                 }
             }
             else
             {
                 if (surfaceRectangle.IntersectsWith(entity.Rectangle))
                 {
                     mSelection.Add(entity);
                     entity.IsSelected = true;
                 }
             }
         }
     }
     RaiseOnNewSelection();
 }
Ejemplo n.º 2
0
 public void AttachConnector(IConnector connector)
 {
     if (connector == null)
     {
         return;
     }
     //only attach'm if not already present and not the parent
     if (!attachedConnectors.Contains(connector) && connector != attachedTo)
     {
         connector.DetachFromParent();
         attachedConnectors.Add(connector);
         //make sure the attached connector is centered at this connector
         connector.Point      = this.point;
         connector.AttachedTo = this;
     }
 }
Ejemplo n.º 3
0
 void mDefaultPage_OnEntityRemoved(object sender, EntityEventArgs e)
 {
     if (mPaintables.Contains(e.Entity))
     {
         //shift the entities above the one to be removed
         int index = e.Entity.SceneIndex;
         foreach (IDiagramEntity entity in mPaintables)
         {
             if (entity.SceneIndex > index)
             {
                 entity.SceneIndex--;
             }
         }
         mPaintables.Remove(e.Entity);
     }
     //if the selection contains the shape we have to remove it from the selection
     if (Selection.SelectedItems.Contains(e.Entity))
     {
         Selection.SelectedItems.Remove(e.Entity);
     }
     RaiseOnEntityRemoved(e);
 }