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 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; } }