/// <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; }
public override void Duplicate(IInputModeContext context, IGraph sourceGraph, Predicate <IModelItem> filter, ElementCopiedCallback elementDuplicated = null) { // store the relative z-order for duplicated items StoreInitialZOrder(sourceGraph, filter); // collect new items in the OnCopiedFromClipboard callbacks newItems.Clear(); base.Duplicate(context, sourceGraph, filter, elementDuplicated); // set final z-orders of newItems depending on their new parent group ArrangeItems(newItems, sourceGraph.GetFoldingView()); }
public override void Paste(IInputModeContext context, IGraph targetGraph, Predicate <IModelItem> filter = null, ElementCopiedCallback elementPasted = null, Predicate <IModelItem> targetFilter = null) { // collect new items in the OnCopiedFromClipboard callbacks newItems.Clear(); base.Paste(context, targetGraph, filter, elementPasted, targetFilter); // set final z-orders of newItems depending on their new parent group ArrangeItems(newItems, targetGraph.GetFoldingView()); }