/// <inheritdoc /> public override void Run(GraphController ctrl) { ctrl.EnsureValidityOfCurrentLayerNumber(); var currentLayerNumber = ctrl.CurrentLayerNumber; var plotLayer = ctrl.ActiveLayer as XYPlotLayer; if (null != plotLayer) { object o = ClipboardSerialization.GetObjectFromClipboard("Altaxo.Graph.Gdi.Plot.PlotItemCollection.AsXml"); // if at this point obj is a memory stream, you probably have forgotten the deserialization constructor of the class you expect to deserialize here if (o is PlotItemCollection coll) { if (PasteExclusively) { plotLayer.PlotItems.ClearPlotItems(); } foreach (IGPlotItem item in coll) // it is neccessary to add the items to the doc first, because otherwise they don't have names { var clonedItem = (IGPlotItem)item.Clone(); plotLayer.PlotItems.Add(clonedItem); // cloning neccessary because coll will be disposed afterwards, which would destroy all items } } } else { Current.Gui.ErrorMessageBox("'Can only paste plot content to an XYPlotLayer. Please select another layer.", "Operation not possible"); } }
/// <summary> /// Try to paste the entire GraphDocument from the clipboard using the specified paste options. /// </summary> /// <param name="doc">The graph document to paste into.</param> /// <param name="options">The options used for paste into that graph.</param> public static void PasteFromClipboard(this GraphDocument doc, GraphCopyOptions options) { object from = ClipboardSerialization.GetObjectFromClipboard("Altaxo.Graph.Graph3D.GraphDocumentAsXml"); if (from is GraphDocument) { doc.CopyFrom((GraphDocument)from, options); } }
/// <summary> /// Pastes a layer on the clipboard as new layer after the layer at index <paramref name="currentActiveLayerNumber"/>. /// </summary> /// <param name="doc">Graph document to paste to.</param> /// <param name="currentActiveLayerNumber">Index of the layer after which to paste the layer from the clipboard.</param> public static void PasteFromClipboardAsNewLayerAfterLayerNumber(this GraphDocument doc, IEnumerable <int> currentActiveLayerNumber) { object o = ClipboardSerialization.GetObjectFromClipboard("Altaxo.Graph.Graph3D.GraphLayerAsXml"); var layer = o as XYZPlotLayer; if (null != layer) { doc.RootLayer.InsertAfter(currentActiveLayerNumber, layer); } }
public static void PasteFromClipboardAsNewLayer(this GraphDocument doc) { object o = ClipboardSerialization.GetObjectFromClipboard("Altaxo.Graph.Graph3D.GraphLayerAsXml"); var layer = o as XYZPlotLayer; if (null != layer) { doc.RootLayer.Layers.Add(layer); } }
/// <summary> /// Pastes a layer on the clipboard as new layer after the layer at index <paramref name="currentActiveLayerNumber"/>. /// </summary> /// <param name="doc">Graph document to paste to.</param> /// <param name="currentActiveLayerNumber">Index of the layer after which to paste the layer from the clipboard.</param> public static void PasteFromClipboardAsNewChildLayerOfLayerNumber(this GraphDocument doc, IEnumerable <int> currentActiveLayerNumber) { object o = ClipboardSerialization.GetObjectFromClipboard("Altaxo.Graph.Graph3D.GraphLayerAsXml"); var layer = o as XYZPlotLayer; if (null != layer) { var parentLayer = doc.RootLayer.ElementAt(currentActiveLayerNumber); parentLayer.Layers.Insert(0, layer); } }
public static void PasteFromClipboardAsTemplateForLayer(GraphDocument doc, IEnumerable <int> layerNumber, GraphCopyOptions options) { object o = ClipboardSerialization.GetObjectFromClipboard("Altaxo.Graph.Graph3D.GraphLayerAsXml"); if (null == o) { return; } var layer = o as XYZPlotLayer; if (null != layer) { doc.RootLayer.ElementAt(layerNumber).CopyFrom(layer, options); } }
/// <summary> /// Try to paste the entire GraphDocument from the clipboard. /// </summary> /// <param name="doc">The graph document to paste into.</param> /// <param name="showOptionsDialog">If <c>true</c>, shows the user an option dialog for choise of specific items to paste.</param> public static void PasteFromClipboardAsGraphStyle(this GraphDocument doc, bool showOptionsDialog) { object from = ClipboardSerialization.GetObjectFromClipboard("Altaxo.Graph.Graph3D.GraphDocumentAsXml"); if (from is GraphDocument) { GraphCopyOptions options = DefaultGraphDocumentPasteOptions; if (showOptionsDialog) { System.Enum o = _lastChoosenGraphDocumentPasteOptions; if (!Current.Gui.ShowDialogForEnumFlag(ref o, "Choose options for pasting")) { return; } _lastChoosenGraphDocumentPasteOptions = (GraphCopyOptions)o; options = _lastChoosenGraphDocumentPasteOptions; } PasteFromClipboard(doc, options); } }