Esempio n. 1
0
 /// <summary>
 /// Called after a part is removed from a group node's members.
 /// </summary>
 /// <param name="group">a <see cref="Group"/></param>
 /// <param name="part">a <see cref="Part"/> that has been removed from the <paramref name="group"/></param>
 /// <remarks>
 /// <para>
 /// Removing a member from a group will request a new automatic layout.
 /// </para>
 /// <para>
 /// The implementation of this method should not modify the model.
 /// This method cannot and should not prevent or alter the membership of the part in the group.
 /// </para>
 /// </remarks>
 protected virtual void OnMemberRemoved(Node group, Part part) {
   if (group == null) return;
   // there isn't any OnMemberRemoving method, so PART has already been removed from the GROUP
   // Thus we have to try to invalidate the GROUP's layout
   group.InvalidateLayout(LayoutChange.MemberRemoved);  // MemberRemoved treated specially for groups
 }
Esempio n. 2
0
 /// <summary>
 /// Called before a <paramref name="node"/> is removed from the diagram.
 /// </summary>
 /// <param name="node">a <see cref="Node"/></param>
 /// <remarks>
 /// <para>
 /// This remove all links that are connected to the <paramref name="node"/>.
 /// </para>
 /// <para>
 /// Removing a node will request a new automatic layout if it has a <see cref="Node.Location"/>.
 /// </para>
 /// <para>
 /// The implementation of this method should not modify the model.
 /// This method cannot and should not prevent or alter the removal of the node from the diagram.
 /// </para>
 /// </remarks>
 protected virtual void OnNodeRemoving(Node node) {
   if (node == null) return;
   Object nodedata = node.Data;
   IDiagramModel model = node.Model;
   if (model != null && !(model is ILinksModel)) {
     foreach (Object n in model.GetConnectedNodesForNode(nodedata).ToList()) {
       RemoveLinkForData(nodedata, n, model);
       RemoveLinkForData(n, nodedata, model);
     }
   }
   foreach (Group g in node.ContainingGroups) {
     g.Remeasure();
   }
   node.InvalidateLayout(LayoutChange.NodeRemoved);
 }
Esempio n. 3
0
 /// <summary>
 /// Called after a part is added to a group node's members.
 /// </summary>
 /// <param name="group">a <see cref="Group"/></param>
 /// <param name="part">a <see cref="Part"/> that has been added to the <paramref name="group"/></param>
 /// <remarks>
 /// <para>
 /// Adding a member to a group will request a new automatic layout.
 /// </para>
 /// <para>
 /// The implementation of this method should not modify the model.
 /// This method cannot and should not prevent or alter the membership of the part in the group.
 /// </para>
 /// </remarks>
 protected virtual void OnMemberAdded(Node group, Part part) {
   if (group == null) return;
   Group sg = group as Group;
   if (sg != null && part != null) {
     bool vis = sg.IsExpandedSubGraph;
     if (part.Visible != vis) part.Visible = vis;
   }
   // invalidate the GROUP's layout
   group.InvalidateLayout(LayoutChange.MemberAdded);  // MemberAdded treated specially for groups
 }
Esempio n. 4
0
    /// <summary>
    /// Called after a <paramref name="node"/> is added to the diagram.
    /// </summary>
    /// <param name="node">a <see cref="Node"/></param>
    /// <remarks>
    /// <para>
    /// For models that are not <see cref="Northwoods.GoXam.Model.ILinksModel"/>,
    /// this will add any <see cref="Link"/>s that should be connected to the new <paramref name="node"/>.
    /// For models that are <see cref="Northwoods.GoXam.Model.ISubGraphModel"/>,
    /// this checks for any <see cref="Group"/> containing this new node is not <see cref="Group.IsExpandedSubGraph"/> --
    /// if so this node is made <c>Visibility.Collapsed</c>.
    /// </para>
    /// <para>
    /// Adding a node will request a new automatic layout if it does not have a <see cref="Node.Location"/>.
    /// </para>
    /// <para>
    /// The implementation of this method should not modify the model.
    /// This method cannot and should not prevent or alter the addition of the node to the diagram.
    /// </para>
    /// </remarks>
    protected virtual void OnNodeAdded(Node node) {
      if (node == null) return;
      Object nodedata = node.Data;
      IDiagramModel model = node.Model;
      ITreeModel tmodel = model as ITreeModel;
      if (tmodel != null) {
        Object parentdata = tmodel.GetParentForNode(nodedata);
        if (parentdata != null) {
          // create link from parent to this new node
          AddLinkForData(parentdata, nodedata, model);
        }
        // create links from this new node
        foreach (Object n in tmodel.GetChildrenForNode(nodedata)) {
          AddLinkForData(nodedata, n, model);
        }
      } else if (model is IConnectedModel) {
        // create links to this new node
        foreach (Object n in model.GetFromNodesForNode(nodedata)) {
          AddLinkForData(n, nodedata, model);
        }
        // create links from this new node
        foreach (Object n in model.GetToNodesForNode(nodedata)) {
          AddLinkForData(nodedata, n, model);
        }
      } // don't need to automatically create links for ILinksModel when nodes get added

      // deal with subgraph visibility
      ISubGraphModel sgmodel = model as ISubGraphModel;
      if (sgmodel != null) {
        // maybe member of a collapsed subgraph -- make the node not visible
        Group containernode = node.ContainingSubGraph;
        if (containernode != null && node.Visible && (!containernode.IsExpandedSubGraph || !containernode.Visible)) {
          node.Visible = false;
          // this propagates to connected links
        }
        // maybe this is a collapsed subgraph -- make sure members are not visible
        Group group = node as Group;
        if (group != null && !group.IsExpandedSubGraph) {
          foreach (Node n in group.MemberNodes) {
            if (n.Visible) n.Visible = false;
          }
          foreach (Link l in group.MemberLinks) {
            if (l.Visible) l.Visible = false;
          }
        }
      }

      // deal with tree visibility
      Diagram diagram = this.Diagram;
      if (node.Visible) {
        // maybe this is a child of a collapsed tree node
        var nodes = (diagram != null && diagram.TreePath == TreePath.Source) ? node.NodesOutOf : node.NodesInto;
        foreach (Node parentnode in nodes) {
          if (!parentnode.IsExpandedTree) {
            node.Visible = false;
            // this propagates to connected links
            break;
          }
        }
      }

      // maybe this is a collapsed tree node -- make sure children are not visible
      if (!node.IsExpandedTree) {
        var links = (diagram != null && diagram.TreePath == TreePath.Source) ? node.LinksInto : node.LinksOutOf;
        foreach (Link childlink in links) {
          Node other = childlink.GetOtherNode(node);
          if (other != null && other != node && other.Visible) {
            other.Visible = false;
            // this propagates to connected links
          }
        }
      }

      node.InvalidateLayout(LayoutChange.NodeAdded);
    }