public ConfigurationViewModel() { // Data UserName = new PropertyModel <string>(); Sites = new ObservableCollection <ConfigurationSiteViewModel>(); SelectedItem = new PropertyModel <ConfigurationSiteViewModel>(); SelectedItemScrollTo = new PropertyReadonlyModel <ConfigurationSiteViewModel>(); // helper to influence grid selection GeneratedForSite = new PropertyReadonlyModel <string>(); GeneratedPassword = new PropertyReadonlyModel <string>(); CurrentMasterPassword = new PropertyModel <SecureString>(); ResetMasterPassword = new PropertyReadonlyModel <bool>(); LastClipboardAction = new PropertyReadonlyModel <string>(); CurrentMasterPassword.PropertyChanged += delegate { ResetMasterPassword.SetValue(false); }; // Commands Add = new DelegateCommand(() => PerformAdd()); RemoveSelected = new DelegateCommand(() => { if (CanRemove(SelectedItem.Value)) { Sites.Remove(SelectedItem.Value); } }, () => SelectedItem.Value != null); GeneratePassword = new DelegateCommand(DoGeneratePassword, () => CurrentMasterPassword.Value != null && SelectedItem.Value != null); CopyToClipBoard = new DelegateCommand(DoCopyPassToClipboard, () => !string.IsNullOrEmpty(GeneratedPassword.Value) && CurrentMasterPassword.Value != null); CopyLoginToClipBoard = new DelegateCommand(DoCopyLoginToClipboard, () => SelectedItem.Value != null); // Change detection DetectChanges = new GenericChangeDetection(); DetectChanges.AddINotifyPropertyChanged(UserName); DetectChanges.AddCollectionOfIDetectChanges(Sites, item => item.DetectChanges); }
public ConfigurationViewModel() { // Data UserName = new PropertyModel<string>(); Sites = new ObservableCollection<ConfigurationSiteViewModel>(); SelectedItem = new PropertyModel<ConfigurationSiteViewModel>(); SelectedItemScrollTo = new PropertyReadonlyModel<ConfigurationSiteViewModel>(); // helper to influence grid selection GeneratedForSite = new PropertyReadonlyModel<string>(); GeneratedPassword = new PropertyReadonlyModel<string>(); CurrentMasterPassword = new PropertyModel<SecureString>(); ResetMasterPassword = new PropertyReadonlyModel<bool>(); LastClipboardAction = new PropertyReadonlyModel<string>(); CurrentMasterPassword.PropertyChanged += delegate { ResetMasterPassword.SetValue(false); }; // Commands Add = new DelegateCommand(() => PerformAdd()); RemoveSelected = new DelegateCommand(() => { if (CanRemove(SelectedItem.Value)) Sites.Remove(SelectedItem.Value); }, () => SelectedItem.Value != null); GeneratePassword = new DelegateCommand(DoGeneratePassword, () => CurrentMasterPassword.Value != null && SelectedItem.Value != null); CopyToClipBoard = new DelegateCommand(DoCopyPassToClipboard, () => !string.IsNullOrEmpty(GeneratedPassword.Value) && CurrentMasterPassword.Value != null); CopyLoginToClipBoard = new DelegateCommand(DoCopyLoginToClipboard, () => SelectedItem.Value != null); // Change detection DetectChanges = new GenericChangeDetection(); DetectChanges.AddINotifyPropertyChanged(UserName); DetectChanges.AddCollectionOfIDetectChanges(Sites, item => item.DetectChanges); }
public ConfigurationSiteViewModel() { SiteName = new PropertyModel <string>(); Login = new PropertyModel <string>(); Counter = new PropertyModel <int>(1); // default should be 1? TypeOfPassword = new PropertyModel <PasswordType>(); DetectChanges = new GenericChangeDetection(); DetectChanges.AddINotifyPropertyChanged(SiteName); DetectChanges.AddINotifyPropertyChanged(Login); DetectChanges.AddINotifyPropertyChanged(Counter); DetectChanges.AddINotifyPropertyChanged(TypeOfPassword); }
public ConfigurationSiteViewModel() { SiteName = new PropertyModel<string>(); Login = new PropertyModel<string>(); Counter = new PropertyModel<int>(1); // default should be 1? TypeOfPassword = new PropertyModel<PasswordType>(); DetectChanges = new GenericChangeDetection(); DetectChanges.AddINotifyPropertyChanged(SiteName); DetectChanges.AddINotifyPropertyChanged(Login); DetectChanges.AddINotifyPropertyChanged(Counter); DetectChanges.AddINotifyPropertyChanged(TypeOfPassword); }