Example #1
0
 private void mnuFile_Click(object sender, EventArgs e)
 {
     using (var frm = new NewDiskForm()) {
         if (frm.ShowDialog(this) == DialogResult.OK) {
             AllowSetForegroundWindowToExplorer();
             var fileName = frm.FileName;
             try {
                 var newDocument = new Medo.IO.VirtualDisk(fileName);
                 UpdateData(newDocument.FileName);
                 this.VhdFileName = newDocument.FileName;
                 Recent.Push(fileName);
                 UpdateRecent();
                 using (var form = new AttachForm(new FileInfo(fileName), false, true)) {
                     form.StartPosition = FormStartPosition.CenterParent;
                     form.ShowDialog(this);
                 }
             } catch (Exception ex) {
                 var exFile = new FileInfo(fileName);
                 Medo.MessageBox.ShowError(this, string.Format("Cannot open \"{0}\".\n\n{1}", exFile.Name, ex.Message));
             }
         }
     }
 }
Example #2
0
        private void mnuAttach_ButtonClick(object sender, EventArgs e)
        {
            if (this.VhdFileName == null) { return; }

            if (Settings.UseService) {
                using (var form = new AttachForm(new FileInfo(this.VhdFileName), false, false)) {
                    form.StartPosition = FormStartPosition.CenterParent;
                    form.ShowDialog(this);
                }
                UpdateData(this.VhdFileName);
            } else {
                mnu.Enabled = false;
                var exe = Path.Combine(new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName, "VhdAttachExecutor.exe");
                var startInfo = Utility.GetProcessStartInfo(exe, @"/Attach """ + this.VhdFileName + @"""");
                this.Cursor = Cursors.WaitCursor;
                bwExecutor.RunWorkerAsync(startInfo);
            }
            AllowSetForegroundWindowToExplorer();
        }