Browse Source

Исправление ошибки, когда не менялось видимость ResultViewer'a. Добавлена возможность запустить новое задание, если в одном из полей изменилось название.

release
Никита 6 years ago
parent
commit
ab61bb5a11
  1. 29
      fileFinder/MainForm.cs
  2. 2
      fileFinder/TaskController.cs

29
fileFinder/MainForm.cs

@ -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(1000); System.Timers.Timer updateInfoTimer = new System.Timers.Timer(1000);
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";
}
} }
} }
} }

2
fileFinder/TaskController.cs

@ -77,6 +77,8 @@ namespace fileFinder
int counter = 0; int counter = 0;
foreach (string item in foundFiles) foreach (string item in foundFiles)
{ {
if (controller.isStopped)
return null;
while (controller.isPaused) while (controller.isPaused)
{ {
Thread.Sleep(100); Thread.Sleep(100);

Loading…
Cancel
Save