/// <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"); // Make sure we cache the delegate locally to avoid other threads unsubscribing before we call them. // See http://piers7.blogspot.com/2010/03/3-races-with-net-events.html for info. EventHandler<AddSettingsPagesEventArgs> handlers = this.AddSettingsPages; if (handlers != null) { handlers(this, e); } }
/// <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> /// <returns>Returns true if at least one settings change was made.</returns> internal bool ShowSettings(string settingsPath, string id) { Param.AssertValidString(settingsPath, "settingsPath"); Param.AssertValidString(id, "id"); // 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()); // And the spelling tab after that. pages.Insert(3, new SpellingTab()); // 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); } // Display the project settings dialog. return this.ShowProjectSettings(settingsPath, pages.AsReadOnly(), id); } finally { if (pages != null) { foreach (IPropertyControlPage page in pages) { IDisposable disposable = page as IDisposable; disposable.Dispose(); } } } }
/// <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); } }