/// <summary> /// Restores the location of the specified windowsForm from the location information saved in the application configuration file. /// </summary> /// <param name="windowsForm">The Form whose location is to be restored.</param> /// <param name="settingsCategory">Settings category used to persist form location information</param> public static void RestoreLocation(this Form windowsForm, string settingsCategory) { CategorizedSettingsElementCollection settings = ConfigurationFile.Current.Settings[settingsCategory]; if ((object)settings[windowsForm.Name] != null) { // Restore last saved window location WindowSetting locationSetting = new WindowSetting(settings[windowsForm.Name].Value); windowsForm.Left = locationSetting.ParamA(ScreenArea.LeftMostBound, ScreenArea.RightMostBound - windowsForm.MinimumSize.Width); windowsForm.Top = locationSetting.ParamB(ScreenArea.TopMostBound, ScreenArea.BottomMostBound - windowsForm.MinimumSize.Height); } }
/// <summary> /// Restores the size of the specified windowsForm from the size information saved in the application configuration file. /// </summary> /// <param name="windowsForm">The Form whose size is to be restored.</param> /// <param name="settingsCategory">Settings category used to persist form size information</param> public static void RestoreSize(this Form windowsForm, string settingsCategory) { CategorizedSettingsElementCollection settings = ConfigurationFile.Current.Settings[settingsCategory]; if ((object)settings[windowsForm.Name] != null) { // Restore last saved window size WindowSetting sizeSetting = new WindowSetting(settings[windowsForm.Name].Value); windowsForm.Width = sizeSetting.ParamA(windowsForm.MinimumSize.Width, ScreenArea.MaximumWidth); windowsForm.Height = sizeSetting.ParamB(windowsForm.MinimumSize.Height, ScreenArea.MaximumHeight); } }