Esempio n. 1
0
        private void OnPropertiesMenuItemClick(System.Object sender, System.EventArgs e)
        {
            if (TabControl.TabPages.Count == 1)
            {
                TabControl.TabPages.Insert(0, Properties);

                // Fill the property grid.
                string  UIXml  = "<ui/>";
                XmlNode UINode = XmlHelper.Find(Data, "ui");
                if ((UINode != null))
                {
                    UIXml = UINode.OuterXml;
                }
                GenericUI.OnLoad(Controller, NodePath, UIXml);
                GenericUI.OnRefresh();

                PropertiesMenuItem.Checked = TabControl.TabPages.Count == 2;
                TabControl.SelectedIndex   = 0;
            }
            else
            {
                // Save the current contents of the grid
                GenericUI.OnSave();
                string Contents = GenericUI.GetData();
                if (!string.IsNullOrEmpty(Contents) && PropertiesMenuItem.Checked)
                {
                    XmlDocument Doc = new XmlDocument();
                    Doc.LoadXml(Contents);
                    XmlNode UINode = XmlHelper.Find(Data, "ui");
                    UINode.InnerXml = Doc.FirstChild.InnerXml;
                }
                TabControl.TabPages.Remove(Properties);
            }
            PropertiesMenuItem.Checked = TabControl.TabPages.Count == 2;
        }
Esempio n. 2
0
        public override void OnSave()
        {
            // --------------------------------------
            // Save the script box if it has changd.
            // --------------------------------------
            string Contents = "";

            if ((GenericUI != null))
            {
                GenericUI.OnSave();
                Contents = GenericUI.GetData();
            }

            List <XmlNode> refs = new List <XmlNode>();

            refs = XmlHelper.ChildNodes(Data, "reference");

            Data.RemoveAll();

            if (!string.IsNullOrEmpty(Contents))
            {
                XmlDocument Doc = new XmlDocument();
                Doc.LoadXml(Contents);
                Data.AppendChild(Data.OwnerDocument.ImportNode(Doc.DocumentElement, true));
            }

            foreach (XmlNode xn in refs)
            {
                Data.AppendChild(Data.OwnerDocument.ImportNode(xn, true));
            }

            XmlHelper.SetValue(Data, "text", TextBox.Text);

            // Store the cursor and text scroll position for the TextBox
            // Firstly find the top visible line number
            int lineVisible = 0;

            while ((lineVisible < TextBox.DisplayLines.Count) && !TextBox.DisplayLines.IsPointVisible(new Point(0, lineVisible)))
            {
                lineVisible++;
            }

            if (TextBox.Selection != null)
            {
                int       charIndex = TextBox.Selection.SelectionStart;
                CursorPos position  = new CursorPos();
                position.TopLine   = lineVisible;
                position.CharIndex = charIndex;
                if (!positions.ContainsKey(this.NodePath))
                {
                    positions.Add(this.NodePath, position);
                }
                else
                {
                    positions[this.NodePath] = position;
                }
            }
        }
Esempio n. 3
0
        public override void OnSave()
        {
            // --------------------------------------
            // Save the script box if it has changd.
            // --------------------------------------
            string Contents = "";

            if (TabControl.TabPages.Count > 0 && TabControl.TabPages[0].Text == "Properties")
            {
                GenericUI.OnSave();
                Contents = GenericUI.GetData();
            }
            Data.RemoveAll();

            if (!string.IsNullOrEmpty(Contents))
            {
                XmlDocument Doc = new XmlDocument();
                Doc.LoadXml(Contents);
                Data.AppendChild(Data.OwnerDocument.ImportNode(Doc.DocumentElement, true));
            }

            foreach (TabPage Page in TabControl.TabPages)
            {
                if (Page.Text != "Properties")
                {
                    XmlNode Script    = Data.AppendChild(Data.OwnerDocument.CreateElement("script"));
                    TextBox ScriptBox = (TextBox)Page.Controls[0];
                    XmlHelper.SetValue(Script, "text", ScriptBox.Text);

                    string[]      EventNames = Page.Text.Split(",".ToCharArray());
                    List <string> Events     = new List <string>();
                    Events.AddRange(EventNames);
                    XmlHelper.SetValues(Script, "event", Events);
                }
            }
        }
Esempio n. 4
0
        public override void OnSave()
        {
            Data.RemoveAll();

            UpdateUIVariable("state", cboState.Text);
            UpdateUIVariable("crop", cboCrops.Text);
            UpdateUIVariable("date1", txtStart.Text);
            UpdateUIVariable("date2", txtEnd.Text);
            UpdateUIVariable("raincrit", txtRain.Text);
            UpdateUIVariable("rainnumdays", txtDaysRain.Text);
            UpdateUIVariable("esw_amount", txtMinWater.Text);

            string sText = "no";

            if (chkSow.Checked)
            {
                sText = "yes";
            }
            UpdateUIVariable("must_sow", sText);
            sText = "no";
            if (chkMachinery.Checked)
            {
                sText = "yes";
            }
            UpdateUIVariable("wait_machinery", sText);

            //Establishment
            UpdateUIVariable("cultivar", cboCultivar.Text);
            UpdateUIVariable("plants", txtDensity.Text);
            UpdateUIVariable("sowing_depth", txtDepth.Text);
            UpdateUIVariable("row_spacing", txtRows.Text);
            UpdateUIVariable("sowing_costs", txtSowingcost.Text);

            //Machinery
            UpdateUIVariable("sow_tractor", cboTractor.Text);
            UpdateUIVariable("sow_implement", cboImplement.Text);

            //Fertiliser
            UpdateUIVariable("fert_type", cboFertiliser.Text);
            UpdateUIVariable("fert_cost", txtFertiliserCost.Text);
            UpdateUIVariable("target_n", txtNitrogen.Text);

            //Harvest
            UpdateUIVariable("harvest_costs", txtHarvestCost.Text);
            UpdateUIVariable("price", txtCropPrice.Text);
            UpdateUIVariable("moisture", txtMoisture.Text);
            UpdateUIVariable("harv_tractor", cboHarvestTractor.Text);
            UpdateUIVariable("harv_implement", cboHarvestImplement.Text);

            //Custom
            GenericUI.OnSave();
            //need to add the saved data into this component's xml
            string savedData = GenericUI.GetData();

            ReplaceNode("CustomUI", savedData);

            XmlNode ScriptNode = Data.AppendChild(Data.OwnerDocument.CreateElement("script"));

            XmlHelper.SetName(ScriptNode, "Init");
            XmlHelper.SetValue(ScriptNode, "text", syntaxEdit1.Text);
            XmlHelper.SetValue(ScriptNode, "event", "init");
        }