/// <summary> /// SERIALIZATION: Serializes current object and all of its children to an XML Node /// </summary> /// <param name="p_Parent">Parent XML Node used in serialization</param> /// <returns>the XML serialized copy of the object</returns> public XmlTreeNode SerializeToXML(XmlTreeNode p_Parent) { XmlTreeNode v_Out = new XmlTreeNode(Xml.SerializationUtils.GetFullTypeName(this), p_Parent); v_Out.AddParameter("ViewX", ViewX.ToString()); v_Out.AddParameter("ViewY", ViewY.ToString()); v_Out.AddParameter("ViewZoom", ViewZoom.ToString(System.Globalization.CultureInfo.GetCultureInfo("en-us"))); // Process Nodes XmlTreeNode v_NodeCollection = v_Out.AddChild("NodeGraphNodeCollection"); foreach (NodeGraphNode i_Node in this.NodeCollection) { v_NodeCollection.AddChild(i_Node.SerializeToXML(v_NodeCollection)); } // Process Links XmlTreeNode v_LinksCollection = v_Out.AddChild("NodeGraphLinkCollection"); foreach (NodeGraphLink i_Link in this.Links) { v_LinksCollection.AddChild(i_Link.SerializeToXML(v_LinksCollection)); } return(v_Out); }
/// <summary> /// CLIPBOARD: Copies the selection as a list of Nodes into ClipBoard. /// </summary> public void CopySelectionToClipboard() { XmlTree v_ClipboardCopy = new XmlTree("NodeGraphCopy"); XmlTreeNode v_NodeRoot = v_ClipboardCopy.m_rootNode.AddChild("Nodes"); XmlTreeNode v_LinksRoot = v_ClipboardCopy.m_rootNode.AddChild("Links"); // Nodes foreach (NodeGraphNode i_Node in this.m_SelectedItems) { v_NodeRoot.AddChild(i_Node.SerializeToXML(v_ClipboardCopy.m_rootNode)); } // Links XmlTreeNode v_CurrentLink; foreach (NodeGraphLink i_Link in this.m_Links) { // if the node is connecting copied nodes if (this.m_SelectedItems.Contains(i_Link.Input.Parent) && this.m_SelectedItems.Contains(i_Link.Output.Parent)) { v_CurrentLink = new XmlTreeNode("ToBeRelinked", v_LinksRoot); v_CurrentLink.AddParameter("InputNodeId", this.GetSelectionNodeIndex(i_Link.Input.Parent).ToString()); v_CurrentLink.AddParameter("InputNodeConnectorIdx", i_Link.Input.Parent.GetConnectorIndex(i_Link.Input).ToString()); v_CurrentLink.AddParameter("OutputNodeId", this.GetSelectionNodeIndex(i_Link.Output.Parent).ToString()); v_CurrentLink.AddParameter("OutputNodeConnectorIdx", i_Link.Output.Parent.GetConnectorIndex(i_Link.Output).ToString()); v_LinksRoot.AddChild(v_CurrentLink); } } Clipboard.Clear(); string v_TempPath = Path.GetTempPath() + "NodeGraphClipboard.xml"; v_ClipboardCopy.SaveXML(v_TempPath); System.Collections.Specialized.StringCollection v_ClipBoardContent = new System.Collections.Specialized.StringCollection(); v_ClipBoardContent.Add(v_TempPath); Clipboard.SetFileDropList(v_ClipBoardContent); }