/// <summary> /// Fills the controls with the needed information for creating a drive. /// </summary> private void NewDriveCreate() { Text = LanguagePool.GetInstance().GetString(LanguageRegion, "NewDrive", _language); // Set _edit to false. _edit = false; // Get the driveletters and the used driveletters and stor them in the lists. foreach (string element in DrivelettersHelper.GetDriveletters()) { _driveletters.Add(element); } foreach (string elemnt in DrivelettersHelper.GetUsedDriveletter()) { _useddriveletters.Add(elemnt); } // Set the datasource for the drivelettercobobox and select the first. comboBoxDriveletter.DataSource = _driveletters; //comboBoxDriveletter.SelectedItem = _driveletters[0]; foreach (string element in DrivelettersHelper.GetDriveletters()) { if (!_useddriveletters.Contains(element)) { comboBoxDriveletter.SelectedItem = element; } } comboBoxHash.Items.AddRange(_hashes); buttonShowPassword.Enabled = false; }
/// <summary> /// Fill all controls with information for creating a new container. /// </summary> private void NewKontainer() { foreach (string element in DrivelettersHelper.GetDriveletters()) { _driveletters.Add(element); } foreach (string elemnt in DrivelettersHelper.GetUsedDriveletter()) { _useddriveletters.Add(elemnt); } comboBoxHash.Items.AddRange(_hashes); comboBoxDriveletter.DataSource = _driveletters; buttonShowPassword.Enabled = false; }
/// <summary> /// Fill the controls with the information that needed to edit the drive. /// </summary> /// <param name="driveName"></param> private void NewDriveEdit(string driveName) { Text = LanguagePool.GetInstance().GetString(LanguageRegion, "DriveEdit", _language); _edit = true; _oldName = driveName; foreach (string element in DrivelettersHelper.GetDriveletters()) { _driveletters.Add(element); } foreach (string elemnt in DrivelettersHelper.GetUsedDriveletter()) { _useddriveletters.Add(elemnt); } comboBoxDriveletter.DataSource = _driveletters; comboBoxHash.Items.AddRange(_hashes); textBoxDescription.Text = driveName; textBoxPartition.Text = _config.GetValue(driveName, ConfigTrm.Drive.Partition, "\\Device\\Harddisk\\Partition"); textBoxKeyfile.Text = _config.GetValue(driveName, ConfigTrm.Drive.Keyfile, ""); checkBoxNoKeyfile.Checked = _config.GetValue(driveName, ConfigTrm.Drive.Nokeyfile, false); checkBoxReadonly.Checked = _config.GetValue(driveName, ConfigTrm.Drive.Readonly, false); checkBoxRemovable.Checked = _config.GetValue(driveName, ConfigTrm.Drive.Removable, false); checkBoxAutomountStart.Checked = _config.GetValue(driveName, ConfigTrm.Drive.Automountstart, false); checkBoxAutomountUsb.Checked = _config.GetValue(driveName, ConfigTrm.Drive.Automountusb, false); checkBoxPim.Checked = _config.GetValue(driveName, ConfigTrm.Drive.Pimuse, false); checkBoxTruecrypt.Checked = _config.GetValue(driveName, ConfigTrm.Drive.Truecrypt, false); comboBoxHash.SelectedItem = _config.GetValue(driveName, ConfigTrm.Drive.Hash, ""); _disknummber = _config.GetValue(driveName, ConfigTrm.Drive.Disknumber, ""); _partnummber = _config.GetValue(driveName, ConfigTrm.Drive.Partnumber, ""); _pnpdeviceid = _config.GetValue(driveName, ConfigTrm.Drive.Pnpdeviceid, ""); _password = _config.GetValue(driveName, ConfigTrm.Drive.Password, ""); _pim = _config.GetValue(driveName, ConfigTrm.Drive.Pim, ""); textBox_PNPDeviceID.Text = _pnpdeviceid; comboBoxDriveletter.SelectedItem = _config.GetValue(driveName, ConfigTrm.Drive.Driveletter, ""); if (string.IsNullOrEmpty(_password)) { buttonShowPassword.Enabled = false; } }
/// <summary> /// Fill all controllelements with selections from configfile. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MainsettingsLoad(object sender, EventArgs e) { string defaultlanguage = ""; string selectedlanguage = ""; textBoxConfigPath.Text = _config.XmlPathName; // Get languages from language.xml file. try { _languages = LanguagePool.GetInstance().GetLanguages(); } catch (Exception ex) { MessageBox.Show(ex.Message); Close(); } // Fill combobox with available languages and get default language if (_languages != null) { foreach (var language in _languages) { comboBoxLanguage.Items.Add(language[0]); if (_config.GetValue(ConfigTrm.Mainconfig.Section, ConfigTrm.Mainconfig.Defaultlanguage, "") == language[1]) { defaultlanguage = language[0]; } if (_config.GetValue(ConfigTrm.Mainconfig.Section, ConfigTrm.Mainconfig.Language, defaultlanguage) == language[1]) { selectedlanguage = language[0]; } } } // Select chosen Language in combobox. If nothing chosen use default language if (selectedlanguage == "") { selectedlanguage = defaultlanguage; } comboBoxLanguage.SelectedItem = selectedlanguage; if (!string.IsNullOrEmpty(_config.GetValue(ConfigTrm.Mainconfig.Section, ConfigTrm.Mainconfig.Truecryptpath, ""))) { select_truecrypt.InitialDirectory = Path.GetDirectoryName(_config.GetValue(ConfigTrm.Mainconfig.Section, ConfigTrm.Mainconfig.Truecryptpath, "")); textBoxTruecryptPath.Text = _config.GetValue(ConfigTrm.Mainconfig.Section, ConfigTrm.Mainconfig.Truecryptpath, ""); } else { string pp = Path.Combine(Environment.ExpandEnvironmentVariables("%ProgramW6432%"), "VeraCrypt", "VeraCrypt.exe"); if (File.Exists(pp)) { select_truecrypt.InitialDirectory = Path.GetDirectoryName(pp); textBoxTruecryptPath.Text = pp; } else { select_truecrypt.InitialDirectory = textBoxTruecryptPath.Text = ""; } } select_konpath.InitialDirectory = textBoxContainerPath.Text = _config.GetValue(ConfigTrm.Mainconfig.Section, ConfigTrm.Mainconfig.Kontainerpath, ""); checkBoxSilentMode.Checked = !_config.GetValue(ConfigTrm.Mainconfig.Section, ConfigTrm.Mainconfig.Silentmode, true); checkBoxReadonly.Checked = _config.GetValue(ConfigTrm.Mainconfig.Section, ConfigTrm.Mainconfig.Readonly, false); checkBoxRemovable.Checked = _config.GetValue(ConfigTrm.Mainconfig.Section, ConfigTrm.Mainconfig.Removable, false); checkBoxNoKeyfilecontainer.Checked = _config.GetValue(ConfigTrm.Mainconfig.Section, ConfigTrm.Mainconfig.Nokeyfile, true); checkBoxAutomount.Checked = _config.GetValue(ConfigTrm.Mainconfig.Section, ConfigTrm.Mainconfig.Automount, false); checkBoxPim.Checked = _config.GetValue(ConfigTrm.Mainconfig.Section, ConfigTrm.Mainconfig.Pim, false); checkBox_startwithwin.Checked = _config.GetValue(ConfigTrm.Mainconfig.Section, ConfigTrm.Mainconfig.AutostartWithWindows, false); // Fill lists for the comboboxdriveletter 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(ConfigTrm.Mainconfig.Section, ConfigTrm.Mainconfig.Driveletter, ""); comboBoxHash.Items.AddRange(_hashes); comboBoxHash.SelectedItem = _config.GetValue(ConfigTrm.Mainconfig.Section, ConfigTrm.Mainconfig.Hash, ""); }
/// <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; } }