Subversion Repositories Code-Repo

Compare Revisions

Ignore whitespace Rev 18 → Rev 19

/SWAT USB App/trunk/SWAT USB App/form_Software.cs
13,9 → 13,10
{
public partial class form_Software : Form
{
public static List<string> softwareList = new List<string>();
private static List<string> subGroups = new List<string>();
private static List<Process> toInstall = new List<Process>();
private static List<CheckBox> formCheckBoxes = new List<CheckBox>();
private static List<RadioButton> formRadioButton = new List<RadioButton>();
private static form_Software _software_Form = null;
public static form_Software software_Form_Instance
{
37,30 → 38,90
DebugText.appendText("Software form initializing");
// Draws the form with a checkbox for each software specified in the text file
InitializeComponent();
// Clears all lists
subGroups.Clear();
toInstall.Clear();
formCheckBoxes.Clear();
formRadioButton.Clear();
// Location placeholder
int nextXLocation = 6, nextYLocation = 19;
// Updates the groupbox size to hold all the checkboxes
this.groupBox_SoftwareList.Size = new Size(169, 40 + (softwareList.Count - 1) * 23);
// Updates the window size to hold all the checkboxes + buttons
this.Size = new Size(200, 121 + (softwareList.Count - 1) * 23);
formCheckBoxes.Clear();
// Adds a checkbox for each software item, adds checkbox to list formCheckBoxes
foreach (string str in softwareList)
{DebugText.appendText("Checking if applications in softwareList is marked as default");
CheckBox chkBox = new CheckBox();
chkBox.Name = "chk_" + str;
chkBox.AutoSize = true;
// Removes the brackets from the name
chkBox.Text = str;
// Checks the checkbox if default is set to yes
if (SettingsParser.isDefaultCheck(str))
chkBox.Checked = true;
chkBox.Location = new Point(nextXLocation, nextYLocation);
// Increments the location placeholder for the next checkbox
nextYLocation += 23;
this.groupBox_SoftwareList.Controls.Add(chkBox);
formCheckBoxes.Add(chkBox);
// Extracts all groups from ApplicationsList
for (int i = 0; i < SettingsParser.ApplicationsList.Count(); i++)
if (SettingsParser.ApplicationsList[i].Group != null)
{
// Check if group exists already
bool groupExist = false;
for (int j = 0; j < subGroups.Count(); j++)
if (SettingsParser.ApplicationsList[i].Group == subGroups[j])
{
groupExist = true;
break;
}
if (!groupExist)
subGroups.Add(SettingsParser.ApplicationsList[i].Group);
}
// Updates the groupbox size to hold all the checkboxes and subgroups
this.groupBox_SoftwareList.Size = new Size(SettingsParser.softwareFormWidth - 30, 19 + SettingsParser.ApplicationsList.Count() * 23 + (subGroups.Count() * 25));
// Updates the window size to hold all elements
this.Size = new Size(SettingsParser.softwareFormWidth, 101 + SettingsParser.ApplicationsList.Count() * 23 + (subGroups.Count() * 25));
// Adds a checkbox for each software item that is ungrouped, adds checkbox to list formCheckBoxes
for (int i = 0; i < SettingsParser.ApplicationsList.Count(); i++)
{
if (SettingsParser.ApplicationsList[i].Group == null)
{
// Creates a new checkbox
CheckBox chkBox = new CheckBox();
chkBox.Name = "chk_" + SettingsParser.ApplicationsList[i].Name;
chkBox.AutoSize = true;
chkBox.Text = SettingsParser.ApplicationsList[i].Name;
if (SettingsParser.ApplicationsList[i].Default)
chkBox.Checked = true;
chkBox.Location = new Point(nextXLocation, nextYLocation);
// Increments the location placeholder for the next element
nextYLocation += 23;
// Adds the checkbox to the parent groupbox
this.groupBox_SoftwareList.Controls.Add(chkBox);
// Adds the checkbox to formCheckBoxes list
formCheckBoxes.Add(chkBox);
}
}
// Adds a groupbox for each entry specified in subGroups as well as any applications under the group
for (int i = 0; i < subGroups.Count(); i++)
{
// Sets the internal location coordinates for the next element
int subNextXLocation = 6;
int subNextYLocation = 19;
// Creates a new groupbox
GroupBox grpBox = new GroupBox();
grpBox.Name = "grp_" + subGroups[i];
grpBox.Text = subGroups[i];
// Finds the number of applications under the group
int numberOfSubentries = 0;
for (int j = 0; j < SettingsParser.ApplicationsList.Count(); j++)
if (SettingsParser.ApplicationsList[j].Group == subGroups[i])
{
// If the group matches, creates a new radiobutton
numberOfSubentries++;
RadioButton rdoBtn = new RadioButton();
rdoBtn.Name = "rdo_" + SettingsParser.ApplicationsList[j].Name;
rdoBtn.AutoSize = true;
rdoBtn.Text = SettingsParser.ApplicationsList[j].Name;
if (SettingsParser.ApplicationsList[j].Default)
rdoBtn.Checked = true;
rdoBtn.Location = new Point(subNextXLocation, subNextYLocation);
// Increments the location placeholder for the next element
subNextYLocation += 23;
// Adds the radiobutton to the parent groupbox
grpBox.Controls.Add(rdoBtn);
// Adds the radiobutton to formRadioButton list
formRadioButton.Add(rdoBtn);
}
grpBox.Size = new Size(SettingsParser.softwareFormWidth - 42, 19 + numberOfSubentries * 23);
grpBox.Location = new Point(nextXLocation, nextYLocation);
nextYLocation += 25 + numberOfSubentries * 23;
// Adds the created groupbox to the parent groupbox
this.groupBox_SoftwareList.Controls.Add(grpBox);
}
}
catch (Exception e)
{
73,14 → 134,19
try
{
DebugText.appendText("Updating list of processes to run from list of software checked");
toInstall.Clear();
// Updates list toInstall with processes for each software checked
for (int i = 0; i < softwareList.Count; i++)
// Updates list toInstall with processes for each software checked in formCheckBoxes
for (int i = 0; i < formCheckBoxes.Count(); i++)
{
if (formCheckBoxes[i].Checked)
{
string[] temp;
temp = SettingsParser.getSetupLocation(formCheckBoxes[i].Text);
string[] temp = null;
// Pulls the setup locations
for (int j = 0; j < SettingsParser.ApplicationsList.Count(); j++)
if (SettingsParser.ApplicationsList[j].Name == formCheckBoxes[i].Text)
{
temp = SettingsParser.ApplicationsList[j].SetupFileLocation;
break;
}
for (int j = 0; j < temp.Count(); j += 2)
{
Process proc = new Process();
90,6 → 156,28
}
}
}
// Updates list toInstall with processes for each software checked in formRadioButton
for (int i = 0; i < formRadioButton.Count(); i++)
{
if (formRadioButton[i].Checked)
{
string[] temp = null;
// Pulls the setup locations
for (int j = 0; j < SettingsParser.ApplicationsList.Count(); j++)
if (SettingsParser.ApplicationsList[j].Name == formRadioButton[i].Text)
{
temp = SettingsParser.ApplicationsList[j].SetupFileLocation;
break;
}
for (int j = 0; j < temp.Count(); j += 2)
{
Process proc = new Process();
proc.StartInfo.FileName = Initialization.pathToSWATDrive + temp[j];
proc.StartInfo.Arguments = temp[j + 1];
toInstall.Add(proc);
}
}
}
}
catch (Exception e)
{
121,10 → 209,6
}
}
}
//catch (Win32Exception e)
//{
//}
catch (Exception e)
{
DebugText.appendText("Exception Thrown: " + e.ToString());
142,5 → 226,12
DebugText.appendText("Closing software form");
software_Form_Instance.Close();
}
private void button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < formCheckBoxes.Count(); i++)
formCheckBoxes[i].Checked = false;
for (int i = 0; i < formRadioButton.Count(); i++)
formRadioButton[i].Checked = false;
}
}
}