mirror of
https://github.com/reactos/RosTE.git
synced 2024-11-23 03:29:57 +00:00
- Give each VM it's own DataSet instead of maintaining separate DataRows. Fixes a bug where by VM config files were loading up multiple images
- Drop the ArrayList as we can rely on the ListView for storing our objects now - Add some primitive error handling svn path=/trunk/tools/RosTE/; revision=254
This commit is contained in:
parent
6bb4c71ab1
commit
d563375c7a
11
GUI/MainForm.Designer.cs
generated
11
GUI/MainForm.Designer.cs
generated
@ -58,6 +58,7 @@ namespace RosTEGUI
|
||||
this.mainmenuHelpContent = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.MainMenuHelpAbout = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.changeSettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mainToolbar.SuspendLayout();
|
||||
this.mainMenu.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
@ -281,6 +282,8 @@ namespace RosTEGUI
|
||||
//
|
||||
// mainmenuOptions
|
||||
//
|
||||
this.mainmenuOptions.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.changeSettingsToolStripMenuItem});
|
||||
this.mainmenuOptions.Name = "mainmenuOptions";
|
||||
this.mainmenuOptions.Size = new System.Drawing.Size(56, 20);
|
||||
this.mainmenuOptions.Text = "Options";
|
||||
@ -313,6 +316,13 @@ namespace RosTEGUI
|
||||
this.MainMenuHelpAbout.Text = "About";
|
||||
this.MainMenuHelpAbout.Click += new System.EventHandler(this.MainMenuHelpAbout_Click);
|
||||
//
|
||||
// changeSettingsToolStripMenuItem
|
||||
//
|
||||
this.changeSettingsToolStripMenuItem.Name = "changeSettingsToolStripMenuItem";
|
||||
this.changeSettingsToolStripMenuItem.Size = new System.Drawing.Size(163, 22);
|
||||
this.changeSettingsToolStripMenuItem.Text = "Change settings";
|
||||
this.changeSettingsToolStripMenuItem.Click += new System.EventHandler(this.changeSettingsToolStripMenuItem_Click);
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
|
||||
@ -376,6 +386,7 @@ namespace RosTEGUI
|
||||
private System.Windows.Forms.ToolStripMenuItem mainmenuOptions;
|
||||
private System.Windows.Forms.ToolStripMenuItem newToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem virtualMachineToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem changeSettingsToolStripMenuItem;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -14,15 +14,22 @@ namespace RosTEGUI
|
||||
public partial class MainForm : Form
|
||||
{
|
||||
private MainConfig mainConf;
|
||||
private ArrayList vmConfigs;
|
||||
private Data mainData;
|
||||
private Data vmData;
|
||||
|
||||
public MainForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void LoadSettingsDialog()
|
||||
{
|
||||
ListViewItem lvi = VirtMachListView.FocusedItem;
|
||||
|
||||
SettingsForm setFrm = new SettingsForm(lvi.Tag);
|
||||
setFrm.StartPosition = FormStartPosition.CenterScreen;
|
||||
setFrm.Show();
|
||||
}
|
||||
|
||||
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Close();
|
||||
@ -33,11 +40,6 @@ namespace RosTEGUI
|
||||
mainData = new Data();
|
||||
if (!mainData.LoadMainData())
|
||||
MessageBox.Show("Failed to load Main Schema");
|
||||
vmData = new Data();
|
||||
if (!vmData.LoadVirtMachData())
|
||||
MessageBox.Show("Failed to load VM Schema");
|
||||
|
||||
vmConfigs = new ArrayList();
|
||||
|
||||
// read config and load any existing vm's
|
||||
mainConf = new MainConfig(mainData);
|
||||
@ -48,7 +50,7 @@ namespace RosTEGUI
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
string image = mainConf.GetExistingImage(i);
|
||||
VirtualMachine vm = new VirtualMachine(vmData);
|
||||
VirtualMachine vm = new VirtualMachine();
|
||||
if (vm.LoadVMConfig(image))
|
||||
{
|
||||
ListViewItem lvi = VirtMachListView.Items.Add(vm.ToString(), 0);
|
||||
@ -67,11 +69,7 @@ namespace RosTEGUI
|
||||
|
||||
private void ImageListView_DoubleClick(object sender, EventArgs e)
|
||||
{
|
||||
ListViewItem lvi = VirtMachListView.FocusedItem;
|
||||
|
||||
SettingsForm setFrm = new SettingsForm(lvi.Tag);
|
||||
setFrm.StartPosition = FormStartPosition.CenterScreen;
|
||||
setFrm.Show();
|
||||
LoadSettingsDialog();
|
||||
}
|
||||
|
||||
private void toolbarExit_Click(object sender, EventArgs e)
|
||||
@ -90,13 +88,12 @@ namespace RosTEGUI
|
||||
{
|
||||
int i = mainConf.AddVirtMach(wizFrm.DefDir);
|
||||
|
||||
VirtualMachine VirtMach = new VirtualMachine(vmData);
|
||||
VirtualMachine VirtMach = new VirtualMachine();
|
||||
VirtMach.CreateVMConfig(wizFrm.VMName,
|
||||
wizFrm.DefDir,
|
||||
wizFrm.DiskSizeGB,
|
||||
wizFrm.ExistImg,
|
||||
wizFrm.MemSizeMB);
|
||||
vmConfigs.Add(VirtMach);
|
||||
|
||||
ListViewItem lvi = VirtMachListView.Items.Add(VirtMach.ToString(), 0);
|
||||
lvi.Tag = VirtMach;
|
||||
@ -106,11 +103,10 @@ namespace RosTEGUI
|
||||
|
||||
DirectoryInfo di = Directory.GetParent(wizFrm.ExistImg);
|
||||
int i = mainConf.AddVirtMach(di.FullName);
|
||||
VirtualMachine VirtMach = new VirtualMachine(vmData);
|
||||
VirtualMachine VirtMach = new VirtualMachine();
|
||||
VirtMach.CreateVMConfig(wizFrm.VMName,
|
||||
wizFrm.ExistImg,
|
||||
wizFrm.MemSizeMB);
|
||||
vmConfigs.Add(VirtMach);
|
||||
|
||||
ListViewItem lvi = VirtMachListView.Items.Add(VirtMach.ToString(), 0);
|
||||
lvi.Tag = VirtMach;
|
||||
@ -118,9 +114,8 @@ namespace RosTEGUI
|
||||
else
|
||||
{
|
||||
int i = mainConf.AddVirtMach("Images\\" + wizFrm.VMName);
|
||||
VirtualMachine VirtMach = new VirtualMachine(vmData);
|
||||
VirtualMachine VirtMach = new VirtualMachine();
|
||||
VirtMach.CreateVMConfig(wizFrm.VMName);
|
||||
vmConfigs.Add(VirtMach);
|
||||
|
||||
ListViewItem lvi = VirtMachListView.Items.Add(VirtMach.ToString(), 0);
|
||||
lvi.Tag = VirtMach;
|
||||
@ -146,7 +141,6 @@ namespace RosTEGUI
|
||||
|
||||
mainConf.DeleteVirtMach(lvi.Index/*lvi.Tag*/);
|
||||
VirtMachListView.Items.Remove(lvi);
|
||||
vmConfigs.Remove(lvi.Tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -155,11 +149,16 @@ namespace RosTEGUI
|
||||
{
|
||||
mainConf.SaveMainConfig();
|
||||
|
||||
for (int i = 0; i < vmConfigs.Count; i++)
|
||||
foreach(ListViewItem lvi in VirtMachListView.Items)
|
||||
{
|
||||
VirtualMachine vm = (VirtualMachine)vmConfigs[i];
|
||||
VirtualMachine vm = (VirtualMachine)lvi.Tag;
|
||||
vm.SaveVMConfig();
|
||||
}
|
||||
}
|
||||
|
||||
private void changeSettingsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadSettingsDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -185,11 +185,11 @@
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAPxJREFUOE9jYKAV
|
||||
8PDwYE9LS2Otr69nIscOxtDw4P+OzvZ/gfQ/EDs+Pp6DJIPCIuz/3L5z6/+u3Tv/h0WE/Pbx8eEiyQCQ
|
||||
7Xfu3v6/e8+u/0DNv0JDQ3kIGgDyr729PQtQMRvI6TADIqLCfkZHR/PhNQDkTyj+B7Ld1d357917d8Au
|
||||
iIwO/4MkD1aHYRhI8M7dW0B8+z9II4gG4QMH96Pgg4cO4DYAFGhHjh7+f/jIIbwYpwvQnXnm7On/IOzs
|
||||
6giKTpgXsbsA3U8gDVeuXgbj8EiHPySnA5AB129cA2OyDbh85dJ/ECbLAFDiCY8M/Q3CIDYobxBMSAOi
|
||||
AACfld9D5OrnOQAAAABJRU5ErkJggg==
|
||||
8PDwYE9LS2Otr69nIscOxtDw4P8OTvZ/gfQ/EDs+Pp6DJIPCIuz+3L5z6/+u3Tv/h0WE/Pbx8eEiyQCQ
|
||||
7Xfu3v6/e8+u/0DNv0JDQ3kIGgDyr729PQtQMRvI6TADIqLCfkZHR/PhNQDkTyj+B7Ldxc3p7917d8Au
|
||||
iIwO/4MkD1aHYRhI8M7dW0B8+z9II4gG4QMH96Pgg4cO4DYAFGhHjh7+f/jIIbwYpwvQnXnm7On/IOzk
|
||||
4gCKTpgXsbsA3U8gDVeuXgbj8Ej7PySnA5AB129cA2OyDbh85dJ/ECbLAFDiCY8M/Q3CIDYobxBMSAOi
|
||||
AAB7J98zlsMqwgAAAABJRU5ErkJggg==
|
||||
</value>
|
||||
</data>
|
||||
<data name="toolbarImageDel.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
@ -203,20 +203,20 @@
|
||||
<data name="toolbarHelpContents.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAttJREFUOE+FU11I
|
||||
U2EYXllBF3VjW91JklGUmCnCbCUqjswl/RCYNwOVTAm8mLkg6ERliS6Xtp/jElqkDhS6sB9FrHXhZEZ4
|
||||
IxYUSDZzU5k7f/Ps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gRezFwQdKISKddM259LaJA/oNCF/WhRrQsnM8Ib
|
||||
saBAspmbytz5m2fn7Jy9nfczJddFBx7Od873vO/3vM/7fls0KY/jQlWxlHusWtm563RSI+/D7a2abeE0
|
||||
gRvb/uXrs2uDw+OpMeSboqgdnlP6wODhQ4rf51N4ngNJkkAURaDpKPjejikDB7MU5CB3U5KhoaE0T05O
|
||||
6IPluiyFQiBMBoBhaIhGIwQME4WYfxxWp6dhrOGKjFyM2UjiOWn42G8yJaTZWWDq64EuKgIm9IskYVka
|
||||
mPAC0KWlwFhaQZiaAq/KxRiSwHmxKteWuV8WZmaAMZmAKSmBSHU1DJw1JlSpccTAuapEtK4O2MpKYMxm
|
||||
4Cf8YMvIkN3njcc1trbbjjdPPEn+1UugCwthpaYGnDpt0lVR5qS6qN0Ij7p27tUlo01NRAk3+hp8z4cV
|
||||
652bLk1np/VHJLKsGrUCbDgEI0aj5C4tepTqtLO8+OH7EwaZX14k3LBaFsai+/FYjCdm4ZvIVk9NTUDU
|
||||
qHuCsPrHWJpwSQJsGbZKEGL/TSCKccJFg0kClLG0tKi6zYLAsfDiaoPorijrSFXgLi+xjZrNcVFVwLIM
|
||||
LCzMr5WARvj6+xS+txfYxkag372DvsxMxV1R7lg30XWm3N6fdUDhvn8Dtu0ecPbH4HM5FWyABlvh0mqT
|
||||
vMUCtF4PPEUB4/fDyA2L1G2n4ogRipJiP+cg5vUCXVAAbG0tONPTkzgCRKlXXzAeyM+HWEsL0AYDcK2t
|
||||
gFJlOaFChoQkAtfdRYI5dR4msrMBYzbKxLF8evTIciAvD7jmZuB63KROnMI1MMA57ORkDEbuplFev0xe
|
||||
vf6zS6dLfrrfLs/PB4nbiGAwCJPtbbJLuyeJnH8u09+O2y9fKuy8e6vHau2Ye2BtFxG4xn941VO78xtK
|
||||
1i8alKXmewAAAABJRU5ErkJggg==
|
||||
</value>
|
||||
</data>
|
||||
<data name="toolbarExit.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
|
2
GUI/SettingsForm.Designer.cs
generated
2
GUI/SettingsForm.Designer.cs
generated
@ -1158,7 +1158,7 @@ namespace RosTEGUI
|
||||
this.generalPanel.Name = "generalPanel";
|
||||
this.generalPanel.Size = new System.Drawing.Size(280, 361);
|
||||
this.generalPanel.TabIndex = 0;
|
||||
this.generalPanel.Layout += new System.Windows.Forms.LayoutEventHandler(this.generalPanel_Layout);
|
||||
this.generalPanel.VisibleChanged += new System.EventHandler(this.generalOnVisible);
|
||||
//
|
||||
// generalGrpBox
|
||||
//
|
||||
|
@ -176,19 +176,6 @@ namespace RosTEGUI
|
||||
floppyConnGrpBox.Enabled = bEnabled;
|
||||
}
|
||||
|
||||
private void generalPanel_Layout(object sender, LayoutEventArgs e)
|
||||
{
|
||||
generalVMName.Text = VirtMach.Name;
|
||||
generalWorkDir.Text = VirtMach.DefDir;
|
||||
|
||||
if (VirtMach.MachType == "pc")
|
||||
generalMachine.SelectedIndex = 0;
|
||||
else
|
||||
generalMachine.SelectedIndex = 1;
|
||||
|
||||
generalSetClockHost.Checked = VirtMach.SetClockToHost;
|
||||
}
|
||||
|
||||
private void generalEditbutton_Click(object sender, EventArgs e)
|
||||
{
|
||||
generalVMName.ReadOnly = false;
|
||||
@ -196,5 +183,23 @@ namespace RosTEGUI
|
||||
generalWorkDirBrows.Enabled = true;
|
||||
generalEditbutton.Enabled = false;
|
||||
}
|
||||
|
||||
private void generalOnVisible(object sender, EventArgs e)
|
||||
{
|
||||
Panel panel = (Panel)sender;
|
||||
|
||||
if (panel.Visible)
|
||||
{
|
||||
generalVMName.Text = VirtMach.Name;
|
||||
generalWorkDir.Text = VirtMach.DefDir;
|
||||
|
||||
if (VirtMach.MachType == "pc")
|
||||
generalMachine.SelectedIndex = 0;
|
||||
else
|
||||
generalMachine.SelectedIndex = 1;
|
||||
|
||||
generalSetClockHost.Checked = VirtMach.SetClockToHost;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
@ -26,11 +27,18 @@ namespace RosTEGUI
|
||||
data = new DataSet();
|
||||
if (File.Exists(filename))
|
||||
{
|
||||
FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
|
||||
XmlTextReader xtr = new XmlTextReader(fs);
|
||||
data.ReadXmlSchema(xtr);
|
||||
xtr.Close();
|
||||
ret = true;
|
||||
try
|
||||
{
|
||||
FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
|
||||
XmlTextReader xtr = new XmlTextReader(fs);
|
||||
data.ReadXmlSchema(xtr);
|
||||
xtr.Close();
|
||||
ret = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show("error loading main config schema: " + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -44,11 +52,18 @@ namespace RosTEGUI
|
||||
data = new DataSet();
|
||||
if (File.Exists(filename))
|
||||
{
|
||||
FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
|
||||
XmlTextReader xtr = new XmlTextReader(fs);
|
||||
data.ReadXmlSchema(xtr);
|
||||
xtr.Close();
|
||||
ret = true;
|
||||
try
|
||||
{
|
||||
FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
|
||||
XmlTextReader xtr = new XmlTextReader(fs);
|
||||
data.ReadXmlSchema(xtr);
|
||||
xtr.Close();
|
||||
ret = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show("error loading VM config schema: " + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -111,14 +111,25 @@ namespace RosTEGUI
|
||||
|
||||
#endregion
|
||||
|
||||
private static void PrintRows(DataTable dt)
|
||||
{
|
||||
for (int i = 0; i < dt.Rows.Count; i++)
|
||||
{
|
||||
string str = "row: " + i + ", Name: " + dt.Rows[i]["Name"] + ", DefDir " + dt.Rows[i]["DefDir"];
|
||||
MessageBox.Show(str);
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
public VirtualMachine(Data dataIn)
|
||||
public VirtualMachine()
|
||||
{
|
||||
data = dataIn;
|
||||
data = new Data();
|
||||
if (!data.LoadVirtMachData())
|
||||
MessageBox.Show("Failed to load VM Schema");
|
||||
}
|
||||
|
||||
// default
|
||||
@ -211,15 +222,19 @@ namespace RosTEGUI
|
||||
|
||||
public void SaveVMConfig()
|
||||
{
|
||||
string fileName = DefDir + "\\Config.xml";
|
||||
Directory.CreateDirectory(DefDir);
|
||||
FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.Write);
|
||||
XmlTextWriter xtw = new XmlTextWriter(fs, System.Text.Encoding.Unicode);
|
||||
data.DataSet.WriteXml(xtw, System.Data.XmlWriteMode.WriteSchema);
|
||||
xtw.Close();
|
||||
try
|
||||
{
|
||||
string fileName = DefDir + "\\Config.xml";
|
||||
Directory.CreateDirectory(DefDir);
|
||||
FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.Write);
|
||||
XmlTextWriter xtw = new XmlTextWriter(fs, System.Text.Encoding.Unicode);
|
||||
data.DataSet.WriteXml(xtw, System.Data.XmlWriteMode.WriteSchema);
|
||||
xtw.Close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show("error loading VM Config.xml: " + e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user