protected void AddTemplateLayoutMenuItems(IContextMenuView contextMenuView, IContainerBase containerBase) { string containerType = "Diagram"; if (containerBase.IsAnImplementationOf <IContainerNode>()) { containerType = "Container"; } IHasLayoutInfo selectedNode = Presenter.GetFirstSelected <IContainerNode>(); if (selectedNode != null) { SubMenuLayout.AddItem(CreateMenuButton.WithCaption("Apply Named Template to Selection...") .WithActionCommand(() => Presenter.ApplyLayoutTemplateToSelection()).AsGroupStarter()); } else { SubMenuLayout.AddItem(CreateMenuButton.WithCaption("Apply Named Template to " + containerType + "...") .WithActionCommand(() => Presenter.ApplyLayoutTemplate(containerBase, "", false))); } SubMenuLayout.AddItem(CreateMenuButton.WithCaption("Apply Named Template to " + containerType + " Recursive...") .WithActionCommand(() => Presenter.ApplyLayoutTemplate(containerBase, "", true))); SubMenuLayout.AddItem(CreateMenuButton.WithCaption("Save " + containerType + " as Named Template...") .WithActionCommand(() => Presenter.SaveContainerToXml(containerBase, ""))); }
protected virtual void SetSelectionMenuItems(IContextMenuView contextMenuView, IContainerBase containerBase, IBaseNode node) { contextMenuView.AddMenuItem(SubMenuSelect); if (containerBase != null) { SubMenuSelect.AddItem(CreateMenuButton.WithCaption("All Children") .WithActionCommand(() => Presenter.SelectChildren(containerBase))); } if (Presenter.SelectionContains <IBaseNode>()) { SubMenuSelect.AddItem(CreateMenuButton.WithCaption("Visible Linked nodes") .WithActionCommand(() => Presenter.SelectVisibleLinkedNodesForDiagramSelection())); if (node != null) { SubMenuSelect.AddItem(CreateMenuButton.WithCaption("Invert Selection") .WithActionCommand(() => Presenter.InvertSelection(node.GetParent()))); } IHasLayoutInfo selectedNode = Presenter.GetFirstSelected <IHasLayoutInfo>(); if (selectedNode != null) { SubMenuDiagram.AddItem(CreateMenuCheckButton.WithCaption("Location Fixed").AsGroupStarter() .WithChecked(selectedNode.LocationFixed) .WithCheckedAction(locationFixed => Presenter.SetLocationFixedForDiagramSelection(locationFixed))); } contextMenuView.AddMenuItem(CreateMenuButton.WithCaption("Hide Selection").WithActionCommand(() => Presenter.HideSelection())); } if (Presenter.SelectionContains <IElementBaseNode>()) { var subMenuNodeSize = CreateSubMenu.WithCaption("Nodesize") .WithItem(CreateMenuButton.WithCaption("Large").WithActionCommand(() => Presenter.SetNodeSizeForDiagramSelection(NodeSize.Large))) .WithItem(CreateMenuButton.WithCaption("Middle").WithActionCommand(() => Presenter.SetNodeSizeForDiagramSelection(NodeSize.Middle))) .WithItem(CreateMenuButton.WithCaption("Small").WithActionCommand(() => Presenter.SetNodeSizeForDiagramSelection(NodeSize.Small))); contextMenuView.AddMenuItem(subMenuNodeSize); } // Shows all children (e.g. after hiding a selection) if (containerBase != null) { contextMenuView.AddMenuItem(CreateMenuButton.WithCaption("Show All Children").WithActionCommand(() => Presenter.ShowChildren(containerBase))); } }
private void setNodeType(GoLayoutLayeredDigraphNetwork net, IList <IHasLayoutInfo> freeNodes) { IList <GoLayoutLayeredDigraphNode> fixedNodes = new List <GoLayoutLayeredDigraphNode>(); foreach (GoLayoutLayeredDigraphNode netNode in net.Nodes) { IHasLayoutInfo hasLayoutInfo = netNode.GoObject as IHasLayoutInfo; if (hasLayoutInfo != null && hasLayoutInfo.LocationFixed) { fixedNodes.Add(netNode); } } foreach (GoLayoutLayeredDigraphNode netNode in fixedNodes) { net.DeleteNode(netNode); } }
private void setNodeType(GoLayoutForceDirectedNetwork net, IList <IHasLayoutInfo> freeNodes) { foreach (GoLayoutForceDirectedNode netNode in net.Nodes) { IHasLayoutInfo hasLayoutInfo = netNode.GoObject as IHasLayoutInfo; if (hasLayoutInfo != null && netNode.UserFlags == 0) { netNode.IsFixed = hasLayoutInfo.LocationFixed || hasLayoutInfo.IsAnImplementationOf <PortNode>() || (freeNodes != null && !freeNodes.Contains(hasLayoutInfo)); netNode.UserFlags = hasLayoutInfo.UserFlags; // position linkless nodes by gravitational force (fix positioning seems not so easy because of moving bounds) if (netNode.LinksCount == 0) { netNode.UserFlags = NodeLayoutType.LINKLESS_NODE; //try to position linkless nodes by grav force, } } } }