@ -16,14 +16,13 @@ namespace fileFinder
public partial class MainForm : Form
{
HintModel hints = new HintModel ( ) ;
TaskController mainController ;
TaskController mainController = new TaskController ( ) ;
SearchQueryModel searchQueryModel ;
System . Timers . Timer updateInfoTimer = new System . Timers . Timer ( 1 0 0 0 ) ;
public MainForm ( )
{
InitializeComponent ( ) ;
mainController = new TaskController ( ) ;
this . updateInfoTimer . Elapsed + = refreshInfoByTimer ;
this . updateInfoTimer . AutoReset = true ;
this . updateInfoTimer . Enabled = true ;
@ -39,6 +38,7 @@ namespace fileFinder
queryTextBox . Text = sets . fileNameQuery ;
searchQueryModel = mainController . updateSearchQueryModel ( sets . fileUrl ,
sets . fileInnerQuery , sets . fileNameQuery ) ;
mainController . isTaskChanged = false ;
}
private void fillImagesToResultViewer ( )
@ -94,26 +94,30 @@ namespace fileFinder
if ( mainController . isStopped | | mainController . isTaskChanged )
{
mainController . stopTask ( ) ;
mainController = new TaskController ( ) ;
searchQueryModel = mainController . updateSearchQueryModel ( curDirTextBox . Text ,
queryTextBox . Text , innerQueryTextBox . Text ) ;
handleSearchBtn . Text = "Pause Task" ;
waitOrPauseLabel . Visible = true ;
resultViewer . Enabled = false ;
mainController . beginTask ( ) ;
TreeNode tN = await Task . Run ( ( ) = > mainController . buildResultTree ( searchQueryModel , progress ) ) ;
updateResultViewer ( tN ) ;
changeVisibilityResultViewer ( ) ;
handleSearchBtn . Text = "Start Task" ;
TreeNode tN = await Task . Run ( ( ) = > mainController . buildResultTree ( searchQueryModel , progress ) ) ;
if ( tN ! = null )
{
updateResultViewer ( tN ) ;
changeVisibilityResultViewer ( ) ;
handleSearchBtn . Text = "Start Task" ;
}
} else if ( mainController . isPaused )
{
handleSearchBtn . Text = "Pause Task" ;
changeVisibilityResultViewer ( ) ;
mainController . resumeTask ( ) ;
changeVisibilityResultViewer ( ) ;
} else
{
handleSearchBtn . Text = "Resume Task" ;
changeVisibilityResultViewer ( ) ;
mainController . pauseTask ( ) ;
changeVisibilityResultViewer ( ) ;
}
}
@ -170,17 +174,26 @@ namespace fileFinder
private void curDirTextBox_TextChanged ( object sender , EventArgs e )
{
mainController . isTaskChanged = true ;
changeTaskBtnStatus ( ) ;
}
private void queryTextBox_TextChanged ( object sender , EventArgs e )
{
mainController . isTaskChanged = true ;
changeTaskBtnStatus ( ) ;
}
private void innerQueryTextBox_TextChanged ( object sender , EventArgs e )
{
mainController . isTaskChanged = true ;
changeTaskBtnStatus ( ) ;
}
private void changeTaskBtnStatus ( )
{
if ( ! mainController . isTaskChanged )
{
mainController . isTaskChanged = true ;
handleSearchBtn . Text = "Start New Task" ;
}
}
}
}