public WangStringOptionDataVM(SettingVM settingVM, ISetting setting, PropertyInfo property, PropertyInfo selector) : base(settingVM, setting, property)
        {
            try
            {
                var value = (string)property.GetValue(setting);
                List <TextObject> list = new List <TextObject>()
                {
                    new TextObject("{=wang_selector_none}please select a item")
                };
                _selectorIndex.Add(0, null);
                var selectedIndex = 0;

                var strs = selector.GetValue(setting);

                if (strs is IReadOnlyList <string> )
                {
                    var datas = (IReadOnlyList <string>)strs;

                    for (int i = 0; i < datas.Count; i++)
                    {
                        var text = new TextObject(datas[i]);
                        list.Add(text);
                        _selectorIndex.Add(i + 1, text.GetID());
                        if (value == text.GetID())
                        {
                            selectedIndex = i + 1;
                        }
                    }
                }
                else if (strs is Dictionary <string, TextObject> )
                {
                    var datas = (Dictionary <string, TextObject>)strs;

                    for (int i = 0; i < datas.Count; i++)
                    {
                        list.Add(datas.ElementAt(i).Value);
                        _selectorIndex.Add(i + 1, datas.ElementAt(i).Key);
                        if (value == datas.ElementAt(i).Key)
                        {
                            selectedIndex = i + 1;
                        }
                    }
                }

                this._selector = new SelectorVM <SelectorItemVM>(list, selectedIndex, new Action <SelectorVM <SelectorItemVM> >(this.UpdateValue));
            }
            catch (Exception e)
            {
                MessageBox.Show(e.FlattenException());
            }
        }
 public WangNumericOptionDataVM(SettingVM settingVM, ISetting setting, PropertyInfo property) : base(settingVM, setting, property)
 {
     this.OptionValue = (float)property.GetValue(setting);
     foreach (var item in property.GetCustomAttributes(true))
     {
         if (item as SettingNumericAttribute != null)
         {
             var b = item as SettingNumericAttribute;
             Max        = b.Max;
             Min        = b.Min;
             IsDiscrete = b.IsDiscrete;
         }
     }
     RefreshValues();
 }
        public WangGenericOptionDataVM(SettingVM settingVM, ISetting setting, PropertyInfo property)
        {
            SettingVM = settingVM;
            Setting   = setting;
            Property  = property;


            if (property.PropertyType == typeof(bool))
            {
                this.OptionTypeID = (int)WangOptionsDataType.BooleanOption;
            }
            else if (property.PropertyType == typeof(float))
            {
                this.OptionTypeID = (int)WangOptionsDataType.NumericOption;
            }
            else if (property.PropertyType == typeof(string))
            {
                this.OptionTypeID = (int)WangOptionsDataType.MultipleSelectionOption;
            }
            else if (property.PropertyType == typeof(DateTime))
            {
                this.OptionTypeID = (int)WangOptionsDataType.Blank;
                this.IsBlank      = true;
            }

            foreach (var item in property.GetCustomAttributes(true))
            {
                if (item as SettingBaseAttribute != null)
                {
                    var b = item as SettingBaseAttribute;

                    _nameObj = new TextObject(b.Name);
                    if (!string.IsNullOrEmpty(b.Description))
                    {
                        _descriptionObj = new TextObject(b.Description);
                        _descriptionObj.SetTextVariable("newline", "{=!}\n");
                    }
                }
            }

            this.RefreshValues();
        }
 public WangBlankOptionDataVM(SettingVM settingVM, ISetting setting, PropertyInfo property) : base(settingVM, setting, property)
 {
 }
 public WangBooleanOptionDataVM(SettingVM settingVM, ISetting setting, PropertyInfo property) : base(settingVM, setting, property)
 {
     this.OptionValueAsBoolean = (bool)property.GetValue(setting);
 }