Browse Source

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

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

37
fileFinder/MainForm.cs

@ -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(1000);
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";
}
}
}
}

2
fileFinder/TaskController.cs

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

Loading…
Cancel
Save