Exemple #1
0
        /// <summary>
        /// Sets the values of the specified group of property settings.
        /// </summary>
        /// <param name="context">
        /// A <see cref="T:System.Configuration.SettingsContext"/> describing the current
        /// application usage.
        /// </param>
        /// <param name="values">
        /// A <see cref="T:System.Configuration.SettingsPropertyValueCollection"/> representing the
        /// group of property settings to set.
        /// </param>
        public override void SetPropertyValues(SettingsContext context, SettingsPropertyValueCollection values)
        {
            try
            {
                var settingsPath = SettingsContextHelper.GetSolutionSettingsPath(context) ?? SettingsContextHelper.GetUserSettingsPath();
                var sectionName  = GetSectionName(context);

                WriteSettingsToFile(settingsPath, sectionName, values);
            }
            catch (Exception ex)
            {
                OutputWindowHelper.ExceptionWriteLine("Unable to SetPropertyValues.", ex);
                throw;
            }
        }
Exemple #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OptionsViewModel" /> class.
        /// </summary>
        /// <param name="package">The hosting package.</param>
        /// <param name="initiallySelectedPageType">The type of the initially selected page.</param>
        public OptionsViewModel(CodeMaidPackage package, Type initiallySelectedPageType = null)
        {
            _settingsContextHelper = SettingsContextHelper.GetInstance(package);

            ActiveSettings = (Settings)SettingsBase.Synchronized(new Settings());
            IsActiveSolutionSpecificSettings = _settingsContextHelper.LoadSolutionSpecificSettings(ActiveSettings);

            Package = package;
            Pages = new OptionsPageViewModel[]
                        {
                            new GeneralViewModel(package, ActiveSettings),
                            new CleaningParentViewModel(package, ActiveSettings)
                                {
                                    Children = new OptionsPageViewModel[]
                                    {
                                        new CleaningGeneralViewModel(package, ActiveSettings),
                                        new CleaningFileTypesViewModel(package, ActiveSettings),
                                        new CleaningVisualStudioViewModel(package, ActiveSettings),
                                        new CleaningInsertViewModel(package, ActiveSettings),
                                        new CleaningRemoveViewModel(package, ActiveSettings),
                                        new CleaningUpdateViewModel(package, ActiveSettings)
                                    }
                                },
                            new CollapsingViewModel(package, ActiveSettings),
                            new DiggingViewModel(package, ActiveSettings),
                            new FindingViewModel(package, ActiveSettings),
                            new FormattingViewModel(package, ActiveSettings),
                            new ProgressingViewModel(package, ActiveSettings),
                            new ReorganizingParentViewModel(package, ActiveSettings)
                            {
                                Children = new OptionsPageViewModel[]
                                {
                                    new ReorganizingGeneralViewModel(package, ActiveSettings),
                                    new ReorganizingTypesViewModel(package, ActiveSettings),
                                    new ReorganizingRegionsViewModel(package, ActiveSettings)
                                }
                            },
                            new SwitchingViewModel(package, ActiveSettings),
                            new ThirdPartyViewModel(package, ActiveSettings)
                        };

            SelectedPage = Pages.Flatten().FirstOrDefault(x => x.GetType() == (initiallySelectedPageType ?? typeof(GeneralViewModel)));

            ReloadPagesFromSettings();
        }
Exemple #3
0
        /// <summary>
        /// Returns the collection of setting property values for the specified application instance
        /// and settings property group.
        /// </summary>
        /// <param name="context">
        /// A <see cref="T:System.Configuration.SettingsContext"/> describing the current
        /// application usage.
        /// </param>
        /// <param name="properties">
        /// A <see cref="T:System.Configuration.SettingsPropertyCollection"/> containing the
        /// settings property group whose values are to be retrieved.
        /// </param>
        /// <returns>
        /// A <see cref="T:System.Configuration.SettingsPropertyValueCollection"/> containing the
        /// values for the specified settings property group.
        /// </returns>
        public override SettingsPropertyValueCollection GetPropertyValues(SettingsContext context, SettingsPropertyCollection properties)
        {
            try
            {
                var solutionSettingsPath = SettingsContextHelper.GetSolutionSettingsPath(context);
                var userSettingsPath     = SettingsContextHelper.GetUserSettingsPath();
                var sectionName          = GetSectionName(context);

                var userSettings     = ReadSettingsFromFile(userSettingsPath, sectionName);
                var solutionSettings = ReadSettingsFromFile(solutionSettingsPath, sectionName);

                var propertyValues = MergeSettingsIntoPropertyValues(userSettings, solutionSettings, properties);

                return(propertyValues);
            }
            catch (Exception ex)
            {
                OutputWindowHelper.ExceptionWriteLine("Unable to GetPropertyValues.", ex);
                throw;
            }
        }
 /// <summary>
 /// Gets an instance of the <see cref="SettingsContextHelper" /> class.
 /// </summary>
 /// <param name="package">The hosting package.</param>
 /// <returns>An instance of the <see cref="SettingsContextHelper" /> class.</returns>
 internal static SettingsContextHelper GetInstance(CodeMaidPackage package)
 {
     return _instance ?? (_instance = new SettingsContextHelper(package));
 }
 /// <summary>
 /// Gets an instance of the <see cref="SettingsContextHelper" /> class.
 /// </summary>
 /// <param name="package">The hosting package.</param>
 /// <returns>An instance of the <see cref="SettingsContextHelper" /> class.</returns>
 internal static SettingsContextHelper GetInstance(CodeMaidPackage package)
 {
     return(_instance ?? (_instance = new SettingsContextHelper(package)));
 }