public static void Cut(SelectedNodes nodes) { if (nodes.Count > 0) { internalClipboard.Clear(); StringBuilder str = new StringBuilder(); MapTextSerializer serializer = new MapTextSerializer(); bool[] exclude = nodes.ExcludeNodesAlreadyPartOfHierarchy(); for (int i = 0; i < nodes.Count; i++) { if (!exclude[i]) { internalClipboard.Add(nodes[i]); } } internalClipboard.ForEach(n => { serializer.Serialize(n, str); n.Detach(); }); var cbData = new MindMateTextDataObject(); cbData.SetData(str.ToString()); Clipboard.SetDataObject(cbData); hasCutNode = true; if (StatusChanged != null) { StatusChanged(); } } }
public static void Copy(SelectedNodes nodes) { if (nodes.Count > 0) { internalClipboard.Clear(); StringBuilder str = new StringBuilder(); MapTextSerializer serializer = new MapTextSerializer(); bool[] exclude = nodes.ExcludeNodesAlreadyPartOfHierarchy(); for (int i = 0; i < nodes.Count; i++) { if (!exclude[i]) { internalClipboard.Add(nodes[i].CloneAsDetached()); serializer.Serialize(nodes[i], str); } } var cbData = new MindMateTextDataObject(); cbData.SetData(str.ToString()); Clipboard.SetDataObject(cbData); //Clipboard.SetText(str.ToString(), TextDataFormat.Text); hasCutNode = false; if (StatusChanged != null) { StatusChanged(); } } }
public static void Copy(SelectedNodes nodes) { if (nodes.Count > 0) { internalClipboard.Clear(); StringBuilder str = new StringBuilder(); MapTextSerializer serializer = new MapTextSerializer(); bool[] exclude = nodes.ExcludeNodesAlreadyPartOfHierarchy(); for (int i = 0; i < nodes.Count; i++ ) { if (!exclude[i]) { internalClipboard.Add(nodes[i].CloneAsDetached()); serializer.Serialize(nodes[i], str); } } var cbData = new MindMateTextDataObject(); cbData.SetData(str.ToString()); Clipboard.SetDataObject(cbData); //Clipboard.SetText(str.ToString(), TextDataFormat.Text); hasCutNode = false; if(StatusChanged != null) { StatusChanged(); } } }
public object GetData(string format, bool autoConvert) { string[] formats = GetFormats(); if (!formats.Contains(format)) { return(null); } if (format == DataFormats.Text || format == MindMateClipboardFormat) { if (text == null) { StringBuilder str = new StringBuilder(); MapTextSerializer serializer = new MapTextSerializer(); mapNodes.ForEach(n => serializer.Serialize(n, str)); text = str.ToString(); } return(text); } else if (format == DataFormats.Bitmap) { return(mapNodes.First(n => n.HasImage).GetImage()); } return(null); }
public void Serialize() { var t = new MapTree(); var r = new MapNode(t, "root"); var n1 = new MapNode(r, "n1"); var n11 = new MapNode(n1, "n11"); var n12 = new MapNode(n1, "n12"); var n2 = new MapNode(r, "n2"); var sut = new MapTextSerializer(); var str = new StringBuilder(); sut.Serialize(r, str); Assert.AreEqual("root" + Environment.NewLine + "\tn1" + Environment.NewLine + "\t\tn11" + Environment.NewLine + "\t\tn12" + Environment.NewLine + "\tn2", str.ToString()); }
public static void Cut(SelectedNodes nodes) { if(nodes.Count > 0) { internalClipboard.Clear(); StringBuilder str = new StringBuilder(); MapTextSerializer serializer = new MapTextSerializer(); bool[] exclude = nodes.ExcludeNodesAlreadyPartOfHierarchy(); for (int i = 0; i < nodes.Count; i++) { if(!exclude[i]) { internalClipboard.Add(nodes[i]); } } internalClipboard.ForEach(n => { serializer.Serialize(n, str); n.Detach(); }); var cbData = new MindMateTextDataObject(); cbData.SetData(str.ToString()); Clipboard.SetDataObject(cbData); hasCutNode = true; if (StatusChanged != null) { StatusChanged(); } } }