33,99 → 33,112 |
} |
public form_Software() |
{ |
this.Load += new EventHandler(form_Software_Load); |
// Draws the form with a checkbox for each software specified in the text file |
InitializeComponent(); |
} |
void form_Software_Load(object sender, EventArgs e) |
{ |
try |
{ |
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; |
// 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.Count() == 0) |
{ |
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); |
} |
DebugText.appendText("No software were found in USBSettings.xml"); |
MessageBox.Show("No software were found in USBSettings.xml"); |
this.Close(); |
} |
// 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++) |
else |
{ |
// 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]) |
DebugText.appendText("Software form initializing"); |
// Clears all lists |
subGroups.Clear(); |
toInstall.Clear(); |
formCheckBoxes.Clear(); |
formRadioButton.Clear(); |
// Location placeholder |
int nextXLocation = 6, nextYLocation = 19; |
// Extracts all groups from ApplicationsList |
for (int i = 0; i < SettingsParser.ApplicationsList.Count(); i++) |
if (SettingsParser.ApplicationsList[i].Group != null) |
{ |
// 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); |
// 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 |
subNextYLocation += 23; |
// Adds the radiobutton to the parent groupbox |
grpBox.Controls.Add(rdoBtn); |
// Adds the radiobutton to formRadioButton list |
formRadioButton.Add(rdoBtn); |
nextYLocation += 23; |
// Adds the checkbox to the parent groupbox |
this.groupBox_SoftwareList.Controls.Add(chkBox); |
// Adds the checkbox to formCheckBoxes list |
formCheckBoxes.Add(chkBox); |
} |
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); |
} |
// 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) |
catch (Exception ex) |
{ |
DebugText.appendText("Exception Thrown: " + e.ToString()); |
DebugText.appendText("Exception Thrown: " + ex.ToString()); |
MessageBox.Show(e.ToString()); |
} |
} |