66
66
ico_file = string.Format("VirtualBox_64px.png@{0}", GetType().Assembly.FullName);
68
68
name = MachineInfo[0].Attributes["name"].Value;
69
//determine the state of thte VM
70
ProcessStartInfo ps = new ProcessStartInfo ("VBoxManage", "showvminfo " + uuid);
71
ps.UseShellExecute = false;
72
ps.RedirectStandardOutput = true;
73
using (Process p = Process.Start (ps)) {
75
string output = p.StandardOutput.ReadToEnd ();
76
int s = output.IndexOf("State:");
77
int e = output.IndexOf("\n", s);
78
string outputState = output.Substring(s, e-s);
79
//States: saved, running, paused, powered off
80
if (outputState.Contains("saved"))
81
state = VMState.saved;
82
else if (outputState.Contains("running"))
84
else if (outputState.Contains("paused"))
85
state = VMState.paused;
86
else if (outputState.Contains("powered off"))
88
if (output.Contains("Snapshots:"))
89
has_saved_states = true;
70
this.state = CurrentState;
73
public VMState CurrentState
77
VMState cur_state = default(VMState);
78
Console.WriteLine("Updating State for {0}", this.name);
79
//determine the state of thte VM
80
ProcessStartInfo ps = new ProcessStartInfo ("VBoxManage", "showvminfo " + uuid);
81
ps.UseShellExecute = false;
82
ps.RedirectStandardOutput = true;
83
using (Process p = Process.Start (ps))
86
string output = p.StandardOutput.ReadToEnd ();
87
int s = output.IndexOf("State:");
88
int e = output.IndexOf("\n", s);
89
string outputState = output.Substring(s, e-s);
90
//States: saved, running, paused, powered off
91
if (outputState.Contains("saved"))
92
cur_state = VMState.saved;
93
else if (outputState.Contains("running"))
94
cur_state = VMState.on;
95
else if (outputState.Contains("paused"))
96
cur_state = VMState.paused;
97
else if (outputState.Contains("powered off"))
98
cur_state = VMState.off;
99
if (output.Contains("Snapshots:"))
100
has_saved_states = true;
93
106
public string Name { get { return name; } }