Skip to content

Commit ac5b53f

Browse files
authored
Merge pull request #39 from CyanCoding/cyancoding-test-branch
Add summaries to the functions
2 parents 8696076 + c682a38 commit ac5b53f

9 files changed

Lines changed: 251 additions & 39 deletions

File tree

app/Project Tracker Installer/Project Tracker Installer/Installer.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99

1010
namespace Project_Tracker_Installer {
1111
class Installer {
12+
/// <summary>
13+
/// Installs the latest Project Tracker program to the user's computer.
14+
/// </summary>
15+
/// <param name="PROGRAM_PATH">The path of the unzipped program.</param>
16+
/// <param name="INSTALL_DIRECTORY">The directory to install to.</param>
17+
/// <param name="ONLINE_PROGRAM_LINK">The URL to the program download.</param>
18+
/// <param name="ZIP_PATH">The zip path to download to and extract from.</param>
19+
/// <returns></returns>
1220
public bool InstallProgram(string PROGRAM_PATH, string INSTALL_DIRECTORY, string ONLINE_PROGRAM_LINK, string ZIP_PATH) {
1321
if (System.IO.File.Exists(PROGRAM_PATH)) {
1422
System.IO.File.Delete(PROGRAM_PATH);
@@ -32,6 +40,16 @@ public bool InstallProgram(string PROGRAM_PATH, string INSTALL_DIRECTORY, string
3240

3341
}
3442

43+
/// <summary>
44+
/// Creates a program uninstall registry and a shortcut.
45+
/// </summary>
46+
/// <param name="REGISTRY">The title of the registry entry to create.</param>
47+
/// <param name="PROGRAM_TITLE">The title of the program.</param>
48+
/// <param name="PROGRAM_VERSION">The version of the program we're installing.</param>
49+
/// <param name="ICON_PATH">The path to the icon.</param>
50+
/// <param name="PROGRAM_PATH">The path to the installed program.</param>
51+
/// <param name="INSTALL_DIRECTORY">The directory of the installed program.</param>
52+
/// <param name="SHORTCUT_LOCATION">The path for the shortcut.</param>
3553
public void CreateUninstaller(string REGISTRY, string PROGRAM_TITLE, string PROGRAM_VERSION, string ICON_PATH, string PROGRAM_PATH, string INSTALL_DIRECTORY, string SHORTCUT_LOCATION) {
3654
RegistryKey keyCheck = Registry.CurrentUser.OpenSubKey(REGISTRY);
3755

app/Project Tracker Installer/Project Tracker Installer/MainWindow.xaml.cs

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ public MainWindow() {
4242
startup();
4343
}
4444

45+
/// <summary>
46+
/// Retrieves the latest available version from the server.
47+
/// </summary>
4548
private void GetVersion(object sender, AsyncCompletedEventArgs e) {
4649
try {
4750
PROGRAM_VERSION = File.ReadAllText(VERSION_PATH);
@@ -66,6 +69,9 @@ private void GetVersion(object sender, AsyncCompletedEventArgs e) {
6669
}
6770
}
6871

72+
/// <summary>
73+
/// Startup method, runs when code execution begins.
74+
/// </summary>
6975
void startup() {
7076
subTitle.Content = "Version: " + PROGRAM_VERSION;
7177

@@ -168,9 +174,9 @@ void startup() {
168174
}
169175
}
170176

171-
/*
172-
* When the user clicks to open the Projet Tracker program
173-
*/
177+
/// <summary>
178+
/// Launches the program from PROGRAM_PATH.
179+
/// </summary>
174180
private void LaunchButtonClick(object sender, RoutedEventArgs e) {
175181
ProcessStartInfo start = new ProcessStartInfo {
176182
// Enter the executable to run, including the complete path
@@ -183,10 +189,10 @@ private void LaunchButtonClick(object sender, RoutedEventArgs e) {
183189
Environment.Exit(0);
184190
}
185191

186-
187-
/* When the user clicks the reinstall button
188-
* This runs the same install button procedure, just deletes the contents of the program first and sets uninstall to false
189-
*/
192+
/// <summary>
193+
/// Runs when the user clicks on the reinstall button.
194+
/// Uninstalls and then installs the program.
195+
/// </summary>
190196
private void ReinstallButtonClick(object sender, RoutedEventArgs e) {
191197
reinstallButton.Visibility = Visibility.Hidden;
192198
installButton.Visibility = Visibility.Hidden;
@@ -218,9 +224,11 @@ private void ReinstallButtonClick(object sender, RoutedEventArgs e) {
218224

219225
FinalResult("Project Tracker has been installed!");
220226
}
221-
/*
222-
* When the user clicks on the install button
223-
*/
227+
228+
/// <summary>
229+
/// Runs when the user clicks on the install button.
230+
/// If the program is already installed, it becomes an uninstall button.
231+
/// </summary>
224232
private void InstallButtonClick(object sender, RoutedEventArgs e) {
225233
if (retrying == true) {
226234
installButton.Content = "Install";
@@ -329,11 +337,15 @@ private void InstallButtonClick(object sender, RoutedEventArgs e) {
329337

330338
FinalResult("Successfully uninstalled!");
331339
}));
332-
333340
}
334341

335342
}
336343

344+
/// <summary>
345+
/// A final display presented to the user after code execution has finished.
346+
/// Used to display the success or failure of the installation.
347+
/// </summary>
348+
/// <param name="main">The main title text.</param>
337349
public void FinalResult(string main) {
338350
Dispatcher.Invoke(new Action(() => {
339351
installBar.Visibility = Visibility.Hidden;
@@ -366,6 +378,9 @@ public void FinalResult(string main) {
366378
}));
367379
}
368380

381+
/// <summary>
382+
/// Runs before window is closed after the user closes the program.
383+
/// </summary>
369384
private void Window_Closing(object sender, CancelEventArgs e) {
370385
Environment.Exit(0);
371386
}

app/Project Tracker Installer/Project Tracker Installer/Uninstaller.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@
55

66
namespace Project_Tracker_Installer {
77
class Uninstaller {
8+
/// <summary>
9+
/// Main uninstall function.
10+
/// Prompts user to delete data and deletes every other file.
11+
/// </summary>
12+
/// <param name="DATA_DIRECTORY_PATH">The directory where the user's data lies.</param>
13+
/// <param name="INSTALLER_PATH">The path of the installer to not delete.</param>
14+
/// <param name="INSTALL_DIRECTORY">The path of the install program directory.</param>
15+
/// <param name="REGISTRY">The title of the registry entry to remove.</param>
16+
/// <param name="SHORTCUT_LOCATION">The path of the shortcut to delete.</param>
817
public void Uninstall(string DATA_DIRECTORY_PATH, string INSTALLER_PATH, string INSTALL_DIRECTORY, string REGISTRY = "", string SHORTCUT_LOCATION = "") {
918
if (Directory.Exists(DATA_DIRECTORY_PATH)) {
1019
var deleteData = MessageBox.Show("Do you wish to delete your projects data?", "Project Tracker Installer", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
@@ -30,6 +39,11 @@ public void Uninstall(string DATA_DIRECTORY_PATH, string INSTALLER_PATH, string
3039

3140
}
3241

42+
/// <summary>
43+
/// Deletes the registry value for the program.
44+
/// </summary>
45+
/// <param name="REGISTRY">The title of the registry entry to remove.</param>
46+
/// <param name="SHORTCUT_LOCATION">The path of the shortcut to delete.</param>
3347
private void RemoveRegistry(string REGISTRY, string SHORTCUT_LOCATION) {
3448
Registry.CurrentUser.DeleteSubKey(REGISTRY);
3549
File.Delete(SHORTCUT_LOCATION);

app/Project Tracker/Project Tracker/AddNewItem.xaml.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ public AddNewItem() {
1919
inputBox.Focus();
2020
}
2121

22+
/// <summary>
23+
/// Adds the item to the current table when the return key is pressed.
24+
/// </summary>
2225
private void KeyPress(object sender, KeyEventArgs e) {
2326
if (e.Key == Key.Return) {
2427
if (inputBox.Text != "") {
@@ -42,6 +45,9 @@ private void KeyPress(object sender, KeyEventArgs e) {
4245
}
4346
}
4447

48+
/// <summary>
49+
/// Adds the item to the current table when the finish button is pressed.
50+
/// </summary>
4551
private void finishButton_Click(object sender, RoutedEventArgs e) {
4652
if (inputBox.Text != "") {
4753
if (Passthrough.SelectedIndex == 0) {
@@ -63,11 +69,17 @@ private void finishButton_Click(object sender, RoutedEventArgs e) {
6369
}
6470
}
6571

72+
/// <summary>
73+
/// Cancels the operation and hides the window.
74+
/// </summary>
6675
private void cancelButton_Click(object sender, RoutedEventArgs e) {
6776
Passthrough.IsAdding = false;
6877
this.Hide();
6978
}
7079

80+
/// <summary>
81+
/// Saves the item to the editing file.
82+
/// </summary>
7183
private void Save() {
7284
StringBuilder sb = new StringBuilder();
7385
StringWriter sw = new StringWriter(sb);

app/Project Tracker/Project Tracker/AddNewProgram.xaml.cs

Lines changed: 67 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ public AddNewProgram() {
5252
projectTitleInputBox.Focus();
5353
}
5454

55-
private void FirstForward() { // Moving from project title to project duration
55+
/// <summary>
56+
/// Moves the form from the project title to the project duration.
57+
/// </summary>
58+
private void FirstForward() {
5659
if (projectTitleInputBox.Text != "") {
5760
level = 1;
5861

@@ -75,7 +78,10 @@ private void FirstForward() { // Moving from project title to project duration
7578
}
7679
}
7780

78-
private void SecondForward() { // Moving from project duration to error list
81+
/// <summary>
82+
/// Moves the form from the project duration to the error list.
83+
/// </summary>
84+
private void SecondForward() {
7985
durationSuccess[0] = CheckValid(projectHourInputBox.Text, "hour");
8086
durationSuccess[1] = CheckValid(projectMinuteInputBox.Text, "minute");
8187
durationSuccess[2] = CheckValid(projectSecondInputBox.Text, "second");
@@ -111,7 +117,10 @@ private void SecondForward() { // Moving from project duration to error list
111117
}
112118
}
113119

114-
private void ThirdForward() { // Moving from error list to feature list
120+
/// <summary>
121+
/// Moves the form from the error list to the feature list.
122+
/// </summary>
123+
private void ThirdForward() {
115124
level = 3;
116125
projectTitleText.Text = "Features";
117126

@@ -124,7 +133,10 @@ private void ThirdForward() { // Moving from error list to feature list
124133
projectFeatureInputBox.Focus();
125134
}
126135

127-
private void FourthForward() { // Moving from feature list to comment list
136+
/// <summary>
137+
/// Moves the form from the feature list to the comment list.
138+
/// </summary>
139+
private void FourthForward() {
128140
level = 4;
129141
projectTitleText.Text = "Comments";
130142

@@ -137,7 +149,10 @@ private void FourthForward() { // Moving from feature list to comment list
137149
projectCommentInputBox.Focus();
138150
}
139151

140-
private void FifthForward() { // Moving from comment list to percent complete
152+
/// <summary>
153+
/// Moves the form from the comment list to the final result
154+
/// </summary>
155+
private void FifthForward() {
141156
level = 5;
142157
projectTitleText.Text = "Percent complete";
143158

@@ -161,6 +176,9 @@ private void FifthForward() { // Moving from comment list to percent complete
161176
commentResult.Visibility = Visibility.Visible;
162177
}
163178

179+
/// <summary>
180+
/// Finalizes the project and writes the files to the data folder.
181+
/// </summary>
164182
private void Finish() { // Creating file for new project
165183
if (!Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "/Project Tracker")) {
166184
Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "/Project Tracker");
@@ -254,6 +272,12 @@ private void FifthForward() { // Moving from comment list to percent complete
254272
* Checks the validitiy of the duration values to make sure they are real numbers.
255273
*/
256274

275+
/// <summary>
276+
/// Checks to make sure that numbers are valid.
277+
/// </summary>
278+
/// <param name="value">The string of the number to test.</param>
279+
/// <param name="identifier">The name for that number.</param>
280+
/// <returns>Returns true if a valid number and false if not.</returns>
257281
private bool CheckValid(string value, string identifier) {
258282
try {
259283
Int32.Parse(value);
@@ -266,6 +290,9 @@ private bool CheckValid(string value, string identifier) {
266290
}
267291
}
268292

293+
/// <summary>
294+
/// Advances to the next item in the form.
295+
/// </summary>
269296
private void nextButton_Click(object sender, RoutedEventArgs e) {
270297
switch (level) {
271298
case 0:
@@ -294,6 +321,12 @@ private void nextButton_Click(object sender, RoutedEventArgs e) {
294321
}
295322
}
296323

324+
/// <summary>
325+
/// Adds a row to the current table.
326+
/// </summary>
327+
/// <param name="value">The value to add to the table.</param>
328+
/// <param name="table">The table to add to.</param>
329+
/// <param name="tableCount">Which table we're adding to (0 = error, 1 = feature, 2 = comment).</param>
297330
private void AddRow(string value, Table table, int tableCount) {
298331
table.RowGroups[0].Rows.Add(new TableRow());
299332

@@ -332,6 +365,9 @@ private void AddRow(string value, Table table, int tableCount) {
332365
newRow.Cells.Add(new TableCell(new Paragraph(new Run(value))));
333366
}
334367

368+
/// <summary>
369+
/// Checks the table input box value and adds a row if valid.
370+
/// </summary>
335371
private void AddValue(object sender, MouseButtonEventArgs e) {
336372
if (level == 2) { // Error table
337373
if (projectErrorInputBox.Text != "") {
@@ -356,6 +392,9 @@ private void AddValue(object sender, MouseButtonEventArgs e) {
356392
}
357393
}
358394

395+
/// <summary>
396+
/// Advances through the thread or adds to the table depending on current view.
397+
/// </summary>
359398
private void KeyPress(object sender, KeyEventArgs e) {
360399
if (e.Key == Key.Return) {
361400
if (level == 0) { // Title page
@@ -394,7 +433,10 @@ private void KeyPress(object sender, KeyEventArgs e) {
394433

395434
}
396435

397-
private void FirstBack() { // From duration to project title
436+
/// <summary>
437+
/// Moves the form from the project duration to the project title.
438+
/// </summary>
439+
private void FirstBack() {
398440
level = 0;
399441

400442
cancelButton.Content = "Cancel";
@@ -410,7 +452,10 @@ private void FirstBack() { // From duration to project title
410452
projectTitleInputBox.Focus();
411453
}
412454

413-
private void SecondBack() { // From errors to duration
455+
/// <summary>
456+
/// Moves the form from the error list to the project duration.
457+
/// </summary>
458+
private void SecondBack() {
414459
level = 1;
415460

416461
this.Height = 190;
@@ -428,7 +473,10 @@ private void SecondBack() { // From errors to duration
428473
errorAddButton.Visibility = Visibility.Hidden;
429474
}
430475

431-
private void ThirdBack() { // From features to errors
476+
/// <summary>
477+
/// Moves the form from the feature list to the error list.
478+
/// </summary>
479+
private void ThirdBack() {
432480
level = 2;
433481

434482
projectTitleText.Text = "Errors";
@@ -441,7 +489,10 @@ private void ThirdBack() { // From features to errors
441489
projectFeatureInputBox.Visibility = Visibility.Hidden;
442490
}
443491

444-
private void FourthBack() { // From comments to features
492+
/// <summary>
493+
/// Moves the form from the comment list to the feature list.
494+
/// </summary>
495+
private void FourthBack() {
445496
level = 3;
446497

447498
projectTitleText.Text = "Features";
@@ -454,7 +505,10 @@ private void FourthBack() { // From comments to features
454505
projectCommentInputBox.Visibility = Visibility.Hidden;
455506
}
456507

457-
private void FifthBack() { // From percent complete to comments
508+
/// <summary>
509+
/// Moves the form from the final window to the comment list.
510+
/// </summary>
511+
private void FifthBack() {
458512
level = 4;
459513

460514
this.Height = 350;
@@ -472,6 +526,9 @@ private void FifthBack() { // From percent complete to comments
472526
commentResult.Visibility = Visibility.Hidden;
473527
}
474528

529+
/// <summary>
530+
/// Moves the form in a reverse order when the back/cancel button is pressed.
531+
/// </summary>
475532
private void cancelButton_Click(object sender, RoutedEventArgs e) {
476533
switch (level) {
477534
case 0:

0 commit comments

Comments
 (0)