public void ExecuteAddViewSuffixCommand() { try { var vm = Kernel.Get <StringDialogViewModel>(); vm.Add(true, "Add View Suffix", "View Suffix:", ViewSuffixes?.Select(s => s.Value), SuffixRegex, SuffixRegexErrorMessage); if (DialogService.ShowDialog(vm)) { var newItem = StringViewModel.CreateFromString(Kernel, vm.Value); ViewSuffixesView.AddNewItem(newItem); // ReSharper disable once PossibleNullReferenceException ViewSuffixesView.MoveCurrentTo(newItem); } } catch { // ignored } }
public void ExecuteRestoreDefaultViewSuffixesCommand() { try { ViewSuffixes = new ObservableCollection <StringViewModel>(SettingsService.DefaultViewSuffixes.Select(s => StringViewModel.CreateFromString(Kernel, s))); } catch { // ignored } }
public async Task RevertSettings() { // If we haven't fully loaded and the user cancels the dialog, // _unmodifiedSettings will be null so abort. if (_unmodifiedSettings == null) { return; } // Reverts properties to the values saved in _unmodifiedSettings. This // is used to cancel changes or to set the properties' initial values. // Unsubscribe from solution events on the old solution. var oldSolutionVm = ProjectsOptions?.FirstOrDefault(); if (oldSolutionVm != null) { oldSolutionVm.PropertyChanging -= SolutionProjectOptionsVmOnPropertyChanging; oldSolutionVm.LocationDescriptorForViewModel.PropertyChanging -= LocationDescriptorOnPropertyChanging; oldSolutionVm.LocationDescriptorForView.PropertyChanging -= LocationDescriptorOnPropertyChanging; oldSolutionVm.PropertyChanged -= SolutionProjectOptionsVmOnPropertyChanged; oldSolutionVm.LocationDescriptorForViewModel.PropertyChanged -= LocationDescriptorForViewModelOnPropertyChanged; oldSolutionVm.LocationDescriptorForView.PropertyChanged -= LocationDescriptorForViewOnPropertyChanged; } SelectedGoToViewOrViewModelOption = _unmodifiedSettings.GoToViewOrViewModelOption; GoToViewOrViewModelSearchSolution = _unmodifiedSettings.GoToViewOrViewModelSearchSolution; ViewSuffixes = new ObservableCollection <StringViewModel>(_unmodifiedSettings.ViewSuffixes.Select(s => StringViewModel.CreateFromString(Kernel, s))); LocalTemplateFolder = _unmodifiedSettings.LocalTemplateFolder; // Add solution and other projects. var tmp = new List <ProjectOptionsUserControlViewModel>(); if (_unmodifiedSettings.SolutionOptions != null) { // Create global vm defaults using the global defaults. var solutiondefaultProjectOptionsVm = await CreateProjectOptionsUserControlViewModel(SettingsService.SolutionDefaultProjectOptions, null, false); // Use the global defaults in the solution vm. var solutionProjectOptionsVm = await CreateProjectOptionsUserControlViewModel(_unmodifiedSettings.SolutionOptions, solutiondefaultProjectOptionsVm, false); tmp.Add(solutionProjectOptionsVm); // Subscribe to solution PropertyChanging and PropertyChanged events so we can // pass them down to the projects. solutionProjectOptionsVm.PropertyChanging += SolutionProjectOptionsVmOnPropertyChanging; solutionProjectOptionsVm.LocationDescriptorForViewModel.PropertyChanging += LocationDescriptorOnPropertyChanging; solutionProjectOptionsVm.LocationDescriptorForView.PropertyChanging += LocationDescriptorOnPropertyChanging; solutionProjectOptionsVm.PropertyChanged += SolutionProjectOptionsVmOnPropertyChanged; solutionProjectOptionsVm.LocationDescriptorForViewModel.PropertyChanged += LocationDescriptorForViewModelOnPropertyChanged; solutionProjectOptionsVm.LocationDescriptorForView.PropertyChanged += LocationDescriptorForViewOnPropertyChanged; // Use the solution vm as the inherited for all the projects. foreach (var po in _unmodifiedSettings.ProjectOptions) { tmp.Add(await CreateProjectOptionsUserControlViewModel(po, solutionProjectOptionsVm, true)); } } ProjectsOptions = tmp; ResetAllToInheritedCommand.RaiseCanExecuteChanged(); }