Esempio n. 1
0
        private void openFileDialogKontainerFileOK(object sender, CancelEventArgs e)
        {
            WmiDriveInfo wmiinfo             = new WmiDriveInfo();
            string       path                = null;
            string       driveletterFromPath = null;

            path = textBoxKontainer.Text = openFileDialogKontainer.FileName;

            try
            {
                driveletterFromPath = Path.GetPathRoot(@path);
                driveletterFromPath = driveletterFromPath.Replace(@"\", "");
                string[] pnpandin = wmiinfo.GetPNPidfromDriveletter(driveletterFromPath);
                textBoxSelectedDrive.Text = pnpandin[0] + " Partition: " + pnpandin[1];
            }
            catch (Exception)
            {
                textBoxSelectedDrive.Text    = LanguagePool.GetInstance().GetString(LanguageRegion, "MessageDriveNotConnected", _language);
                checkBoxAutomountUsb.Checked = false;
                checkBoxAutomountUsb.Enabled = false;
            }
        }
Esempio n. 2
0
        private void buttonOk_Click(object sender, EventArgs e)
        {
            string       description         = textBoxDescription.Text;
            string       driveletterFromPath = "";
            string       keyfile             = textBoxKeyfile.Text;
            string       usedriveletter      = DrivelettersHelper.IsDrivletterUsedByConfig(comboBoxDriveletter.SelectedItem.ToString());
            WmiDriveInfo wmiinfo             = new WmiDriveInfo();

            try
            {
                if (checkBoxPim.Checked)
                {
                    if (string.IsNullOrEmpty(_pim) && !string.IsNullOrEmpty(_password))
                    {
                        throw new Exception(LanguagePool.GetInstance().GetString(LanguageRegion, "MessagePimNotSet", _language));
                    }
                }
            }
            catch (Exception ex)
            {
                DialogResult res = MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                buttonSavePassword_Click(this, e);
            }

            try
            {
                if (usedriveletter != null && usedriveletter != description)
                {
                    throw new Exception(LanguagePool.GetInstance().GetString(LanguageRegion, "MessageDrivletterIsUsed", _language) + usedriveletter);
                }
            }
            catch (Exception ex)
            {
                DialogResult res = MessageBox.Show(ex.Message, "", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Warning);
                if (res == DialogResult.Abort)
                {
                    return;
                }
                if (res == DialogResult.Retry)
                {
                    buttonOk_Click(sender, e);
                    return;
                }
            }

            try
            {
                if (string.IsNullOrEmpty(description))
                {
                    throw new Exception(LanguagePool.GetInstance().GetString(LanguageRegion, "MessageDescriptionNullorEmpty", _language));
                }

                if (_oldName != null)
                {
                    if (description != _oldName)
                    {
                        _config.RemoveSection(_oldName);
                    }
                }



                if (!checkBoxNoKeyfile.Checked)
                {
                    _config.SetValue(description, ConfigTrm.Container.Keyfile, keyfile);
                }

                driveletterFromPath = Path.GetPathRoot(@textBoxKontainer.Text);
                driveletterFromPath = driveletterFromPath.Replace(@"\", "");
                string[] pnpandin = wmiinfo.GetPNPidfromDriveletter(driveletterFromPath);

                //if no pnpdeviceid is found set to nothing
                if (pnpandin == null)
                {
                    pnpandin    = new string[2];
                    pnpandin[0] = "";
                    pnpandin[1] = "";
                }

                textBoxSelectedDrive.Text = pnpandin[0] + " Partition: " + pnpandin[1];

                if (checkBoxAutomountUsb.Checked)
                {
                }

                string hash = (comboBoxHash.SelectedItem == null) ? "" : comboBoxHash.SelectedItem.ToString();

                _config.SetValue(description, ConfigTrm.Container.Type, ConfigTrm.Container.Typename);
                _config.SetValue(description, ConfigTrm.Container.Kontainerpath, textBoxKontainer.Text);
                _config.SetValue(description, ConfigTrm.Container.Driveletter, comboBoxDriveletter.SelectedItem.ToString());
                _config.SetValue(description, ConfigTrm.Container.Readonly, checkBoxReadonly.Checked);
                _config.SetValue(description, ConfigTrm.Container.Removable, checkBoxRemovable.Checked);
                _config.SetValue(description, ConfigTrm.Container.Nokeyfile, checkBoxNoKeyfile.Checked);
                _config.SetValue(description, ConfigTrm.Container.Automountstart, checkBoxAutomountStart.Checked);
                _config.SetValue(description, ConfigTrm.Container.Automountusb, checkBoxAutomountUsb.Checked);
                _config.SetValue(description, ConfigTrm.Container.Pimuse, checkBoxPim.Checked);
                _config.SetValue(description, ConfigTrm.Container.Truecrypt, checkBoxTrueCrypt.Checked);
                _config.SetValue(description, ConfigTrm.Container.Hash, hash);
                _config.SetValue(description, ConfigTrm.Container.Pnpid, pnpandin[0]);
                _config.SetValue(description, ConfigTrm.Container.Partnummber, pnpandin[1]);

                if (!string.IsNullOrEmpty(_password))
                {
                    _config.SetValue(description, ConfigTrm.Container.Password, _password);
                    _config.SetValue(description, ConfigTrm.Container.Pim, _pim);
                }

                if (checkBoxPassword.Checked)
                {
                    _config.SetValue(description, ConfigTrm.Container.Password, "");
                    _config.SetValue(description, ConfigTrm.Container.Pim, "");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            _password = null;
            _pim      = null;
            Close();
        }
Esempio n. 3
0
        /// <summary>
        /// Fill all controls for editing a container.
        /// </summary>
        /// <param name="description"></param>
        private void NewKontainerEdit(string description)
        {
            _oldName = description;
            string path = _config.GetValue(description, ConfigTrm.Container.Kontainerpath, "");

            textBoxDescription.Text = description;
            comboBoxHash.Items.AddRange(new object[] { "", "sha512", "sha256", "wirlpool", "ripemd160", "streebog" });
            comboBoxHash.SelectedItem = _config.GetValue(description, ConfigTrm.Container.Hash, "");
            checkBoxNoKeyfile.Checked = _config.GetValue(description, ConfigTrm.Container.Nokeyfile, false);

            textBoxKontainer.Text          = path;
            textBoxKeyfile.Text            = _config.GetValue(description, ConfigTrm.Container.Keyfile, "");
            checkBoxReadonly.Checked       = _config.GetValue(description, ConfigTrm.Container.Readonly, false);
            checkBoxRemovable.Checked      = _config.GetValue(description, ConfigTrm.Container.Removable, false);
            checkBoxAutomountStart.Checked = _config.GetValue(description, ConfigTrm.Container.Automountstart, false);
            checkBoxAutomountUsb.Checked   = _config.GetValue(description, ConfigTrm.Container.Automountusb, false);
            checkBoxTrueCrypt.Checked      = _config.GetValue(description, ConfigTrm.Container.Truecrypt, false);
            checkBoxPim.Checked            = _config.GetValue(description, ConfigTrm.Container.Pimuse, false);
            _password = _config.GetValue(description, ConfigTrm.Drive.Password, "");
            _pim      = _config.GetValue(description, ConfigTrm.Drive.Pim, "");

            foreach (string element in DrivelettersHelper.GetDriveletters())
            {
                _driveletters.Add(element);
            }
            foreach (string elemnt in DrivelettersHelper.GetUsedDriveletter())
            {
                _useddriveletters.Add(elemnt);
            }

            comboBoxDriveletter.DataSource = _driveletters;

            comboBoxDriveletter.SelectedItem = _config.GetValue(description, ConfigTrm.Container.Driveletter, "");

            WmiDriveInfo wmiinfo = new WmiDriveInfo();

            // TODO Automatisch ermitteln der PNPID für den pfad FEHLERBEHANDLUNG
            _pnpid       = _config.GetValue(description, ConfigTrm.Container.Pnpid, "");
            _partnummber = _config.GetValue(description, ConfigTrm.Container.Partnummber, "");

            if (!string.IsNullOrEmpty(_pnpid) || !string.IsNullOrEmpty(_partnummber))
            {
                string driveletterFromPath = "";
                try
                {
                    driveletterFromPath = Path.GetPathRoot(@path);
                    driveletterFromPath = driveletterFromPath.Replace(@"\", "");
                    string[] pnpandin = wmiinfo.GetPNPidfromDriveletter(driveletterFromPath);
                    textBoxSelectedDrive.Text = pnpandin[0] + " Partition: " + pnpandin[1];
                }
                catch (Exception)
                {
                    textBoxSelectedDrive.Text = LanguagePool.GetInstance().GetString(LanguageRegion, "MessageDriveNotConnected", _language);
                }
            }

            if (string.IsNullOrEmpty(_password))
            {
                buttonShowPassword.Enabled = false;
            }
        }