Browse Source

Рефакторинг: curDirTextBox -> fileUrlTextBox, querytextBox -> nameQueryTextBox, changeTaskBtnState -> prepareToNewTask

master
Никита 6 years ago
parent
commit
af86789c95
  1. 40
      fileFinder/MainForm.Designer.cs
  2. 27
      fileFinder/MainForm.cs

40
fileFinder/MainForm.Designer.cs

@ -31,11 +31,11 @@
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
this.resultViewer = new System.Windows.Forms.TreeView();
this.dirSelectBtn = new System.Windows.Forms.Button();
this.curDirTextBox = new System.Windows.Forms.TextBox();
this.fileUrlTextBox = new System.Windows.Forms.TextBox();
this.splitContainer = new System.Windows.Forms.SplitContainer();
this.handleSearchBtn = new System.Windows.Forms.Button();
this.innerQueryTextBox = new System.Windows.Forms.TextBox();
this.queryTextBox = new System.Windows.Forms.TextBox();
this.nameQueryTextBox = new System.Windows.Forms.TextBox();
this.waitOrPauseLabel = new System.Windows.Forms.Label();
this.bottomPanel = new System.Windows.Forms.Panel();
this.infoLabel = new System.Windows.Forms.Label();
@ -67,13 +67,13 @@
//
// curDirTextBox
//
this.curDirTextBox.Location = new System.Drawing.Point(12, 10);
this.curDirTextBox.Name = "curDirTextBox";
this.curDirTextBox.Size = new System.Drawing.Size(650, 20);
this.curDirTextBox.TabIndex = 1;
this.curDirTextBox.Text = "C:\\Users\\itsmy_000\\Desktop\\a\\";
this.curDirTextBox.TextChanged += new System.EventHandler(this.curDirTextBox_TextChanged);
this.curDirTextBox.Enter += new System.EventHandler(this.curDirTextBox_Enter);
this.fileUrlTextBox.Location = new System.Drawing.Point(12, 10);
this.fileUrlTextBox.Name = "curDirTextBox";
this.fileUrlTextBox.Size = new System.Drawing.Size(650, 20);
this.fileUrlTextBox.TabIndex = 1;
this.fileUrlTextBox.Text = "C:\\Users\\itsmy_000\\Desktop\\a\\";
this.fileUrlTextBox.TextChanged += new System.EventHandler(this.fileUrlTextBox_TextChanged);
this.fileUrlTextBox.Enter += new System.EventHandler(this.curDirTextBox_Enter);
//
// splitContainer
//
@ -88,8 +88,8 @@
this.splitContainer.Panel1.Controls.Add(this.handleSearchBtn);
this.splitContainer.Panel1.Controls.Add(this.dirSelectBtn);
this.splitContainer.Panel1.Controls.Add(this.innerQueryTextBox);
this.splitContainer.Panel1.Controls.Add(this.queryTextBox);
this.splitContainer.Panel1.Controls.Add(this.curDirTextBox);
this.splitContainer.Panel1.Controls.Add(this.nameQueryTextBox);
this.splitContainer.Panel1.Controls.Add(this.fileUrlTextBox);
//
// splitContainer.Panel2
//
@ -121,13 +121,13 @@
//
// queryTextBox
//
this.queryTextBox.Location = new System.Drawing.Point(12, 36);
this.queryTextBox.Name = "queryTextBox";
this.queryTextBox.Size = new System.Drawing.Size(776, 20);
this.queryTextBox.TabIndex = 3;
this.queryTextBox.Tag = "";
this.queryTextBox.Text = "*.txt";
this.queryTextBox.TextChanged += new System.EventHandler(this.queryTextBox_TextChanged);
this.nameQueryTextBox.Location = new System.Drawing.Point(12, 36);
this.nameQueryTextBox.Name = "queryTextBox";
this.nameQueryTextBox.Size = new System.Drawing.Size(776, 20);
this.nameQueryTextBox.TabIndex = 3;
this.nameQueryTextBox.Tag = "";
this.nameQueryTextBox.Text = "*.txt";
this.nameQueryTextBox.TextChanged += new System.EventHandler(this.nameQueryTextBox_TextChanged);
//
// waitOrPauseLabel
//
@ -188,12 +188,12 @@
private System.Windows.Forms.TreeView resultViewer;
private System.Windows.Forms.Button dirSelectBtn;
private System.Windows.Forms.TextBox curDirTextBox;
private System.Windows.Forms.TextBox fileUrlTextBox;
private System.Windows.Forms.SplitContainer splitContainer;
private System.Windows.Forms.Button handleSearchBtn;
private System.Windows.Forms.Panel bottomPanel;
private System.Windows.Forms.Label infoLabel;
private System.Windows.Forms.TextBox queryTextBox;
private System.Windows.Forms.TextBox nameQueryTextBox;
private System.Windows.Forms.TextBox innerQueryTextBox;
private System.Windows.Forms.Label waitOrPauseLabel;
}

27
fileFinder/MainForm.cs

@ -27,9 +27,9 @@ namespace fileFinder
private void restoreLastSession()
{
MainSettings sets = MainSettings.Default;
curDirTextBox.Text = sets.fileUrl;
fileUrlTextBox.Text = sets.fileUrl;
innerQueryTextBox.Text = sets.fileInnerQuery;
queryTextBox.Text = sets.fileNameQuery;
nameQueryTextBox.Text = sets.fileNameQuery;
searchQueryModel = mainController.updateSearchQueryModel(sets.fileUrl,
sets.fileInnerQuery, sets.fileNameQuery);
isFieldsChanged = false;
@ -58,7 +58,7 @@ namespace fileFinder
DialogResult result = dialog.ShowDialog();
if (result == DialogResult.OK && !String.IsNullOrWhiteSpace(dialog.SelectedPath))
{
curDirTextBox.Text = dialog.SelectedPath;
fileUrlTextBox.Text = dialog.SelectedPath;
hints.isDirectoryHintActive = false;
}
}
@ -90,6 +90,7 @@ namespace fileFinder
{
Progress<ProgressReportModel> progress = new Progress<ProgressReportModel>();
progress.ProgressChanged += reportProgress;
if (isFieldsChanged) // если в форме изменился запрос
mainController.stopTask(); // то принудительно завершаем задание
@ -98,8 +99,8 @@ namespace fileFinder
switch (mainController.state)
{
case TaskState.Created:
searchQueryModel = mainController.updateSearchQueryModel(curDirTextBox.Text,
queryTextBox.Text, innerQueryTextBox.Text);
searchQueryModel = mainController.updateSearchQueryModel(fileUrlTextBox.Text,
nameQueryTextBox.Text, innerQueryTextBox.Text);
handleSearchBtn.Text = "Pause Task";
mainController.beginTask();
changeVisibilityResultViewer();
@ -175,28 +176,28 @@ namespace fileFinder
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
MainSettings.Default.fileUrl = curDirTextBox.Text;
MainSettings.Default.fileNameQuery = queryTextBox.Text;
MainSettings.Default.fileUrl = fileUrlTextBox.Text;
MainSettings.Default.fileNameQuery = nameQueryTextBox.Text;
MainSettings.Default.fileInnerQuery = innerQueryTextBox.Text;
MainSettings.Default.Save();
}
private void curDirTextBox_TextChanged(object sender, EventArgs e)
private void fileUrlTextBox_TextChanged(object sender, EventArgs e)
{
changeTaskBtnStatus();
prepareToNewTask();
}
private void queryTextBox_TextChanged(object sender, EventArgs e)
private void nameQueryTextBox_TextChanged(object sender, EventArgs e)
{
changeTaskBtnStatus();
prepareToNewTask();
}
private void innerQueryTextBox_TextChanged(object sender, EventArgs e)
{
changeTaskBtnStatus();
prepareToNewTask();
}
private void changeTaskBtnStatus()
private void prepareToNewTask()
{
if (!isFieldsChanged)
{

Loading…
Cancel
Save