Beispiel #1
0
        private void SolutionProjectOptionsVmOnPropertyChanged(object sender, PropertyChangedEventArgs args)
        {
            var solution = (ProjectOptionsUserControlViewModel)sender;

            // Index 0 is the solution, so we start at 1.
            for (int index = 1; index < ProjectsOptions.Count; index++)
            {
                var po = ProjectsOptions[index];

                switch (args.PropertyName)
                {
                case "ViewModelSuffix":
                    // if the solution's old suffix was the same as the project's current
                    // value, update it to match the solution's new suffix.  If the old value
                    // was different from the project's suffix, then the user has changed
                    // it and the suffix is no longer considered inherited so we do nothing.
                    if (po.ViewModelSuffix == (string)_oldValue)
                    {
                        po.ViewModelSuffix = solution.ViewModelSuffix;
                    }
                    ResetAllToInheritedCommand.RaiseCanExecuteChanged();
                    break;
                }
            }
        }
Beispiel #2
0
        private void UpdateLocationDescriptor(string propertyName, bool isView)
        {
            // This method is called by each of the PropertyChanged handlers, once
            // with isView==true, and once isView==false.
            // The path here is to use the _oldValue (which is the property value
            // we saved in the PropertyChanging event handler), and if the
            // solution's original value (_oldValue) is the same as the location
            // descriptor vm (for the chainged property), we copy in (inherit)
            // the the project's location descriptor.

            // Index 0 is the solution, so we start at 1.
            for (int index = 1; index < ProjectsOptions.Count; index++)
            {
                var projectOptions = ProjectsOptions[index];

                var solution = ProjectsOptions[0];

                switch (propertyName)
                {
                case "ProjectIdentifier":
                    if (isView)
                    {
                        if (projectOptions.LocationDescriptorForView.ProjectIdentifier == (string)_oldValue)
                        {
                            projectOptions.LocationDescriptorForView.ProjectIdentifier = solution.LocationDescriptorForView.ProjectIdentifier;
                        }
                    }
                    else
                    {
                        if (projectOptions.LocationDescriptorForViewModel.ProjectIdentifier == (string)_oldValue)
                        {
                            projectOptions.LocationDescriptorForViewModel.ProjectIdentifier = solution.LocationDescriptorForViewModel.ProjectIdentifier;
                        }
                    }
                    ResetAllToInheritedCommand.RaiseCanExecuteChanged();
                    break;

                case "PathOffProject":
                    if (isView)
                    {
                        if (projectOptions.LocationDescriptorForView.PathOffProject == (string)_oldValue)
                        {
                            projectOptions.LocationDescriptorForView.PathOffProject = solution.LocationDescriptorForView.PathOffProject;
                        }
                    }
                    else
                    {
                        if (projectOptions.LocationDescriptorForViewModel.PathOffProject == (string)_oldValue)
                        {
                            projectOptions.LocationDescriptorForViewModel.PathOffProject = solution.LocationDescriptorForViewModel.PathOffProject;
                        }
                    }
                    ResetAllToInheritedCommand.RaiseCanExecuteChanged();
                    break;

                case "Namespace":
                    if (isView)
                    {
                        if (projectOptions.LocationDescriptorForView.Namespace == (string)_oldValue)
                        {
                            projectOptions.LocationDescriptorForView.Namespace = solution.LocationDescriptorForView.Namespace;
                        }
                    }
                    else
                    {
                        if (projectOptions.LocationDescriptorForViewModel.Namespace == (string)_oldValue)
                        {
                            projectOptions.LocationDescriptorForViewModel.Namespace = solution.LocationDescriptorForViewModel.Namespace;
                        }
                    }
                    ResetAllToInheritedCommand.RaiseCanExecuteChanged();
                    break;
                }
            }
        }
Beispiel #3
0
        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();
        }