예제 #1
0
 public DictionarySettingItemVM(string key, SettingsNodeVM value)
 {
     Key   = key;
     Value = value;
 }
 public EnumDictionarySettingsVM(FieldMeta fieldMeta, KeyValuePair <string, SettingsNodeVM>[] values, SettingsNodeVM prototype)
     : base(fieldMeta, values, prototype)
 {
 }
예제 #3
0
 public DictionarySettingsVM(FieldMeta fieldMeta, KeyValuePair <string, SettingsNodeVM>[] values, SettingsNodeVM prototype)
     : base(fieldMeta, values, prototype)
 {
     _dictionary = this.Items.ToDictionary(x => x.Key, x => x);
     AddCommand  = ReactiveCommand.Create(
         canExecute: this.WhenAnyValue(x => x.AddPaneText)
         .Select(x => !x.IsNullOrWhitespace() && !this._dictionary.ContainsKey(x)),
         execute: () =>
     {
         var vm = prototype.Duplicate();
         vm.WrapUp();
         var item = new DictionarySettingItemVM(AddPaneText, vm);
         _dictionary[AddPaneText] = item;
         Items.Add(item);
         AddPaneText = string.Empty;
     });
     DeleteCommand = ReactiveCommand.Create(
         canExecute: Observable.CombineLatest(
             this.WhenAnyValue(x => x.Selected).Select(x => x != null),
             this.WhenAnyValue(x => x.MidDelete),
             (hasSelected, midDelete) => hasSelected || midDelete),
         execute: () =>
     {
         MidDelete = !MidDelete;
     });
     ConfirmCommand = ReactiveCommand.Create(
         canExecute: Observable.CombineLatest(
             this.WhenAnyValue(x => x.Selected).Select(x => x != null),
             this.WhenAnyValue(x => x.MidDelete),
             (hasSelected, midDelete) => hasSelected && midDelete),
         execute: () =>
     {
         if (Selected == null)
         {
             return;
         }
         _dictionary.Remove(Selected.Key);
         Items.Remove(Selected);
         MidDelete = false;
     });
 }