Exemplo n.º 1
0
        private void SyncUserControlStateWithAppSettings()
        {
            var settings = _applicationSettingsService.Settings;

            if (TopMost != settings.AlwaysOntop)
            {
                TopMost = settings.AlwaysOntop;
            }

            topMostToolStripMenuItem.Checked = settings.AlwaysOntop;

            _changeImageAnimation = settings.NextImageAnimation;
            autoLoadPreviousFolderToolStripMenuItem.Enabled = settings.EnableAutoLoadFunctionFromMenu &&
                                                              !string.IsNullOrWhiteSpace(settings.LastFolderLocation);
            if (settings.MainWindowBackgroundColor != null)
            {
                pictureBox1.BackColor = settings.MainWindowBackgroundColor.ToColor();
                BackColor             = settings.MainWindowBackgroundColor.ToColor();
            }

            if (settings.ExtendedAppSettings.FormStateDictionary.ContainsKey(this.GetType().Name))
            {
                var formState = settings.ExtendedAppSettings.FormStateDictionary[this.GetType().Name];
                RestoreFormState.SetFormSizeAndPosition(this, formState);
            }
        }
Exemplo n.º 2
0
        private void FormMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (!AllowApplicationExit())
            {
                e.Cancel = true;
                return;
            }

            if (!ScreenSaver.ScreenSaverEnabled)
            {
                ScreenSaver.Enable();
            }

            timerSlideShow.Enabled = false;
            _bookmarkService.SaveBookmarks();
            _applicationSettingsService.UpdateOrInsertFormState(RestoreFormState.GetFormState(this));
            _applicationSettingsService.SetSettingsStateModified();
            _applicationSettingsService.SaveSettings();
        }
Exemplo n.º 3
0
        private void FormThumbnailView_Load(object sender, EventArgs e)
        {
            if (DesignMode)
            {
                return;
            }

            ImageViewApplicationSettings appSettings = _applicationSettingsService.Settings;

            if (appSettings.ThumbnailFormSize != null && appSettings.ThumbnailFormLocation != null)
            {
                RestoreFormState.SetFormSizeAndPosition(this, appSettings.ThumbnailFormSize.ToSize(), appSettings.ThumbnailFormLocation.ToPoint(), Screen.PrimaryScreen.WorkingArea);
            }

            Closing += FormThumbnailView_Closing;
            SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
            flowLayoutPanel1.BackColor = appSettings.MainWindowBackgroundColor.ToColor();
            picBoxMaximized.BackColor  = appSettings.MainWindowBackgroundColor.ToColor();
            UpdateStyles();
        }
Exemplo n.º 4
0
        private void FormBookmarks_Load(object sender, EventArgs e)
        {
            if (DesignMode)
            {
                return;
            }

            bookmarksDataGridView.RowPrePaint  += bookmarksDataGridView_RowPrePaint;
            _bookmarkManager.OnBookmarksUpdate += Instance_OnBookmarksUpdate;
            bookmarksTree.AfterSelect          += BookmarksTree_AfterSelect;
            InitBookmarksDataGridViev();
            _treeViewDataContext = new TreeViewDataContext(bookmarksTree, _bookmarkManager.RootFolder);
            _overlayFormManager.HideImageDelay = 250;
            _overlayFormManager.ShowImageDelay = 500;

            var settings = _applicationSettingsService.Settings.ExtendedAppSettings;

            if (settings.BookmarksShowMaximizedImageArea)
            {
                Invoke(new EventHandler(maximizePreviewAreaToolStripMenuItem_Click));
            }

            if (settings.BookmarksShowOverlayWindow)
            {
                Invoke(new EventHandler(showOverlayPreviewToolStripMenuItem_Click));
            }

            if (_applicationSettingsService.Settings.ExtendedAppSettings.FormStateDictionary.ContainsKey(GetType().Name))
            {
                var formState = settings.FormStateDictionary[GetType().Name];
                RestoreFormState.SetFormSizeAndPosition(this, formState.Size.ToSize(), formState.Location.ToPoint(), formState.ScreenArea.ToRectangle());
            }

            if (_applicationSettingsService.Settings.PasswordProtectBookmarks)
            {
                using (var formGetPassword = new FormGetPassword
                {
                    PasswordDerivedString = _applicationSettingsService.Settings.PasswordDerivedString
                })
                {
                    if (formGetPassword.ShowDialog() == DialogResult.OK)
                    {
                        if (!formGetPassword.PasswordVerified)
                        {
                            MessageBox.Show(this, Resources.Invalid_password_);
                            Close();
                            return;
                        }

                        if (_bookmarkService.OpenBookmarks(formGetPassword.PasswordString))
                        {
                            InitBookmarksDataSource();
                        }
                        else
                        {
                            MessageBox.Show(Resources.failed_to_decode_file_);
                            Close();
                        }
                    }
                    else
                    {
                        Close();
                    }
                }
            }
            else
            {
                if (!_bookmarkManager.LoadedFromFile)
                {
                    if (!_bookmarkService.OpenBookmarks())
                    {
                        Log.Error("Load Bookmarks failed");
                    }
                }

                InitBookmarksDataSource();
            }
        }
Exemplo n.º 5
0
        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;
        }