only allow the user to select qemu harddisks which are not already being used

svn path=/trunk/tools/RosTE/; revision=264
This commit is contained in:
Ged Murphy 2007-06-28 20:10:56 +00:00
parent cc7ef61b33
commit dcb849141e
2 changed files with 31 additions and 6 deletions

View File

@ -1,10 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;
namespace RosTEGUI
{
@ -35,9 +32,29 @@ namespace RosTEGUI
get { return newhdBoot.Checked; }
}
public NewHardDiskForm()
public NewHardDiskForm(ArrayList curDrives)
{
InitializeComponent();
string[] allDrives = { "hda", "hdb", "hdd" };
foreach (string str in allDrives)
{
bool found = false;
foreach (string drive in curDrives)
{
if (string.Compare(drive, str, true) == 0)
{
found = true;
}
}
if (!found)
newhdDrive.Items.Add(str);
}
if (newhdDrive.Items.Count > 0)
newhdDrive.SelectedIndex = 0;
}
}
}

View File

@ -321,7 +321,15 @@ namespace RosTEGUI
{
if (harddiskLstBox.Items.Count < 3)
{
NewHardDiskForm hdf = new NewHardDiskForm();
ArrayList curDrives = new ArrayList(3);
ArrayList hardDisks = VirtMach.GetHardDisks();
foreach (VMHardDrive vmhd in hardDisks)
{
curDrives.Add(vmhd.Drive);
}
NewHardDiskForm hdf = new NewHardDiskForm(curDrives);
if (hdf.ShowDialog() == DialogResult.OK)
{
VMHardDrive vmhd = VirtMach.AddHardDisk(hdf.DiskName,