Subversion Repositories Code-Repo

Rev

Rev 67 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 67 Rev 70
Line 21... Line 21...
21
        {
21
        {
22
            // Draws the form with a checkbox for each software specified in the text file
22
            // Draws the form with a checkbox for each software specified in the text file
23
            InitializeComponent();
23
            InitializeComponent();
24
            try
24
            try
25
            {
25
            {
-
 
26
                Debug.appendText("Software form initializing");
-
 
27
                // Clears all lists
-
 
28
                subGroups.Clear();
-
 
29
                toInstall.Clear();
-
 
30
                formCheckBoxes.Clear();
-
 
31
                formRadioButton.Clear();
-
 
32
                // Location placeholder 
-
 
33
                int nextXLocation = 6, nextYLocation = 19;
-
 
34
                // Extracts all groups from ApplicationsList
-
 
35
                for (int i = 0; i < SettingsParser.ApplicationsList.Count(); i++)
26
                if (SettingsParser.ApplicationsList.Count() == 0)
36
                    if (SettingsParser.ApplicationsList[i].Group != null)
-
 
37
                    {
-
 
38
                        // Check if group exists already
-
 
39
                        bool groupExist = false;
-
 
40
                        for (int j = 0; j < subGroups.Count(); j++)
-
 
41
                            if (SettingsParser.ApplicationsList[i].Group == subGroups[j])
-
 
42
                            {
-
 
43
                                groupExist = true;
-
 
44
                                break;
-
 
45
                            }
-
 
46
                        if (!groupExist)
-
 
47
                            subGroups.Add(SettingsParser.ApplicationsList[i].Group);
-
 
48
                    }
-
 
49
                // Updates the groupbox size to hold all the checkboxes and subgroups
-
 
50
                this.groupBox_SoftwareList.Size = new Size(SettingsParser.softwareFormWidth - 30, 19 + SettingsParser.ApplicationsList.Count() * 23 + (subGroups.Count() * 25));
-
 
51
                // Updates the window size to hold all elements
-
 
52
                this.Size = new Size(SettingsParser.softwareFormWidth, 101 + SettingsParser.ApplicationsList.Count() * 23 + (subGroups.Count() * 25));
-
 
53
                // Adds a checkbox for each software item that is ungrouped, adds checkbox to list formCheckBoxes
-
 
54
                for (int i = 0; i < SettingsParser.ApplicationsList.Count(); i++)
27
                {
55
                {
-
 
56
                    if (SettingsParser.ApplicationsList[i].Group == null)
-
 
57
                    {
-
 
58
                        // Creates a new checkbox
-
 
59
                        CheckBox chkBox = new CheckBox();
-
 
60
                        chkBox.Name = "chk_" + SettingsParser.ApplicationsList[i].Name;
-
 
61
                        chkBox.AutoSize = true;
28
                    Debug.appendText("No software were found in USBSettings.xml");
62
                        chkBox.Text = SettingsParser.ApplicationsList[i].Name;
-
 
63
                        if (SettingsParser.ApplicationsList[i].Default)
-
 
64
                            chkBox.Checked = true;
-
 
65
                        chkBox.Location = new Point(nextXLocation, nextYLocation);
-
 
66
                        // Increments the location placeholder for the next element
-
 
67
                        nextYLocation += 23;
-
 
68
                        // Adds the checkbox to the parent groupbox
29
                    MessageBox.Show("No software were found in USBSettings.xml");
69
                        this.groupBox_SoftwareList.Controls.Add(chkBox);
-
 
70
                        // Adds the checkbox to formCheckBoxes list
-
 
71
                        formCheckBoxes.Add(chkBox);
30
                    this.Close();
72
                    }
31
                }
73
                }
-
 
74
                // Adds a groupbox for each entry specified in subGroups as well as any applications under the group
32
                else
75
                for (int i = 0; i < subGroups.Count(); i++)
33
                {
76
                {
34
                    Debug.appendText("Software form initializing");
77
                    // Sets the internal location coordinates for the next element
35
                    // Clears all lists
78
                    int subNextXLocation = 6;
36
                    subGroups.Clear();
79
                    int subNextYLocation = 19;
37
                    toInstall.Clear();
80
                    // Creates a new groupbox
38
                    formCheckBoxes.Clear();
81
                    GroupBox grpBox = new GroupBox();
39
                    formRadioButton.Clear();
82
                    grpBox.Name = "grp_" + subGroups[i];
40
                    // Location placeholder 
83
                    grpBox.Text = subGroups[i];
41
                    int nextXLocation = 6, nextYLocation = 19;
-
 
42
                    // Extracts all groups from ApplicationsList
84
                    // Finds the number of applications under the group
43
                    for (int i = 0; i < SettingsParser.ApplicationsList.Count(); i++)
-
 
44
                        if (SettingsParser.ApplicationsList[i].Group != null)
-
 
45
                        {
-
 
46
                            // Check if group exists already
-
 
47
                            bool groupExist = false;
85
                    int numberOfSubentries = 0;
48
                            for (int j = 0; j < subGroups.Count(); j++)
-
 
49
                                if (SettingsParser.ApplicationsList[i].Group == subGroups[j])
-
 
50
                                {
-
 
51
                                    groupExist = true;
-
 
52
                                    break;
-
 
53
                                }
-
 
54
                            if (!groupExist)
-
 
55
                                subGroups.Add(SettingsParser.ApplicationsList[i].Group);
-
 
56
                        }
-
 
57
                    // Updates the groupbox size to hold all the checkboxes and subgroups
-
 
58
                    this.groupBox_SoftwareList.Size = new Size(SettingsParser.softwareFormWidth - 30, 19 + SettingsParser.ApplicationsList.Count() * 23 + (subGroups.Count() * 25));
-
 
59
                    // Updates the window size to hold all elements
-
 
60
                    this.Size = new Size(SettingsParser.softwareFormWidth, 101 + SettingsParser.ApplicationsList.Count() * 23 + (subGroups.Count() * 25));
-
 
61
                    // Adds a checkbox for each software item that is ungrouped, adds checkbox to list formCheckBoxes
-
 
62
                    for (int i = 0; i < SettingsParser.ApplicationsList.Count(); i++)
86
                    for (int j = 0; j < SettingsParser.ApplicationsList.Count(); j++)
63
                    {
-
 
64
                        if (SettingsParser.ApplicationsList[i].Group == null)
87
                        if (SettingsParser.ApplicationsList[j].Group == subGroups[i])
65
                        {
88
                        {
-
 
89
                            // If the group matches, creates a new radiobutton
66
                            // Creates a new checkbox
90
                            numberOfSubentries++;
67
                            CheckBox chkBox = new CheckBox();
91
                            RadioButton rdoBtn = new RadioButton();
68
                            chkBox.Name = "chk_" + SettingsParser.ApplicationsList[i].Name;
92
                            rdoBtn.Name = "rdo_" + SettingsParser.ApplicationsList[j].Name;
69
                            chkBox.AutoSize = true;
93
                            rdoBtn.AutoSize = true;
70
                            chkBox.Text = SettingsParser.ApplicationsList[i].Name;
94
                            rdoBtn.Text = SettingsParser.ApplicationsList[j].Name;
71
                            if (SettingsParser.ApplicationsList[i].Default)
95
                            if (SettingsParser.ApplicationsList[j].Default)
72
                                chkBox.Checked = true;
96
                                rdoBtn.Checked = true;
73
                            chkBox.Location = new Point(nextXLocation, nextYLocation);
97
                            rdoBtn.Location = new Point(subNextXLocation, subNextYLocation);
74
                            // Increments the location placeholder for the next element
98
                            // Increments the location placeholder for the next element
75
                            nextYLocation += 23;
99
                            subNextYLocation += 23;
76
                            // Adds the checkbox to the parent groupbox
100
                            // Adds the radiobutton to the parent groupbox
77
                            this.groupBox_SoftwareList.Controls.Add(chkBox);
101
                            grpBox.Controls.Add(rdoBtn);
78
                            // Adds the checkbox to formCheckBoxes list
102
                            // Adds the radiobutton to formRadioButton list
79
                            formCheckBoxes.Add(chkBox);
103
                            formRadioButton.Add(rdoBtn);
80
                        }
104
                        }
81
                    }
-
 
82
                    // Adds a groupbox for each entry specified in subGroups as well as any applications under the group
-
 
83
                    for (int i = 0; i < subGroups.Count(); i++)
-
 
84
                    {
-
 
85
                        // Sets the internal location coordinates for the next element
-
 
86
                        int subNextXLocation = 6;
-
 
87
                        int subNextYLocation = 19;
-
 
88
                        // Creates a new groupbox
-
 
89
                        GroupBox grpBox = new GroupBox();
-
 
90
                        grpBox.Name = "grp_" + subGroups[i];
-
 
91
                        grpBox.Text = subGroups[i];
-
 
92
                        // Finds the number of applications under the group
-
 
93
                        int numberOfSubentries = 0;
-
 
94
                        for (int j = 0; j < SettingsParser.ApplicationsList.Count(); j++)
-
 
95
                            if (SettingsParser.ApplicationsList[j].Group == subGroups[i])
-
 
96
                            {
-
 
97
                                // If the group matches, creates a new radiobutton
-
 
98
                                numberOfSubentries++;
-
 
99
                                RadioButton rdoBtn = new RadioButton();
-
 
100
                                rdoBtn.Name = "rdo_" + SettingsParser.ApplicationsList[j].Name;
-
 
101
                                rdoBtn.AutoSize = true;
-
 
102
                                rdoBtn.Text = SettingsParser.ApplicationsList[j].Name;
-
 
103
                                if (SettingsParser.ApplicationsList[j].Default)
-
 
104
                                    rdoBtn.Checked = true;
-
 
105
                                rdoBtn.Location = new Point(subNextXLocation, subNextYLocation);
-
 
106
                                // Increments the location placeholder for the next element
-
 
107
                                subNextYLocation += 23;
-
 
108
                                // Adds the radiobutton to the parent groupbox
-
 
109
                                grpBox.Controls.Add(rdoBtn);
-
 
110
                                // Adds the radiobutton to formRadioButton list
-
 
111
                                formRadioButton.Add(rdoBtn);
-
 
112
                            }
-
 
113
                        grpBox.Size = new Size(SettingsParser.softwareFormWidth - 42, 19 + numberOfSubentries * 23);
105
                    grpBox.Size = new Size(SettingsParser.softwareFormWidth - 42, 19 + numberOfSubentries * 23);
114
                        grpBox.Location = new Point(nextXLocation, nextYLocation);
106
                    grpBox.Location = new Point(nextXLocation, nextYLocation);
115
                        nextYLocation += 25 + numberOfSubentries * 23;
107
                    nextYLocation += 25 + numberOfSubentries * 23;
116
                        // Adds the created groupbox to the parent groupbox
108
                    // Adds the created groupbox to the parent groupbox
117
                        this.groupBox_SoftwareList.Controls.Add(grpBox);
109
                    this.groupBox_SoftwareList.Controls.Add(grpBox);
118
                    }
-
 
119
                }
110
                }
120
            }
111
            }
121
            catch (Exception ex)
112
            catch (Exception ex)
122
            {
113
            {
123
                Debug.appendText("Exception Thrown: " + ex.ToString());
114
                Debug.appendText("Exception Thrown: " + ex.ToString());