示例#1
0
 // ------------------------------------------------------------------
 /// <summary>
 /// Handles the OnEntityAdded event of the Page and adds the new
 /// entity to the Paintables.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The
 /// <see cref="T:Netron.Diagramming.Core.EntityEventArgs"/> instance
 /// containing the event data.</param>
 // ------------------------------------------------------------------
 void mDefaultPage_OnEntityAdded(object sender, EntityEventArgs e)
 {
     //don't add it if it's already there or if it's a group (unless you want to deploy something special to emphasize a group shape).
     if (!Paintables.Contains(e.Entity))
     {
         if ((e.Entity is IGroup) && !(e.Entity as IGroup).EmphasizeGroup)
         {
             return;
         }
         //set the new entity on top of the stack
         e.Entity.SceneIndex = Paintables.Count;
         Paintables.Add(e.Entity);
     }
     #region Addition callback
     IAdditionCallback callback = e.Entity.GetService(typeof(IAdditionCallback)) as IAdditionCallback;
     if (callback != null)
     {
         callback.OnAddition();
     }
     #endregion
     RaiseOnEntityAdded(e);
 }
示例#2
0
 // ------------------------------------------------------------------
 /// <summary>
 /// Handles the OnEntityRemoved event of the DefaultPage.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The
 /// <see cref="T:Netron.Diagramming.Core.EntityEventArgs"/> instance
 /// containing the event data.</param>
 // ------------------------------------------------------------------
 void mDefaultPage_OnEntityRemoved(object sender, EntityEventArgs e)
 {
     if (Paintables.Contains(e.Entity))
     {
         //shift the entities above the one to be removed
         int index = e.Entity.SceneIndex;
         foreach (IDiagramEntity entity in Paintables)
         {
             if (entity.SceneIndex > index)
             {
                 entity.SceneIndex--;
             }
         }
         Paintables.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);
 }