diff --git a/src/EncodingTools/EncodingTools.cs b/src/EncodingTools/EncodingTools.cs index 86ecdeb..f768995 100644 --- a/src/EncodingTools/EncodingTools.cs +++ b/src/EncodingTools/EncodingTools.cs @@ -6,7 +6,7 @@ using System.Threading; using FindAndReplace; -namespace href.Utils +namespace FindAndReplace { public static class EncodingTools { diff --git a/src/EncodingTools/EncodingTools.csproj b/src/EncodingTools/EncodingTools.csproj index e6d51a9..41ce2ea 100644 --- a/src/EncodingTools/EncodingTools.csproj +++ b/src/EncodingTools/EncodingTools.csproj @@ -1,5 +1,5 @@  - + Debug AnyCPU @@ -10,7 +10,7 @@ Properties EncodingTools EncodingTools - v4.5 + v4.8 2.0 diff --git a/src/FindAndReplace.App/FindAndReplace.App.csproj b/src/FindAndReplace.App/FindAndReplace.App.csproj index 70dc0a6..18e8cd2 100644 --- a/src/FindAndReplace.App/FindAndReplace.App.csproj +++ b/src/FindAndReplace.App/FindAndReplace.App.csproj @@ -1,5 +1,5 @@  - + Debug x86 @@ -10,7 +10,7 @@ Properties FindAndReplace.App fnr - v4.0 + v4.8 512 @@ -142,13 +142,6 @@ true - - - {4E35E2C7-099B-4356-9215-0DC77D156CFA} - FindAndReplace - True - - @@ -158,6 +151,16 @@ + + + {ca19d4de-b232-491a-92bf-7bf3a2758694} + EncodingTools + + + {4e35e2c7-099b-4356-9215-0dc77d156cfa} + FindAndReplace + + diff --git a/src/FindAndReplace.App/MainForm.cs b/src/FindAndReplace.App/MainForm.cs index 0c5dca0..99109c0 100644 --- a/src/FindAndReplace.App/MainForm.cs +++ b/src/FindAndReplace.App/MainForm.cs @@ -189,19 +189,27 @@ private void ShowFindResult(Finder.FindResultItem findResultItem, Stats stats, S if (findResultItem.IsSuccess && findResultItem.NumMatches > 0) //Account for errors and IncludeFilesWithoutMatches { - string fileContent = string.Empty; - - using (var sr = new StreamReader(findResultItem.FilePath, findResultItem.FileEncoding)) + if (Path.GetExtension(findResultItem.FilePath).Equals(".pdf", StringComparison.OrdinalIgnoreCase)) { - fileContent = sr.ReadToEnd(); + string lineSeparator = ("\r\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r\n"); + gvResults.Rows[currentRow].Cells[columnIndex].Value = string.Join(lineSeparator, findResultItem.Matches.Select(x => x.PreviewText)); } + else + { + string fileContent = string.Empty; + using (var sr = new StreamReader(findResultItem.FilePath, findResultItem.FileEncoding)) + { + fileContent = sr.ReadToEnd(); + } - List lineNumbers = Utils.GetLineNumbersForMatchesPreview(fileContent, - findResultItem.Matches); - gvResults.Rows[currentRow].Cells[columnIndex].Value = GenerateMatchesPreviewText(fileContent, - lineNumbers.Select( - ln => ln.LineNumber).ToList()); + + List lineNumbers = Utils.GetLineNumbersForMatchesPreview(fileContent, + findResultItem.Matches); + gvResults.Rows[currentRow].Cells[columnIndex].Value = GenerateMatchesPreviewText(fileContent, + lineNumbers.Select( + ln => ln.LineNumber).ToList()); + } } //Grid likes to select the first row for some reason diff --git a/src/FindAndReplace.App/Properties/Resources.Designer.cs b/src/FindAndReplace.App/Properties/Resources.Designer.cs index 4692244..3aceda5 100644 --- a/src/FindAndReplace.App/Properties/Resources.Designer.cs +++ b/src/FindAndReplace.App/Properties/Resources.Designer.cs @@ -1,10 +1,10 @@ //------------------------------------------------------------------------------ // -// Ce code a été généré par un outil. -// Version du runtime :4.0.30319.42000 +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 // -// Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si -// le code est régénéré. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. // //------------------------------------------------------------------------------ @@ -13,13 +13,13 @@ namespace FindAndReplace.App.Properties { /// - /// Une classe de ressource fortement typée destinée, entre autres, à la consultation des chaînes localisées. + /// A strongly-typed resource class, for looking up localized strings, etc. /// - // Cette classe a été générée automatiquement par la classe StronglyTypedResourceBuilder - // à l'aide d'un outil, tel que ResGen ou Visual Studio. - // Pour ajouter ou supprimer un membre, modifiez votre fichier .ResX, puis réexécutez ResGen - // avec l'option /str ou régénérez votre projet VS. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { @@ -33,7 +33,7 @@ internal Resources() { } /// - /// Retourne l'instance ResourceManager mise en cache utilisée par cette classe. + /// Returns the cached ResourceManager instance used by this class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Resources.ResourceManager ResourceManager { @@ -47,8 +47,8 @@ internal Resources() { } /// - /// Remplace la propriété CurrentUICulture du thread actuel pour toutes - /// les recherches de ressources à l'aide de cette classe de ressource fortement typée. + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Globalization.CultureInfo Culture { @@ -61,7 +61,7 @@ internal Resources() { } /// - /// Recherche une ressource localisée de type System.Drawing.Bitmap. + /// Looks up a localized resource of type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap donate { get { @@ -71,7 +71,7 @@ internal static System.Drawing.Bitmap donate { } /// - /// Recherche une ressource localisée de type System.Drawing.Bitmap. + /// Looks up a localized resource of type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap donate2 { get { @@ -81,7 +81,7 @@ internal static System.Drawing.Bitmap donate2 { } /// - /// Recherche une ressource localisée de type System.Drawing.Bitmap. + /// Looks up a localized resource of type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap swap_icon { get { diff --git a/src/FindAndReplace.App/Properties/Settings.Designer.cs b/src/FindAndReplace.App/Properties/Settings.Designer.cs index 598863b..4fec8a8 100644 --- a/src/FindAndReplace.App/Properties/Settings.Designer.cs +++ b/src/FindAndReplace.App/Properties/Settings.Designer.cs @@ -1,10 +1,10 @@ //------------------------------------------------------------------------------ // -// Ce code a été généré par un outil. -// Version du runtime :4.0.30319.42000 +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 // -// Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si -// le code est régénéré. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. // //------------------------------------------------------------------------------ @@ -12,7 +12,7 @@ namespace FindAndReplace.App.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.7.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.14.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); diff --git a/src/FindAndReplace.App/app.config b/src/FindAndReplace.App/app.config index 4fc654f..ed65776 100644 --- a/src/FindAndReplace.App/app.config +++ b/src/FindAndReplace.App/app.config @@ -5,7 +5,7 @@
- + diff --git a/src/FindAndReplace.App/packages.config b/src/FindAndReplace.App/packages.config index 70f48f8..fc8d7ac 100644 --- a/src/FindAndReplace.App/packages.config +++ b/src/FindAndReplace.App/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/src/FindAndReplace.Tests.CommandLine/App.config b/src/FindAndReplace.Tests.CommandLine/App.config index 8e15646..4bfa005 100644 --- a/src/FindAndReplace.Tests.CommandLine/App.config +++ b/src/FindAndReplace.Tests.CommandLine/App.config @@ -1,6 +1,6 @@ - + - + - \ No newline at end of file + diff --git a/src/FindAndReplace.Tests.CommandLine/FindAndReplace.Tests.CommandLine.csproj b/src/FindAndReplace.Tests.CommandLine/FindAndReplace.Tests.CommandLine.csproj index d8fad83..61890d6 100644 --- a/src/FindAndReplace.Tests.CommandLine/FindAndReplace.Tests.CommandLine.csproj +++ b/src/FindAndReplace.Tests.CommandLine/FindAndReplace.Tests.CommandLine.csproj @@ -1,5 +1,5 @@  - + Debug @@ -9,12 +9,13 @@ Properties FindAndReplace.Tests.CommandLine FindAndReplace.Tests.CommandLine - v4.5 + v4.8 512 SAK SAK SAK SAK + AnyCPU diff --git a/src/FindAndReplace.Tests/DetectEncodingAccuracyTest.cs b/src/FindAndReplace.Tests/DetectEncodingAccuracyTest.cs index d34b81f..ae5a75e 100644 --- a/src/FindAndReplace.Tests/DetectEncodingAccuracyTest.cs +++ b/src/FindAndReplace.Tests/DetectEncodingAccuracyTest.cs @@ -4,7 +4,6 @@ using System.Threading; using NUnit.Framework; using System.Linq; -using href.Utils; namespace FindAndReplace.Tests { diff --git a/src/FindAndReplace.Tests/FindAndReplace.Tests.csproj b/src/FindAndReplace.Tests/FindAndReplace.Tests.csproj index 51aa415..17d1f14 100644 --- a/src/FindAndReplace.Tests/FindAndReplace.Tests.csproj +++ b/src/FindAndReplace.Tests/FindAndReplace.Tests.csproj @@ -1,5 +1,5 @@  - + Debug AnyCPU @@ -10,7 +10,7 @@ Properties FindAndReplace.Tests FindAndReplace.Tests - v4.5 + v4.8 512 SAK diff --git a/src/FindAndReplace.sln b/src/FindAndReplace.sln index ad9307b..330ce6e 100644 --- a/src/FindAndReplace.sln +++ b/src/FindAndReplace.sln @@ -1,16 +1,23 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27130.2010 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36221.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FindAndReplace.App", "FindAndReplace.App\FindAndReplace.App.csproj", "{128F4172-1975-4ABA-A8D8-4B55DC9AB481}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FindAndReplace.Tests", "FindAndReplace.Tests\FindAndReplace.Tests.csproj", "{2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}" + ProjectSection(ProjectDependencies) = postProject + {4E35E2C7-099B-4356-9215-0DC77D156CFA} = {4E35E2C7-099B-4356-9215-0DC77D156CFA} + {CA19D4DE-B232-491A-92BF-7BF3A2758694} = {CA19D4DE-B232-491A-92BF-7BF3A2758694} + EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FindAndReplace", "FindAndReplace\FindAndReplace.csproj", "{4E35E2C7-099B-4356-9215-0DC77D156CFA}" + ProjectSection(ProjectDependencies) = postProject + {CA19D4DE-B232-491A-92BF-7BF3A2758694} = {CA19D4DE-B232-491A-92BF-7BF3A2758694} + EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EncodingTools", "EncodingTools\EncodingTools.csproj", "{CA19D4DE-B232-491A-92BF-7BF3A2758694}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FindAndReplace.Tests", "FindAndReplace.Tests\FindAndReplace.Tests.csproj", "{2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}" +EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FindAndReplace.Tests.CommandLine", "FindAndReplace.Tests.CommandLine\FindAndReplace.Tests.CommandLine.csproj", "{72B4C6BB-E2C8-4162-AE69-23B588048689}" EndProject Global @@ -33,17 +40,6 @@ Global {128F4172-1975-4ABA-A8D8-4B55DC9AB481}.Release|Mixed Platforms.Build.0 = Release|x86 {128F4172-1975-4ABA-A8D8-4B55DC9AB481}.Release|x86.ActiveCfg = Release|x86 {128F4172-1975-4ABA-A8D8-4B55DC9AB481}.Release|x86.Build.0 = Release|x86 - {2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Debug|x86.ActiveCfg = Debug|Any CPU - {2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Debug|x86.Build.0 = Debug|Any CPU - {2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Release|Any CPU.Build.0 = Release|Any CPU - {2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Release|x86.ActiveCfg = Release|Any CPU {4E35E2C7-099B-4356-9215-0DC77D156CFA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4E35E2C7-099B-4356-9215-0DC77D156CFA}.Debug|Any CPU.Build.0 = Debug|Any CPU {4E35E2C7-099B-4356-9215-0DC77D156CFA}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU @@ -64,16 +60,30 @@ Global {CA19D4DE-B232-491A-92BF-7BF3A2758694}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {CA19D4DE-B232-491A-92BF-7BF3A2758694}.Release|Mixed Platforms.Build.0 = Release|Any CPU {CA19D4DE-B232-491A-92BF-7BF3A2758694}.Release|x86.ActiveCfg = Release|Any CPU + {2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Debug|x86.ActiveCfg = Debug|Any CPU + {2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Debug|x86.Build.0 = Debug|Any CPU + {2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Release|Any CPU.Build.0 = Release|Any CPU + {2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Release|x86.ActiveCfg = Release|Any CPU + {2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Release|x86.Build.0 = Release|Any CPU {72B4C6BB-E2C8-4162-AE69-23B588048689}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {72B4C6BB-E2C8-4162-AE69-23B588048689}.Debug|Any CPU.Build.0 = Debug|Any CPU {72B4C6BB-E2C8-4162-AE69-23B588048689}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {72B4C6BB-E2C8-4162-AE69-23B588048689}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {72B4C6BB-E2C8-4162-AE69-23B588048689}.Debug|x86.ActiveCfg = Debug|Any CPU + {72B4C6BB-E2C8-4162-AE69-23B588048689}.Debug|x86.Build.0 = Debug|Any CPU {72B4C6BB-E2C8-4162-AE69-23B588048689}.Release|Any CPU.ActiveCfg = Release|Any CPU {72B4C6BB-E2C8-4162-AE69-23B588048689}.Release|Any CPU.Build.0 = Release|Any CPU {72B4C6BB-E2C8-4162-AE69-23B588048689}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {72B4C6BB-E2C8-4162-AE69-23B588048689}.Release|Mixed Platforms.Build.0 = Release|Any CPU {72B4C6BB-E2C8-4162-AE69-23B588048689}.Release|x86.ActiveCfg = Release|Any CPU + {72B4C6BB-E2C8-4162-AE69-23B588048689}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/FindAndReplace/EncodingDetector.cs b/src/FindAndReplace/EncodingDetector.cs index 2852975..e01ee46 100644 --- a/src/FindAndReplace/EncodingDetector.cs +++ b/src/FindAndReplace/EncodingDetector.cs @@ -1,12 +1,40 @@ using System; +using System.Collections.Generic; using System.Linq; using System.Text; -using href.Utils; - namespace FindAndReplace { - + //public class StopWatchObject + //{ + // public int Milliseconds; + + // public StopWatchObject(int milliseconds) + // { + // Milliseconds = milliseconds; + // } + //} + + //public class StopWatch + //{ + // public static Dictionary Collection { get; } = + // new Dictionary() + // { + // { "FileGetter.Run", new StopWatchObject(100) } + // }; + + // public static void Start(string key) + // { + // } + + // public static void Stop(string key) + // { + // } + + // public static void PrintCollection(object milliseconds) + // { + // } + //} public class EncodingDetector { diff --git a/src/FindAndReplace/FindAndReplace.csproj b/src/FindAndReplace/FindAndReplace.csproj index 9d09709..c4144d4 100644 --- a/src/FindAndReplace/FindAndReplace.csproj +++ b/src/FindAndReplace/FindAndReplace.csproj @@ -1,5 +1,5 @@  - + Debug AnyCPU @@ -10,7 +10,7 @@ Properties FindAndReplace FindAndReplace - v4.0 + v4.8 512 SAK @@ -41,12 +41,49 @@ ..\packages\CommandLineParser.1.9.71\lib\net40\CommandLine.dll + + ..\packages\Microsoft.Bcl.HashCode.6.0.0\lib\net462\Microsoft.Bcl.HashCode.dll + + + ..\packages\System.Buffers.4.6.0\lib\net462\System.Buffers.dll + + + ..\packages\System.Memory.4.6.0\lib\net462\System.Memory.dll + + + + ..\packages\System.Numerics.Vectors.4.6.0\lib\net462\System.Numerics.Vectors.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.6.1.0\lib\net462\System.Runtime.CompilerServices.Unsafe.dll + + + ..\packages\PdfPig.0.1.11\lib\net471\UglyToad.PdfPig.dll + + + ..\packages\PdfPig.0.1.11\lib\net471\UglyToad.PdfPig.Core.dll + + + ..\packages\PdfPig.0.1.11\lib\net471\UglyToad.PdfPig.DocumentLayoutAnalysis.dll + + + ..\packages\PdfPig.0.1.11\lib\net471\UglyToad.PdfPig.Fonts.dll + + + ..\packages\PdfPig.0.1.11\lib\net471\UglyToad.PdfPig.Package.dll + + + ..\packages\PdfPig.0.1.11\lib\net471\UglyToad.PdfPig.Tokenization.dll + + + ..\packages\PdfPig.0.1.11\lib\net471\UglyToad.PdfPig.Tokens.dll + @@ -63,17 +100,17 @@ + + + Designer + + {ca19d4de-b232-491a-92bf-7bf3a2758694} EncodingTools - - - Designer - -