public OptionsCollectionViewModel( bool expandAllSyncProfiles, Func <Guid, string> profileDataDirectoryFactory, IUiService uiService, IOptionTasks optionTasks, IProfileTypeRegistry profileTypeRegistry, Func <IOptionsViewModelParent, IProfileType, IProfileModelFactory> profileModelFactoryFactory, IViewOptions viewOptions) { _optionTasks = optionTasks; ViewOptions = viewOptions; _profileDataDirectoryFactory = profileDataDirectoryFactory; _uiService = uiService; if (profileDataDirectoryFactory == null) { throw new ArgumentNullException(nameof(profileDataDirectoryFactory)); } if (optionTasks == null) { throw new ArgumentNullException(nameof(optionTasks)); } if (viewOptions == null) { throw new ArgumentNullException(nameof(viewOptions)); } _expandAllSyncProfiles = expandAllSyncProfiles; _profileTypeRegistry = profileTypeRegistry; _profileModelFactoriesByType = profileTypeRegistry.AllTypes.ToDictionary(t => t, t => profileModelFactoryFactory(this, t)); RegisterPropertyChangeHandler(viewOptions, nameof(viewOptions.IsAdvancedViewEnabled), () => { if (!viewOptions.IsAdvancedViewEnabled) { OnAdvancedViewDisabled(); } }); AddCommand = new DelegateCommand(_ => Add()); AddMultipleCommand = new DelegateCommand(_ => AddMultiple()); CloseCommand = new DelegateCommand(shouldSaveNewOptions => Close((bool)shouldSaveNewOptions)); DeleteSelectedCommand = new DelegateCommandHandlingRequerySuggested(_ => DeleteSelected(), _ => CanDeleteSelected); ClearCacheOfSelectedCommand = new DelegateCommandHandlingRequerySuggested(_ => ClearCacheOfSelected(), _ => CanClearCacheOfSelected); CopySelectedCommand = new DelegateCommandHandlingRequerySuggested(_ => CopySelected(), _ => CanCopySelected); MoveSelectedUpCommand = new DelegateCommandHandlingRequerySuggested(_ => MoveSelectedUp(), _ => CanMoveSelectedUp); MoveSelectedDownCommand = new DelegateCommandHandlingRequerySuggested(_ => MoveSelectedDown(), _ => CanMoveSelectedDown); OpenProfileDataDirectoryCommand = new DelegateCommandHandlingRequerySuggested(_ => OpenProfileDataDirectory(), _ => CanOpenProfileDataDirectory); ExpandAllCommand = new DelegateCommandHandlingRequerySuggested(_ => ExpandAll(), _ => _options.Count > 0); CollapseAllCommand = new DelegateCommandHandlingRequerySuggested(_ => CollapseAll(), _ => _options.Count > 0); ExportAllCommand = new DelegateCommandHandlingRequerySuggested(_ => ExportAll(), _ => _options.Count > 0); ImportCommand = new DelegateCommandHandlingRequerySuggested(_ => Import(), _ => true); }
public OptionsCollectionViewModel( GeneralOptions generalOptions, IOutlookAccountPasswordProvider outlookAccountPasswordProvider, IReadOnlyList <string> availableEventCategories, Func <Guid, string> profileDataDirectoryFactory, IUiService uiService, IOptionTasks optionTasks) { _optionTasks = optionTasks; _profileDataDirectoryFactory = profileDataDirectoryFactory; _uiService = uiService; if (generalOptions == null) { throw new ArgumentNullException(nameof(generalOptions)); } if (profileDataDirectoryFactory == null) { throw new ArgumentNullException(nameof(profileDataDirectoryFactory)); } if (optionTasks == null) { throw new ArgumentNullException(nameof(optionTasks)); } _generalOptions = generalOptions; _optionsViewModelFactory = new OptionsViewModelFactory( this, outlookAccountPasswordProvider, availableEventCategories, optionTasks); AddCommand = new DelegateCommand(_ => Add()); AddMultipleCommand = new DelegateCommand(_ => AddMultiple()); CloseCommand = new DelegateCommand(shouldSaveNewOptions => Close((bool)shouldSaveNewOptions)); DeleteSelectedCommand = new DelegateCommandHandlingRequerySuggested(_ => DeleteSelected(), _ => CanDeleteSelected); CopySelectedCommand = new DelegateCommandHandlingRequerySuggested(_ => CopySelected(), _ => CanCopySelected); MoveSelectedUpCommand = new DelegateCommandHandlingRequerySuggested(_ => MoveSelectedUp(), _ => CanMoveSelectedUp); MoveSelectedDownCommand = new DelegateCommandHandlingRequerySuggested(_ => MoveSelectedDown(), _ => CanMoveSelectedDown); OpenProfileDataDirectoryCommand = new DelegateCommandHandlingRequerySuggested(_ => OpenProfileDataDirectory(), _ => CanOpenProfileDataDirectory); ExpandAllCommand = new DelegateCommandHandlingRequerySuggested(_ => ExpandAll(), _ => _options.Count > 0); CollapseAllCommand = new DelegateCommandHandlingRequerySuggested(_ => CollapseAll(), _ => _options.Count > 0); ExportAllCommand = new DelegateCommandHandlingRequerySuggested(_ => ExportAll(), _ => _options.Count > 0); ImportCommand = new DelegateCommandHandlingRequerySuggested(_ => Import(), _ => true); }
public OptionsCollectionViewModel ( GeneralOptions generalOptions, IOutlookAccountPasswordProvider outlookAccountPasswordProvider, IReadOnlyList<string> availableEventCategories, Func<Guid, string> profileDataDirectoryFactory, IUiService uiService, IOptionTasks optionTasks) { _optionTasks = optionTasks; _profileDataDirectoryFactory = profileDataDirectoryFactory; _uiService = uiService; if (generalOptions == null) throw new ArgumentNullException (nameof (generalOptions)); if (profileDataDirectoryFactory == null) throw new ArgumentNullException (nameof (profileDataDirectoryFactory)); if (optionTasks == null) throw new ArgumentNullException(nameof(optionTasks)); _generalOptions = generalOptions; _optionsViewModelFactory = new OptionsViewModelFactory ( this, outlookAccountPasswordProvider, availableEventCategories, optionTasks); AddCommand = new DelegateCommand (_ => Add()); AddMultipleCommand = new DelegateCommand (_ => AddMultiple()); CloseCommand = new DelegateCommand (shouldSaveNewOptions => Close((bool)shouldSaveNewOptions)); DeleteSelectedCommand = new DelegateCommandHandlingRequerySuggested (_ => DeleteSelected (), _ => CanDeleteSelected); CopySelectedCommand = new DelegateCommandHandlingRequerySuggested (_ => CopySelected (), _ => CanCopySelected); MoveSelectedUpCommand = new DelegateCommandHandlingRequerySuggested (_ => MoveSelectedUp (), _ => CanMoveSelectedUp); MoveSelectedDownCommand = new DelegateCommandHandlingRequerySuggested (_ => MoveSelectedDown (), _ => CanMoveSelectedDown); OpenProfileDataDirectoryCommand = new DelegateCommandHandlingRequerySuggested (_ => OpenProfileDataDirectory (), _ => CanOpenProfileDataDirectory); ExpandAllCommand = new DelegateCommandHandlingRequerySuggested (_ => ExpandAll (), _ => _options.Count > 0); CollapseAllCommand = new DelegateCommandHandlingRequerySuggested (_ => CollapseAll (), _ => _options.Count > 0); ExportAllCommand = new DelegateCommandHandlingRequerySuggested (_ => ExportAll (), _ => _options.Count > 0); ImportCommand = new DelegateCommandHandlingRequerySuggested (_ => Import (), _ => true); }