diff --git a/fileFinder/App.config b/fileFinder/App.config index 1260fc0..d4733c8 100644 --- a/fileFinder/App.config +++ b/fileFinder/App.config @@ -2,6 +2,7 @@ +
@@ -9,6 +10,17 @@ + + + C:\nextcloud\ + + + * + + + sh + + C:\nextcloud\ diff --git a/fileFinder/HintModel.cs b/fileFinder/HintModel.cs deleted file mode 100644 index 8374935..0000000 --- a/fileFinder/HintModel.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace fileFinder -{ - class HintModel - { - public HintModel () - { - isDirectoryHintActive = true; - isNameQueryHintActive = true; - isInnerQueryHintActive = true; - } - - public bool isDirectoryHintActive { get; set; } - public bool isNameQueryHintActive { get; set; } - public bool isInnerQueryHintActive { get; set; } - } -} diff --git a/fileFinder/MainForm.Designer.cs b/fileFinder/MainForm.Designer.cs index 840c860..a7745b4 100644 --- a/fileFinder/MainForm.Designer.cs +++ b/fileFinder/MainForm.Designer.cs @@ -31,11 +31,14 @@ 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.fileInnerQueryLabel = new System.Windows.Forms.Label(); + this.fileNameQueryLabel = new System.Windows.Forms.Label(); + this.fileUrlLabel = new System.Windows.Forms.Label(); 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(); @@ -61,19 +64,18 @@ this.dirSelectBtn.Name = "dirSelectBtn"; this.dirSelectBtn.Size = new System.Drawing.Size(120, 21); this.dirSelectBtn.TabIndex = 2; - this.dirSelectBtn.Text = "Select Directory"; + this.dirSelectBtn.Text = "Выбрать путь"; this.dirSelectBtn.UseVisualStyleBackColor = true; this.dirSelectBtn.Click += new System.EventHandler(this.dirSelectBtn_Click); // - // curDirTextBox + // fileUrlTextBox // - 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(151, 10); + this.fileUrlTextBox.Name = "fileUrlTextBox"; + this.fileUrlTextBox.Size = new System.Drawing.Size(511, 20); + this.fileUrlTextBox.TabIndex = 1; + this.fileUrlTextBox.Text = "C:\\Users\\itsmy_000\\Desktop\\a\\"; + this.fileUrlTextBox.TextChanged += new System.EventHandler(this.fileUrlTextBox_TextChanged); // // splitContainer // @@ -85,11 +87,14 @@ // // splitContainer.Panel1 // + this.splitContainer.Panel1.Controls.Add(this.fileInnerQueryLabel); + this.splitContainer.Panel1.Controls.Add(this.fileNameQueryLabel); + this.splitContainer.Panel1.Controls.Add(this.fileUrlLabel); 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 // @@ -100,34 +105,61 @@ this.splitContainer.SplitterDistance = 88; this.splitContainer.TabIndex = 4; // + // fileInnerQueryLabel + // + this.fileInnerQueryLabel.AutoSize = true; + this.fileInnerQueryLabel.Location = new System.Drawing.Point(12, 65); + this.fileInnerQueryLabel.Name = "fileInnerQueryLabel"; + this.fileInnerQueryLabel.Size = new System.Drawing.Size(133, 13); + this.fileInnerQueryLabel.TabIndex = 6; + this.fileInnerQueryLabel.Text = "Искомый текст в файле:"; + // + // fileNameQueryLabel + // + this.fileNameQueryLabel.AutoSize = true; + this.fileNameQueryLabel.Location = new System.Drawing.Point(12, 39); + this.fileNameQueryLabel.Name = "fileNameQueryLabel"; + this.fileNameQueryLabel.Size = new System.Drawing.Size(119, 13); + this.fileNameQueryLabel.TabIndex = 6; + this.fileNameQueryLabel.Text = "Шаблон имени файла:"; + // + // fileUrlLabel + // + this.fileUrlLabel.AutoSize = true; + this.fileUrlLabel.Location = new System.Drawing.Point(12, 13); + this.fileUrlLabel.Name = "fileUrlLabel"; + this.fileUrlLabel.Size = new System.Drawing.Size(76, 13); + this.fileUrlLabel.TabIndex = 6; + this.fileUrlLabel.Text = "Путь к папке:"; + // // handleSearchBtn // - this.handleSearchBtn.Location = new System.Drawing.Point(668, 62); + this.handleSearchBtn.Location = new System.Drawing.Point(668, 61); this.handleSearchBtn.Name = "handleSearchBtn"; this.handleSearchBtn.Size = new System.Drawing.Size(120, 21); this.handleSearchBtn.TabIndex = 5; - this.handleSearchBtn.Text = "Start Task"; + this.handleSearchBtn.Text = "Запустить поиск"; this.handleSearchBtn.UseVisualStyleBackColor = true; this.handleSearchBtn.Click += new System.EventHandler(this.handleSearchBtn_Click); // // innerQueryTextBox // - this.innerQueryTextBox.Location = new System.Drawing.Point(12, 62); + this.innerQueryTextBox.Location = new System.Drawing.Point(151, 62); this.innerQueryTextBox.Name = "innerQueryTextBox"; - this.innerQueryTextBox.Size = new System.Drawing.Size(650, 20); + this.innerQueryTextBox.Size = new System.Drawing.Size(511, 20); this.innerQueryTextBox.TabIndex = 4; this.innerQueryTextBox.Tag = ""; this.innerQueryTextBox.TextChanged += new System.EventHandler(this.innerQueryTextBox_TextChanged); // - // queryTextBox + // nameQueryTextBox // - 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(151, 36); + this.nameQueryTextBox.Name = "nameQueryTextBox"; + this.nameQueryTextBox.Size = new System.Drawing.Size(511, 20); + this.nameQueryTextBox.TabIndex = 3; + this.nameQueryTextBox.Tag = ""; + this.nameQueryTextBox.Text = "*.txt"; + this.nameQueryTextBox.TextChanged += new System.EventHandler(this.nameQueryTextBox_TextChanged); // // waitOrPauseLabel // @@ -156,9 +188,9 @@ this.infoLabel.AutoSize = true; this.infoLabel.Location = new System.Drawing.Point(0, 0); this.infoLabel.Name = "infoLabel"; - this.infoLabel.Size = new System.Drawing.Size(263, 13); + this.infoLabel.Size = new System.Drawing.Size(301, 13); this.infoLabel.TabIndex = 0; - this.infoLabel.Text = "Time: 00:00:00 | Processed files: 0 | Current item: none"; + this.infoLabel.Text = "Время: 00:00:00 | Кол-во файлов: 0/0/0 | Состояние: готов"; // // MainForm // @@ -188,14 +220,17 @@ 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; + private System.Windows.Forms.Label fileInnerQueryLabel; + private System.Windows.Forms.Label fileNameQueryLabel; + private System.Windows.Forms.Label fileUrlLabel; } } diff --git a/fileFinder/MainForm.cs b/fileFinder/MainForm.cs index a0fa060..72f8aaa 100644 --- a/fileFinder/MainForm.cs +++ b/fileFinder/MainForm.cs @@ -8,7 +8,6 @@ namespace fileFinder { public partial class MainForm : Form { - HintModel hints = new HintModel(); TaskController mainController = new TaskController(); SearchQueryModel searchQueryModel; System.Timers.Timer updateInfoTimer = new System.Timers.Timer(1000); @@ -26,10 +25,10 @@ namespace fileFinder private void restoreLastSession() { - MainSettings sets = MainSettings.Default; - curDirTextBox.Text = sets.fileUrl; + var sets = Properties.Settings.Default; + 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; @@ -40,10 +39,10 @@ namespace fileFinder try { ImageList iconList = new ImageList(); - iconList.Images.Add(Image.FromFile("Folder.png")); // 0 - iconList.Images.Add(Image.FromFile("OpenedFolder.png")); // 1 - iconList.Images.Add(Image.FromFile("File.png")); // 2 - iconList.Images.Add(Image.FromFile("Search.png")); // 3 + iconList.Images.Add(Properties.Resources.Folder); // 0 + iconList.Images.Add(Properties.Resources.OpenedFolder); // 1 + iconList.Images.Add(Properties.Resources.File); // 2 + iconList.Images.Add(Properties.Resources.Search); // 3 resultViewer.ImageList = iconList; resultViewer.ImageIndex = 3; resultViewer.SelectedImageIndex = 3; @@ -58,31 +57,21 @@ namespace fileFinder DialogResult result = dialog.ShowDialog(); if (result == DialogResult.OK && !String.IsNullOrWhiteSpace(dialog.SelectedPath)) { - curDirTextBox.Text = dialog.SelectedPath; - hints.isDirectoryHintActive = false; + fileUrlTextBox.Text = dialog.SelectedPath; } } } - - private void curDirTextBox_Enter(object sender, EventArgs e) - { - //if (hints.isDirectoryHintActive) - //{ - // hints.isDirectoryHintActive = false; - // curDirTextBox.Text = ""; - //} - } private void reportProgress(object sender, ProgressReportModel report) { switch (mainController.state) { - case TaskState.Work: - updateInfoLabel(report.currentFileUrl, report.progress); - break; case TaskState.Pause: updateResultViewer(report.currentTreeNode); break; + default: + updateInfoLabel(report.currentFileUrl, report); + break; } } @@ -91,6 +80,13 @@ namespace fileFinder Progress progress = new Progress(); progress.ProgressChanged += reportProgress; + if (fileUrlTextBox.Text.Equals("") || nameQueryTextBox.Text.Equals("") || innerQueryTextBox.Text.Equals("")) + { + MessageBox.Show("Вы не заполнили одно из полей. Проверьте все и повторно нажмите \"Запуск задания\"!", + "Сообщение"); + return; + } + if (isFieldsChanged) // если в форме изменился запрос mainController.stopTask(); // то принудительно завершаем задание isFieldsChanged = false; @@ -98,24 +94,24 @@ namespace fileFinder switch (mainController.state) { case TaskState.Created: - searchQueryModel = mainController.updateSearchQueryModel(curDirTextBox.Text, - queryTextBox.Text, innerQueryTextBox.Text); - handleSearchBtn.Text = "Pause Task"; + searchQueryModel = mainController.updateSearchQueryModel(fileUrlTextBox.Text, + nameQueryTextBox.Text, innerQueryTextBox.Text); + handleSearchBtn.Text = "Поставить на паузу"; mainController.beginTask(); changeVisibilityResultViewer(); TreeNode tN = await Task.Run(() => mainController.buildResultTree(searchQueryModel, progress)); if (tN != null) { updateResultViewer(tN); - handleSearchBtn.Text = "Start Task"; + handleSearchBtn.Text = "Запустить поиск"; } break; case TaskState.Work: - handleSearchBtn.Text = "Resume Task"; + handleSearchBtn.Text = "Продолжить"; mainController.pauseTask(); break; case TaskState.Pause: - handleSearchBtn.Text = "Pause Task"; + handleSearchBtn.Text = "Поставить на паузу"; mainController.resumeTask(); break; case TaskState.Finished: @@ -133,7 +129,7 @@ namespace fileFinder waitOrPauseLabel.Visible = true; resultViewer.Enabled = false; break; - case TaskState.Pause: // если задание на паузе, то показываем промеж. результат + case TaskState.Pause: // если задание на паузе, то показываем промеж. результат waitOrPauseLabel.Visible = false; resultViewer.Enabled = true; break; @@ -142,16 +138,17 @@ namespace fileFinder } } - public void updateInfoLabel (string fileUrl, int counter) + private void updateInfoLabel(string fileUrl, ProgressReportModel rpm) { TimeSpan tS = mainController.elapsedTime(); + string fileNumCounters = rpm.matchingFiles + "/" + rpm.processedFiles + "/" + rpm.totalNumOfFiles; string time = String.Format("{0:00}:{1:00}:{2:00}", tS.Hours, tS.Minutes, tS.Seconds); - infoLabel.Text = "Time: " + time + " " + "| Processed files: " + counter + - " | Current file: " + fileUrl; + infoLabel.Text = "Время: " + time + " " + "| Кол-во файлов: " + fileNumCounters + + " | Статус: " + fileUrl; } - public void updateResultViewer(TreeNode tN) + private void updateResultViewer(TreeNode tN) { if (tN != null) { @@ -160,13 +157,13 @@ namespace fileFinder } } - public void refreshInfoByTimer (object sender, ElapsedEventArgs e) + private void refreshInfoByTimer(object sender, ElapsedEventArgs e) { Action refresh = () => { TimeSpan tS = mainController.elapsedTime(); string time = String.Format("{0:00}:{1:00}:{2:00}", tS.Hours, tS.Minutes, tS.Seconds); - infoLabel.Text = "Time: " + time + " |" + + infoLabel.Text = "Время: " + time + " |" + infoLabel.Text.Substring(infoLabel.Text.IndexOf("|") + 1); }; try { this.Invoke(refresh); } catch { } @@ -174,33 +171,33 @@ namespace fileFinder private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { - MainSettings.Default.fileUrl = curDirTextBox.Text; - MainSettings.Default.fileNameQuery = queryTextBox.Text; - MainSettings.Default.fileInnerQuery = innerQueryTextBox.Text; - MainSettings.Default.Save(); + Properties.Settings.Default.fileUrl = fileUrlTextBox.Text; + Properties.Settings.Default.fileNameQuery = nameQueryTextBox.Text; + Properties.Settings.Default.fileInnerQuery = innerQueryTextBox.Text; + Properties.Settings.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) { isFieldsChanged = true; - handleSearchBtn.Text = "Start New Task"; + handleSearchBtn.Text = "Начать поиск"; } } } diff --git a/fileFinder/MainSettings.Designer.cs b/fileFinder/MainSettings.Designer.cs deleted file mode 100644 index 020f0e1..0000000 --- a/fileFinder/MainSettings.Designer.cs +++ /dev/null @@ -1,62 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Этот код создан программой. -// Исполняемая версия:4.0.30319.42000 -// -// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае -// повторной генерации кода. -// -//------------------------------------------------------------------------------ - -namespace fileFinder { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.8.0.0")] - internal sealed partial class MainSettings : global::System.Configuration.ApplicationSettingsBase { - - private static MainSettings defaultInstance = ((MainSettings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new MainSettings()))); - - public static MainSettings Default { - get { - return defaultInstance; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("C:\\nextcloud\\")] - public string fileUrl { - get { - return ((string)(this["fileUrl"])); - } - set { - this["fileUrl"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("*")] - public string fileNameQuery { - get { - return ((string)(this["fileNameQuery"])); - } - set { - this["fileNameQuery"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("sh")] - public string fileInnerQuery { - get { - return ((string)(this["fileInnerQuery"])); - } - set { - this["fileInnerQuery"] = value; - } - } - } -} diff --git a/fileFinder/MainSettings.cs b/fileFinder/MainSettings.cs deleted file mode 100644 index 88d1e7c..0000000 --- a/fileFinder/MainSettings.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace fileFinder { - - - // Этот класс позволяет обрабатывать определенные события в классе параметров: - // Событие SettingChanging возникает перед изменением значения параметра. - // Событие PropertyChanged возникает после изменения значения параметра. - // Событие SettingsLoaded возникает после загрузки значений параметров. - // Событие SettingsSaving возникает перед сохранением значений параметров. - internal sealed partial class MainSettings { - - public MainSettings() { - // // Для добавления обработчиков событий для сохранения и изменения параметров раскомментируйте приведенные ниже строки: - // - // this.SettingChanging += this.SettingChangingEventHandler; - // - // this.SettingsSaving += this.SettingsSavingEventHandler; - // - } - - private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) { - // Добавьте здесь код для обработки события SettingChangingEvent. - } - - private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) { - // Добавьте здесь код для обработки события SettingsSaving. - } - } -} diff --git a/fileFinder/MainSettings.settings b/fileFinder/MainSettings.settings deleted file mode 100644 index f9232cd..0000000 --- a/fileFinder/MainSettings.settings +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - C:\nextcloud\ - - - * - - - sh - - - \ No newline at end of file diff --git a/fileFinder/ProgressReportModel.cs b/fileFinder/ProgressReportModel.cs index b459a40..a36cbfa 100644 --- a/fileFinder/ProgressReportModel.cs +++ b/fileFinder/ProgressReportModel.cs @@ -4,7 +4,9 @@ namespace fileFinder { class ProgressReportModel { - public int progress { get; set; } + public int matchingFiles { get; set; } + public int processedFiles { get; set; } + public int totalNumOfFiles { get; set; } public string currentFileUrl { get; set; } public TreeNode currentTreeNode { get; set; } } diff --git a/fileFinder/Properties/Resources.Designer.cs b/fileFinder/Properties/Resources.Designer.cs index 5f07002..9779f1d 100644 --- a/fileFinder/Properties/Resources.Designer.cs +++ b/fileFinder/Properties/Resources.Designer.cs @@ -1,71 +1,103 @@ //------------------------------------------------------------------------------ // -// Этот код создан программным средством. -// Версия среды выполнения: 4.0.30319.42000 +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 // -// Изменения в этом файле могут привести к неправильному поведению и будут утрачены, если -// код создан повторно. +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. // //------------------------------------------------------------------------------ -namespace fileFinder.Properties -{ - - +namespace fileFinder.Properties { + using System; + + /// - /// Класс ресурсов со строгим типом для поиска локализованных строк и пр. + /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. /// - // Этот класс был автоматически создан при помощи StronglyTypedResourceBuilder - // класс с помощью таких средств, как ResGen или Visual Studio. - // Для добавления или удаления члена измените файл .ResX, а затем перезапустите ResGen - // с параметром /str или заново постройте свой VS-проект. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + // Этот класс создан автоматически классом StronglyTypedResourceBuilder + // с помощью такого средства, как ResGen или Visual Studio. + // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen + // с параметром /str или перестройте свой проект VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources - { - + internal class Resources { + private static global::System.Resources.ResourceManager resourceMan; - + private static global::System.Globalization.CultureInfo resourceCulture; - + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() - { + internal Resources() { } - + /// - /// Возврат кэшированного экземпляра ResourceManager, используемого этим классом. + /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager - { - get - { - if ((resourceMan == null)) - { + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("fileFinder.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; } } - + /// - /// Переопределяет свойство CurrentUICulture текущего потока для всех - /// подстановки ресурсов с помощью этого класса ресурсов со строгим типом. + /// Перезаписывает свойство CurrentUICulture текущего потока для всех + /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture - { - get - { + internal static global::System.Globalization.CultureInfo Culture { + get { return resourceCulture; } - set - { + set { resourceCulture = value; } } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap File { + get { + object obj = ResourceManager.GetObject("File", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Folder { + get { + object obj = ResourceManager.GetObject("Folder", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap OpenedFolder { + get { + object obj = ResourceManager.GetObject("OpenedFolder", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Search { + get { + object obj = ResourceManager.GetObject("Search", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } } } diff --git a/fileFinder/Properties/Resources.resx b/fileFinder/Properties/Resources.resx index af7dbeb..ca468e3 100644 --- a/fileFinder/Properties/Resources.resx +++ b/fileFinder/Properties/Resources.resx @@ -46,7 +46,7 @@ mimetype: application/x-microsoft.net.object.binary.base64 value : The object must be serialized with - : System.Serialization.Formatters.Binary.BinaryFormatter + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : and then encoded with base64 encoding. mimetype: application/x-microsoft.net.object.soap.base64 @@ -60,6 +60,7 @@ : and then encoded with base64 encoding. --> + @@ -68,9 +69,10 @@ - + + @@ -85,9 +87,10 @@ - + + @@ -109,9 +112,22 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\File.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Folder.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\OpenedFolder.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Search.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/fileFinder/Properties/Settings.Designer.cs b/fileFinder/Properties/Settings.Designer.cs index 560fc82..a7cc4c6 100644 --- a/fileFinder/Properties/Settings.Designer.cs +++ b/fileFinder/Properties/Settings.Designer.cs @@ -1,30 +1,62 @@ //------------------------------------------------------------------------------ // -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 // -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. // //------------------------------------------------------------------------------ -namespace fileFinder.Properties -{ - - +namespace fileFinder.Properties { + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.8.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { + + public static Settings Default { + get { return defaultInstance; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("C:\\nextcloud\\")] + public string fileUrl { + get { + return ((string)(this["fileUrl"])); + } + set { + this["fileUrl"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("*")] + public string fileNameQuery { + get { + return ((string)(this["fileNameQuery"])); + } + set { + this["fileNameQuery"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("sh")] + public string fileInnerQuery { + get { + return ((string)(this["fileInnerQuery"])); + } + set { + this["fileInnerQuery"] = value; + } + } } } diff --git a/fileFinder/Properties/Settings.settings b/fileFinder/Properties/Settings.settings index 3964565..d4c995d 100644 --- a/fileFinder/Properties/Settings.settings +++ b/fileFinder/Properties/Settings.settings @@ -1,7 +1,15 @@  - - - - - - + + + + + C:\nextcloud\ + + + * + + + sh + + + \ No newline at end of file diff --git a/fileFinder/Resources/File.png b/fileFinder/Resources/File.png new file mode 100644 index 0000000..34f6b38 Binary files /dev/null and b/fileFinder/Resources/File.png differ diff --git a/fileFinder/Resources/Folder.png b/fileFinder/Resources/Folder.png new file mode 100644 index 0000000..ada85c4 Binary files /dev/null and b/fileFinder/Resources/Folder.png differ diff --git a/fileFinder/Resources/OpenedFolder.png b/fileFinder/Resources/OpenedFolder.png new file mode 100644 index 0000000..adc99d5 Binary files /dev/null and b/fileFinder/Resources/OpenedFolder.png differ diff --git a/fileFinder/Resources/Search.png b/fileFinder/Resources/Search.png new file mode 100644 index 0000000..7a5ae62 Binary files /dev/null and b/fileFinder/Resources/Search.png differ diff --git a/fileFinder/TaskController.cs b/fileFinder/TaskController.cs index 22988ec..48a7b96 100644 --- a/fileFinder/TaskController.cs +++ b/fileFinder/TaskController.cs @@ -54,42 +54,51 @@ namespace fileFinder { TaskController controller = this; TreeNode itemsNode = new TreeNode(); - ProgressReportModel _report = new ProgressReportModel(); + report.Report(createReport(null, "Индексирование заданного пути", 0, 0, 0)); List foundFiles = getFileList(query.fileUrl, query.fileNameQuery); + report.Report(createReport(null, null, 0, 0, foundFiles.Count)); - int counter = 0; + int matchingFiles = 0, processedFiles = 0; foreach (string item in foundFiles) { switch (state) { case TaskState.Finished: return null; - case TaskState.Pause: - _report.progress = counter; - _report.currentFileUrl = item; - _report.currentTreeNode = (TreeNode)itemsNode.Clone(); - report.Report(_report); + case TaskState.Pause: + report.Report(createReport((TreeNode)itemsNode.Clone(), + item, matchingFiles, processedFiles, foundFiles.Count)); while (state == TaskState.Pause) Thread.Sleep(100); goto case TaskState.Work; case TaskState.Work: string[] fileLines = getFileContents(item); - _report.progress = counter; - _report.currentFileUrl = item; - report.Report(_report); - + report.Report(createReport(null, item, matchingFiles, processedFiles, foundFiles.Count)); if ((fileLines.Length > 0) && (isFileContainQuery(fileLines, query.fileInnerQuery))) { - counter++; await fillChildNode(itemsNode, item.Replace(query.fileUrl, "")); + matchingFiles++; } + processedFiles++; break; } } + report.Report(createReport(null, "none", matchingFiles, processedFiles, foundFiles.Count)); controller.stopTask(); return itemsNode; } + private ProgressReportModel createReport(TreeNode treeNode, string fileUrl, int matchingFiles, int processedFiles, int totalNumOfFiles) + { + ProgressReportModel prm = new ProgressReportModel(); + prm.currentTreeNode = treeNode; + prm.currentFileUrl = fileUrl; + prm.matchingFiles = matchingFiles; + prm.processedFiles = processedFiles; + prm.totalNumOfFiles = totalNumOfFiles; + return prm; + } + private List getFileList(string directory, string nameQuery) { diff --git a/fileFinder/fileFinder.csproj b/fileFinder/fileFinder.csproj index 015a164..e225be6 100644 --- a/fileFinder/fileFinder.csproj +++ b/fileFinder/fileFinder.csproj @@ -45,19 +45,12 @@ - Form MainForm.cs - - - True - True - MainSettings.settings - @@ -74,11 +67,8 @@ True Resources.resx + True - - SettingsSingleFileGenerator - MainSettings.Designer.cs - SettingsSingleFileGenerator Settings.Designer.cs @@ -92,5 +82,17 @@ + + + + + + + + + + + + \ No newline at end of file