Author: cwittich Date: Wed Jun 21 18:40:56 2006 New Revision: 22460
URL: http://svn.reactos.ru/svn/reactos?rev=22460&view=rev Log: first working version after the redesign
Modified: trunk/tools/Qemu GUI/QEmu.cs trunk/tools/Qemu GUI/Qemu GUI.csproj trunk/tools/Qemu GUI/Qemu GUI.suo trunk/tools/Qemu GUI/frmMain.cs
Modified: trunk/tools/Qemu GUI/QEmu.cs URL: http://svn.reactos.ru/svn/reactos/trunk/tools/Qemu%20GUI/QEmu.cs?rev=22460&a... ============================================================================== --- trunk/tools/Qemu GUI/QEmu.cs (original) +++ trunk/tools/Qemu GUI/QEmu.cs Wed Jun 21 18:40:56 2006 @@ -4,6 +4,7 @@ using System.Diagnostics; using System.Xml; using System.Xml.Serialization; +using System.IO;
namespace Qemu_GUI { @@ -18,6 +19,7 @@ private Debug m_Debug = new Debug(); private Paths m_Paths = new Paths(); private CDROM m_CDROM = new CDROM(); + private string m_LastError = "";
public QEmu() { @@ -30,35 +32,54 @@ public bool CreateImage(string FileName, long Size, string Format) { long d = Size * 1024; - string argv = " create -f " + Format + " " + FileName + "." + Format + " " + d.ToString(); ; - - Process Qemu = new Process(); - Qemu.StartInfo.FileName = this.Paths.QEmu + "\" + "qemu-img.exe"; - Qemu.StartInfo.WorkingDirectory = this.Paths.QEmu; - Qemu.StartInfo.Arguments = argv; + string argv = " create -f " + Format + " " + (char) 34 + FileName + (char) 34 + " " + d.ToString(); ; + Process p = new Process(); + p.StartInfo.FileName = Path.GetDirectoryName (this.Paths.QEmu) + "\" + "qemu-img.exe"; + p.StartInfo.WorkingDirectory = Path.GetDirectoryName(this.Paths.QEmu); + p.StartInfo.Arguments = argv; + p.StartInfo.RedirectStandardError = true; + p.StartInfo.UseShellExecute = false; + p.StartInfo.CreateNoWindow = true; try { - Qemu.Start(); + p.Start(); + m_LastError = p.StandardError.ReadToEnd(); + if (m_LastError.Length > 0) + return false; } catch { + m_LastError = "qemu-img.exe not found!"; return false; } return true; }
+ public string GetLastError() + { + return m_LastError; + } + public bool Start() { - Process Qemu = new Process(); - Qemu.StartInfo.FileName = this.Paths.QEmu + "\" + "qemu.exe"; - Qemu.StartInfo.WorkingDirectory = this.Paths.QEmu; - Qemu.StartInfo.Arguments = GetArgv(); + Process p = new Process(); + p.StartInfo.FileName = this.Paths.QEmu; + p.StartInfo.WorkingDirectory = Path.GetDirectoryName(this.Paths.QEmu); + p.StartInfo.Arguments = GetArgv(); + p.StartInfo.RedirectStandardError = true; + p.StartInfo.UseShellExecute = false; + p.StartInfo.CreateNoWindow = true; + try { - Qemu.Start(); + p.Start(); + m_LastError = p.StandardError.ReadToEnd(); + if (m_LastError.Length > 0) + return false; } catch { + m_LastError = "qemu.exe not found!"; return false; } return true; @@ -115,40 +136,16 @@
private string GetArgv() { - string arg = "-L " + this.Paths.QEmu + " "; - /* bool audio_on = false; */ - - /* Machine settings */ - if (!this.m_Misc.StandardPC) - arg = arg + "-M isapc "; - else - arg = arg + "-M pc "; - - - /* Floppy settings */ - if (this.Floppies.FDD[0].Enabled && (this.Floppies.FDD[0].Path.Length > 0)) - arg = arg + "-fda " + this.Floppies.FDD[0].Path + " "; - - if (this.Floppies.FDD[1].Enabled && (this.Floppies.FDD[1].Path.Length > 0)) - arg = arg + "-fdb " + this.Floppies.FDD[1].Path + " "; - - - /* Harddisk settings */ - for (int i = 0; i < 4; i++) - { - if (this.Harddisks.HDD[i].Enabled && (this.Harddisks.HDD[i].Path.Length > 0)) - arg = arg + "-hd" + ((char) i + 97) + " " + this.Harddisks.HDD[i].Path + " "; - } - - - /* CD-ROM */ - if (this.CDROM.Enabled) - { - if (this.CDROM.UseFromHost) - arg = arg + "-cdrom " + this.CDROM.HostDrive + " "; - else if (this.CDROM.Image.Length > 0) - arg = arg + "-cdrom " + this.CDROM.Image + " "; - } + string arg = "-L " + Path.GetDirectoryName(this.Paths.QEmu) + " "; + + arg += Misc.ToString(); + arg += Floppies.ToString(); + arg += Harddisks.ToString(); + arg += CDROM.ToString(); + arg += Audio.ToString(); + arg += Debug.ToString(); + + Console.WriteLine(arg);
return arg; } @@ -166,6 +163,17 @@ m_HardDisks[i] = new Drive(); }
+ public override string ToString() + { + string buffer = ""; + for (int i = 0; i < 4; i++) + { + if (this.HDD[i].Enabled && (this.HDD[i].Path.Length > 0)) + buffer += "-hd" + ((char)i + 97) + " " + (char) 34 + this.HDD[i].Path + (char) 34 +" "; + } + return buffer; + } + [XmlElement("Harddisk")] public Drive[] HDD { @@ -185,6 +193,18 @@ m_Floppies[i] = new Drive(); }
+ public override string ToString() + { + string buffer = ""; + if (this.FDD[0].Enabled && (this.FDD[0].Path.Length > 0)) + buffer += "-fda " + (char) 34 + this.FDD[0].Path + (char) 34 + " "; + + if (this.FDD[1].Enabled && (this.FDD[1].Path.Length > 0)) + buffer += "-fdb " + (char) 34 + this.FDD[1].Path + (char) 34 + " "; + + return buffer; + } + [XmlElement("Floppy")] public Drive[] FDD { @@ -195,13 +215,29 @@
public class Paths { + private string m_QEmu = ""; + [XmlElement("QEmu")] - public string QEmu; + public string QEmu + { + get + { + return m_QEmu; + } + set + { + if (value != "") + m_QEmu = value; + else + m_QEmu = "."; + } + } [XmlElement("VDK")] - public string VDK; + public string VDK = ".";
public Paths() { + m_QEmu = "."; } }
@@ -213,6 +249,65 @@ public int Memory; [XmlElement("CPUs")] public int CPUs; + [XmlElement("BootFrom")] + public string BootFrom = ""; + [XmlElement("SetClock")] + public bool SetClock; + [XmlElement("Fullscreen")] + public bool Fullscreen; + [XmlElement("VGA")] + public bool VGA; + [XmlElement("KQEmu")] + public bool KQEmu; + + public override string ToString() + { + /* Memory settings */ + string buffer = "-m " + this.Memory.ToString() + " "; + + /* SMP settings */ + buffer += "-smp " + this.CPUs.ToString() + " "; + + /* Set clock */ + if (this.SetClock) + buffer += "-localtime "; + + /* No vga output */ + if (this.VGA) + buffer += "-nographic "; + + /* Fullscreen */ + if (this.Fullscreen) + buffer += "-full-screen "; + + /* KQEmu */ + if (!this.KQEmu) + buffer += "-no-kqemu "; + + /* Machine settings */ + if (!this.StandardPC) + buffer += "-M isapc "; + else + buffer += "-M pc "; + + /* Boot options */ + switch (this.BootFrom) + { + case "Floppy": + buffer += "-boot a "; + break; + case "Harddisk": + buffer += "-boot c "; + break; + case "CD-ROM": + buffer += "-boot d "; + break; + default: + break; + } + + return buffer; + }
public Misc() { @@ -233,6 +328,28 @@ public Audio() { } + + public override string ToString() + { + bool audio_on = (this.ES1370 | this.OPL2 | this.Soundblaster | this.Speaker); + + if (!audio_on) + return ""; + + string buffer = "-soundhw "; + + if (this.Speaker) + buffer += "pcspk,"; + if (this.Soundblaster) + buffer += "sb16,"; + if (this.OPL2) + buffer += "adlib,"; + if (this.ES1370) + buffer += "es1370,"; + + return buffer.Substring(0, buffer.Length - 1) + " "; + } + }
public class Debug @@ -242,6 +359,31 @@
[XmlElement("VBE3")] public bool VBE3; + + public override string ToString() + { + string buffer = ""; + + /* Serial port */ + if (this.SerialPort.Redirect) + { + if (this.SerialPort.FileName.Length > 0) + buffer = "-serial file:" + (char) 34 + this.SerialPort.FileName + (char) 34 + " "; + } + + /* Parallel port */ + if (this.ParallelPort.Redirect) + { + if (this.ParallelPort.FileName.Length > 0) + buffer += "-parallel file:" + (char) 34 + this.ParallelPort.FileName + (char) 34 + " "; + } + + /* Standard VGA */ + if (this.VBE3) + buffer += "-std-vga "; + + return buffer; + }
public Debug() { @@ -283,6 +425,19 @@ [XmlAttribute("Enabled")] public bool Enabled;
+ public override string ToString() + { + string buffer = ""; + if (this.Enabled) + { + if (this.UseFromHost) + buffer = "-cdrom " + this.HostDrive + " "; + else if (this.Image.Length > 0) + buffer = "-cdrom " + (char)34 + this.Image + (char)34 + " "; + } + return buffer; + } + public CDROM() { }
Modified: trunk/tools/Qemu GUI/Qemu GUI.csproj URL: http://svn.reactos.ru/svn/reactos/trunk/tools/Qemu%20GUI/Qemu%20GUI.csproj?r... ============================================================================== --- trunk/tools/Qemu GUI/Qemu GUI.csproj (original) +++ trunk/tools/Qemu GUI/Qemu GUI.csproj Wed Jun 21 18:40:56 2006 @@ -96,6 +96,12 @@ <Compile Include="AssemblyInfo.cs"> <SubType>Code</SubType> </Compile> + <Compile Include="frmError.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="frmError.Designer.cs"> + <DependentUpon>frmError.cs</DependentUpon> + </Compile> <Compile Include="frmMain.cs"> <SubType>Form</SubType> </Compile> @@ -105,6 +111,10 @@ <DependentUpon>Resources.resx</DependentUpon> </Compile> <Compile Include="QEmu.cs" /> + <EmbeddedResource Include="frmError.resx"> + <SubType>Designer</SubType> + <DependentUpon>frmError.cs</DependentUpon> + </EmbeddedResource> <EmbeddedResource Include="frmMain.resx"> <DependentUpon>frmMain.cs</DependentUpon> <SubType>Designer</SubType>
Modified: trunk/tools/Qemu GUI/Qemu GUI.suo URL: http://svn.reactos.ru/svn/reactos/trunk/tools/Qemu%20GUI/Qemu%20GUI.suo?rev=... ============================================================================== Binary files - no diff available.
Modified: trunk/tools/Qemu GUI/frmMain.cs URL: http://svn.reactos.ru/svn/reactos/trunk/tools/Qemu%20GUI/frmMain.cs?rev=2246... ============================================================================== --- trunk/tools/Qemu GUI/frmMain.cs (original) +++ trunk/tools/Qemu GUI/frmMain.cs Wed Jun 21 18:40:56 2006 @@ -988,19 +988,17 @@ // // cboImageFormat // + this.cboImageFormat.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cboImageFormat.Items.AddRange(new object[] { "cloop", - "cow ", + "cow", "qcow", - "raw ", - "vmdk ", - "", - " "}); + "raw", + "vmdk"}); this.cboImageFormat.Location = new System.Drawing.Point(99, 39); this.cboImageFormat.Name = "cboImageFormat"; this.cboImageFormat.Size = new System.Drawing.Size(56, 21); this.cboImageFormat.TabIndex = 7; - this.cboImageFormat.Text = "vmdk "; // // tabAudio // @@ -1430,6 +1428,7 @@ this.ImeMode = System.Windows.Forms.ImeMode.On; this.MaximizeBox = false; this.Name = "frmMain"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Qemu GUI Launcher Version 1.0 written by Magnus Olsen for ReactOS"; this.Load += new System.EventHandler(this.frmMain_Load); this.grpMachine.ResumeLayout(false); @@ -1492,8 +1491,20 @@
private void btnCreateImage_Click(object sender, System.EventArgs e) { + saveFileDialog1.Filter = "All files (*.*)|*.*"; + saveFileDialog1.FileName = "image." + cboImageFormat.Text; + saveFileDialog1.DefaultExt = cboImageFormat.Text; if (saveFileDialog1.ShowDialog() == DialogResult.OK) - qemu.CreateImage(saveFileDialog1.FileName, Convert.ToInt32(txtImageSize.Text), cboImageFormat.Text); + { + if (!qemu.CreateImage(saveFileDialog1.FileName, Convert.ToInt32(txtImageSize.Text), cboImageFormat.Text)) + { + frmError fError = new frmError(); + fError.txtError.Text = qemu.GetLastError(); + fError.ShowDialog(this); + } + else + MessageBox.Show("Image created"); + } }
private void button11_Click(object sender, System.EventArgs e) @@ -1560,6 +1571,7 @@ #region CDROM private void btnBrowseCDROM_Click(object sender, System.EventArgs e) { + openFile.Filter = "CD-Images (*.iso)|*.iso"; if (openFile.ShowDialog() == DialogResult.OK) txtCDROM.Text = openFile.FileName; } @@ -1645,126 +1657,17 @@ private void btnLaunch_Click(object sender, System.EventArgs e) { SaveSettings(); - qemu.Start(); + if (!qemu.Start()) + { + frmError fError = new frmError(); + fError.txtError.Text = qemu.GetLastError(); + fError.ShowDialog(this); + } + } /* private string GetArgv() { - - /// boot options - if (cboBootFrom.Text == "Floppy") - { - arg = arg + "-boot a "; - } - else if (cboBootFrom.Text == "HardDisk") - { - arg = arg + "-boot c "; - } - - else if (cboBootFrom.Text == "CDRom") - { - arg = arg + "-boot d "; - } - - /// memmory setting - arg = arg + "-m " + numMemory.Value.ToString() + " "; - - // smp setting - arg = arg + "-smp " + numSMP.Value.ToString() + " "; - - // no vga output - if (chkVGAoutput.Checked == false) - { - arg = arg + "-nographic "; - } - - // set clock - if (chkSetClock.Checked) - { - arg = arg + "-localtime "; - } - - // fullscreen - if (chkFullscreen.Checked) - { - arg = arg + "-full-screen "; - } - - if (!chkKQEmu.Checked) - { - arg = arg + "-no-kqemu "; - } - - /// Audio setting - if (chkPCSpeaker.Checked == true) - { - audio_on = true; - arg = arg + "-soundhw pcspk"; - } - - if (chkSoundBlaster.Checked == true) - { - if (audio_on == false) - { - arg = arg + "-soundhw sb16"; - audio_on = true; - } - else - { - arg = arg + ",sb16"; - } - } - - if (chkOPL2.Checked == true) - { - if (audio_on == false) - { - arg = arg + "-soundhw adlib"; - audio_on = true; - } - else - { - arg = arg + ",adlib"; - } - } - - if (chkES1370.Checked == true) - { - if (audio_on == false) - { - arg = arg + "-soundhw es1370"; - audio_on = true; - } - else - { - arg = arg + ",es1370"; - } - } - - if (audio_on == true) - { - arg = arg + " "; - } - - /// serial - if (chkSerialToFile.Checked == true) - { - if (qemu.Debug.SerialPort.FileName != "") - arg = arg + "-serial file:" + qemu.Debug.SerialPort.FileName + " "; - } - - // paraell port - if (chkParallelToFile.Checked == true) - { - if (par_path != "") - arg = arg + "-parallel file:" + par_path +" "; - } - - // vga standard - if (chkVBE30.Checked == true) - { - arg = arg + "-std-vga "; - }
// gdb if (checkBox14.Checked == true) @@ -1784,7 +1687,6 @@ arg = arg + "-loadvm "+qemu_state+" "; }
- return arg; }
*/ @@ -1818,6 +1720,7 @@
cboCDROM.SelectedIndex = 0; cboBootFrom.SelectedIndex = 1; + cboImageFormat.SelectedIndex = 4; }
#region Floppy @@ -1852,7 +1755,7 @@ { openFile.Filter = "Executable files (*.exe)|*.exe"; if (openFile.ShowDialog() == DialogResult.OK) - txtQEmuPath.Text = Path.GetDirectoryName(openFile.FileName); + txtQEmuPath.Text = openFile.FileName; }
private void btnVDKBrowse_Click(object sender, EventArgs e) @@ -1902,18 +1805,50 @@ optLegacyPC.Checked = !qemu.Misc.StandardPC; numMemory.Value = qemu.Misc.Memory; numSMP.Value = qemu.Misc.CPUs; + cboBootFrom.Text = qemu.Misc.BootFrom; + chkSetClock.Checked = qemu.Misc.SetClock; + chkVGAoutput.Checked = qemu.Misc.VGA; + chkFullscreen.Checked = qemu.Misc.Fullscreen; + chkKQEmu.Checked = qemu.Misc.KQEmu;
/* CD-ROM */ optHostCDROM.Checked = qemu.CDROM.UseFromHost; optCDImage.Checked = !qemu.CDROM.UseFromHost; txtCDROM.Text = qemu.CDROM.Image; cboCDROM.Text = qemu.CDROM.HostDrive; - chkUseCDROM.Checked = qemu.CDROM.Enabled; + chkUseCDROM.Checked = qemu.CDROM.Enabled; + + /* Floppies */ + chkFloppyA.Checked = qemu.Floppies.FDD[0].Enabled; + txtFloppyA.Text = qemu.Floppies.FDD[0].Path; + chkFloppyB.Checked = qemu.Floppies.FDD[1].Enabled; + txtFloppyB.Text = qemu.Floppies.FDD[1].Path;
/* Paths */ txtQEmuPath.Text = qemu.Paths.QEmu; txtVDKPath.Text = qemu.Paths.VDK; - grpVDK.Enabled = (txtVDKPath.Text.Length > 0); + grpVDK.Enabled = (txtVDKPath.Text.Length > 0); + + /* Harddisks */ + chkUseHDA.Checked = qemu.Harddisks.HDD[0].Enabled; + txtHDA.Text = qemu.Harddisks.HDD[0].Path; + chkUseHDB.Checked = qemu.Harddisks.HDD[1].Enabled; + txtHDB.Text = qemu.Harddisks.HDD[1].Path; + chkUseHDC.Checked = qemu.Harddisks.HDD[2].Enabled; + txtHDC.Text = qemu.Harddisks.HDD[2].Path; + chkUseHDD.Checked = qemu.Harddisks.HDD[3].Enabled; + txtHDD.Text = qemu.Harddisks.HDD[3].Path; + + /* Audio */ + chkES1370.Checked = qemu.Audio.ES1370; + chkSoundBlaster.Checked = qemu.Audio.Soundblaster; + chkPCSpeaker.Checked = qemu.Audio.Speaker; + chkOPL2.Checked = qemu.Audio.OPL2; + + /* Debug */ + chkSerialToFile.Checked = qemu.Debug.SerialPort.Redirect; + chkParallelToFile.Checked = qemu.Debug.ParallelPort.Redirect; + chkVBE30.Checked = qemu.Debug.VBE3;
}
@@ -1922,7 +1857,12 @@ /* Misc */ qemu.Misc.StandardPC = optStandardPC.Checked; qemu.Misc.Memory = (int) numMemory.Value; - qemu.Misc.CPUs = (int) numSMP.Value; + qemu.Misc.CPUs = (int) numSMP.Value; + qemu.Misc.BootFrom = cboBootFrom.Text; + qemu.Misc.SetClock = chkSetClock.Checked; + qemu.Misc.VGA = chkVGAoutput.Checked; + qemu.Misc.Fullscreen = chkFullscreen.Checked; + qemu.Misc.KQEmu = chkKQEmu.Checked;
/* Paths */ qemu.Paths.QEmu = txtQEmuPath.Text;