Esempio n. 1
0
        private void openDatabaseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (var formGetPassword = new FormGetPassword())

            {
                formGetPassword.PasswordSalt          = _appSettingsService.Settings.ApplicationSaltValue;
                formGetPassword.PasswordDerivedString = _appSettingsService.Settings.PasswordDerivedString;


                if (formGetPassword.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                string password = formGetPassword.PasswordString;
                _passwordStorage.Set(PwdKey, password);
            }


            try
            {
                bool result = _logicManager.OpenDatabase();
                //tabPageCollection = _memoStorageService.LoadTabPageCollection(password);

                if (_logicManager.HasExistingDatabase)
                {
                    _logicManager.SaveDatabase();
                    Log.Warning("FoundDatabaseErrors Saving new recreated database");
                }

                // Make sure that every tabPageData has a unique Id
                //bool uniqueIdCreated = tabPageCollection.TabPageDictionary.Values.Aggregate(false, (current, tabPageData) => current | tabPageData.GenerateUniqueIdIfNoneExists());

                //if (uniqueIdCreated)
                //    _applicationState.UniqueIdMissingFromExistingTabPage = true;

                //if (tabPageCollection.TabPageDictionary.Count == 0)
                //    tabPageCollection = TabPageDataCollection.CreateNewPageDataCollection(_appSettingsService.Settings.DefaultEmptyTabPages);
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "Unable to load database, please verify that you entered the correct password. " + ex.Message, "Failed to load database", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }

            InitializeTabControls();
            _applicationState.DatabaseLoaded     = true;
            _applicationState.TabIndexChanged    = false;
            _applicationState.TabPageAddOrRemove = false;
            _applicationState.TabTextDataChanged = false;
            UpdateApplicationState();
        }
Esempio n. 2
0
        private void chkPasswordProtectBookmarks_MouseUp(object sender, MouseEventArgs e)
        {
            if (chkPasswordProtectBookmarks.Checked)
            {
                using (var formSetPassword = new FormSetPassword())
                {
                    if (formSetPassword.ShowDialog(this) == DialogResult.OK)
                    {
                        if (formSetPassword.VerifiedPassword == null)
                        {
                            chkPasswordProtectBookmarks.Checked = false;
                            return;
                        }

                        _applicationSettingsService.Settings.EnablePasswordProtectBookmarks(formSetPassword.VerifiedPassword);
                        _applicationSettingsService.SaveSettings();
                        _bookmarkService.SaveBookmarks();
                    }
                    else
                    {
                        chkPasswordProtectBookmarks.Checked = false;
                    }
                }
            }
            else
            {
                using (
                    var formgetPassword = new FormGetPassword
                {
                    PasswordDerivedString = _applicationSettingsService.Settings.PasswordDerivedString
                })
                {
                    if (formgetPassword.ShowDialog() == DialogResult.OK && formgetPassword.PasswordVerified)
                    {
                        _applicationSettingsService.Settings.DisablePasswordProtectBookmarks();
                        _applicationSettingsService.SaveSettings();

                        // Check bookmark status
                        //if (BookmarkService.Instance.BookmarkManager == null)
                        //    BookmarkService.Instance.Dispose();
                    }
                    else
                    {
                        chkPasswordProtectBookmarks.Checked = true;
                    }
                }
            }
        }
Esempio n. 3
0
        private void openToolStripMenuItem_Click(object sender, EventArgs eventArgs)
        {
            var openFileDialog = new OpenFileDialog();
            var passwordDialog = new FormGetPassword();

            openFileDialog.Filter = "FileSystemImage files (*.fsi)|*.fsi";

            if (openFileDialog.ShowDialog() == DialogResult.OK && passwordDialog.ShowDialog(this) == DialogResult.OK)
            {
                string password = passwordDialog.PasswordString;
                _currentFileSystemDrive = null;
                _currentFileName        = openFileDialog.FileName;

                LoadAndSaveProgressInfoLabel.Text = "Opening file: " + openFileDialog.FileName;
                LoadFileSystemImageFromFile(_currentFileName, password);
                Log.Debug("Successfuly opened file: {FileName}", openFileDialog.FileName);
            }
        }
Esempio n. 4
0
        private void RestoreDatabaseFromSyncPathMenuItem_Click(object sender, EventArgs e)
        {
            if (_applicationState.DatabaseExists &&
                MessageBox.Show("Are you sure that you want to replace the existing database?\nIt is recommended that you perform a backup before replacing the existing database!",
                                "Replace database from sync folder",
                                MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
            {
                return;
            }

            var formGetPassword = new FormGetPassword {
                UsePasswordValidation = false
            };

            if (formGetPassword.ShowDialog(this) != DialogResult.OK)
            {
                formGetPassword.Dispose();
                return;
            }


            string password = formGetPassword.PasswordString;

            _passwordStorage.Set("RestoreDatabaseFromSync", password);
            formGetPassword.Dispose();

            _applicationState.DatabaseLoaded = false;
            _appSettingsService.LoadSettings();
            InitFormSettings();

            RestoreSyncDataResult result = _logicManager.RestoreBackupFromSyncFolder();

            if (result.Successful)
            {
                MessageBox.Show("Database and app settings restored from sync folder.", "Restore complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
                _applicationState.DatabaseExists = true;
                UpdateApplicationState();
            }
            else
            {
                MessageBox.Show("Could not restore sync folder content: " + result.ErrorText, "Error restoring data", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 5
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();
            }
        }