/// <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> /// Overrides XML Serialization by using base then adding our custom members /// </summary> /// <param name="p_Parent">Parent Tree Node used in Serialization</param> /// <returns>a Serialized Copy of our object</returns> public override XmlTreeNode SerializeToXML(XmlTreeNode p_Parent) { // Base SerializeToXML provides initial work for the XMLTreeNode XmlTreeNode v_Out = base.SerializeToXML(p_Parent); // ... then I will encode our custom data v_Out.AddParameter("Behavior", m_eBehavior.ToString()); v_Out.AddParameter("DefaultValue", m_fDefaultValue.ToString(System.Globalization.CultureInfo.GetCultureInfo("en-us"))); return(v_Out); }
/// <summary> /// SERIALIZATION: Creates a XML Serialized copy of the link /// </summary> /// <param name="p_XmlParentTreeNode"></param> /// <returns></returns> public XmlTreeNode SerializeToXML(XmlTreeNode p_XmlParentTreeNode) { XmlTreeNode v_Out = new XmlTreeNode(SerializationUtils.GetFullTypeName(this), p_XmlParentTreeNode); NodeGraphView v_View = Input.Parent.ParentView; NodeGraphNode v_InputNode = Input.Parent; NodeGraphNode v_OutputNode = Output.Parent; v_Out.AddParameter("InputNodeId", v_View.GetNodeIndex(v_InputNode).ToString()); v_Out.AddParameter("OutputNodeId", v_View.GetNodeIndex(v_OutputNode).ToString()); v_Out.AddParameter("InputNodeConnectorIdx", v_InputNode.GetConnectorIndex(Input).ToString()); v_Out.AddParameter("OutputNodeConnectorIdx", v_OutputNode.GetConnectorIndex(Output).ToString()); 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); }