/// <summary> /// Perform special actions when the page is to be committed. /// </summary> /// <remarks> /// Stores the current state of the settings. Ensure that the project is set dirty if the settings have changed from the original values. /// Setting the project dirty ensure that the application asks to "save changes" when the project is closed. The settings will be /// saved when the project is saved. /// </remarks> /// <returns>A Task that represents CommitAsync</returns> protected override Task CommitAsync() { if (IsDirty()) { // store the new settings in the dictionary ... save happens in OnProjectSave Dictionary <string, string> settings = Module1.Current.Settings; if (settings.ContainsKey("Setting1")) { settings["Setting1"] = ModuleSetting1.ToString(); } else { settings.Add("Setting1", ModuleSetting1.ToString()); } if (settings.ContainsKey("Setting2")) { settings["Setting2"] = ModuleSetting2; } else { settings.Add("Setting2", ModuleSetting2); } // set the project dirty Project.Current.SetDirty(true); } return(Task.FromResult(0)); }
/// <summary> /// Invoked when the OK or apply button on the property sheet has been clicked. /// </summary> /// <returns>A task that represents the work queued to execute in the ThreadPool.</returns> /// <remarks>This function is only called if the page has set its IsModified flag to true.</remarks> protected override Task CommitAsync() { try { if (IsDirty()) { // store the new settings in the dictionary ... save happens in OnProjectSave Dictionary <string, string> settings = SapConfigModule.Current.Settings; if (settings.ContainsKey("Setting1")) { settings["Setting1"] = ModuleSetting1.ToString(); } else { settings.Add("Setting1", ModuleSetting1.ToString()); } if (settings.ContainsKey("Setting2")) { settings["Setting2"] = ModuleSetting2; } else { settings.Add("Setting2", ModuleSetting2); } if (settings.ContainsKey("Setting3")) { settings["Setting3"] = ModuleSetting3; } else { settings.Add("Setting3", ModuleSetting3); } // set the project dirty Project.Current.SetDirty(true); } return(Task.FromResult(0)); } catch (Exception ex) { MessageBox.Show("Error : " + ex.Message.ToString() + " "); return(null); } }