diff --git a/.gitignore b/.gitignore
index 0d90f29..b5297f1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,4 +9,5 @@ Z.Lab/
*.userprefs
_ReSharper.*
*.ReSharper.user
-*.resharper.user
\ No newline at end of file
+*.resharper.user
+src/log.txt
diff --git a/README.md b/README.md
index 85f73e7..5804d6b 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,14 @@
+**Note:**
+Original [FindAndReplace project](https://github.com/zzzprojects/findandreplace) does not seem to be maintained anymore, so I've decided to forked and fix some bugs. Feel free to use it as you wish.
+
# What's Find and Replace (FNR)?
Find and Replace (FNR) is an open source tool to find and replace text in multiple files. It can quickly search through large numbers of files and also find the information using regular expressions specifying the form of what you want, instead of literal text.
+
+
Read more on our [Website](http://findandreplace.io/).
-[Download](http://findandreplace.io/download)
+[Download](https://github.com/Pr0metheus2/findandreplace/releases)
## Sponsors
diff --git a/src/BuildProject.bat b/src/BuildProject.bat
new file mode 100644
index 0000000..1893cd7
--- /dev/null
+++ b/src/BuildProject.bat
@@ -0,0 +1,32 @@
+@echo off
+setlocal
+
+set "SRC_DIR=%~dp0"
+set "BUILD_DIR=%SRC_DIR%FindAndReplace.App\bin\Release"
+set "PACKAGE_DIR=%SRC_DIR%release"
+set "MSBUILD=C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe"
+set "ILMERGE=C:\Program Files (x86)\Microsoft\ILMerge\ilmerge.exe"
+
+if not exist "%MSBUILD%" (
+ echo ERROR: MSBuild was not found at "%MSBUILD%".
+ exit /b 1
+)
+
+if not exist "%ILMERGE%" (
+ echo ERROR: ILMerge was not found at "%ILMERGE%".
+ exit /b 1
+)
+
+echo Building Release executable...
+"%MSBUILD%" "%SRC_DIR%FindAndReplace.sln" /t:Build /p:Configuration=Release /p:Platform="Mixed Platforms" /v:minimal
+if errorlevel 1 exit /b 1
+
+if not exist "%PACKAGE_DIR%" mkdir "%PACKAGE_DIR%"
+
+echo Creating one-file package...
+"%ILMERGE%" /ndebug /targetplatform:4 /out:"%PACKAGE_DIR%\fnr.exe" "%BUILD_DIR%\fnr.exe" "%BUILD_DIR%\FindAndReplace.dll" "%BUILD_DIR%\CommandLine.dll" "%BUILD_DIR%\EncodingTools.dll"
+if errorlevel 1 exit /b 1
+
+echo.
+echo Done: "%PACKAGE_DIR%\fnr.exe"
+endlocal
diff --git a/src/EncodingTools/EncodingTools.csproj b/src/EncodingTools/EncodingTools.csproj
index e6d51a9..0233f7e 100644
--- a/src/EncodingTools/EncodingTools.csproj
+++ b/src/EncodingTools/EncodingTools.csproj
@@ -10,7 +10,7 @@
Properties
EncodingTools
EncodingTools
- v4.5
+ v4.0
2.0
diff --git a/src/EncodingTools/StopWatch.cs b/src/EncodingTools/StopWatch.cs
index 86fc549..8cdc199 100644
--- a/src/EncodingTools/StopWatch.cs
+++ b/src/EncodingTools/StopWatch.cs
@@ -210,10 +210,12 @@ public static void PrintCollection(int? totalMilliseconds, StringBuilder sb)
line = key + ": " + secs + " secs, " + stopWatch.Milliseconds + " millisecs";
- decimal avgDuration = Math.Round((((decimal)stopWatch.Milliseconds) / stopWatch.StopCount), 1);
+ decimal avgDuration = stopWatch.StopCount == 0
+ ? 0
+ : Math.Round((((decimal)stopWatch.Milliseconds) / stopWatch.StopCount), 1);
line += ", " + stopWatch.StopCount + " stops, Avg Duration " + avgDuration + " millisecs";
- if (totalMilliseconds != null)
+ if (totalMilliseconds != null && totalMilliseconds.Value > 0)
{
percent = Math.Round((stopWatch.Milliseconds / (decimal)totalMilliseconds.Value) * 100, 1);
line += ", " + percent + "%";
diff --git a/src/FindAndReplace.App/AboutBox.Designer.cs b/src/FindAndReplace.App/AboutBox.Designer.cs
index deaac0f..efb9613 100644
--- a/src/FindAndReplace.App/AboutBox.Designer.cs
+++ b/src/FindAndReplace.App/AboutBox.Designer.cs
@@ -34,6 +34,8 @@ private void InitializeComponent()
this.lnkProduct = new System.Windows.Forms.LinkLabel();
this.uiSupportedBy = new System.Windows.Forms.LinkLabel();
this.label1 = new System.Windows.Forms.Label();
+ this.labelUpdates = new System.Windows.Forms.Label();
+ this.linkUpdates = new System.Windows.Forms.LinkLabel();
this.SuspendLayout();
//
// lblProductName
@@ -57,7 +59,7 @@ private void InitializeComponent()
// lblCopyright
//
this.lblCopyright.AutoSize = true;
- this.lblCopyright.Location = new System.Drawing.Point(22, 140);
+ this.lblCopyright.Location = new System.Drawing.Point(22, 130);
this.lblCopyright.Name = "lblCopyright";
this.lblCopyright.Size = new System.Drawing.Size(51, 13);
this.lblCopyright.TabIndex = 2;
@@ -66,7 +68,7 @@ private void InitializeComponent()
// lnkCompany
//
this.lnkCompany.AutoSize = true;
- this.lnkCompany.Location = new System.Drawing.Point(22, 160);
+ this.lnkCompany.Location = new System.Drawing.Point(124, 130);
this.lnkCompany.Name = "lnkCompany";
this.lnkCompany.Size = new System.Drawing.Size(51, 13);
this.lnkCompany.TabIndex = 3;
@@ -88,7 +90,7 @@ private void InitializeComponent()
// uiSupportedBy
//
this.uiSupportedBy.AutoSize = true;
- this.uiSupportedBy.Location = new System.Drawing.Point(22, 110);
+ this.uiSupportedBy.Location = new System.Drawing.Point(124, 90);
this.uiSupportedBy.Name = "uiSupportedBy";
this.uiSupportedBy.Size = new System.Drawing.Size(51, 13);
this.uiSupportedBy.TabIndex = 6;
@@ -101,15 +103,37 @@ private void InitializeComponent()
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(22, 90);
this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(71, 13);
+ this.label1.Size = new System.Drawing.Size(74, 13);
this.label1.TabIndex = 5;
- this.label1.Text = "Supported By";
+ this.label1.Text = "Supported By:";
+ //
+ // labelUpdates
+ //
+ this.labelUpdates.AutoSize = true;
+ this.labelUpdates.Location = new System.Drawing.Point(22, 110);
+ this.labelUpdates.Name = "labelUpdates";
+ this.labelUpdates.Size = new System.Drawing.Size(87, 13);
+ this.labelUpdates.TabIndex = 7;
+ this.labelUpdates.Text = "GitHub support:";
+ //
+ // linkUpdates
+ //
+ this.linkUpdates.AutoSize = true;
+ this.linkUpdates.Location = new System.Drawing.Point(124, 110);
+ this.linkUpdates.Name = "linkUpdates";
+ this.linkUpdates.Size = new System.Drawing.Size(59, 13);
+ this.linkUpdates.TabIndex = 8;
+ this.linkUpdates.TabStop = true;
+ this.linkUpdates.Text = "Repository";
+ this.linkUpdates.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkUpdates_LinkClicked);
//
// AboutBox
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(228, 191);
+ this.Controls.Add(this.linkUpdates);
+ this.Controls.Add(this.labelUpdates);
this.Controls.Add(this.uiSupportedBy);
this.Controls.Add(this.label1);
this.Controls.Add(this.lnkProduct);
@@ -140,5 +164,7 @@ private void InitializeComponent()
private System.Windows.Forms.LinkLabel lnkProduct;
private System.Windows.Forms.LinkLabel uiSupportedBy;
private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.Label labelUpdates;
+ private System.Windows.Forms.LinkLabel linkUpdates;
}
}
diff --git a/src/FindAndReplace.App/AboutBox.cs b/src/FindAndReplace.App/AboutBox.cs
index 793280c..251fc80 100644
--- a/src/FindAndReplace.App/AboutBox.cs
+++ b/src/FindAndReplace.App/AboutBox.cs
@@ -119,5 +119,10 @@ private void uiSupportedBy_LinkClicked(object sender, LinkLabelLinkClickedEventA
{
Process.Start("http://www.zzzprojects.com/");
}
+
+ private void linkUpdates_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
+ {
+ Process.Start("https://github.com/Pr0metheus2/findandreplace");
+ }
}
}
diff --git a/src/FindAndReplace.App/FindAndReplace.App.csproj b/src/FindAndReplace.App/FindAndReplace.App.csproj
index 70dc0a6..32ba63d 100644
--- a/src/FindAndReplace.App/FindAndReplace.App.csproj
+++ b/src/FindAndReplace.App/FindAndReplace.App.csproj
@@ -10,6 +10,7 @@
Properties
FindAndReplace.App
fnr
+ Resources\favicon.ico
v4.0
@@ -150,6 +151,7 @@
+
@@ -170,4 +172,4 @@
-->
-
\ No newline at end of file
+
diff --git a/src/FindAndReplace.App/MainForm.Designer.cs b/src/FindAndReplace.App/MainForm.Designer.cs
index db06540..e33f4f0 100644
--- a/src/FindAndReplace.App/MainForm.Designer.cs
+++ b/src/FindAndReplace.App/MainForm.Designer.cs
@@ -97,6 +97,8 @@ private void InitializeComponent()
this.label8 = new System.Windows.Forms.Label();
this.linkLabel1 = new System.Windows.Forms.LinkLabel();
this.label7 = new System.Windows.Forms.Label();
+ this.labelUpdates = new System.Windows.Forms.Label();
+ this.linkUpdates = new System.Windows.Forms.LinkLabel();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.pictureBox2 = new System.Windows.Forms.PictureBox();
((System.ComponentModel.ISupportInitialize)(this.errorProvider1)).BeginInit();
@@ -127,15 +129,13 @@ private void InitializeComponent()
//
// txtDir
//
- this.txtDir.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
+ this.txtDir.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.errorProvider1.SetIconPadding(this.txtDir, 30);
this.txtDir.Location = new System.Drawing.Point(79, 2);
this.txtDir.Margin = new System.Windows.Forms.Padding(0);
- this.txtDir.MinimumSize = new System.Drawing.Size(539, 20);
this.txtDir.Name = "txtDir";
- this.txtDir.Size = new System.Drawing.Size(539, 20);
+ this.txtDir.Size = new System.Drawing.Size(441, 20);
this.txtDir.TabIndex = 0;
this.txtDir.Validating += new System.ComponentModel.CancelEventHandler(this.txtDir_Validating);
//
@@ -162,7 +162,8 @@ private void InitializeComponent()
// chkIncludeFilesWithoutMatches
//
this.chkIncludeFilesWithoutMatches.AutoSize = true;
- this.chkIncludeFilesWithoutMatches.Location = new System.Drawing.Point(109, 49);
+ this.chkIncludeFilesWithoutMatches.Location = new System.Drawing.Point(150, 49);
+ this.chkIncludeFilesWithoutMatches.Margin = new System.Windows.Forms.Padding(44, 3, 3, 3);
this.chkIncludeFilesWithoutMatches.Name = "chkIncludeFilesWithoutMatches";
this.chkIncludeFilesWithoutMatches.Size = new System.Drawing.Size(162, 17);
this.chkIncludeFilesWithoutMatches.TabIndex = 5;
@@ -254,8 +255,7 @@ private void InitializeComponent()
//
// btnSelectDir
//
- this.btnSelectDir.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Right)));
+ this.btnSelectDir.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnSelectDir.CausesValidation = false;
this.btnSelectDir.Location = new System.Drawing.Point(526, 1);
this.btnSelectDir.Margin = new System.Windows.Forms.Padding(0, 0, 5, 0);
@@ -274,7 +274,7 @@ private void InitializeComponent()
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.label4.AutoSize = true;
- this.label4.Location = new System.Drawing.Point(8, 6);
+ this.label4.Location = new System.Drawing.Point(1, 6);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(23, 13);
this.label4.TabIndex = 2;
@@ -323,9 +323,9 @@ private void InitializeComponent()
//
this.lblStats.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Right)));
- this.lblStats.Location = new System.Drawing.Point(619, 9);
+ this.lblStats.Location = new System.Drawing.Point(619, 100);
this.lblStats.Name = "lblStats";
- this.lblStats.Size = new System.Drawing.Size(212, 187);
+ this.lblStats.Size = new System.Drawing.Size(212, 174);
this.lblStats.TabIndex = 51;
this.lblStats.Text = "Stats";
//
@@ -343,9 +343,9 @@ private void InitializeComponent()
this.panel5.Controls.Add(this.panel8);
this.panel5.Controls.Add(this.flowLayoutPanel1);
this.panel5.Controls.Add(this.label1);
- this.panel5.Location = new System.Drawing.Point(3, 40);
+ this.panel5.Location = new System.Drawing.Point(0, 40);
this.panel5.Name = "panel5";
- this.panel5.Size = new System.Drawing.Size(879, 284);
+ this.panel5.Size = new System.Drawing.Size(882, 284);
this.panel5.TabIndex = 2;
//
// pnlReplace
@@ -499,7 +499,8 @@ private void InitializeComponent()
// chkIsRegEx
//
this.chkIsRegEx.AutoSize = true;
- this.chkIsRegEx.Location = new System.Drawing.Point(103, 3);
+ this.chkIsRegEx.Location = new System.Drawing.Point(150, 3);
+ this.chkIsRegEx.Margin = new System.Windows.Forms.Padding(50, 3, 3, 3);
this.chkIsRegEx.Name = "chkIsRegEx";
this.chkIsRegEx.Size = new System.Drawing.Size(138, 17);
this.chkIsRegEx.TabIndex = 1;
@@ -529,7 +530,8 @@ private void InitializeComponent()
// lblEncoding
//
this.lblEncoding.AutoSize = true;
- this.lblEncoding.Location = new System.Drawing.Point(121, 69);
+ this.lblEncoding.Location = new System.Drawing.Point(150, 74);
+ this.lblEncoding.Margin = new System.Windows.Forms.Padding(32, 5, 3, 3);
this.lblEncoding.Name = "lblEncoding";
this.lblEncoding.Size = new System.Drawing.Size(55, 13);
this.lblEncoding.TabIndex = 7;
@@ -539,7 +541,7 @@ private void InitializeComponent()
//
this.cmbEncoding.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbEncoding.FormattingEnabled = true;
- this.cmbEncoding.Location = new System.Drawing.Point(182, 72);
+ this.cmbEncoding.Location = new System.Drawing.Point(211, 72);
this.cmbEncoding.Name = "cmbEncoding";
this.cmbEncoding.Size = new System.Drawing.Size(121, 21);
this.cmbEncoding.TabIndex = 8;
@@ -547,7 +549,7 @@ private void InitializeComponent()
// label1
//
this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(3, 7);
+ this.label1.Location = new System.Drawing.Point(1, 7);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(30, 13);
this.label1.TabIndex = 1;
@@ -604,7 +606,7 @@ private void InitializeComponent()
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.label5.AutoSize = true;
- this.label5.Location = new System.Drawing.Point(3, 6);
+ this.label5.Location = new System.Drawing.Point(1, 6);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(55, 13);
this.label5.TabIndex = 1;
@@ -666,7 +668,7 @@ private void InitializeComponent()
// lblResults
//
this.lblResults.AutoSize = true;
- this.lblResults.Location = new System.Drawing.Point(2, 4);
+ this.lblResults.Location = new System.Drawing.Point(-1, 4);
this.lblResults.Name = "lblResults";
this.lblResults.Size = new System.Drawing.Size(45, 13);
this.lblResults.TabIndex = 52;
@@ -825,13 +827,39 @@ private void InitializeComponent()
//
this.label7.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Right)));
- this.label7.AutoSize = true;
+ this.label7.AutoSize = false;
this.label7.Location = new System.Drawing.Point(664, 104);
this.label7.MaximumSize = new System.Drawing.Size(74, 13);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(74, 13);
this.label7.TabIndex = 84;
this.label7.Text = "Supported By:";
+ this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
+ //
+ // labelUpdates
+ //
+ this.labelUpdates.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.labelUpdates.AutoSize = false;
+ this.labelUpdates.Location = new System.Drawing.Point(664, 123);
+ this.labelUpdates.Name = "labelUpdates";
+ this.labelUpdates.Size = new System.Drawing.Size(74, 13);
+ this.labelUpdates.TabIndex = 90;
+ this.labelUpdates.Text = "Updates:";
+ this.labelUpdates.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
+ //
+ // linkUpdates
+ //
+ this.linkUpdates.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.linkUpdates.AutoSize = true;
+ this.linkUpdates.Location = new System.Drawing.Point(744, 123);
+ this.linkUpdates.Name = "linkUpdates";
+ this.linkUpdates.Size = new System.Drawing.Size(89, 13);
+ this.linkUpdates.TabIndex = 91;
+ this.linkUpdates.TabStop = true;
+ this.linkUpdates.Text = "GitHub Releases";
+ this.linkUpdates.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkUpdates_LinkClicked);
//
// pictureBox1
//
@@ -869,6 +897,8 @@ private void InitializeComponent()
this.AutoValidate = System.Windows.Forms.AutoValidate.Disable;
this.ClientSize = new System.Drawing.Size(884, 651);
this.Controls.Add(this.pictureBox2);
+ this.Controls.Add(this.linkUpdates);
+ this.Controls.Add(this.labelUpdates);
this.Controls.Add(this.label8);
this.Controls.Add(this.linkLabel1);
this.Controls.Add(this.label7);
@@ -976,6 +1006,8 @@ private void InitializeComponent()
private System.Windows.Forms.Label label8;
private System.Windows.Forms.LinkLabel linkLabel1;
private System.Windows.Forms.Label label7;
+ private System.Windows.Forms.Label labelUpdates;
+ private System.Windows.Forms.LinkLabel linkUpdates;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.TextBox txtExcludeFileMask;
private System.Windows.Forms.Label label3;
diff --git a/src/FindAndReplace.App/MainForm.cs b/src/FindAndReplace.App/MainForm.cs
index 0c5dca0..db1b712 100644
--- a/src/FindAndReplace.App/MainForm.cs
+++ b/src/FindAndReplace.App/MainForm.cs
@@ -8,6 +8,7 @@
using System.Threading;
using System.Windows.Forms;
using System.Linq;
+using FindAndReplace;
namespace FindAndReplace.App
@@ -1077,6 +1078,11 @@ private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs
Process.Start("http://www.zzzprojects.com/");
}
+ private void linkUpdates_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
+ {
+ Process.Start("https://github.com/Pr0metheus2/findandreplace/releases");
+ }
+
private void pictureBox2_Click(object sender, EventArgs e)
{
Process.Start("http://www.zzzprojects.com/contribute");
diff --git a/src/FindAndReplace.App/Program.cs b/src/FindAndReplace.App/Program.cs
index 53832bb..c5db09e 100644
--- a/src/FindAndReplace.App/Program.cs
+++ b/src/FindAndReplace.App/Program.cs
@@ -8,6 +8,7 @@
using System.Text;
using System.Windows.Forms;
using CommandLine;
+using FindAndReplace;
diff --git a/src/FindAndReplace.App/Properties/AssemblyInfo.cs b/src/FindAndReplace.App/Properties/AssemblyInfo.cs
index 1eb1b16..4c0b9c6 100644
--- a/src/FindAndReplace.App/Properties/AssemblyInfo.cs
+++ b/src/FindAndReplace.App/Properties/AssemblyInfo.cs
@@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.8.1")]
-[assembly: AssemblyFileVersion("1.8.1")]
+[assembly: AssemblyVersion("1.8.4")]
+[assembly: AssemblyFileVersion("1.8.4")]
diff --git a/src/FindAndReplace.App/Resources/Create Multi-resolution icon.py b/src/FindAndReplace.App/Resources/Create Multi-resolution icon.py
new file mode 100644
index 0000000..6a540bb
--- /dev/null
+++ b/src/FindAndReplace.App/Resources/Create Multi-resolution icon.py
@@ -0,0 +1,10 @@
+from PIL import Image
+
+# Open the source PNG
+img = Image.open("logo256X256.png").convert("RGBA")
+
+# Define standard Windows icon resolutions
+icon_sizes = [(16, 16), (32, 32), (48, 48), (64, 64), (128, 128), (256, 256)]
+
+# Save as multi-resolution ICO
+img.save("favicon.ico", format="ICO", sizes=icon_sizes)
\ No newline at end of file
diff --git a/src/FindAndReplace.App/Resources/favicon.ico b/src/FindAndReplace.App/Resources/favicon.ico
new file mode 100644
index 0000000..8bf1b1f
Binary files /dev/null and b/src/FindAndReplace.App/Resources/favicon.ico differ
diff --git a/src/FindAndReplace.App/Resources/logo256X256.png b/src/FindAndReplace.App/Resources/logo256X256.png
new file mode 100644
index 0000000..e133f6d
Binary files /dev/null and b/src/FindAndReplace.App/Resources/logo256X256.png differ
diff --git a/src/FindAndReplace.Tests/DetectEncodingSpeedTest.cs b/src/FindAndReplace.Tests/DetectEncodingSpeedTest.cs
index 686099c..b5c9111 100644
--- a/src/FindAndReplace.Tests/DetectEncodingSpeedTest.cs
+++ b/src/FindAndReplace.Tests/DetectEncodingSpeedTest.cs
@@ -50,16 +50,11 @@ protected void DeleteTestDir()
protected void CreateSpeedDir()
{
- speedDir = "D:\\Temp\\FindAndReplaceTest2" + "\\Speed";
+ speedDir = Path.Combine(_tempDir, "Speed");
if (Directory.Exists(speedDir))
-
- {
- speedDir = "D:\\Temp\\FindAndReplaceTest2" + "\\Speed";
+ Directory.Delete(speedDir, true);
- if (Directory.Exists(speedDir))
- Directory.Delete(speedDir, true);
- }
if (Directory.Exists(speedDir))
throw new InvalidOperationException("Dir '" + speedDir + "' already exists.");
@@ -68,7 +63,7 @@ protected void CreateSpeedDir()
protected void DeleteSpeedDir()
{
- speedDir = "D:\\Temp\\FindAndReplaceTest2" + "\\Speed";
+ speedDir = Path.Combine(_tempDir, "Speed");
if (Directory.Exists(speedDir))
Directory.Delete(speedDir, true);
@@ -143,7 +138,7 @@ public void KlerkSoft_Bom_And_MLang_Real_Dir()
[Test]
public void MLang_Real_Dir_MultiThreaded()
{
- string filePath = "D:\\Temp\\FindAndReplaceTest3";
+ string filePath = Path.Combine(_tempDir, "MultiThreaded");
//http://msdn.microsoft.com/en-us/library/aa767865(v=vs.85).aspx
//http://www.dotnetframework.org/default.aspx/Dotnetfx_Vista_SP2/Dotnetfx_Vista_SP2/8@0@50727@4016/DEVDIV/depot/DevDiv/releases/whidbey/NetFxQFE/ndp/clr/src/BCL/System/Text/MLangCodePageEncoding@cs/1/MLangCodePageEncoding@cs
@@ -332,13 +327,10 @@ private void DetectEncodingAsyncAction(int taskIndex)
private void DetectEncodingSyncAction(DetectEncodingFileDto dto)
{
- string stopWatchKey = "DetectEncodingSyncAction_" + Thread.CurrentThread.ManagedThreadId;
- StopWatch.Start(stopWatchKey);
-
//First try BOM detection and Unicode detection using Klerks Soft encoder
//stream.Seek(0, SeekOrigin.Begin);
- Encoding encoding = EncodingDetector.Detect(dto.SampleBytes, EncodingDetector.Options.MLang);
+ Encoding encoding = EncodingDetector.Detect(dto.SampleBytes, EncodingDetector.Options.MLang, null, false);
//Encoding encoding = null;
//Encoding[] detected;
@@ -367,7 +359,6 @@ private void DetectEncodingSyncAction(DetectEncodingFileDto dto)
//WriteToConsole(dto.FilePath + ": " + encoding);
- StopWatch.Stop(stopWatchKey);
}
diff --git a/src/FindAndReplace/EncodingDetector.cs b/src/FindAndReplace/EncodingDetector.cs
index 2852975..61ee7f5 100644
--- a/src/FindAndReplace/EncodingDetector.cs
+++ b/src/FindAndReplace/EncodingDetector.cs
@@ -18,17 +18,19 @@ public enum Options
MLang = 4
}
- public static Encoding Detect(byte[] bytes, EncodingDetector.Options opts = Options.KlerkSoftBom | Options.MLang, Encoding defaultEncoding = null)
+ public static Encoding Detect(byte[] bytes, EncodingDetector.Options opts = Options.KlerkSoftBom | Options.MLang | Options.KlerkSoftHeuristics, Encoding defaultEncoding = null, bool collectStopwatchData = true)
{
Encoding encoding = null;
if ((opts & Options.KlerkSoftBom) == Options.KlerkSoftBom)
{
- StopWatch.Start("DetectEncoding: UsingKlerksSoftBom");
+ if (collectStopwatchData)
+ StopWatch.Start("DetectEncoding: UsingKlerksSoftBom");
encoding = DetectEncodingUsingKlerksSoftBom(bytes);
- StopWatch.Stop("DetectEncoding: UsingKlerksSoftBom");
+ if (collectStopwatchData)
+ StopWatch.Stop("DetectEncoding: UsingKlerksSoftBom");
}
if (encoding != null)
@@ -36,9 +38,11 @@ public static Encoding Detect(byte[] bytes, EncodingDetector.Options opts = Opti
if ((opts & Options.KlerkSoftHeuristics) == Options.KlerkSoftHeuristics)
{
- StopWatch.Start("DetectEncoding: UsingKlerksSoftHeuristics");
+ if (collectStopwatchData)
+ StopWatch.Start("DetectEncoding: UsingKlerksSoftHeuristics");
encoding = DetectEncodingUsingKlerksSoftHeuristics(bytes);
- StopWatch.Stop("DetectEncoding: UsingKlerksSoftHeuristics");
+ if (collectStopwatchData)
+ StopWatch.Stop("DetectEncoding: UsingKlerksSoftHeuristics");
}
if (encoding != null)
@@ -46,9 +50,11 @@ public static Encoding Detect(byte[] bytes, EncodingDetector.Options opts = Opti
if ((opts & Options.MLang) == Options.MLang)
{
- StopWatch.Start("DetectEncoding: UsingMLang");
+ if (collectStopwatchData)
+ StopWatch.Start("DetectEncoding: UsingMLang");
encoding = DetectEncodingUsingMLang(bytes);
- StopWatch.Stop("DetectEncoding: UsingMLang");
+ if (collectStopwatchData)
+ StopWatch.Stop("DetectEncoding: UsingMLang");
}
if (encoding == null)
diff --git a/src/MakeOneExe.bat b/src/MakeOneExe.bat
deleted file mode 100644
index 7ffca4a..0000000
--- a/src/MakeOneExe.bat
+++ /dev/null
@@ -1,7 +0,0 @@
-REM Requires ILMerge from http://www.microsoft.com/download/en/confirmation.aspx?id=17630
-REM makes fnr2.exe that includes fnr.exe and both assemblies. Can be renamed to fnr.exe
-
-set RELEASE_DIR=C:\Users\Jonathan\Desktop\Z\GitHub\findandreplace\src\FindAndReplace.App\bin\Release
-
-cd %RELEASE_DIR%
-"C:\Program Files (x86)\Microsoft\ILMerge\ilmerge.exe" /log:log.txt /targetplatform:4 /out:fnr2.exe fnr.exe FindAndReplace.dll CommandLine.dll EncodingTools.dll
\ No newline at end of file
diff --git a/src/log.txt b/src/log.txt
deleted file mode 100644
index eef266b..0000000
--- a/src/log.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-ILMerge version 2.12.803.0
-Copyright (C) Microsoft Corporation 2004-2006. All rights reserved.
-ILMerge /log:log.txt /targetplatform:4 /out:fnr2.exe fnr.exe FindAndReplace.dll CommandLine.dll EncodingTools.dll
-Set platform to '4', using directory 'C:\Windows\Microsoft.NET\Framework64\v2.0.50727\..\v4.0.30319' for mscorlib.dll
-Running on Microsoft (R) .NET Framework v2.0.50727
-mscorlib.dll version = 2.0.0.0
-The list of input assemblies is:
- fnr.exe
- FindAndReplace.dll
- CommandLine.dll
- EncodingTools.dll
-Could not find the file 'fnr.exe'.
-An exception occurred during merging:
-ILMerge.Merge: Could not find the file 'fnr.exe'.
- at ILMerging.ILMerge.Merge()
- at ILMerging.ILMerge.Main(String[] args)
diff --git a/src/release/fnr.exe b/src/release/fnr.exe
new file mode 100644
index 0000000..78ab42e
Binary files /dev/null and b/src/release/fnr.exe differ