22using System ;
33using System . Collections . Generic ;
44using System . ComponentModel ;
5+ using System . Diagnostics ;
56using System . IO ;
67using System . Net ;
78using System . Text ;
@@ -23,7 +24,7 @@ public partial class MainWindow : UWPHost.Window {
2324 Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData )
2425 + "/Project Tracker" ;
2526 // IF YOU CHANGE THIS, ALSO CHANGE IT IN UpdateWindow.xaml.cs
26- private readonly string CURRENT_VERSION = "2.2 " ;
27+ private readonly string CURRENT_VERSION = "2.4 " ;
2728
2829 private readonly string DATA_DIRECTORY =
2930 Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData )
@@ -91,7 +92,7 @@ public partial class MainWindow : UWPHost.Window {
9192 private string icon ;
9293
9394
94-
95+ #pragma warning disable CS0472 // The result of the expression is always the same since a value of this type is never equal to 'null'
9596 public MainWindow ( ) {
9697 InitializeComponent ( ) ;
9798 Startup ( ) ;
@@ -387,14 +388,16 @@ private void CheckmarkPressed(object sender, MouseButtonEventArgs e) {
387388 string name = callingImage . Name ;
388389 name = name . Remove ( 0 , 1 ) ; // Removes the t from the name (e.g. t5 -> 5)
389390
390- if ( taskData [ Int32 . Parse ( name ) - 1 ] == "1" ) {
391+ if ( taskData [ Int32 . Parse ( name ) - 1 ] == "1" ) { // It's already checked
391392 taskData [ Int32 . Parse ( name ) - 1 ] = "0" ;
393+ tasksCompleted -- ;
392394 }
393- else {
395+ else { // It's not checked
394396 taskData [ Int32 . Parse ( name ) - 1 ] = "1" ;
397+ tasksCompleted ++ ;
395398 }
396399
397- tasksCompleted ++ ;
400+
398401
399402 CalculatePercentage ( ) ;
400403 }
@@ -1312,7 +1315,17 @@ private void ProjectStatisticsMouseDown(object sender, MouseButtonEventArgs e) {
13121315 tasksMadeLabel . Content = "Tasks created: " + tasksMade ;
13131316 tasksCompletedLabel . Content = "Tasks completed: " + tasksCompleted ;
13141317 statisticsDurationLabel . Content = "Duration: coming soon..." ;
1315- linesOfCodeLabel . Content = "Lines of code: " + Statistics . CountLines ( linesOfCodeFiles . ToArray ( ) ) ;
1318+ linesOfCodeLabel . Content = "Lines of code: " + String . Format ( "{0:#,###0}" , Statistics . CountLines ( linesOfCodeFiles . ToArray ( ) ) ) ;
1319+
1320+
1321+ if ( folderLocation != "" && Directory . Exists ( folderLocation ) ) {
1322+ folderLocationResetButton . Content = "Reset folder location" ;
1323+ folderLocationLabel . Content = "Folder location: " + folderLocation ;
1324+ }
1325+ else {
1326+ folderLocationLabel . Content = "Folder location: not set" ;
1327+ folderLocationResetButton . Content = "Set folder location" ;
1328+ }
13161329 }
13171330
13181331 private void RenameProjectButtonPressed ( object sender , MouseButtonEventArgs e ) {
@@ -1609,6 +1622,7 @@ private void SetSelectedProject() {
16091622 completeGrid . Visibility = Visibility . Visible ;
16101623 addItemBorder . Visibility = Visibility . Visible ;
16111624 settingsImage . Visibility = Visibility . Visible ;
1625+ folderImage . Visibility = Visibility . Visible ;
16121626
16131627 string json = File . ReadAllText ( filesRead [ selectedIndex - 1 ] ) ;
16141628 MainTableManifest . Rootobject projectInfo =
@@ -2077,7 +2091,10 @@ private void UpdateButtonMouseDown(object sender, MouseButtonEventArgs e) {
20772091 File . Delete ( NEXT_VERSION_INFO ) ;
20782092 }
20792093
2094+ #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
20802095 DisableUpdateButton ( ) ;
2096+ #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
2097+
20812098 // Download latest version information
20822099 try {
20832100 updateButton1 . IsEnabled = false ;
@@ -2215,6 +2232,7 @@ private void Window_SizeChanged(object sender, SizeChangedEventArgs e) {
22152232 blackRectangle . Height = this . Height + 5 ;
22162233 addItemBorder . Width = this . Width - 450 ;
22172234 changeTitleBorder . Width = this . Width - 700 ;
2235+ folderLocationLabel . Width = this . Width - 420 ;
22182236
22192237 scrollviewerGrid . Width = this . Width - 450 ;
22202238
@@ -2411,7 +2429,14 @@ private void FeatureItemPressed(object sender, MouseButtonEventArgs e) {
24112429 #endregion Item selection presses
24122430
24132431 private void folderImage_PreviewMouseDown ( object sender , MouseButtonEventArgs e ) {
2432+ if ( folderLocation == "" || ! Directory . Exists ( folderLocation ) ) {
2433+ folderLocation = Folder . SelectFolder ( ) ;
24142434
2435+ Save ( filesRead [ selectedIndex - 1 ] ) ;
2436+ }
2437+ else {
2438+ Process . Start ( folderLocation ) ;
2439+ }
24152440 }
24162441
24172442 private void setCodeCountingButton_PreviewMouseDown ( object sender , MouseButtonEventArgs e ) {
@@ -2423,7 +2448,18 @@ private void setCodeCountingButton_PreviewMouseDown(object sender, MouseButtonEv
24232448
24242449 Save ( filesRead [ selectedIndex - 1 ] ) ;
24252450
2426- linesOfCodeLabel . Content = "Lines of code: " + Statistics . CountLines ( linesOfCodeFiles . ToArray ( ) ) ;
2451+ linesOfCodeLabel . Content = "Lines of code: " + String . Format ( "{0:#,###0}" , Statistics . CountLines ( linesOfCodeFiles . ToArray ( ) ) ) ;
2452+ }
2453+
2454+ private void folderLocationResetButton_PreviewMouseDown ( object sender , MouseButtonEventArgs e ) {
2455+ folderLocation = Folder . SelectFolder ( ) ;
2456+ Save ( filesRead [ selectedIndex - 1 ] ) ;
2457+
2458+ folderLocationLabel . Content = "Folder location: " + folderLocation ;
2459+
2460+ if ( folderLocation != "" && Directory . Exists ( folderLocation ) ) {
2461+ folderLocationResetButton . Content = "Reset folder location" ;
2462+ }
24272463 }
24282464 }
24292465}
0 commit comments