Skip to content

Commit

Permalink
Merge pull request #1 from derco0n/testing
Browse files Browse the repository at this point in the history
merge 0.151 from testing to master
  • Loading branch information
derco0n authored Nov 27, 2018
2 parents b12a23d + 24417fd commit ea64b96
Show file tree
Hide file tree
Showing 40 changed files with 385 additions and 88 deletions.
8 changes: 6 additions & 2 deletions Co0nSearchC/CSearch.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<AutorunEnabled>true</AutorunEnabled>
<ApplicationRevision>4</ApplicationRevision>
<ApplicationVersion>0.1.4.4</ApplicationVersion>
<ApplicationRevision>1</ApplicationRevision>
<ApplicationVersion>0.1.5.1</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
Expand Down Expand Up @@ -106,6 +106,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="C_BaseDir.cs" />
<Compile Include="C_Settings.cs" />
<Compile Include="F_Main.cs">
<SubType>Form</SubType>
Expand All @@ -129,12 +130,15 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="F_About.resx">
<DependentUpon>F_About.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="F_Main.resx">
<DependentUpon>F_Main.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="F_Settings.resx">
<DependentUpon>F_Settings.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
Expand Down
79 changes: 79 additions & 0 deletions Co0nSearchC/C_BaseDir.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSearch
{
public class C_BaseDir:IComparable<C_BaseDir>
{
private String _Path;
private Boolean _IsEnabled;
public static String ENABLEDPREFIX = "SearchBaseDir";
public static String DISABLEDPREFIX = "DisabledSearchBaseDir";

public C_BaseDir(String Path, Boolean Enabled)
{
this._Path = Path;
this._IsEnabled = Enabled;

}

public String Path
{
get
{
return this._Path;
}
}

public Boolean IsEnabled
{
get
{
return this._IsEnabled;
}
}

/// <summary>
/// Enables a Basedir
/// </summary>
/// <param name="BaseDir"></param>
/// <returns>True if success</returns>
public bool Enable()
{
if (!this._IsEnabled)
{
this._IsEnabled = true;
return true;
}
return false;
}

/// <summary>
/// Disables a Basedir
/// </summary>
/// <param name="BaseDir"></param>
/// <returns>True if success</returns>
public bool Disable()
{
if (this._IsEnabled)
{
this._IsEnabled = false;
return true;
}
return false;
}

public override string ToString()
{
return this._Path;
}

public int CompareTo(C_BaseDir other)
{
return this._Path.CompareTo(other._Path);
}
}
}
76 changes: 61 additions & 15 deletions Co0nSearchC/C_Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Co0nUtilZ;
using Microsoft.Win32;

namespace Co0nSearchC
namespace CSearch
{
/// <summary>
/// Defines possible settings
Expand All @@ -16,8 +16,9 @@ public class C_Settings

#region variables
private C_RegistryHelper _regHelper;
private List<String> _baseDirs = new List<string>();
private String _BaseDirPrefix="SearchBaseDir";
private List<C_BaseDir> _baseDirs = new List<C_BaseDir>();
private String _EnabledBaseDirPrefix=C_BaseDir.ENABLEDPREFIX; //Prefix for Enabled folders
private String _DisabledBaseDirPrefix = C_BaseDir.DISABLEDPREFIX; //Prefix for Disabled folders
private String _Instancename = "Main";
#endregion

Expand All @@ -30,7 +31,7 @@ public C_Settings()

#region properties
//Returns a String-List of all BaseDirectories saved in RAM
public List<String> BaseDirs
public List<C_BaseDir> BaseDirs
{// Property BaseDirs
get
{
Expand All @@ -49,7 +50,7 @@ private void dropAllBaseDirs()

foreach (String res in result)
{
if (res.StartsWith(this._BaseDirPrefix)) // Wenn der gefundene Schlüssel mit dem gesuchten Präfix übereinstimmt.
if (res.StartsWith(this._EnabledBaseDirPrefix) || res.StartsWith(this._DisabledBaseDirPrefix)) // Wenn der gefundene Schlüssel mit dem gesuchten Präfix übereinstimmt.
{
this._regHelper.dropValue(this._Instancename, res);
}
Expand All @@ -62,7 +63,7 @@ private void dropAllBaseDirs()
/// </summary>
/// <param name="Value"></param>
/// <returns></returns>
public bool removeBaseDir(String Value) // Entfernt einen Basisordner ... muss anschließend noch mit "putAllBaseDirs()" geschrieben werden.
public bool removeBaseDir(C_BaseDir Value) // Entfernt einen Basisordner ... muss anschließend noch mit "putAllBaseDirs()" geschrieben werden.
{
try
{
Expand All @@ -87,8 +88,8 @@ public bool removeBaseDir(String Value) // Entfernt einen Basisordner ... muss a
/// Adds a new Path to the Basedirectories saved in RAM
/// </summary>
/// <param name="Value">Basedir-Path</param>
/// <returns></returns>
public bool AddBaseDir(String Value) // Fügt einen Basisordner hinzu ... muss anschließend noch mit "putAllBaseDirs()" geschrieben werden.
/// <returns>True on success</returns>
public bool AddBaseDir(C_BaseDir Value) // Fügt einen Basisordner hinzu ... muss anschließend noch mit "putAllBaseDirs()" geschrieben werden.
{
try
{
Expand Down Expand Up @@ -120,13 +121,20 @@ public void getAllBaseDirs()

foreach (String res in result)
{
if (res.StartsWith(this._BaseDirPrefix)) // Wenn der gefundene Schlüssel mit dem gesuchten Präfix übereinstimmt.
{
if (res.StartsWith(this._EnabledBaseDirPrefix)) // Wenn der gefundene Schlüssel mit dem gesuchten Präfix für aktivierte übereinstimmt.
{//Enabled Folders
String value = this._regHelper.ReadSettingFromRegistry(this._Instancename, res);
this._baseDirs.Add(new C_BaseDir(value, true));
}
else if (res.StartsWith(this._DisabledBaseDirPrefix)) // Wenn der gefundene Schlüssel mit dem gesuchten Präfix für deaktivierte Ordner übereinstimmt.
{//Disabled Folders
String value = this._regHelper.ReadSettingFromRegistry(this._Instancename, res);
this._baseDirs.Add(value);
this._baseDirs.Add(new C_BaseDir(value, false));
}
}

this._baseDirs.Sort(); //Sort results by their name

}

/// <summary>
Expand All @@ -141,15 +149,53 @@ public void putAllBaseDirs()
this.dropAllBaseDirs(); //... und dort löschen.

//Anschließend die aktuelle definierten, zwischengepseicherten in die Registry schreiben.
int counter=0;
foreach (String Value in this._baseDirs)
int counterenabled=0;
int counterdisabled = 0;
foreach (C_BaseDir Value in this._baseDirs)
//foreach (String Value in currentbasedirs)
{
this._regHelper.WriteSettingToRegistry(this._Instancename, this._BaseDirPrefix+counter.ToString(), Value);
counter++;
if (Value.IsEnabled)
{//Enabled folders
this._regHelper.WriteSettingToRegistry(this._Instancename, this._EnabledBaseDirPrefix + counterenabled.ToString(), Value.Path);
counterenabled++;
}
else if (!Value.IsEnabled)
{//Disabled folders
this._regHelper.WriteSettingToRegistry(this._Instancename, this._DisabledBaseDirPrefix + counterdisabled.ToString(), Value.Path);
counterdisabled++;
}
}
}

}

/// <summary>
/// Sets the Enabled/Disabled state of a specific item in RAM
/// </summary>
/// <param name="value"></param>
/// <param name="Enable"></param>
/// <returns></returns>
public bool setState(C_BaseDir value, Boolean Enable)
{
foreach (C_BaseDir bdir in this._baseDirs)
//foreach (String Value in currentbasedirs)
{
if (bdir.Equals(value))
{
if (Enable)
{
return bdir.Enable();
}
else
{
return bdir.Disable();
}
}

}


return false; //Item not found
}
#endregion

Expand Down
2 changes: 1 addition & 1 deletion Co0nSearchC/F_About.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Co0nSearchC/F_About.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Co0nSearchC
namespace CSearch
{
public partial class F_About : Form
{
Expand Down
2 changes: 1 addition & 1 deletion Co0nSearchC/F_Main.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 27 additions & 14 deletions Co0nSearchC/F_Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
using System.Threading;
using System.IO;
using System.Diagnostics;
using Co0nUtilZ;

namespace Co0nSearchC
namespace CSearch
{
public partial class F_Main : Form
{
Expand Down Expand Up @@ -258,9 +259,12 @@ private void intializeIndexers()
}
else
{
foreach (String BaseDir in this.settings.BaseDirs)
{ //Für jedes Basisverzeichnis einen Sucher initilisieren.
this.indexers.Add(new C_FilesIndexer(@BaseDir, this._showhiddenfiles));
foreach (C_BaseDir BaseDir in this.settings.BaseDirs)
{ //Für jedes aktive Basisverzeichnis einen Sucher initilisieren.
if (BaseDir.IsEnabled)
{
this.indexers.Add(new C_FilesIndexer(@BaseDir.Path, this._showhiddenfiles));
}
}

foreach (C_FilesIndexer indexer in this.indexers)
Expand Down Expand Up @@ -311,6 +315,16 @@ private void StopSeachers()
}
}

//Wait for SearchThreads to stop
foreach (C_FilesIndexer indexer in this.indexers)
{
if (indexer._SearchThread != null && indexer._SearchThread.ThreadState == System.Threading.ThreadState.Running)
{
indexer._SearchThread.Join();
}

}

}
}

Expand Down Expand Up @@ -345,6 +359,8 @@ private void beendenToolStripMenuItem_Click(object sender, EventArgs e)

private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{// Catches the Form closing Event to ask the user to really quit.

/* //Commented out, because it prevents Windows 10 from shutting down... :/ Thx Microsoft.
MessageBoxButtons buttons = MessageBoxButtons.YesNo;
DialogResult result;
Expand All @@ -358,6 +374,9 @@ private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
this.StopSeachers();
}
*/

this.StopSeachers();
}

private void suchordnerToolStripMenuItem_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -474,15 +493,7 @@ private void txtSearch_KeyDown(object sender, KeyEventArgs e)
//Enter pressed
this.StopSeachers();

//Wait for SearchThreads to stop
foreach (C_FilesIndexer indexer in this.indexers)
{
if (indexer._SearchThread != null && indexer._SearchThread.ThreadState == System.Threading.ThreadState.Running)
{
indexer._SearchThread.Join();
}

}


if (this.txtSearch.Text.Length >= 2)
{
Expand All @@ -499,7 +510,9 @@ private void changelogToolStripMenuItem_Click(object sender, EventArgs e)
{
String title = "Changelog:";
String msg = "";
msg+="Version 0.144 (20181123):\r\n=========================\r\n- Added:\r\n\t- Changelog\r\n- fixed Bugs:\r\n\t- Itemlist behind statusbar\r\n";
msg += "Version 0.151 (20181126):\r\n=========================\r\n- fixed Bugs:\r\n\t- Stopping searchers (e.g. when changing folders) and waiting for them to finish \r\n\r\n";
msg += "Version 0.150 (20181126):\r\n=========================\r\n- Added:\r\n\t- En-/Disabling of Searchdirectories\r\n- fixed Bugs:\r\n\t- Fixed wrong namespaces in source code\r\n\r\n";
msg += "Version 0.144 (20181123):\r\n=========================\r\n- Added:\r\n\t- Changelog\r\n- fixed Bugs:\r\n\t- Itemlist behind statusbar\r\n";
Form AboutForm = new F_About(msg, title);
AboutForm.ShowDialog();
}
Expand Down
Loading

0 comments on commit ea64b96

Please sign in to comment.