Exemplo n.º 1
0
        private bool SaveCurrent(bool forcePrompts = false)
        {
            var effectiveFilePath = lastFilePath;
            var effectivePassword = lastPassword;

            if (forcePrompts || effectiveFilePath == null)
            {
                if (saveFileDialog.ShowDialog(this) != true)
                {
                    return false;
                }
                effectiveFilePath = saveFileDialog.FileName;
            }

            if (forcePrompts || effectivePassword == null)
            {
                var passwordDialog = new PasswordDialog();
                if (passwordDialog.ShowDialog() != true)
                {
                    return false;
                }
                effectivePassword = passwordDialog.Password;
            }

            IVaultContent content = new VaultContent() { Text = textBox.Text };
            VaultSerializer.Serialize(effectiveFilePath, content, effectivePassword);

            lastFilePath = effectiveFilePath;
            lastPassword = effectivePassword;
            dataIsChanged = false;
            UpdateActions();

            return true;
        }
Exemplo n.º 2
0
        private void openButton_Click(object sender, RoutedEventArgs e)
        {
            if (CheckSaveChanges() == false)
            {
                return;
            }

            var result = openFileDialog.ShowDialog(this);
            if (result.HasValue && result.Value)
            {
                var passwordDialog = new PasswordDialog();
                if (passwordDialog.ShowDialog() == true)
                {
                    LoadText(openFileDialog.FileName, passwordDialog.Password);
                }
            }
        }