@@ -42,8 +42,6 @@ public partial class FormMain : Form
4242
4343 private BackgroundWorker runDeleteSlidesThread = null ;
4444
45- private BackgroundWorker runDeleteOldScreenshotsThread = null ;
46-
4745 private BackgroundWorker runFilterSearchThread = null ;
4846
4947 private BackgroundWorker runSaveScreenshotsThread = null ;
@@ -113,8 +111,6 @@ public FormMain(string[] args)
113111 // Get rid of the old "slides" directory that may still remain from an old version of the application.
114112 DeleteSlides ( ) ;
115113
116- DeleteOldScreenshots ( ) ;
117-
118114 if ( args . Length > 0 )
119115 {
120116 ParseCommandLineArguments ( args ) ;
@@ -140,13 +136,6 @@ private void InitializeThreads()
140136 {
141137 Log . Write ( "Initializing threads" ) ;
142138
143- runDeleteOldScreenshotsThread = new BackgroundWorker
144- {
145- WorkerReportsProgress = false ,
146- WorkerSupportsCancellation = true
147- } ;
148- runDeleteOldScreenshotsThread . DoWork += new DoWorkEventHandler ( DoWork_runDeleteOldScreenshotsThread ) ;
149-
150139 runDeleteSlidesThread = new BackgroundWorker
151140 {
152141 WorkerReportsProgress = false ,
@@ -379,7 +368,7 @@ private void FormViewer_FormClosing(object sender, FormClosingEventArgs e)
379368 HideInterface ( ) ;
380369
381370 Log . Write ( "Saving screenshots on forced application exit because Windows is shutting down" ) ;
382- _screenshotCollection . Save ( ) ;
371+ _screenshotCollection . Save ( ( int ) numericUpDownKeepScreenshotsForDays . Value ) ;
383372
384373 if ( runDateSearchThread != null && runDateSearchThread . IsBusy )
385374 {
@@ -391,11 +380,6 @@ private void FormViewer_FormClosing(object sender, FormClosingEventArgs e)
391380 runScreenshotSearchThread . CancelAsync ( ) ;
392381 }
393382
394- if ( runDeleteOldScreenshotsThread != null && runDeleteOldScreenshotsThread . IsBusy )
395- {
396- runDeleteOldScreenshotsThread . CancelAsync ( ) ;
397- }
398-
399383 // Exit.
400384 Environment . Exit ( 0 ) ;
401385 }
@@ -476,17 +460,6 @@ private void SearchFilterValues()
476460 comboBoxFilterValue . EndUpdate ( ) ;
477461 }
478462
479- /// <summary>
480- /// Deletes old screenshots.
481- /// </summary>
482- private void DeleteOldScreenshots ( )
483- {
484- if ( runDeleteOldScreenshotsThread != null && ! runDeleteOldScreenshotsThread . IsBusy )
485- {
486- runDeleteOldScreenshotsThread . RunWorkerAsync ( ) ;
487- }
488- }
489-
490463 /// <summary>
491464 /// This thread is responsible for finding slides.
492465 /// </summary>
@@ -547,7 +520,7 @@ private void RunDeleteSlides(DoWorkEventArgs e)
547520
548521 private void RunSaveScreenshots ( DoWorkEventArgs e )
549522 {
550- _screenshotCollection . Save ( ) ;
523+ _screenshotCollection . Save ( ( int ) numericUpDownKeepScreenshotsForDays . Value ) ;
551524 }
552525
553526 private void RunFilterSearch ( DoWorkEventArgs e )
@@ -569,15 +542,6 @@ private void RunFilterSearch(DoWorkEventArgs e)
569542 }
570543 }
571544
572- /// <summary>
573- /// This thread is responsible for deleting screenshots older than a specified number of days.
574- /// </summary>
575- /// <param name="e"></param>
576- private void RunDeleteOldScreenshots ( DoWorkEventArgs e )
577- {
578- _screenshotCollection . KeepScreenshotsForDays ( ( int ) numericUpDownKeepScreenshotsForDays . Value ) ;
579- }
580-
581545 /// <summary>
582546 /// Saves the user's settings.
583547 /// </summary>
@@ -756,8 +720,6 @@ private void StartScreenCapture()
756720 {
757721 SaveSettings ( ) ;
758722
759- DeleteOldScreenshots ( ) ;
760-
761723 // Stop the date search thread if it's busy.
762724 if ( runDateSearchThread != null && runDateSearchThread . IsBusy )
763725 {
@@ -1033,7 +995,7 @@ private void ExitApplication()
1033995 HideInterface ( ) ;
1034996
1035997 Log . Write ( "Saving screenshots on clean application exit" ) ;
1036- _screenshotCollection . Save ( ) ;
998+ _screenshotCollection . Save ( ( int ) numericUpDownKeepScreenshotsForDays . Value ) ;
1037999
10381000 if ( runDateSearchThread != null && runDateSearchThread . IsBusy )
10391001 {
@@ -1045,11 +1007,6 @@ private void ExitApplication()
10451007 runScreenshotSearchThread . CancelAsync ( ) ;
10461008 }
10471009
1048- if ( runDeleteOldScreenshotsThread != null && runDeleteOldScreenshotsThread . IsBusy )
1049- {
1050- runDeleteOldScreenshotsThread . CancelAsync ( ) ;
1051- }
1052-
10531010 // Exit.
10541011 Environment . Exit ( 0 ) ;
10551012 }
@@ -1090,16 +1047,6 @@ private void DoWork_runSaveScreenshotsThread(object sender, DoWorkEventArgs e)
10901047 RunSaveScreenshots ( e ) ;
10911048 }
10921049
1093- /// <summary>
1094- /// Runs the "delete old screenshots" thread.
1095- /// </summary>
1096- /// <param name="sender"></param>
1097- /// <param name="e"></param>
1098- private void DoWork_runDeleteOldScreenshotsThread ( object sender , DoWorkEventArgs e )
1099- {
1100- RunDeleteOldScreenshots ( e ) ;
1101- }
1102-
11031050 private void DoWork_runFilterSearchThread ( object sender , DoWorkEventArgs e )
11041051 {
11051052 RunFilterSearch ( e ) ;
@@ -2882,16 +2829,6 @@ private void notifyIcon_MouseMove(object sender, MouseEventArgs e)
28822829 }
28832830 }
28842831
2885- /// <summary>
2886- /// Deletes old screenshots (and also writes to the screenshots.xml file) every minute.
2887- /// </summary>
2888- /// <param name="sender"></param>
2889- /// <param name="e"></param>
2890- private void timerDeleteOldScreenshots_Tick ( object sender , EventArgs e )
2891- {
2892- DeleteOldScreenshots ( ) ;
2893- }
2894-
28952832 private void tabControlViews_Selected ( object sender , TabControlEventArgs e )
28962833 {
28972834 ShowScreenshotBySlideIndex ( ) ;
@@ -2945,11 +2882,11 @@ private void comboBoxFilterType_SelectedIndexChanged(object sender, EventArgs e)
29452882 }
29462883
29472884 /// <summary>
2948- /// Saves screenshots every hour .
2885+ /// Saves screenshots every minute .
29492886 /// </summary>
29502887 /// <param name="sender"></param>
29512888 /// <param name="e"></param>
2952- private void timerSaveScreenshots_Tick ( object sender , EventArgs e )
2889+ private void timerPerformMaintenance_Tick ( object sender , EventArgs e )
29532890 {
29542891 SaveScreenshots ( ) ;
29552892 }
0 commit comments