private void SetAddressBookAndUpdateViewModel(AddressBook addressBook) { Entries = new ObservableCollection <EntryViewModel>(); foreach (AddressBookEntry abe in addressBook.Entries) { EntryViewModel evm = new EntryViewModel(); evm.Source = abe; foreach (EntryDataItem edi in abe.Data) { EntryDataItemViewModel edivm = new EntryDataItemViewModel(evm); edivm.IsEnabled = edi.IsEnabled; edivm.Source = edi; edivm.Editor = CustomDataEditors.CustomDataEditorCache.CreateTypeEditor(edi.Identifier); if (edivm.Editor != null) { try { edivm.Editor.Value = edi.Data; } catch (Exception ex) { Logger.Instance.LogFormat(LogType.Error, this, Properties.Resources.ErrorWhileLoadingDataItemValue, edi.Identifier); Logger.Instance.LogException(this, ex); } } evm.DataItems.Add(edivm); } Entries.Add(evm); } }
private void SetAddressBookAndUpdateViewModel(AddressBook addressBook) { Entries = new ObservableCollection<EntryViewModel>(); foreach (AddressBookEntry abe in addressBook.Entries) { EntryViewModel evm = new EntryViewModel(); evm.Source = abe; foreach (EntryDataItem edi in abe.Data) { EntryDataItemViewModel edivm = new EntryDataItemViewModel(evm); edivm.IsEnabled = edi.IsEnabled; edivm.Source = edi; edivm.Editor = CustomDataEditors.CustomDataEditorCache.CreateTypeEditor(edi.Identifier); if (edivm.Editor != null) { try { edivm.Editor.Value = edi.Data; } catch (Exception ex) { Logger.Instance.LogFormat(LogType.Error, this, Properties.Resources.ErrorWhileLoadingDataItemValue, edi.Identifier); Logger.Instance.LogException(this, ex); } } evm.DataItems.Add(edivm); } Entries.Add(evm); } }
private void AddDataItemCommand_Execute(object parameter) { string displayName = (string)parameter; ICustomDataEditor editor = CustomDataEditors.CustomDataEditorCache.CreateTypeEditorFromDisplayName(displayName); EntryDataItemViewModel vm = new EntryDataItemViewModel(this); vm.Editor = editor; DataItems.Add(vm); }
private void AddDataItemCommand_Execute(object parameter) { string displayName = (string)parameter; ICustomDataEditor editor = CustomDataEditors.CustomDataEditorCache.CreateTypeEditorFromDisplayName(displayName); EntryDataItemViewModel vm = new EntryDataItemViewModel(this); vm.Editor = editor; DataItems.Add(vm); }