Exemplo n.º 1
0
		public Check(string labelText,bool ticked,FuncParamType paramType,string propertyName) : this()
			{
			this.ParameterType = paramType;
			this.LabelText = labelText;
			this.Checked = ticked;
			this.PropertyName = propertyName;
			}
Exemplo n.º 2
0
        public CheckList(string groupText, string[] elements, FuncParamType paramType) : this()
        {
            this.LabelText     = groupText;
            this.ParameterType = paramType;

            if (elements != null)
            {
                this.CheckedList.Items.AddRange(elements);
            }
        }
Exemplo n.º 3
0
		public FunctionControlParam(string name,string display,ControlType conType,FuncParamType paramType,EntryType keyType,EntryType valueType,string initValue)
			{
			ParamName = name;
			DisplayName = display;
			ParamType = paramType;
			ControlType = conType;
			KeyType = keyType;
			ValueType = valueType;
			InitValue = initValue;
			}
Exemplo n.º 4
0
        public ComboSelection(string lableText, string[] values, string defaultText, FuncParamType paramType) : this()
        {
            this.ParameterType = paramType;
            this.LabelText     = lableText;
            this.EntryText     = defaultText;

            if (values != null)
            {
                //this.Entry.Items.AddRange(values);
                ListTextCollection = values;
            }
        }
Exemplo n.º 5
0
 public TextEntry(string labelText, string defaultText, FuncParamType paramType) : this()
 {
     this.ParameterType = paramType;
     this.LabelText     = labelText;
     this.EntryText     = defaultText;
 }
Exemplo n.º 6
0
		public FunctionControlParam(string name,string display,ControlType conType,FuncParamType paramType,EntryType keyType,EntryType valueType)
			: this(name,display,conType,paramType,keyType,valueType,null)
			{
			}
Exemplo n.º 7
0
 public TextDump(string groupText, string defaultText, FuncParamType paramType) : this()
 {
     this.ParameterType = paramType;
     this.LabelText     = groupText;
     this.EntryText     = defaultText;
 }
Exemplo n.º 8
0
 public ComboListBuilder(string defaultLabel, string[] elements, string defaultText, FuncParamType paramType) : this()
 {
     this.ParameterType = paramType;
     this.LabelText     = defaultLabel;
     this.EntryText     = defaultText;
     if (elements != null)
     {
         this.Entry.Items.AddRange(elements);
     }
 }
Exemplo n.º 9
0
 public ListBuilder(string groupText, FuncParamType paramType) : this()
 {
     this.ParameterType = paramType;
     this.LabelText     = groupText;
 }
Exemplo n.º 10
0
 public ComboMapBuilder(string defaultLabel, string[] elements, string defaultText, FuncParamType paramType) : this()
 {
     this.ParameterType = paramType;
     this.LabelText     = defaultLabel;
     this.EntryText     = defaultText;
     if (elements != null)
     {
         //this.Key.Items.AddRange(elements);
         KeyCollection = elements;
     }
 }
Exemplo n.º 11
0
        public DoubleComboMap(string defaultLabel, string[] keys, string[] values, string defaultKey, string defaultValue, FuncParamType paramType) : this()
        {
            this.ParameterType = paramType;
            this.LabelText     = defaultLabel;
            this.KeyEntry      = defaultKey;
            this.ValueEntry    = defaultValue;
            if (values != null)
            {
                //this.Key.Items.AddRange(keys);
                KeyCollection = keys;
            }

            if (values != null)
            {
                //this.Value.Items.AddRange(values);
                ValueCollection = values;
            }
        }
Exemplo n.º 12
0
 public RightComboMapBuilder(string defaultLabel, string[] values, string defaultText, FuncParamType paramType) : this()
 {
     this.ParameterType = paramType;
     this.LabelText     = defaultLabel;
     this.EntryText     = defaultText;
     if (values != null)
     {
         //this.Value.Items.AddRange(values);
         ValueCollection = values;
     }
 }
Exemplo n.º 13
0
        public object CreateControl(Tag c)
        {
            Control control = null;

            //get the list of initial values that a control might have
            List <string> Values      = GetControlValues(c, "");
            List <string> Values2     = GetControlValues(c, "2");
            string        Init        = GetControlInit(c, "");
            string        Init2       = GetControlInit(c, "2");
            string        subType     = "";
            string        displayName = "";
            string        header      = "";
            FuncParamType paramType   = FuncParamType.None;
            EntryType     keyType     = EntryType.NA;
            EntryType     valueType   = EntryType.NA;
            bool          enabled     = true;

            //check if this control has paramtype specified. If not,
            //either it doesn't need one or someone forgot it!
            if (c.Attributes.ContainsKey("paramtype"))
            {
                foreach (Stellarmap.FuncParamType check in Stellarmap.FuncParamTypesList.List)
                {
                    //yeah, the ToLower() was 'cause I was too lazy to
                    //go back and change either the tags or the enums.
                    //Bite me >:B
                    string attribute = c.Attributes["paramtype"].ToLower();
                    string converted = check.ToString().ToLower();
                    if (attribute == converted)
                    {
                        paramType = check;
                        break;
                    }
                }
                //MessageBox.Show("XMLFile: " + c.Attributes["paramtype"] + "\nResult: " + paramType.ToString().ToLower());
            }
            if (c.Attributes.ContainsKey("keytype"))
            {
                foreach (Stellarmap.EntryType check in Stellarmap.EntryTypesList.List)
                {
                    //yeah, the ToLower() was 'cause I was too lazy to
                    //go back and change either the tags or the enums.
                    //Bite me >:B
                    string attribute = c.Attributes["keytype"].ToLower();
                    string converted = check.ToString().ToLower();
                    if (attribute == converted)
                    {
                        keyType = check;
                        break;
                    }
                }
            }
            if (c.Attributes.ContainsKey("valuetype"))
            {
                foreach (Stellarmap.EntryType check in Stellarmap.EntryTypesList.List)
                {
                    //yeah, the ToLower() was 'cause I was too lazy to
                    //go back and change either the tags or the enums.
                    //Bite me >:B
                    string attribute = c.Attributes["valuetype"].ToLower();
                    string converted = check.ToString().ToLower();
                    if (attribute == converted)
                    {
                        valueType = check;
                        break;
                    }
                }
            }
            if (c.Attributes.ContainsKey("enable"))
            {
                if (c.Attributes["enable"] == "false")
                {
                    enabled = false;
                }
            }
            if (c.Attributes.ContainsKey("text"))
            {
                displayName = c.Attributes["text"];
            }
            if (c.Attributes.ContainsKey("subtype"))
            {
                subType = c.Attributes["subtype"];
            }
            if (c.Attributes.ContainsKey("header"))
            {
                header = c.Attributes["header"];
            }


            try {
                //process each control tag
                #region control creation switch
                switch (c.Attributes["type"].ToLower())
                {
                case "checklist":
                {
                    control = new CheckList(displayName, Values.ToArray(), paramType);
                    break;
                }

                case "comboselection":
                {
                    control = new ComboSelection(displayName, Values.ToArray(), Init, paramType);
                    break;
                }

                case "comboselectiontypeable":
                {
                    control = new ComboSelectionTypeable(displayName, Values.ToArray(), Init, paramType);
                    break;
                }

                case "listbuilder":
                {
                    control = new ListBuilder(displayName, paramType);
                    break;
                }

                case "mapbuilder":
                {
                    control = new MapBuilder(displayName);
                    break;
                }

                case "numberentry":
                {
                    decimal     temp = 0;
                    NumberEntry numCon;

                    if (Init != "")
                    {
                        temp = Convert.ToDecimal(Init);
                    }
                    control = new NumberEntry(displayName, temp, 0, 10000);
                    numCon  = control as NumberEntry;
                    if (numCon != null)
                    {
                        if (c.Attributes.ContainsKey("min"))
                        {
                            numCon.EntryMinimum = Convert.ToDecimal(c.Attributes["min"]);
                        }
                        if (c.Attributes.ContainsKey("max"))
                        {
                            numCon.EntryMaxmimum = Convert.ToDecimal(c.Attributes["max"]);
                        }
                        if (c.Attributes.ContainsKey("inc"))
                        {
                            numCon.EntryIncrement = Convert.ToDecimal(c.Attributes["inc"]);
                        }
                        if (c.Attributes.ContainsKey("decimalplaces"))
                        {
                            numCon.DecimalPlaces = Convert.ToInt32(c.Attributes["decimalplaces"]);
                        }
                    }
                    break;
                }

                case "textentry":
                {
                    control = new TextEntry(displayName, Init, paramType);
                    break;
                }

                case "textdump":
                {
                    control = new TextDump(displayName, Init, paramType);
                    break;
                }

                case "checkbox":
                {
                    int  val  = 0;
                    bool temp = false;
                    if (Init != "")
                    {
                        val = Convert.ToInt32(Init);
                        if (val >= 1)
                        {
                            temp = true;
                        }
                        else
                        {
                            temp = false;
                        }
                        //temp = Convert.ToBoolean(Init);
                    }
                    control = new Stellarmap.Check(displayName, temp, paramType, "");
                    break;
                }

                case "combomapbuilder":
                {
                    control = new Stellarmap.ComboMapBuilder(displayName, Values.ToArray(), Init, paramType);
                    break;
                }

                case "rightcombomapbuilder":
                {
                    control = new Stellarmap.RightComboMapBuilder(displayName, Values.ToArray(), Init, paramType);
                    break;
                }

                case "doublecombomapbuilder":
                {
                    control = new Stellarmap.DoubleComboMap(displayName, Values.ToArray(), Values2.ToArray(), Init, Init2, paramType);
                    break;
                }

                case "combolistbuilder":
                {
                    control = new Stellarmap.ComboListBuilder(displayName, Values.ToArray(), Init, paramType);
                    break;
                }

                case "param":
                {
                    break;
                }

                case "multiparam":
                {
                    if (c.Children != null)
                    {
                        List <FunctionControlParam> paramList = new List <FunctionControlParam>();
                        foreach (object obj in CreateControlsList(c.Children))
                        {
                            IFunctionControl funcControl = obj as IFunctionControl;
                            if (funcControl != null)
                            {
                                string init = funcControl.PullEntry();
                                if (init.Length < 1 || init == "({})" || init == "([])" || init == "")
                                {
                                    init = null;
                                }
                                paramList.Add(new FunctionControlParam(funcControl.FunctionName, funcControl.LabelText,
                                                                       funcControl.FunctionControlType, funcControl.ParameterType,
                                                                       funcControl.KeyType, funcControl.ValueType, init));
                            }
                        }

                        control = (Control) new FlexiFunction(displayName, c.Attributes["function"], (List <FunctionControlParam>)paramList);
                    }
                    else
                    {
                        break;
                    }
                    //MessageBox.Show("Failed to load a dynamic control. No support for 'Multiparam' yet.");

                    IFunctionControl func = control as IFunctionControl;
                    if (func != null)
                    {
                        func.FunctionName   = c.Attributes["function"];
                        func.Enabled        = enabled;
                        func.RequiredHeader = header;
                        //TODO: set tool tip here as well
                    }
                    return(control);
                }

                //case "window":
                //    {
                //    break;
                //    }
                case "tab":
                {
                    TabControl tab = new TabControl();
                    tab.Name = displayName;

                    //List<Control> subcons = this.CreateControlsList(c.Children);
                    List <Control> subcons = new List <Control>();
                    foreach (object obj in CreateControlsList(c.Children))
                    {
                        Control c2 = obj as Control;
                        if (c2 != null)
                        {
                            subcons.Add(c2);
                        }
                    }
                    if (subcons != null)
                    {
                        tab.Controls.AddRange(subcons.ToArray());
                    }
                    break;
                }
                }
                #endregion
            }                    //end try

            catch (Stellarmap.InvalidFunctionControlParamException e)
            {
                MessageBox.Show("Could not generate dynamic controls. You hosed one of the xml file's ParamTypes.\n" + e.Message);
                return(null);
            }

            if (control as Control != null)
            {
                IFunctionControl func = control as IFunctionControl;
                if (func != null)
                {
                    func.FunctionName   = c.Attributes["function"];
                    func.Enabled        = enabled;
                    func.RequiredHeader = header;
                    if (keyType != EntryType.NA)
                    {
                        func.KeyType = keyType;
                    }
                    if (valueType != EntryType.NA)
                    {
                        func.ValueType = valueType;
                    }
                    //TODO: set tool tip here as well
                }

                keyType     = EntryType.NA;
                valueType   = EntryType.NA;
                Values      = null;
                Values2     = null;
                Init        = null;
                Init2       = null;
                displayName = "";
                paramType   = FuncParamType.None;
            }

            return(control);
        }