Ejemplo n.º 1
0
        /// <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);
        }