Esempio n. 1
0
        private void SetupApplication()
        {
            try
            {
                ROMNode node = ROMNode.LoadXML("config.xml", null);
                if (node == null)
                {
                    return;
                }

                ROMNode childNode = new ROMNode("Child1");
                childNode.SetAttribute("attr1", "A child attr");
                node.AddChildROMObject(childNode);
                ROMNode childNode2 = new ROMNode("Child2");
                childNode2.SetAttribute("attr2", "A child attr");
                node.AddChildROMObject(childNode2);
                ROMNode childNode3 = new ROMNode("Child3");
                childNode3.SetAttribute("attr3", "A child attr");
                childNode3.SetAttribute("attr3", "attrSub1", "A sub child attr");
                childNode3.SetAttribute("attr3", "attrSub2", "A 2nd sub child attr");
                childNode2.AddChildROMObject(childNode3);

                Debugger.RootNode = node;
                Debugger.Update();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 2
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Filter = "XML files (*.xml)|*.xml";
            dialog.Title  = "Open XML file";

            if (dialog.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            //string contents = null;
            //using (StreamReader reader = new StreamReader(dialog.FileName))
            //{
            //    while (!reader.EndOfStream)
            //    {
            //        contents = reader.ReadToEnd();
            //    }
            //}

            //reload
            if (!string.IsNullOrEmpty(dialog.FileName))
            {
                var newNode = ROMNode.LoadXML(dialog.FileName, null);
                if (newNode != null)
                {
                    newNode.Rules = m_rules;
                    m_rootNode    = newNode;
                    m_engine      = new LinearEngine(m_rootNode, "HydraulicCylinderDictionary");
                    m_engine.EvaluateAll();

                    UpdateControls();
                }
            }
        }