예제 #1
0
        private void createNewDatabaseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (
                MessageBox.Show(this, "Do you want to create a new Memo database? Doing so will overwrite any existing stored database under this account.", "Create new database?",
                                MessageBoxButtons.OKCancel, MessageBoxIcon.Question) !=
                DialogResult.OK)
            {
                return;
            }

            var frmSetPassword = new FormSetPassword {
                Text = "Choose password"
            };

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

            string password = frmSetPassword.VerifiedPassword;

            if (string.IsNullOrEmpty(password))
            {
                MessageBox.Show(this, "Password can not be empty!", Resources.FormMain__ErrorText, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            _passwordStorage.Set(PwdKey, password);
            _logicManager.CreateNewDatabase();


            _appSettingsService.Settings.PasswordDerivedString =
                GeneralConverters.GeneratePasswordDerivedString(_appSettingsService.Settings.ApplicationSaltValue + password + _appSettingsService.Settings.ApplicationSaltValue);

            _appSettingsService.SaveSettings();
            InitializeTabControls();
            _applicationState.DatabaseLoaded = true;
            _applicationState.DatabaseExists = true;
            UpdateApplicationState();
        }