Example #1
0
        /// <summary>
        /// Save Disk in configuration.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonSaveDisk_Click(object sender, EventArgs e)
        {
            EncryptedDiskPartition newEncDiskPartition = new EncryptedDiskPartition(labelDiskCaption.Text,
                uint.Parse(labelDiskSignature.Text), uint.Parse(labelDiskPartition.Text));

            // save all the params in the new object
            newEncDiskPartition.PasswordFile = textBoxDiskPasswordFile.Text;
            newEncDiskPartition.IsActive = checkBoxDiskActive.Checked;
            newEncDiskPartition.OpenExplorer = checkBoxDiskOpenExplorer.Checked;
            newEncDiskPartition.Readonly = checkBoxDiskRo.Checked;
            newEncDiskPartition.Removable = checkBoxDiskRm.Checked;
            newEncDiskPartition.System = checkBoxDiskSm.Checked;
            newEncDiskPartition.Timestamp = checkBoxDiskTs.Checked;
            newEncDiskPartition.KeyFiles = diskKeyFilesList[listBoxDisks.SelectedIndex];
            newEncDiskPartition.TriggerDismount = checkBoxDiskDismountTrigger.Checked;
            newEncDiskPartition.FetchUserPassword = checkBoxFetchDiskPassword.Checked;
            if(radioButtonDiskDLFixed.Checked)
                newEncDiskPartition.DriveLetter = comboBoxDiskDriveLetter.Text;
            else
            {
                newEncDiskPartition.DriveLetter = string.Empty;
                newEncDiskPartition.NextFreeLetter = radioButtonDiskDLFree.Checked;
                newEncDiskPartition.RandomFreeLetter = radioButtonDiskDLRandom.Checked;
            }

            // replace the disk with the new settings
            if (config.EncryptedDiskPartitions.Contains(newEncDiskPartition))
                config.EncryptedDiskPartitions[config.EncryptedDiskPartitions.IndexOf(newEncDiskPartition)] = newEncDiskPartition;
            else
                config.EncryptedDiskPartitions.Add(newEncDiskPartition);

            MessageBox.Show(langRes.GetString("MsgTSaved"), langRes.GetString("MsgHSaved"),
                    MessageBoxButtons.OK, MessageBoxIcon.Information);

            // we saved the content, no warn dialog on close needed
            editInProgress = false;
            groupBoxExistingDisks.Enabled = true;
            pictureBoxAddDisk.Enabled = true;
        }
Example #2
0
        /// <summary>
        /// Add new encrypted disk.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonAddDisk_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            // no new disk until new disk is removed or saved
            groupBoxLocalDiskDrives.Enabled = false;

            // get disk and partition from linked list
            ManagementObject newDisk = encDeviceList[comboBoxDiskDrives.SelectedIndex][0];
            // if the entire disk is encrypted there is no partition
            ManagementObject newPart = null;
            // if there is no partition, the partition index is 0
            if (int.Parse(comboBoxDiskPartitions.SelectedItem.ToString()) > 0)
                newPart = encDeviceList[comboBoxDiskDrives.SelectedIndex][int.Parse(comboBoxDiskPartitions.SelectedItem.ToString())];

            // temporary encrypted disk object to check for doubles
            EncryptedDiskPartition temp =
                new EncryptedDiskPartition((string)newDisk["Caption"],
                    (uint)newDisk["Signature"],
                    (newPart != null) ? (uint)newPart["Index"] : 0);

            if (config.EncryptedDiskPartitions.Contains(temp))
            {
                MessageBox.Show(langRes.GetString("MsgTDiskDouble"), langRes.GetString("MsgHDiskDouble"),
                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                groupBoxLocalDiskDrives.Enabled = true;
                return;
            }

            // fill information into form elements
            labelDiskCaption.Text = (string)newDisk["Caption"];
            labelDiskSignature.Text = ((uint)newDisk["Signature"]).ToString();
            if (newPart != null)
                labelDiskPartition.Text = ((uint)newPart["Index"] + 1).ToString();
            else
                labelDiskPartition.Text = comboBoxDiskPartitions.SelectedItem.ToString();
            textBoxDiskPasswordFile.Text = null;
            checkBoxDiskActive.Checked = true;
            checkBoxDiskOpenExplorer.Checked = false;
            checkBoxFetchDiskPassword.Checked = false;

            string diskTitle = labelDiskCaption.Text + ", Partition: " + labelDiskPartition.Text;

            // new disk, new node in tree
            listBoxDisks.Items.Add(diskTitle);
            listBoxDisks.SelectedItem = diskTitle;

            // new key files list
            diskKeyFilesList.Add(new List<string>());

            // unsaved content will raise a save dialog box
            editInProgress = true;
            // panel to add disks must be hidden
            panelLocalDiskDrives.Visible = false;
            // enable disk details area and make visible
            groupBoxDiskDetails.Text = diskTitle;
            groupBoxDiskDetails.Visible = true;
            groupBoxDiskDetails.Enabled = true;
            // restore old color
            tabPageDiskDrives.BackColor = Color.Transparent;
            Cursor.Current = Cursors.Default;
        }