Exemple #1
0
        public override void FromXml(string source)
        {
            // Attempts to load a position from the given xml string
            XqlParser parser = new XqlParser();

            parser.LoadData(source);
            List <Hashtable> results = parser.Query("SELECT type, evaluateLUAFcn FROM " + ElementType);

            if (results.Count == 0)
            {
                throw new HsfElementException("Unable to parse " + ElementType + " from xml");
            }

            // Load enum
            Array posValues = Enum.GetValues(typeof(ScheduleEvaluatorType));

            foreach (ScheduleEvaluatorType v in posValues)
            {
                if (Enum.GetName(typeof(ScheduleEvaluatorType), v) == results[0]["type"].ToString())
                {
                    Type = v;
                }
            }

            // Load LUA function?
            if (Type == ScheduleEvaluatorType.scripted)
            {
                _evaluateLuaFcn = results[0]["evaluateLUAFcn"].ToString();
            }
            else
            {
                _evaluateLuaFcn = "";
            }
        }
        private void typeComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            // First, disable / enable script function based on selection
            ScheduleEvaluatorType current = (ScheduleEvaluatorType)(typeComboBox.SelectedItem);

            if (current != ScheduleEvaluatorType.scripted)
            {
                evalFunctionTextbox.Enabled = false;
            }
            else
            {
                evalFunctionTextbox.Enabled = true;
            }

            // Then, write changes and register event
            ModelComponent before = (ModelComponent)Model.Clone();

            Model.ScheduleEvaluator.Type = current;
            ModelComponent after = (ModelComponent)Model.Clone();

            if (_mManager != null && before.ToXml() != after.ToXml())
            {
                _mManager.RegisterEvent(before, after, Model, "Change Type");
            }
        }