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

27
fileFinder/MainForm.cs

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

Loading…
Cancel
Save