Exemplo n.º 1
0
        /// <summary>
        /// Creates the master password print pop-up.
        /// </summary>
        private void CreatePrintPopUp()
        {
            MasterPasswordPrintPopUp printPopUp;

            if (passwordOptionsDarkThemeEnabled)
            {
                printPopUp = new MasterPasswordPrintPopUp(PassEntry1.Text, Color.White, Color.DarkGray, Color.DarkSlateGray, passwordOptionsDarkThemeEnabled);
            }
            else
            {
                printPopUp = new MasterPasswordPrintPopUp(PassEntry1.Text, SystemColors.ControlText, SystemColors.Window, SystemColors.Control, passwordOptionsDarkThemeEnabled);
            }

            // Adding all the printPopUp components to the list of components in the master from.
            // This is done to apply the same theme and text size to all of the forms
            MasterForm controlForm = new MasterForm();

            controlForm.labels.AddRange(printPopUp.printPopUpLabels);
            controlForm.buttons.AddRange(printPopUp.printPopUpButtons);
            controlForm.forms.Add(printPopUp);

            // Changing text size of printPopUp
            if (passwordOptionsDefaultTextSizeEnabled)
            {
                controlForm.ChangeFontSize(8.0f);
                printPopUp.printPopUpDefaultTextSizeEnabled = true;
                printPopUp.printPopUpSmallTextSizeEnabled   = false;
                printPopUp.printPopUpLargeTextSizeEnabled   = false;
            }

            else if (passwordOptionsSmallTextSizeEnabled)
            {
                controlForm.ChangeFontSize(6.0f);
                printPopUp.printPopUpDefaultTextSizeEnabled = false;
                printPopUp.printPopUpSmallTextSizeEnabled   = true;
                printPopUp.printPopUpLargeTextSizeEnabled   = false;
            }

            else if (passwordOptionsLargeTextSizeEnabled)
            {
                controlForm.ChangeFontSize(10.0f);
                printPopUp.printPopUpDefaultTextSizeEnabled = false;
                printPopUp.printPopUpSmallTextSizeEnabled   = false;
                printPopUp.printPopUpLargeTextSizeEnabled   = true;
            }

            printPopUp.ShowDialog();
            TheParent.PerformRefresh(true);
            success = true;
            this.Close();
        }
        private void OkButton_Click(object sender, EventArgs e)
        {
            if ((PassEntry1.Text == PassEntry2.Text) && String.IsNullOrEmpty(PassEntry1.Text) == false && String.IsNullOrEmpty(PassEntry2.Text) == false)
            {
                if (KeyFileCheckBox.Checked)
                {
                    if (FileOP.GetKeyFile() != "" && FileOP.GetKeyFile() != null && File.Exists(FileOP.GetKeyFile()))
                    {
                        Compressor.Compress(FileOP.GetFile());
                        Crypto.EncryptFile(FileOP.GetFile(), PassEntry1.Text);
                        Crypto.EncryptFile(FileOP.GetFile(), FileOP.KeyFileToBits(FileOP.GetKeyFile()));
                        KeyFileLocationText.Text = FileOP.GetKeyFile();
                        FileOP.ClearKeyFile();

                        MasterPasswordPrintPopUp printPopUp = new MasterPasswordPrintPopUp(PassEntry1.Text);
                        printPopUp.ShowDialog();
                        FileOP.ClearFile();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Your key file is invalid. Please reselect your keyfile.", "File Error", MessageBoxButtons.OK);
                    }
                }
                else
                {
                    Compressor.Compress(FileOP.GetFile());
                    Crypto.EncryptFile(FileOP.GetFile(), PassEntry1.Text);

                    MasterPasswordPrintPopUp printPopUp = new MasterPasswordPrintPopUp(PassEntry1.Text);
                    printPopUp.ShowDialog();
                    FileOP.ClearFile();
                    this.Close();
                }
            }
            else
            {
                string            message = "Your passwords do not match or the boxes are blank. Please try entering them again";
                string            title   = "Pass Keeper";
                MessageBoxButtons buttons = MessageBoxButtons.OK;
                _ = MessageBox.Show(message, title, buttons);
            }
        }