private void FormMain_Load(object sender, EventArgs e) { if (DesignMode) { return; } DoubleBuffered = true; _applicationSettingsService.OnSettingsSaved += Instance_OnSettingsSaved; _applicationSettingsService.OnRegistryAccessDenied += Instance_OnRegistryAccessDenied; _imageLoaderService.OnImportComplete += Instance_OnImportComplete; _imageLoaderService.OnImageWasDeleted += Instance_OnImageWasDeleted; _pictureBoxAnimation.LoadCompleted += pictureBoxAnimation_LoadCompleted; bool settingsLoaded = _applicationSettingsService.LoadSettings(); if (!settingsLoaded) { // Problem. Settings could not be loaded due to deserialization error because the decryption used an invalid key which made protobuffer try to deserialize garbage. _applicationSettingsService.SaveSettings(); _applicationSettingsService.LoadSettings(); SyncUserControlStateWithAppSettings(); } else { SyncUserControlStateWithAppSettings(); try { var fileConfig = _applicationSettingsService.Settings.ExtendedAppSettings; if (fileConfig.FormStateDictionary.ContainsKey(GetType().Name)) { var formState = fileConfig.FormStateDictionary[GetType().Name]; RestoreFormState.SetFormSizeAndPosition(this, formState); } } catch (Exception exception) { Console.WriteLine(exception); } _changeImageAnimation = _applicationSettingsService.Settings.NextImageAnimation; timerSlideShow.Interval = _applicationSettingsService.Settings.SlideshowInterval; addBookmarkToolStripMenuItem.Enabled = false; Text = _windowTitle; ToggleSlideshowMenuState(); } // MessageBox.Show(Resources.Unable_To_Access_application_settings_in_registry, // Resources.Faild_to_load_settings, MessageBoxButtons.OK, MessageBoxIcon.Error); // _formRestartWithAdminPrivileges = new FormRestartWithAdminPrivileges(); // if (_formRestartWithAdminPrivileges.ShowDialog(this) == DialogResult.OK) // { // return; // } //Notification Service _interactionService.Initialize(this); _interactionService.UserInformationReceived += InteractionServiceUserInformationReceived; _interactionService.UserQuestionReceived += InteractionServiceUserQuestionReceived; }