Browse Source

Добавлен набор файлов для хранения последнего задания пользователя (MainSettings). Добавлен метод MainForm_FormClosing для сохранения конфига.

release
Никита 6 years ago
parent
commit
45c6a79c4a
  1. 18
      fileFinder/App.config
  2. 22
      fileFinder/HintModel.cs
  3. 1
      fileFinder/MainForm.Designer.cs
  4. 27
      fileFinder/MainForm.cs
  5. 62
      fileFinder/MainSettings.Designer.cs
  6. 28
      fileFinder/MainSettings.cs
  7. 15
      fileFinder/MainSettings.settings
  8. 11
      fileFinder/fileFinder.csproj

18
fileFinder/App.config

@ -1,6 +1,24 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="fileFinder.MainSettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<userSettings>
<fileFinder.MainSettings>
<setting name="urlDirectory" 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.MainSettings>
</userSettings>
</configuration>

22
fileFinder/HintModel.cs

@ -0,0 +1,22 @@
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; }
}
}

1
fileFinder/MainForm.Designer.cs

@ -168,6 +168,7 @@
this.MaximizeBox = false;
this.Name = "MainForm";
this.Text = "fileFinder";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);
this.splitContainer.Panel1.ResumeLayout(false);
this.splitContainer.Panel1.PerformLayout();
this.splitContainer.Panel2.ResumeLayout(false);

27
fileFinder/MainForm.cs

@ -15,7 +15,7 @@ namespace fileFinder
{
public partial class MainForm : Form
{
bool hintHided = false;
HintModel hints = new HintModel();
TaskController mainController;
System.Timers.Timer updateInfoTimer = new System.Timers.Timer(1000);
@ -37,7 +37,6 @@ namespace fileFinder
resultViewer.ImageIndex = 3;
resultViewer.SelectedImageIndex = 3;
} catch { }
}
private void dirSelectBtn_Click(object sender, EventArgs e)
@ -48,28 +47,28 @@ namespace fileFinder
if (result == DialogResult.OK && !String.IsNullOrWhiteSpace(dialog.SelectedPath))
{
curDirTextBox.Text = dialog.SelectedPath;
hintHided = true;
hints.isDirectoryHintActive = false;
}
}
}
private void curDirTextBox_Enter(object sender, EventArgs e)
{
if (!hintHided)
{
hintHided = true;
curDirTextBox.Text = "";
}
//if (hints.isDirectoryHintActive)
//{
// hints.isDirectoryHintActive = false;
// curDirTextBox.Text = "";
//}
}
private async Task<TreeNode> buildResultTree(TaskController controller, IProgress<ProgressReportModel> report)
{
TreeNode itemsNode = new TreeNode();
ProgressReportModel _report = new ProgressReportModel();
List<String> foundFiles = getFileList(curDirTextBox.Text, queryTextBox.Text);
List<string> foundFiles = getFileList(curDirTextBox.Text, queryTextBox.Text);
int counter = 0;
foreach (String item in foundFiles)
foreach (string item in foundFiles)
{
while (controller.isPaused)
{
@ -228,5 +227,13 @@ namespace fileFinder
};
try { this.Invoke(refresh); } catch { }
}
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
MainSettings.Default.urlDirectory = curDirTextBox.Text;
MainSettings.Default.fileNameQuery = queryTextBox.Text;
MainSettings.Default.fileInnerQuery = innerQueryTextBox.Text;
MainSettings.Default.Save();
}
}
}

62
fileFinder/MainSettings.Designer.cs

@ -0,0 +1,62 @@
//------------------------------------------------------------------------------
// <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 urlDirectory {
get {
return ((string)(this["urlDirectory"]));
}
set {
this["urlDirectory"] = 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

@ -0,0 +1,28 @@
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

@ -0,0 +1,15 @@
<?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="urlDirectory" 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>

11
fileFinder/fileFinder.csproj

@ -45,12 +45,19 @@
<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" />
@ -67,6 +74,10 @@
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</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>

Loading…
Cancel
Save