/// <summary>
        /// Helper method for the <see cref="ShowContentsCommand"/> binding.
        /// </summary>
        private void OnShowContentsExecuted(object sender, ExecutedCommandEventArgs e)
        {
            if (graphControl == null)
            {
                e.Handled = false;
                return;
            }
            // get the IFoldingView instance
            IFoldingView graph = graphControl.Graph.Lookup <IFoldingView>();

            if (graph != null)
            {
                // find the node to show the contents for
                INode node = FindNode(graph, e.Parameter);
                // if we found one
                if (node != null)
                {
                    // show it
                    ShowContents(graph.GetMasterItem(node));
                    e.Handled = true;
                }
            }
            else
            {
                e.Handled = false;
            }
        }
 /// <summary>
 /// Handler for the <see cref="ShowAllCommand"/>
 /// </summary>
 private async void ShowAllExecuted(object sender, ExecutedCommandEventArgs e)
 {
     if (!doingLayout)
     {
         hiddenNodesSet.Clear();
         await RefreshLayout(-1, graphControl.CurrentItem as INode);
     }
 }
Exemple #3
0
        /// <summary>
        /// Handler for the <see cref="DecreaseSequenceCommand"/>
        /// </summary>
        private void DecreaseSequenceExecuted(object sender, ExecutedCommandEventArgs e)
        {
            var node = e.Parameter as INode;

            if (node != null)
            {
                var data = (SequenceConstraintsInfo)node.Tag;
                data.DecreaseValue();
            }
        }
Exemple #4
0
        /// <summary>
        /// Handler for the <see cref="ToggleConstraintsStateCommand"/>
        /// </summary>
        private void ToggleConstraintsStateExecuted(object sender, ExecutedCommandEventArgs e)
        {
            var node = e.Parameter as INode;

            if (node != null)
            {
                var data = (SequenceConstraintsInfo)node.Tag;
                data.ToggleState();
            }
        }
        /// <summary>
        /// Handler for the <see cref="IncreaseLayerCommand"/>
        /// </summary>
        private void IncreaseLayerExecuted(object sender, ExecutedCommandEventArgs e)
        {
            var node = e.Parameter as INode;

            if (node != null)
            {
                var data = (LayerConstraintsInfo)node.Tag;
                data.IncreaseValue();
            }
        }
        /// <summary>
        /// Handler for the <see cref="HideChildrenCommand"/>
        /// </summary>
        private async void HideChildrenExecuted(object sender, ExecutedCommandEventArgs e)
        {
            var node = (e.Parameter ?? graphControl.CurrentItem) as INode;

            if (node != null && !doingLayout)
            {
                int count = hiddenNodesSet.Count;
                foreach (var child in filteredGraphWrapper.Successors(node))
                {
                    HideAllExcept(child, node);
                }
                await RefreshLayout(count, node);
            }
        }
Exemple #7
0
        /// <summary>
        /// Called when the ToggleChildren command has been executed.
        /// </summary>
        /// <remarks>
        /// Toggles the visiblity of the node's children.
        /// </remarks>
        public async void ToggleChildrenExecuted(object sender, ExecutedCommandEventArgs e)
        {
            var node = (e.Parameter ?? graphControl.CurrentItem) as INode;

            if (node != null)
            {
                bool canExpand = filteredGraph.OutDegree(node) != filteredGraph.WrappedGraph.OutDegree(node);
                if (canExpand)
                {
                    await Expand(node);
                }
                else
                {
                    await Collapse(node);
                }
            }
        }
        /// <summary>
        /// Handler for the <see cref="ShowParentCommand"/>
        /// </summary>
        private async void ShowParentExecuted(object sender, ExecutedCommandEventArgs e)
        {
            var node = (e.Parameter ?? graphControl.CurrentItem) as INode;

            if (node != null && !doingLayout)
            {
                int count = hiddenNodesSet.Count;
                foreach (var parentEdge in filteredGraphWrapper.WrappedGraph.InEdgesAt(node))
                {
                    var parent = parentEdge.GetSourceNode();
                    if (hiddenNodesSet.Remove(parent))
                    {
                        filteredGraphWrapper.WrappedGraph.SetNodeCenter(parent, node.Layout.GetCenter());
                        filteredGraphWrapper.WrappedGraph.ClearBends(parentEdge);
                    }
                }
                await RefreshLayout(count, node);
            }
        }
        /// <summary>
        /// Handler for the <see cref="ShowChildrenCommand"/>
        /// </summary>
        public async void ShowChildrenExecuted(object sender, ExecutedCommandEventArgs e)
        {
            var node = (e.Parameter ?? graphControl.CurrentItem) as INode;

            if (node != null && !doingLayout)
            {
                int count = hiddenNodesSet.Count;
                foreach (var childEdge in filteredGraphWrapper.WrappedGraph.OutEdgesAt(node))
                {
                    var child = childEdge.GetTargetNode();
                    if (hiddenNodesSet.Remove(child))
                    {
                        filteredGraphWrapper.WrappedGraph.SetNodeCenter(child, node.Layout.GetCenter());
                        filteredGraphWrapper.WrappedGraph.ClearBends(childEdge);
                    }
                }
                await RefreshLayout(count, node);
            }
        }
        /// <summary>
        /// Handler for the <see cref="HideParentCommand"/>
        /// </summary>
        private async void HideParentExecuted(object sender, ExecutedCommandEventArgs e)
        {
            var node = (e.Parameter ?? graphControl.CurrentItem) as INode;

            if (node != null && !doingLayout)
            {
                int count = hiddenNodesSet.Count;

                foreach (var testNode in filteredGraphWrapper.WrappedGraph.Nodes)
                {
                    if (testNode != node && filteredGraphWrapper.Contains(testNode) &&
                        filteredGraphWrapper.InDegree(testNode) == 0)
                    {
                        // this is a root node - remove it and all children unless
                        HideAllExcept(testNode, node);
                    }
                }
                await RefreshLayout(count, node);
            }
        }
        /// <summary>
        /// Custom command handler that allows toggling the selection state of an item
        /// respecting the single selection policy.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ToggleItemSelectionExecuted(object sender, ExecutedCommandEventArgs e)
        {
            // get the item
            var modelItem = (e.Parameter as IModelItem) ?? graphControl.CurrentItem;
            var inputMode = (GraphEditorInputMode)graphControl.InputMode;

            // check if it allowed to be selected
            if (modelItem != null && graphControl.Graph.Contains(modelItem) && inputMode.SelectableItems.Is(modelItem))
            {
                var isSelected = inputMode.GraphSelection.IsSelected(modelItem);
                if (isSelected)
                {
                    // the item is selected and needs to be unselected - just clear the selection
                    inputMode.GraphSelection.Clear();
                }
                else
                {
                    // the items is unselected - unselect all other items and select the currentItem
                    inputMode.GraphSelection.Clear();
                    inputMode.SetSelected(modelItem, true);
                }
                e.Handled = true;
            }
        }
        /// <summary>
        /// Paste implementation that uses a filter delegate to copy only nodes and labels as well as a different paste offset.
        /// </summary>
        /// <remarks>The customized paste operations (i.e. label text change) from <see cref="TaggedNodeClipboardHelper"/>
        /// will still be used.</remarks>
        private void OnPasteSpecialCommandExecuted(object sender, ExecutedCommandEventArgs executedCommandEventArgs)
        {
            var control = (GraphControl)sender;

            GraphClipboard clipboard = control.Clipboard;

            // Clear the old selection.
            control.Selection.Clear();

            // This is the filter delegate for the Paste call.
            Predicate <IModelItem> filter = item => item is INode || (item is ILabel && ((ILabel)item).Owner is INode);
            // This delegate is executed for every pasted element. We use it to select the pasted nodes.
            ElementCopiedCallback pasted =
                delegate(IModelItem originalItem, IModelItem pastedItem) {
                if (pastedItem is INode)
                {
                    control.Selection.SetSelected(pastedItem, true);
                }
            };

            clipboard.Paste(control.Graph, filter, pasted);
            // The next paste location should be shifted a little (just like the normal paste)
            clipboard.PasteDelta += ((GraphEditorInputMode)graphControl.InputMode).PasteDelta;
        }
 private void NextPage_Executed(object sender, ExecutedCommandEventArgs e)
 {
     SetPageNumber(pageNumber + 1, null);
 }
 private void PreviousPage_Executed(object sender, ExecutedCommandEventArgs e)
 {
     SetPageNumber(pageNumber - 1, null);
 }