/// <summary> /// The form's OnLoad event. Initializes the PropertyControl object. /// </summary> /// <param name="e">The event arguments.</param> protected override void OnLoad(EventArgs e) { Param.Ignore(e); base.OnLoad(e); if (this.helpCallback == null) { PropertyDialog.MoveButton(this.ok, this.cancel); PropertyDialog.MoveButton(this.cancel, this.apply); PropertyDialog.MoveButton(this.apply, this.help); this.help.Visible = false; } this.apply.Enabled = false; try { this.properties.Initialize(this, this.pages, this.settingsFile, this.core, this.context); } catch (IOException ioex) { AlertDialog.Show( this.core, this, string.Format(CultureInfo.CurrentUICulture, Strings.LocalSettingsNotOpenedOrCreated, ioex.Message), Strings.Title, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } catch (SecurityException secex) { AlertDialog.Show( this.core, this, string.Format(CultureInfo.CurrentUICulture, Strings.LocalSettingsNotOpenedOrCreated, secex.Message), Strings.Title, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } catch (UnauthorizedAccessException unauthex) { AlertDialog.Show( this.core, this, string.Format(CultureInfo.CurrentUICulture, Strings.LocalSettingsNotOpenedOrCreated, unauthex.Message), Strings.Title, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } catch (XmlException xmlex) { AlertDialog.Show( this.core, this, string.Format(CultureInfo.CurrentUICulture, Strings.LocalSettingsNotOpenedOrCreated, xmlex.Message), Strings.Title, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } }
/// <summary> /// Displays a settings dialog for a project. /// </summary> /// <param name="settings">The settings manager.</param> /// <param name="pages">The list of pages to display on the settings dialog.</param> /// <param name="id">A unique identifier string for the property page group.</param> /// <returns>Returns true if at least one settings change was made.</returns> internal bool ShowProjectSettings( WritableSettings settings, IList<IPropertyControlPage> pages, string id) { Param.AssertNotNull(settings, "settings"); Param.AssertNotNull(pages, "pages"); Param.AssertValidString(id, "id"); // Create the properties dialog object. using (PropertyDialog properties = new PropertyDialog(pages, settings, id, this, null)) { string styleCopTitleText = settings.DefaultSettings ? Strings.SettingsDialogTitleDefault : Strings.SettingsDialogTitleLocal; styleCopTitleText = string.Format(styleCopTitleText, this.VersionNumberMajorMinor + " (" + this.VersionNumberFull + ")"); // Set the dialog title. properties.Text = string.Format(Strings.SettingsDialogTitleFormat, styleCopTitleText, settings.Location); // Make sure that we're not running in a non-UI mode. if (!this.displayUI) { throw new InvalidOperationException(Strings.CannotDisplaySettingsInNonUIMode); } // Show the dialog. properties.ShowDialog(); // Always fire the event regardless of whether any settings were changed. This ensures // that everything is always updated properly when settings change. this.OnProjectSettingsChanged(new EventArgs()); // Return true if one or more properties were changed. return properties.SettingsChanged; } }
/// <summary> /// Displays a settings dialog for a project. /// </summary> /// <param name="settings">The settings manager.</param> /// <param name="pages">The list of pages to display on the settings dialog.</param> /// <param name="caption">The caption for the dialog.</param> /// <param name="id">A unique identifier string for the property page group.</param> /// <returns>Returns true if at least one settings change was made.</returns> internal bool ShowProjectSettings( WritableSettings settings, IList<IPropertyControlPage> pages, string caption, string id) { Param.AssertNotNull(settings, "settings"); Param.AssertNotNull(pages, "pages"); Param.AssertValidString(caption, "caption"); Param.AssertValidString(id, "id"); // Create the properties dialog object. using (PropertyDialog properties = new PropertyDialog(pages, settings, id, this, null)) { // Set the dialog title. properties.Text = caption; // Make sure that we're not running in a non-UI mode. if (!this.displayUI) { throw new InvalidOperationException(Strings.CannotDisplaySettingsInNonUIMode); } // Show the dialog. properties.ShowDialog(); // Always fire the event regardless of whether any settings were changed. This ensures // that everything is always updated properly when settings change. this.OnProjectSettingsChanged(new EventArgs()); // Return true if one or more properties were changed. return properties.SettingsChanged; } }