Exemplo n.º 1
0
        private void bw_DoWork(string fileName, long diskSize, bool preAllocate)
        {
            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }

            this.Disk = new Medo.IO.VirtualDisk(fileName);

            Medo.IO.VirtualDiskCreateOptions opt = preAllocate ?
                                                   Medo.IO.VirtualDiskCreateOptions.FullPhysicalAllocation : Medo.IO.VirtualDiskCreateOptions.None;

            this.Disk.CreateAsync(diskSize, opt);

            try
            {
                var progress = this.Disk.GetCreateProgress();
                while (!progress.IsDone)
                {
                    bw_ProgressChanged(progress.ProgressPercentage);
                    System.Threading.Thread.Sleep(250);
                    progress = this.Disk.GetCreateProgress();
                }
            }
            catch (Exception err)
            {
                PopUp.Error(err.ToString(), Text);
            }
            bw_RunWorkerCompleted();
        }
 private void m_mnuExplore_Click(object sender, EventArgs e)
 {
     try
     {
         Process.Start(m_txtSelectedFolder.Text);
     }
     catch (Exception err)
     {
         PopUp.Error(err.Message);
     }
 }
        private void m_btnAttachVHDandMount_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(GetPasswordFunc()))
            {
                PopUp.Error("Password is empty", "Password");
                return;
            }

            FileInfo fi = new FileInfo(m_cmbVHD_FileName.Text);

            if (!fi.Exists)
            {
                if (PopUp.Question("File not found: " + fi.FullName + "\nRemove from Recent Files List?", "Mount VHD - ERROR",
                                   MessageBoxImage.Asterisk, TextAlignment.Center, PopUp.PopUpButtonsType.NoYes) == PopUp.PopUpResult.Yes)
                {
                    _recentFiles.RemoveFromList(m_cmbVHD_FileName.Text, m_mnuFileAttachVHD.DropDown, m_cmbVHD_FileName);
                }
                return;
            }

            ExecuteClickAction(() =>
            {
                _recentFiles.AddRecent(m_cmbVHD_FileName.Text, m_mnuFileAttachVHD.DropDown, m_cmbVHD_FileName);

                fi.IsReadOnly = false; //unlock file to enable load

                _cachedDriveInfo = new List <DiskCryptor.DriveInfo>(_diskCryptor.DriveList);

                if (_virtualDisk != null)
                {
                    _virtualDisk.Close();
                }

                _virtualDisk = new Medo.IO.VirtualDisk(fi.FullName);
                _virtualDisk.Open();
                try { _virtualDisk.Detach(); } catch (Exception err) { Debug.WriteLine("Cannot detach: " + err.Message); }

                _selectedDriveLetterForMount = _selectedDriveLetter;
                _diskCryptor.OnDisksAdded   += OnDiskAddedMountDiskCryptorDisk; //mount DiskCryptor disk

                Medo.IO.VirtualDiskAttachOptions options = Medo.IO.VirtualDiskAttachOptions.NoDriveLetter;
                if (m_chkPermanent.Checked)
                {
                    options |= Medo.IO.VirtualDiskAttachOptions.PermanentLifetime;
                }
                _virtualDisk.Attach(options);

                fi.IsReadOnly = true; //lock file to improve security
            }, sender);
        }
Exemplo n.º 4
0
        public static void BrowseForFolder(this Form owner, ref string folderName, string selectedPath = "", string prompt = "Select Folder")
        {
            selectedPath = string.IsNullOrWhiteSpace(selectedPath) ? folderName : selectedPath;

            try
            {
                FormBrowseForFolder frm = new FormBrowseForFolder();
                frm.SelectedFolder = selectedPath;
                frm.Description    = prompt;

                if (frm.ShowDialog(owner) == DialogResult.OK)
                {
                    folderName = frm.SelectedFolder;
                }
            }
            catch (Exception err)
            {
                PopUp.Error(err.Message, prompt);
            }
        }
Exemplo n.º 5
0
        private void ExecuteDiskCryptorCommanLine(string args)
        {
            if (args == "-enum") //if enum command
            {
                DriveList.Clear();
            }

            try
            {
                if (!File.Exists(DiskCryptorConsolePath))
                {
                    throw new FileNotFoundException("File Not Found: " + DiskCryptorConsolePath);
                }

                ProcessStartInfo startInfo = new ProcessStartInfo();
                Process          p         = new Process();

                startInfo.CreateNoWindow         = true;
                startInfo.RedirectStandardOutput = true;
                startInfo.RedirectStandardInput  = true;

                startInfo.UseShellExecute = false;
                startInfo.Arguments       = args;
                startInfo.FileName        = DiskCryptorConsolePath;

                p.StartInfo = startInfo;

                p.StartInfo.UseShellExecute        = false;
                p.StartInfo.RedirectStandardOutput = true;
                p.OutputDataReceived += OutputDataReceived;

                p.Start();
                p.BeginOutputReadLine();
            }
            catch (Exception err)
            {
                PopUp.Error(err.Message);
            }
        }
Exemplo n.º 6
0
        }//end MsgBoxErr

        public static void MsgBoxErr(string msg, string title = "Clipboard Manager")
        {
            PopUp.Error(msg, title);
        }//end MsgBoxErr