private void TakeSnapshot_Click(object sender, EventArgs e) { if (HostInfoInvalid()) return; if (SnapshotInfoInvalid()) return; VMController vmController = new VMController(GetHostInfo()); try { foreach (VMController.VMInfo vmInfo in GetVmInfos()) { vmController.TakeSnapshot(SnapshotName.Text, vmInfo); AppendLogBox("Take snapshot {0} on {1}", SnapshotName.Text, vmInfo.name); } AddHistory(); } catch (Exception ex) { AppendLogBox("Take snapshot fail: {0}", ErrMsg(ex)); } }
private void Copy_Click(object sender, EventArgs e) { if (HostInfoInvalid()) return; if (VmInfoInvalid()) return; if (string.IsNullOrWhiteSpace(PathInGuest.Text)) return; if (_toCopyFiles.Count == 0) return; string guestPath = PathInGuest.Text; string fileList = ""; foreach (string file in _toCopyFiles) fileList += Path.GetFileName(file) + "\n"; string text = "Do you want to copy the following files\n\n"; DialogResult dialogResult = MessageBox.Show(text + fileList, "VmManager", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { try { VMController vmController = new VMController(GetHostInfo()); foreach (VMController.VMInfo vmInfo in GetVmInfos()) { foreach (string fileName in _toCopyFiles) { vmController.CopyFileToGuest(fileName, guestPath, vmInfo); AppendLogBox("Copy {0} ==> {1}", Path.GetFileName(fileName), vmInfo.name); } } AddHistory(); } catch (Exception ex) { AppendLogBox("Copy fail: {0}", ErrMsg(ex)); } } else { _toCopyFiles.Clear(); } }
private void RunProg_Click(object sender, EventArgs e) { if (HostInfoInvalid()) return; VMController vmController = new VMController(GetHostInfo()); try { foreach (VMController.VMInfo vmInfo in GetVmInfos()) { VMWareVirtualMachine.Process proc = vmController.RunProgram(PathInGuest.Text, vmInfo); AppendLogBox("Program Exit Code {0}", proc.ExitCode); } AddHistory(); } catch (Exception ex) { AppendLogBox("Run Program Fail: {0}", ErrMsg(ex)); } }