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