/// <summary> /// SERIALIZATION: Creates a NodeGraphView from a Serialized XML Copy /// </summary> /// <param name="p_XmlTreeNode">the parent XmlTreeNode used in serialization</param> /// <param name="p_Panel">the panel that will contain this NodeGraphView</param> public NodeGraphView(XmlTreeNode p_XmlTreeNode, NodeGraphPanel p_Panel) { System.Globalization.CultureInfo v_IntlCultureInfo = new System.Globalization.CultureInfo("en-us"); this.m_oPanel = p_Panel; this.ViewX = int.Parse(p_XmlTreeNode.m_attributes["ViewX"]); this.ViewY = int.Parse(p_XmlTreeNode.m_attributes["ViewY"]); this.ViewZoom = float.Parse(p_XmlTreeNode.m_attributes["ViewZoom"], v_IntlCultureInfo); this.m_NodeCollection = new List <NodeGraphNode>(); XmlTreeNode v_NodesXml = p_XmlTreeNode.GetFirstChild("NodeGraphNodeCollection"); foreach (XmlTreeNode i_ChildNode in v_NodesXml.m_childNodes) { this.m_NodeCollection.Add(NodeGraphNode.DeserializeFromXML(i_ChildNode, this)); } this.m_Links = new List <NodeGraphLink>(); XmlTreeNode v_LinksXml = p_XmlTreeNode.GetFirstChild("NodeGraphLinkCollection"); foreach (XmlTreeNode i_ChildLink in v_LinksXml.m_childNodes) { this.m_Links.Add(NodeGraphLink.DeserializeFromXML(i_ChildLink, this)); } this.m_SelectedItems = new List <NodeGraphNode>(); }
/// <summary> /// SERIALIZATION: Creates a NodeGraphView from a Pipeline Descriptor /// </summary> /// <param name="p_Pipeline">Pipeline descriptor</param> /// <param name="p_Panel">the panel that will contain this NodeGraphView</param> public NodeGraphView(PipelineDescriptor p_Pipeline, NodeGraphPanel p_Panel) { //System.Globalization.CultureInfo v_IntlCultureInfo = new System.Globalization.CultureInfo("en-us"); this.m_oPanel = p_Panel; this.ViewX = 0; this.ViewY = 0; this.ViewZoom = 1.0f; this.m_NodeCollection = new List <NodeGraphNode>(); foreach (var module in p_Pipeline.modules) { this.m_NodeCollection.Add(NodeGraphNode.FromModuleDescriptor(module, this)); } m_NodeConnectorCollection = new List <NodeGraphConnector>(); foreach (var endpoint in p_Pipeline.inputEndpoints) { this.m_NodeConnectorCollection.Add(new NodeGraphConnector(endpoint, this, ConnectorType.InputConnector)); } foreach (var endpoint in p_Pipeline.outputEndpoints) { this.m_NodeConnectorCollection.Add(new NodeGraphConnector(endpoint, this, ConnectorType.OutputConnector)); } this.m_Links = new List <NodeGraphLink>(); foreach (var connection in p_Pipeline.connections) { this.m_Links.Add(NodeGraphLink.FromConnectionDescriptor(connection, this)); } for (int i = 0; i < this.m_NodeCollection.Count; i++) { //! TODO : normal algorythm for module placement this.m_NodeCollection[i].X = i * 100; this.m_NodeCollection[i].Y = i * 100; this.m_NodeCollection[i].UpdateHitRectangle(); } this.m_SelectedItems = new List <NodeGraphNode>(); }