Exemplo n.º 1
0
        /// <summary>
        /// Displays the settings dialog for a project.
        /// </summary>
        /// <param name="settingsPath">The path to the settings to edit.</param>
        /// <param name="id">The ID of the settings property page.</param>
        /// <param name="defaultSettings">The settings being shown are the default settings for the installation.</param>
        /// <returns>Returns true if at least one settings change was made.</returns>
        internal bool ShowSettings(string settingsPath, string id, bool defaultSettings)
        {
            Param.AssertValidString(settingsPath, "settingsPath");
            Param.AssertValidString(id, "id");
            Param.Ignore(defaultSettings);

            // Get the list of settings pages from each of the analyzers and parsers.
            List<IPropertyControlPage> pages = StyleCopCore.GetSettingsPages(this);

            try
            {
                // Add the analyzer options page at the beginning.
                pages.Insert(0, new AnalyzersOptions());

                // And insert the settings tab after that.
                pages.Insert(1, new GlobalSettingsFileOptions());

                // And the cache tab after that.
                pages.Insert(2, new CacheOptions());

                // Get settings pages from event listeners and add them to the end.
                AddSettingsPagesEventArgs eventArgs = new AddSettingsPagesEventArgs(settingsPath);
                this.OnAddSettingsPages(eventArgs);

                foreach (IPropertyControlPage pageFromEvent in eventArgs.Pages)
                {
                    pages.Add(pageFromEvent);
                }

                // Set the appropriate dialog title.
                string title = defaultSettings ? Strings.DefaultSettingsDialogTitle : Strings.LocalSettingsDialogTitle;

                // Display the project settings dialog.
                return this.ShowProjectSettings(settingsPath, pages.AsReadOnly(), title, id, defaultSettings);
            }
            finally
            {
                if (pages != null)
                {
                    foreach (IPropertyControlPage page in pages)
                    {
                        IDisposable disposable = page as IDisposable;
                        disposable.Dispose();
                    }
                }
            }
        }
Exemplo n.º 2
0
 private void OnAddSettingsPages(AddSettingsPagesEventArgs e)
 {
     if (this.AddSettingsPages != null)
     {
         this.AddSettingsPages(this, e);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Event that is fired before the settings dialog is displayed, to allow
        /// listeners to add settings pages.
        /// </summary>
        /// <param name="e">The event arguments.</param>
        private void OnAddSettingsPages(AddSettingsPagesEventArgs e)
        {
            Param.AssertNotNull(e, "e");

            if (this.AddSettingsPages != null)
            {
                this.AddSettingsPages(this, e);
            }
        }
Exemplo n.º 4
0
 internal bool ShowSettings(string settingsPath, string id, bool defaultSettings)
 {
     List<IPropertyControlPage> settingsPages = GetSettingsPages(this);
     settingsPages.Insert(0, new AnalyzersOptions());
     settingsPages.Insert(1, new GlobalSettingsFileOptions());
     settingsPages.Insert(2, new CacheOptions());
     AddSettingsPagesEventArgs e = new AddSettingsPagesEventArgs(settingsPath);
     this.OnAddSettingsPages(e);
     foreach (IPropertyControlPage page in e.Pages)
     {
         settingsPages.Add(page);
     }
     string caption = defaultSettings ? Strings.DefaultSettingsDialogTitle : Strings.LocalSettingsDialogTitle;
     return this.ShowProjectSettings(settingsPath, settingsPages.AsReadOnly(), caption, id, defaultSettings);
 }