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 static void Paste(MapNode pasteLocation, bool asText = false) { if (Clipboard.ContainsData(MindMateTextFormat)) { foreach (MapNode node in internalClipboard) { if (asText) { new MapNode(pasteLocation, node.Text); } else { node.CloneAsDetached().AttachTo(pasteLocation); } } } else if (Clipboard.ContainsText()) { string link = GetBrowserSourceLink(); MapTextSerializer serializer = new MapTextSerializer(); serializer.Deserialize(Clipboard.GetText(TextDataFormat.Text), pasteLocation, (parent, text) => { if (asText) { return(new MapNode(parent, text)); } else { string tempLink = link; if (text.StartsWith("http://", StringComparison.OrdinalIgnoreCase) || text.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) { tempLink = text; } return(new MapNode(parent, text) { Link = tempLink }); } }); } else if (Clipboard.ContainsFileDropList()) { PasteFileDropList(pasteLocation, asText); } hasCutNode = false; if (StatusChanged != null) { StatusChanged(); } if (pasteLocation.Folded) { pasteLocation.Folded = false; } }
public void Deserialize() { string str = "root" + Environment.NewLine + "\tn1" + Environment.NewLine + "\t\tn11" + Environment.NewLine + "\t\tn12" + Environment.NewLine + "\tn2"; var n = new MapNode(new MapTree(), "1"); var sut = new MapTextSerializer(); sut.Deserialize(str, n, (p, t) => new MapNode(p, t)); Assert.AreEqual(6, n.RollUpAggregate(node => 1, (a, b) => a + b)); }
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(); } } }
public static void Paste(MapNode pasteLocation, bool asText = false) { if(Clipboard.ContainsData(MindMateTextFormat)) { foreach(MapNode node in internalClipboard) { if(asText) { new MapNode(pasteLocation, node.Text); } else { node.CloneAsDetached().AttachTo(pasteLocation); } } } else if(Clipboard.ContainsText()) { string link = GetBrowserSourceLink(); MapTextSerializer serializer = new MapTextSerializer(); serializer.Deserialize(Clipboard.GetText(TextDataFormat.Text), pasteLocation, (parent, text) => { if (asText) { return new MapNode(parent, text); } else { string tempLink = link; if (text.StartsWith("http://", StringComparison.OrdinalIgnoreCase) || text.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) tempLink = text; return new MapNode(parent, text) { Link = tempLink }; } }); } else if(Clipboard.ContainsFileDropList()) { PasteFileDropList(pasteLocation, asText); } hasCutNode = false; if (StatusChanged != null) { StatusChanged(); } if (pasteLocation.Folded) { pasteLocation.Folded = false; } }
public static void Paste(MapNode pasteLocation, bool asText = false, bool pasteFileAsImage = false) { if (Clipboard.ContainsData(MindMateClipboardFormat)) { foreach (MapNode node in internalClipboard) { if (asText) { new MapNode(pasteLocation, node.Text); } else { node.CloneAsDetached().AttachTo(pasteLocation); } } } else if (Clipboard.ContainsText()) { string link = GetBrowserSourceLink(); MapTextSerializer serializer = new MapTextSerializer(); serializer.Deserialize(Clipboard.GetText(TextDataFormat.Text), pasteLocation, (parent, text) => { if (asText) { return(new MapNode(parent, text)); } else { string tempLink = link; // add link to source website in case text itself is not a URL (if text is URL, link to it) if (text.StartsWith("http://", StringComparison.OrdinalIgnoreCase) || text.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) { tempLink = text; } return(new MapNode(parent, text) { Link = tempLink }); } }); } else if (Clipboard.ContainsImage()) { PasteImage(pasteLocation); } else if (Clipboard.ContainsFileDropList()) { if (pasteFileAsImage) { PasteFileListAsImage(pasteLocation); } else { PasteFileDropList(pasteLocation, asText); } } hasCutNode = false; StatusChanged?.Invoke(); if (pasteLocation.Folded) { pasteLocation.Folded = false; } }