Example #1
0
        public virtual void Apply(ConfTree conf)
        {
            if (conf == null)
            {
                return;
            }

            CurrentConf = conf;
            conf.Visit("Apply", (item, level) =>
            {
                if (item is ConfItem)
                {
                    if (item.Attributes.ContainsKey("guitype") && item.Attributes["guitype"] == "RadioButton")
                    {
                        var control = Controls.Find($"{item.Name}_{item.Value}", true);
                        if (control.Length > 0)
                        {
                            (control[0] as RadioButton).Checked = true;
                        }
                    }
                    else if (item.Attributes.ContainsKey("guitype") && item.Attributes["guitype"].Contains("ComboBox"))
                    {
                        var control = Controls.Find($"{item.Name}", true);
                        if (control.Length > 0)
                        {
                            var cb = (control[0] as ComboBox);

                            var type_value = item.Attributes["guitype"].Split(':');
                            if (type_value.Length > 1)
                            {
                                cb.DataSource    = type_value[1].Split(',');
                                cb.SelectedIndex = cb.Items.IndexOf(item.Value);
                            }
                            else
                            {
                                control[0].Text = item.Value;
                            }
                        }
                    }
                    else
                    {
                        var control = Controls.Find(item.Name, true);
                        if (control.Length > 0)
                        {
                            control[0].Text = item.Value;
                        }
                    }
                }

                return(false);
            });
        }