Browse Source

Merged in master (pull request #1)

Release 1.0.0
release release_1.0.0
  1. 12
      fileFinder/App.config
  2. 22
      fileFinder/HintModel.cs
  3. 93
      fileFinder/MainForm.Designer.cs
  4. 89
      fileFinder/MainForm.cs
  5. 62
      fileFinder/MainSettings.Designer.cs
  6. 28
      fileFinder/MainSettings.cs
  7. 15
      fileFinder/MainSettings.settings
  8. 4
      fileFinder/ProgressReportModel.cs
  9. 108
      fileFinder/Properties/Resources.Designer.cs
  10. 26
      fileFinder/Properties/Resources.resx
  11. 66
      fileFinder/Properties/Settings.Designer.cs
  12. 20
      fileFinder/Properties/Settings.settings
  13. BIN
      fileFinder/Resources/File.png
  14. BIN
      fileFinder/Resources/Folder.png
  15. BIN
      fileFinder/Resources/OpenedFolder.png
  16. BIN
      fileFinder/Resources/Search.png
  17. 33
      fileFinder/TaskController.cs
  18. 24
      fileFinder/fileFinder.csproj

12
fileFinder/App.config

@ -2,6 +2,7 @@
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="fileFinder.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="fileFinder.MainSettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
@ -9,6 +10,17 @@
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<userSettings>
<fileFinder.Properties.Settings>
<setting name="fileUrl" serializeAs="String">
<value>C:\nextcloud\</value>
</setting>
<setting name="fileNameQuery" serializeAs="String">
<value>*</value>
</setting>
<setting name="fileInnerQuery" serializeAs="String">
<value>sh</value>
</setting>
</fileFinder.Properties.Settings>
<fileFinder.MainSettings>
<setting name="fileUrl" serializeAs="String">
<value>C:\nextcloud\</value>

22
fileFinder/HintModel.cs

@ -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; }
}
}

93
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;
}
}

89
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<ProgressReportModel> progress = new Progress<ProgressReportModel>();
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 = "Начать поиск";
}
}
}

62
fileFinder/MainSettings.Designer.cs

@ -1,62 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
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;
}
}
}
}

28
fileFinder/MainSettings.cs

@ -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.
}
}
}

15
fileFinder/MainSettings.settings

@ -1,15 +0,0 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="fileFinder" GeneratedClassName="MainSettings">
<Profiles />
<Settings>
<Setting Name="fileUrl" Type="System.String" Scope="User">
<Value Profile="(Default)">C:\nextcloud\</Value>
</Setting>
<Setting Name="fileNameQuery" Type="System.String" Scope="User">
<Value Profile="(Default)">*</Value>
</Setting>
<Setting Name="fileInnerQuery" Type="System.String" Scope="User">
<Value Profile="(Default)">sh</Value>
</Setting>
</Settings>
</SettingsFile>

4
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; }
}

108
fileFinder/Properties/Resources.Designer.cs

@ -1,71 +1,103 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программным средством.
// Версия среды выполнения: 4.0.30319.42000
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильному поведению и будут утрачены, если
// код создан повторно.
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
namespace fileFinder.Properties
{
namespace fileFinder.Properties {
using System;
/// <summary>
/// Класс ресурсов со строгим типом для поиска локализованных строк и пр.
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
/// </summary>
// Этот класс был автоматически создан при помощи 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() {
}
/// <summary>
/// Возврат кэшированного экземпляра ResourceManager, используемого этим классом.
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
/// </summary>
[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;
}
}
/// <summary>
/// Переопределяет свойство CurrentUICulture текущего потока для всех
/// подстановки ресурсов с помощью этого класса ресурсов со строгим типом.
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
/// </summary>
[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;
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap File {
get {
object obj = ResourceManager.GetObject("File", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap Folder {
get {
object obj = ResourceManager.GetObject("Folder", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap OpenedFolder {
get {
object obj = ResourceManager.GetObject("OpenedFolder", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap Search {
get {
object obj = ResourceManager.GetObject("Search", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

26
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.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
@ -68,9 +69,10 @@
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
@ -85,9 +87,10 @@
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
@ -109,9 +112,22 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="File" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\File.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Folder" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Folder.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="OpenedFolder" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\OpenedFolder.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Search" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Search.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

66
fileFinder/Properties/Settings.Designer.cs

@ -1,30 +1,62 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
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;
}
}
}
}

20
fileFinder/Properties/Settings.settings

@ -1,7 +1,15 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="fileFinder.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="fileUrl" Type="System.String" Scope="User">
<Value Profile="(Default)">C:\nextcloud\</Value>
</Setting>
<Setting Name="fileNameQuery" Type="System.String" Scope="User">
<Value Profile="(Default)">*</Value>
</Setting>
<Setting Name="fileInnerQuery" Type="System.String" Scope="User">
<Value Profile="(Default)">sh</Value>
</Setting>
</Settings>
</SettingsFile>

BIN
fileFinder/Resources/File.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 596 B

BIN
fileFinder/Resources/Folder.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 476 B

BIN
fileFinder/Resources/OpenedFolder.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 647 B

BIN
fileFinder/Resources/Search.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 700 B

33
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<string> 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<string> getFileList(string directory, string nameQuery)
{

24
fileFinder/fileFinder.csproj

@ -45,19 +45,12 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="HintModel.cs" />
<Compile Include="MainForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MainForm.Designer.cs">
<DependentUpon>MainForm.cs</DependentUpon>
</Compile>
<Compile Include="MainSettings.cs" />
<Compile Include="MainSettings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>MainSettings.settings</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="ProgressReportModel.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
@ -74,11 +67,8 @@
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="MainSettings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>MainSettings.Designer.cs</LastGenOutput>
</None>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
@ -92,5 +82,17 @@
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\File.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\Folder.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\OpenedFolder.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\Search.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Loading…
Cancel
Save