コード例 #1
0
        /// <summary>
        /// Detaches the given connector from this connector. No exception will be thrown if the given connector is not a child.
        ///
        /// </summary>
        /// <param name="connector"></param>
        public void DetachConnector(IConnector connector)
        {
            if (connector == null || !Enabled)
            {
                return;
            }

            if (attachedConnectors.Contains(connector))
            {
                attachedConnectors.Remove(connector);
                connector.AttachedTo = null;
            }
        }
コード例 #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 (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);
 }
コード例 #3
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)
        {
            //IShape sp = e.Entity as IShape;
            //if(sp != null)
            //{
            //    foreach(IConnector cr in sp.Connectors)
            //        mConnectorHolders.Remove(cr);
            //}

            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);

            IConnection cn = e.Entity as IConnection;

            if (cn != null)
            {
                mConnectorHolders.Remove(cn.From);
                mConnectorHolders.Remove(cn.To);
            }
        }
コード例 #4
0
 internal void SelectEntity(IDiagramEntity entity, Point surfacePoint)
 {
     // Groups are treated specially because we can drill-down
     // into the group.  The process of drilling is the first
     // mouse hit will select the group.  The second mouse hit
     // will select a child, if there's a child at that point.
     if (entity is IGroup)
     {
         if (entity.IsSelected == false)
         {
             entity.IsSelected = true;
             mSelection.Add(entity);
         }
         else
         {
             IGroup group = entity as IGroup;
             for (int j = group.Entities.Count - 1; j >= 0; j--)
             {
                 IDiagramEntity child = group.Entities[j];
                 if (child.Hit(surfacePoint))
                 {
                     // Repeat the process because what if this
                     // child is too a group!
                     SelectEntity(child, surfacePoint);
                     group.IsSelected = false;
                     if (mSelection.Contains(group))
                     {
                         mSelection.Remove(group);
                     }
                     break;
                 }
             }
         }
     }
     //else if (entity.Group != null)
     //{
     //    //entity.Group.IsSelected = true;
     //    //mSelection.Add(entity.Group);
     //}
     else
     {
         entity.IsSelected = true;
         mSelection.Add(entity);
     }
 }