internal bool CanExecute(INode node, CanvasControl hostingControl) { var commandParameter = CommandParameter; if (commandParameter == UseNodeParameter) { commandParameter = node; } else if (commandParameter == UseNodeTagParameter) { commandParameter = node.Tag; } var commandTarget = CommandTarget; if (commandTarget == UseCanvasControlTarget) { commandTarget = hostingControl; } if (CanExecuteHandler != null) { var args = new CanExecuteCommandEventArgs(Command, commandParameter, commandTarget); CanExecuteHandler(commandTarget, args); if (args.Handled) { return(args.CanExecute); } } return(Command.CanExecute(commandParameter, commandTarget)); }
/// <summary> /// Helper method for the <see cref="ShowContentsCommand"/> binding. /// </summary> private void OnCanShowContentsExecuted(object sender, CanExecuteCommandEventArgs e) { if (graphControl == null) { e.Handled = false; return; } // see if we can execute the command... IFoldingView graph = graphControl.Graph.Lookup <IFoldingView>(); if (graph != null) { INode node = FindNode(graph, e.Parameter); if (node != null) { // yes, we found a node - notify the binding. e.CanExecute = true; e.Handled = true; } } else { e.Handled = false; } }
private void ToggleItemSelectionCanExecute(object sender, CanExecuteCommandEventArgs e) { // if we have an item, the command can be executed var modelItem = (e.Parameter as IModelItem) ?? graphControl.CurrentItem; e.CanExecute = modelItem != null; e.Handled = true; }
/// <summary> /// Helper method that determines whether the <see cref="HideChildrenCommand"/> can be executed. /// </summary> private void CanExecuteHideChildren(object sender, CanExecuteCommandEventArgs e) { var node = (e.Parameter ?? graphControl.CurrentItem) as INode; if (node != null && !doingLayout && filteredGraphWrapper != null) { e.CanExecute = filteredGraphWrapper.OutDegree(node) > 0; } else { e.CanExecute = false; } e.Handled = true; }
/// <summary> /// Helper method that determines whether the <see cref="DecreaseSequenceCommand"/> can be executed. /// </summary> private void CanExecuteDecreaseSequence(object sender, CanExecuteCommandEventArgs e) { var node = e.Parameter as INode; if (node != null) { var data = (SequenceConstraintsInfo)node.Tag; e.CanExecute = data.CanDecreaseValue(); } else { e.CanExecute = false; } e.Handled = true; }
/// <summary> /// Helper method that determines whether the <see cref="ToggleConstraintsStateCommand"/> can be executed. /// </summary> /// <remarks> /// Always returns true. /// </remarks> private void CanExecuteToggleConstraintsState(object sender, CanExecuteCommandEventArgs e) { e.CanExecute = true; e.Handled = true; }
private void NextPage_CanExecute(object sender, CanExecuteCommandEventArgs e) { e.CanExecute = IsPageNumberValid(pageNumber + 1); e.Handled = true; }
private void DisableCommand(object sender, CanExecuteCommandEventArgs e) { e.CanExecute = false; e.Handled = true; }
/// <summary> /// Helper method that determines whether the <see cref="ShowParentCommand"/> can be executed. /// </summary> private void CanExecuteShowAll(object sender, CanExecuteCommandEventArgs e) { e.CanExecute = filteredGraphWrapper != null && hiddenNodesSet.Count != 0 && !doingLayout; e.Handled = true; }