-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathMainForm.cs
857 lines (735 loc) · 30.3 KB
/
MainForm.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;
using System.Xml.Serialization;
using Microsoft.Win32;
namespace Qemu_GUI
{
public partial class MainForm : Form
{
private ToolStripSeparator toolStripSeparator2;
private ToolStripMenuItem setAsDefaultToolStripMenuItem;
private const string strRegKey = "Software\\RosTE";
private const string strDefCon = "DefaultConfig";
private Runner runner;
private string currentDir = Directory.GetCurrentDirectory();
private Data data = new Data();
public MainForm()
{
InitializeComponent();
}
private void frmMain_Load(object sender, EventArgs e)
{
/* Fill a list with possible free driveletters */
ArrayList DriveLetters = new ArrayList();
for (int i = 100; i < 123; i++)
{
DriveLetters.Add(Convert.ToChar(i).ToString().ToUpper() + @":\");
}
DriveInfo[] drives = DriveInfo.GetDrives();
foreach (DriveInfo drive in drives)
{
/* remove all driveletters which are in use */
DriveLetters.Remove(drive.RootDirectory.ToString());
}
/* add to vdk drop box */
foreach (object o in DriveLetters)
cboVDKDrive.Items.Add(o);
cboVDKDrive.SelectedIndex = 0;
cboBootFrom.SelectedIndex = 1;
cboImageFormat.SelectedIndex = 4;
cboMachine.SelectedIndex = 0;
/* load default config file */
LoadDefaultConfig();
/* Find out which controls should be enabled or disabled */
chkSerialToFile_CheckedChanged(null, null);
chkSerialToPipe_CheckedChanged(null, null);
}
#region Harddisks
private void btnBrowseHDA_Click(object sender, System.EventArgs e)
{
openFile.Title = "Select Harddisk Image";
openFile.Filter = "Harddisk images |*.vmdk;*.cloop;*.cow;*.qcow;*.raw;*.img|All Files | *.*";
if (openFile.ShowDialog() == DialogResult.OK)
txtHDA.Text = openFile.FileName;
}
private void btnBrowseHDB_Click(object sender, System.EventArgs e)
{
openFile.Title = "Select Harddisk Image";
openFile.Filter = "Harddisk images |*.vmdk;*.cloop;*.cow;*.qcow;*.raw;*.img|All Files | *.*";
if (openFile.ShowDialog() == DialogResult.OK)
txtHDB.Text = openFile.FileName;
}
private void btnBrowseHDC_Click(object sender, System.EventArgs e)
{
openFile.Title = "Select Harddisk Image";
openFile.Filter = "Harddisk images |*.vmdk;*.cloop;*.cow;*.qcow;*.raw;*.img|All Files | *.*";
if (openFile.ShowDialog() == DialogResult.OK)
txtHDC.Text = openFile.FileName;
}
private void btnBrowseHDD_Click(object sender, System.EventArgs e)
{
openFile.Title = "Select Harddisk Image";
openFile.Filter = "Harddisk images |*.vmdk;*.cloop;*.cow;*.qcow;*.raw;*.img|All Files | *.*";
if (openFile.ShowDialog() == DialogResult.OK)
txtHDD.Text = openFile.FileName;
}
private void chkUseHDA_CheckedChanged(object sender, System.EventArgs e)
{
btnBrowseHDA.Enabled = chkUseHDA.Checked;
txtHDA.Enabled = chkUseHDA.Checked;
}
private void chkUseHDB_CheckedChanged(object sender, System.EventArgs e)
{
btnBrowseHDB.Enabled = chkUseHDB.Checked;
txtHDB.Enabled = chkUseHDB.Checked;
}
private void chkUseHDC_CheckedChanged(object sender, System.EventArgs e)
{
btnBrowseHDC.Enabled = chkUseHDC.Checked;
txtHDC.Enabled = chkUseHDC.Checked;
txtHDC.Text = "";
}
private void chkUseHDD_CheckedChanged(object sender, System.EventArgs e)
{
btnBrowseHDD.Enabled = chkUseHDD.Checked;
txtHDD.Enabled = chkUseHDD.Checked;
}
#endregion
#region CDROM
private void btnBrowseCDROM_Click(object sender, System.EventArgs e)
{
openFile.Title = "Select CD-ROM image";
openFile.Filter = "CD-Images (*.iso)|*.iso";
if (openFile.ShowDialog() == DialogResult.OK)
txtCDROM.Text = openFile.FileName;
}
private void chkUseCDROM_CheckedChanged(object sender, System.EventArgs e)
{
if (chkUseHDC.Checked == true)
{
btnBrowseCDROM.Enabled = false;
txtCDROM.Enabled = false;
}
else
{
chkUseCDROM.Enabled = true;
}
if (chkUseCDROM.Checked == true)
{
chkUseHDC.Enabled = false;
chkUseHDC.Checked = false;
txtHDC.Text = "Used for CD-ROM!";
txtHDC.Enabled = false;
txtCDROM.Enabled = true;
btnBrowseCDROM.Enabled = true;
}
else
{
btnBrowseCDROM.Enabled = false;
txtCDROM.Enabled = false;
chkUseHDC.Enabled = true;
txtHDC.Text = "";
}
}
private void optHostCDROM_CheckedChanged(object sender, System.EventArgs e)
{
txtCDROM.Enabled = false;
}
private void optCDImage_CheckedChanged(object sender, System.EventArgs e)
{
txtCDROM.Enabled = true;
}
#endregion
#region Debug
private void chkSerialToScrn_CheckedChanged(object sender, EventArgs e)
{
if (chkSerialToScrn.Checked == true)
{
btnBrowseSerial.Enabled = false;
txtSerialFile.Enabled = false;
txtSerialPipe.Enabled = false;
data.Debug.SerialPort.SRedirect = true;
data.Debug.SerialPort.FRedirect = false;
data.Debug.SerialPort.PRedirect = false;
chkSerialToPipe.Enabled = false;
chkSerialToFile.Enabled = false;
chkSerialToPipe.Checked = false;
chkSerialToFile.Checked = false;
}
else
{
btnBrowseSerial.Enabled = true;
data.Debug.SerialPort.SRedirect = false;
data.Debug.SerialPort.FRedirect = false;
data.Debug.SerialPort.PRedirect = false;
chkSerialToPipe.Enabled = true;
chkSerialToFile.Enabled = true;
}
}
private void chkSerialToFile_CheckedChanged(object sender, System.EventArgs e)
{
if (chkSerialToFile.Checked == true)
{
btnBrowseSerial.Enabled = true;
txtSerialFile.Enabled = true;
txtSerialPipe.Enabled = false;
data.Debug.SerialPort.FRedirect = true;
data.Debug.SerialPort.PRedirect = false;
chkSerialToPipe.Enabled = false;
chkSerialToPipe.Checked = false;
chkSerialToScrn.Enabled = false;
chkSerialToScrn.Checked = false;
}
else
{
data.Debug.SerialPort.FRedirect = false;
chkSerialToPipe.Enabled = true;
chkSerialToScrn.Enabled = true;
txtSerialFile.Enabled = false;
btnBrowseSerial.Enabled = false;
}
}
private void chkSerialToPipe_CheckedChanged(object sender, EventArgs e)
{
if (chkSerialToPipe.Checked == true)
{
txtSerialPipe.Enabled = true;
data.Debug.SerialPort.FRedirect = false;
data.Debug.SerialPort.PRedirect = true;
chkSerialToFile.Enabled = false;
chkSerialToFile.Checked = false;
txtSerialFile.Enabled = false;
btnBrowseSerial.Enabled = false;
}
else
{
chkSerialToFile.Enabled = true;
data.Debug.SerialPort.PRedirect = false;
txtSerialPipe.Enabled = false;
}
}
private void btnBrowseSerial_Click(object sender, System.EventArgs e)
{
saveFileDialog.Title = "Serial output to file";
saveFileDialog.FileName = "serial_ouput.txt";
saveFileDialog.Filter = "Text File (*.txt)|*.txt";
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
txtSerialFile.Text = saveFileDialog.FileName;
}
}
static string saved_state;
private void btnLoadVM_Click(object sender, System.EventArgs e)
{
openFile.ShowDialog();
saved_state = openFile.FileName;
data.Debug.EnableSavedState = true;
}
private void chkVNC_CheckedChanged(object sender, System.EventArgs e)
{
txtVNC.Enabled = chkVNC.Checked;
}
#endregion
#region Floppy
private void chkFloppyA_CheckedChanged(object sender, EventArgs e)
{
btnBrowseFloppyA.Enabled = chkFloppyA.Checked;
txtFloppyA.Enabled = chkFloppyA.Checked;
}
private void chkFloppyB_CheckedChanged(object sender, EventArgs e)
{
btnBrowseFloppyB.Enabled = chkFloppyB.Checked;
txtFloppyB.Enabled = chkFloppyB.Checked;
}
private void btnBrowseFloppyA_Click(object sender, System.EventArgs e)
{
openFile.Title = "Browse for a floppy image";
openFile.Filter = "All Files | *.*";
if (openFile.ShowDialog() == DialogResult.OK)
txtFloppyA.Text = openFile.FileName;
}
private void btnBrowseFloppyB_Click(object sender, System.EventArgs e)
{
openFile.Title = "Browse for a floppy image";
openFile.Filter = "All Files | *.*";
if (openFile.ShowDialog() == DialogResult.OK)
txtFloppyB.Text = openFile.FileName;
}
#endregion
#region Paths
private void btnQEmuPath_Click(object sender, EventArgs e)
{
folderBrowserDialog1.Description = "Select Qemu path";
folderBrowserDialog1.ShowNewFolderButton = false;
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
txtQEmuPath.Text = folderBrowserDialog1.SelectedPath;
data.Paths.Qemu = txtQEmuPath.Text;
}
}
private void btnVDKBrowse_Click(object sender, EventArgs e)
{
folderBrowserDialog1.Description = "Select VDK path";
folderBrowserDialog1.ShowNewFolderButton = false;
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
txtVDKPath.Text = folderBrowserDialog1.SelectedPath;
data.Paths.VDK = txtVDKPath.Text;
}
}
#endregion
#region Settings
private void LoadDefaultConfig()
{
/* Load the default config file */
bool bLoaded = false;
RegistryKey RegKey = Registry.CurrentUser.OpenSubKey(strRegKey);
if (RegKey != null)
{
string DefaultConfig = (string)RegKey.GetValue(strDefCon);
if (File.Exists(DefaultConfig))
{
XmlSerializer s = new XmlSerializer(typeof(Data));
TextReader r = new StreamReader(DefaultConfig);
data = (Data)s.Deserialize(r);
r.Close();
LoadSettings();
bLoaded = true;
this.Text += " - " +DefaultConfig;
}
else
{
MessageBox.Show("Unable to load the default config file");
}
RegKey.Close();
}
if (!bLoaded)
{
/* if no settings file found, fallback to hardcoded defaults */
/* Network */
VNic nic = new VNic("", NicModel.ne2k_pci);
VUser use = new VUser("reactos", 0);
data.Network.AddNetString(nic.ToString() + use.ToString());
string[] lans = data.Network.GetNetStrings();
listVLANs.Items.Add(lans[0]);
}
}
private void btnSave_Click(object sender, EventArgs e)
{
XmlSerializer s;
TextWriter w;
SaveSettings();
saveFileDialog.Title = "Save settings";
saveFileDialog.InitialDirectory = currentDir;
saveFileDialog.FileName = "config.xml";
saveFileDialog.Filter = "QEMU GUI Config (*.xml)|*.xml";
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
try
{
s = new XmlSerializer(typeof(Data));
w = new StreamWriter(saveFileDialog.FileName);
s.Serialize(w, data);
}
catch (Exception ex)
{
ErrorForm error = new ErrorForm();
error.txtError.Text = "Error trying to save settings!";
error.txtError.Text += "Exception Info:" + Environment.NewLine + ex.Message;
error.txtError.Text += Environment.NewLine + ex.StackTrace;
}
}
}
private void LoadSettings()
{
/* General */
cboMachine.SelectedIndex = (int) data.General.Machine;
try
{
numMemory.Value = data.General.Memory;
}
catch (Exception)
{
numMemory.Value = 128;
}
try
{
numSMP.Value = data.General.CPUs;
}
catch (Exception)
{
numSMP.Value = 1;
}
cboBootFrom.SelectedItem = data.General.BootFrom;
chkSetClock.Checked = data.General.SetClock;
chkVGAoutput.Checked = data.General.VGA;
chkFullscreen.Checked = data.General.Fullscreen;
chkKQEmu.Checked = data.General.KQEmu;
chkACPI.Checked = data.General.ACPI;
/* CD-ROM */
chkUseCDROM.Checked = data.CDROM.Enabled;
if (chkUseCDROM.Checked)
{
txtHDC.Text = "Used for CD-ROM!";
txtHDC.Enabled = false;
}
txtCDROM.Text = data.CDROM.Image;
/* Floppies */
chkFloppyA.Checked = data.Floppies.FDD[0].Enabled;
txtFloppyA.Text = data.Floppies.FDD[0].Path;
chkFloppyB.Checked = data.Floppies.FDD[1].Enabled;
txtFloppyB.Text = data.Floppies.FDD[1].Path;
/* Paths */
txtQEmuPath.Text = data.Paths.Qemu;
txtVDKPath.Text = data.Paths.VDK;
/* Harddisks */
chkUseHDA.Checked = data.Harddisks.HDD[0].Enabled;
txtHDA.Text = data.Harddisks.HDD[0].Path;
chkUseHDB.Checked = data.Harddisks.HDD[1].Enabled;
txtHDB.Text = data.Harddisks.HDD[1].Path;
chkUseHDC.Checked = data.Harddisks.HDD[2].Enabled;
txtHDC.Text = data.Harddisks.HDD[2].Path;
chkUseHDD.Checked = data.Harddisks.HDD[3].Enabled;
txtHDD.Text = data.Harddisks.HDD[3].Path;
/* Audio */
chkES1370.Checked = data.Audio.ES1370;
chkSoundBlaster.Checked = data.Audio.Soundblaster;
chkPCSpeaker.Checked = data.Audio.Speaker;
chkOPL2.Checked = data.Audio.OPL2;
/* Debug */
chkSerialToFile.Checked = data.Debug.SerialPort.FRedirect;
txtSerialFile.Text = data.Debug.SerialPort.FileName;
chkSerialToPipe.Checked = data.Debug.SerialPort.PRedirect;
txtSerialPipe.Text = data.Debug.SerialPort.PipeName;
chkSerialToScrn.Checked = data.Debug.SerialPort.SRedirect;
chkSerialToFile_CheckedChanged(null, null);
saved_state = data.Debug.SavedStatePath;
chkVBE30.Checked = data.Debug.VBE3;
txtGDBPort.Text = data.Debug.GDBPort.ToString();
/* Network */
string[] temp = data.Network.GetNetStrings();
listVLANs.Items.Clear();
if(temp[0] != null)
for (int i = 0; i < data.Network.Count; i++)
{
listVLANs.Items.Add(temp[i]);
}
/* Tools */
txtVDKImage.Text = data.Tools.vdk.Image;
cboVDKDrive.Text = data.Tools.vdk.DriveLetter;
/* Other */
txtLinuxK.Text = data.Other.LKernel;
txtABios.Text = data.Other.ABios;
txtAppendCmd.Text = data.Other.AppendCmdLine;
}
private void SaveSettings()
{
/* General */
data.General.Machine = (Platforms) cboMachine.SelectedIndex;
data.General.Memory = (int) numMemory.Value;
data.General.CPUs = (int) numSMP.Value;
data.General.BootFrom = cboBootFrom.SelectedItem.ToString();
data.General.SetClock = chkSetClock.Checked;
data.General.VGA = chkVGAoutput.Checked;
data.General.Fullscreen = chkFullscreen.Checked;
data.General.KQEmu = chkKQEmu.Checked;
data.General.ACPI = chkACPI.Checked;
/* Paths */
data.Paths.Qemu = txtQEmuPath.Text;
data.Paths.VDK = txtVDKPath.Text;
/* Floppies */
data.Floppies.FDD[0].Enabled = chkFloppyA.Checked;
data.Floppies.FDD[0].Path = txtFloppyA.Text;
data.Floppies.FDD[1].Enabled = chkFloppyB.Checked;
data.Floppies.FDD[1].Path = txtFloppyB.Text;
/* CD-ROM */
data.CDROM.Image = txtCDROM.Text;
data.CDROM.Enabled = chkUseCDROM.Checked;
/* Harddisks */
data.Harddisks.HDD[0].Enabled = chkUseHDA.Checked;
data.Harddisks.HDD[0].Path = txtHDA.Text;
data.Harddisks.HDD[1].Enabled = chkUseHDB.Checked;
data.Harddisks.HDD[1].Path = txtHDB.Text;
data.Harddisks.HDD[2].Enabled = chkUseHDC.Checked;
data.Harddisks.HDD[2].Path = txtHDC.Text;
data.Harddisks.HDD[3].Enabled = chkUseHDD.Checked;
data.Harddisks.HDD[3].Path = txtHDD.Text;
/* Audio */
data.Audio.ES1370 = chkES1370.Checked;
data.Audio.Soundblaster = chkSoundBlaster.Checked;
data.Audio.Speaker = chkPCSpeaker.Checked;
data.Audio.OPL2 = chkOPL2.Checked;
/* Debug */
data.Debug.SerialPort.SRedirect = chkSerialToScrn.Checked;
data.Debug.SerialPort.FRedirect = chkSerialToFile.Checked;
data.Debug.SerialPort.FileName = txtSerialFile.Text;
data.Debug.SerialPort.PRedirect = chkSerialToPipe.Checked;
data.Debug.SerialPort.PipeName = txtSerialPipe.Text;
data.Debug.SavedStatePath = saved_state;
data.Debug.VBE3 = chkVBE30.Checked;
data.Debug.GDBPort = Int32.Parse(txtGDBPort.Text);
/* Network */
for (int i = 0; i < listVLANs.Items.Count; i++)
{
if(data.Network.GetNetStrings()[i] != listVLANs.Items[i].Text)
data.Network.AddNetString(listVLANs.Items[i].ToString());
}
/* Tools */
data.Tools.vdk.Image = txtVDKImage.Text;
data.Tools.vdk.DriveLetter = cboVDKDrive.Text;
/* Other */
data.Other.LKernel = txtLinuxK.Text;
data.Other.ABios = txtABios.Text;
data.Other.AppendCmdLine = txtAppendCmd.Text;
}
#endregion
#region VDK
private void btnVDKImage_Click(object sender, EventArgs e)
{
openFile.Title = "Virtual Hardisk Image";
openFile.Filter = "Harddisk images |*.vmdk;*.cloop;*.cow;*.qcow;*.raw;*.img|All Files | *.*";
if (openFile.ShowDialog() == DialogResult.OK)
{
txtVDKImage.Text = openFile.FileName;
data.Tools.vdk.Image = openFile.FileName;
}
}
private void cboVDKDrive_SelectedIndexChanged(object sender, EventArgs e)
{
data.Tools.vdk.DriveLetter = cboVDKDrive.SelectedItem.ToString();
}
private void btnUnmount_Click(object sender, EventArgs e)
{
data.Paths.VDK = txtVDKPath.Text;
if (data.Paths.VDK == "")
return;
runner = new Runner(data);
runner.UnmountImage();
}
private void btnMount_Click(object sender, EventArgs e)
{
data.Tools.vdk.Image = txtVDKImage.Text;
data.Paths.VDK = txtVDKPath.Text;
/* Check out if we have a vdk path and a image path */
if (!File.Exists(data.Tools.vdk.Image) || !Directory.Exists(data.Paths.VDK))
{
MessageBox.Show("Error on vdk path or image target");
return;
}
runner = new Runner(data);
if (runner.MountImage() == true)
{
System.Threading.Thread.Sleep(500);
Process p = new Process();
p.StartInfo.FileName = "explorer";
p.StartInfo.Arguments = data.Tools.vdk.DriveLetter;
try
{
p.Start();
}
catch
{
MessageBox.Show("Error launching explorer!", "Error!");
}
}
}
#endregion VDK
#region Network
/* Please fix this entire section */
private void btnNetAdd_Click(object sender, EventArgs e)
{
}
private void rbtnNetUser_CheckedChanged(object sender, EventArgs e)
{
panelUser.Visible = rbtnNetUser.Checked;
}
private void rbtnNetNic_CheckedChanged(object sender, EventArgs e)
{
panelNic.Visible = rbtnNetNic.Checked;
}
private void btnNetRemove_Click(object sender, EventArgs e)
{
//for (int i = 0; i < listVLANs.SelectedIndices.Count; i++)
//{
// VLanlist.RemoveAt(listVLANs.SelectedIndices[i]);
// listVLANs.Items.RemoveAt(listVLANs.SelectedIndices[i]);
//}
}
#endregion
private void btnCreateImage_Click(object sender, System.EventArgs e)
{
saveFileDialog.Title = "Create a virtual Hardisk";
saveFileDialog.Filter = "Harddisk images |*.vmdk;*.cloop;*.cow;*.qcow;*.raw;*.img|All Files | *.*";
saveFileDialog.FileName = "image." + cboImageFormat.Text;
saveFileDialog.DefaultExt = cboImageFormat.Text;
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
SaveSettings();
runner = new Runner(data);
if (runner.CreateImage(saveFileDialog.FileName, Convert.ToInt32(txtImageSize.Text), cboImageFormat.Text))
MessageBox.Show("Image created");
}
}
private void btnLaunch_Click(object sender, System.EventArgs e)
{
SaveSettings();
bool HasHDisk = false;
bool HasFDisk = false;
/* check the QEmu path */
if (!Directory.Exists(data.Paths.Qemu))
{
MessageBox.Show("Qemu path does not exist", "Error - Qemu path");
return;
}
/* There must be atleast one source of OS */
for (int i = 0; i < data.Harddisks.HDD.Length; i++)
{
if (data.Harddisks.HDD[i].Enabled == true)
{
if (File.Exists(data.Harddisks.HDD[i].Path))
{
HasHDisk = true;
}
else
{
MessageBox.Show("\"" + data.Harddisks.HDD[i].Path + "\"" + " image does not exist", "Error - Harddisk image");
return;
}
}
}
for (int i = 0; i < data.Floppies.FDD.Length; i++)
{
if (data.Floppies.FDD[i].Enabled == true)
{
if (File.Exists(data.Floppies.FDD[i].Path))
{
HasFDisk = true;
}
else
{
MessageBox.Show("\"" + data.Floppies.FDD[i].Path + "\"" + " image does not exist", "Error - Floppy image");
return;
}
}
}
/* ensure we have a correct CD image if we need to boot from it */
if ((txtCDROM.Text.Length > 0) && (File.Exists(data.CDROM.Image)))
{
data.CDROM.Enabled = true;
}
else
{
data.CDROM.Enabled = false;
}
if (HasHDisk == false && data.CDROM.Enabled == false && HasFDisk == false)
{
MessageBox.Show("Must enable atleast 1 Hard disk, CD-Rom or Floppy disk!", "Error");
return;
}
if ((data.General.BootFrom == "Floppy" && !HasFDisk) || (data.General.BootFrom == "Hardisk" && !HasHDisk) ||
(data.General.BootFrom == "CD-ROM" && !data.CDROM.Enabled))
{
MessageBox.Show("Booting from invalid media!", "Error");
return;
}
runner = new Runner(data);
runner.StartQemu((Platforms)cboMachine.SelectedIndex);
}
private void loadConfigToolStripMenuItem_Click(object sender, EventArgs e)
{
XmlSerializer s;
TextReader r;
openFile.Title = "Load settings";
openFile.InitialDirectory = currentDir;
openFile.FileName = "config.xml";
openFile.Filter = "Config (*.xml)|*.xml";
if (openFile.ShowDialog() == DialogResult.OK)
{
try
{
s = new XmlSerializer(typeof(Data));
r = new StreamReader(openFile.FileName);
data = (Data)s.Deserialize(r);
LoadSettings();
this.Text += " - " + openFile.FileName;
}
catch (Exception ex)
{
ErrorForm error = new ErrorForm();
error.txtError.Text = "Error Ocourred while loading settings! Exception Information:";
error.txtError.Text += ex.Message;
error.txtError.Text += Environment.NewLine + "Your settings file may be corrupt.";
error.Show();
}
}
}
private void saveConfigToolStripMenuItem_Click(object sender, EventArgs e)
{
XmlSerializer s;
TextWriter w;
SaveSettings();
saveFileDialog.Title = "Save settings";
saveFileDialog.InitialDirectory = currentDir;
saveFileDialog.FileName = "config.xml";
saveFileDialog.Filter = "Config (*.xml)|*.xml";
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
try
{
s = new XmlSerializer(typeof(Data));
w = new StreamWriter(saveFileDialog.FileName);
s.Serialize(w, data);
}
catch (Exception ex)
{
ErrorForm error = new ErrorForm();
error.txtError.Text = "Error trying to save settings!";
error.txtError.Text += "Exception Info:" + Environment.NewLine + ex.Message;
error.txtError.Text += Environment.NewLine + ex.StackTrace;
}
}
}
private void helpContentsToolStripMenuItem_Click(object sender, EventArgs e)
{
// load up html help file
}
private void aboutReactOSQEmuManagerToolStripMenuItem_Click(object sender, EventArgs e)
{
AboutForm Dlg = new AboutForm();
Dlg.Show();
}
private void setAsDefaultToolStripMenuItem_Click(object sender, EventArgs e)
{
openFile.Title = "Default config settings";
openFile.InitialDirectory = currentDir;
openFile.FileName = "config.xml";
openFile.Filter = "Config (*.xml)|*.xml";
if (openFile.ShowDialog() == DialogResult.OK)
{
RegistryKey RegKey = Registry.CurrentUser.CreateSubKey(strRegKey);
if (RegKey != null)
{
RegKey.SetValue(strDefCon, (string)openFile.FileName);
RegKey.Close();
}
}
LoadDefaultConfig();
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void btnStop_Click(object sender, EventArgs e)
{
try
{
runner.StopQemu();
}
catch { }
}
}
}