Skip to content

Commit

Permalink
Added icons for clear and browse buttons. Deleted unused nuget library.
Browse files Browse the repository at this point in the history
  • Loading branch information
unchase committed Aug 21, 2018
1 parent 4ac9c64 commit 779f3e0
Show file tree
Hide file tree
Showing 8 changed files with 219 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,74 +5,11 @@
using Code7248.word_reader;
using iTextSharp.text.pdf;
using iTextSharp.text.pdf.parser;
using Spire.Doc;
using Spire.Pdf;
using PdfDocument = Spire.Pdf.PdfDocument;

namespace SimpleFullTextSearcher.FileSearcher.Helpers
{
public static class FullTextSearchHelper
{
// Spire.Office может обрабатывать только 10 файлов, поэтому не задействуем его. Если приобрести лицензию, то можно раскомментировать
//#region Spire.Office

//public static bool FindTextInPdf(string fileFullPath, string text)
//{
// try
// {
// var pdf = new PdfDocument(fileFullPath);
// foreach (PdfPageBase page in pdf.Pages)
// {
// if (page.FindText(text).Finds.Any() || page.FindText(text.ToLower()).Finds.Any())
// return true;
// }

// return false;
// }
// catch (Exception e)
// {
// return false;
// }
//}

//public static bool FindTextInWordFile(string fileFullPath, string text)
//{
// try
// {
// var doc = new Document(fileFullPath);
// return doc.GetText().IndexOf(text, StringComparison.OrdinalIgnoreCase) >= 0;
// }
// catch (Exception e)
// {
// return false;
// }
//}

//public static bool FindTextInExcellFile(string fileFullPath, string text)
//{
// try
// {
// var workbook = new Workbook();
// workbook.LoadFromFile(fileFullPath);
// foreach (var sheet in workbook.Worksheets)
// {
// foreach (var range in sheet.Range)
// {
// if (range.Text.IndexOf(text, StringComparison.OrdinalIgnoreCase) >= 0)
// return true;
// }
// }

// return false;
// }
// catch (Exception e)
// {
// return false;
// }
//}

//#endregion

public static bool FindTextInPdf(string fileFullPath, string text) => (GetTextFromPdf(fileFullPath).IndexOf(text, StringComparison.OrdinalIgnoreCase) >= 0);

private static string GetTextFromPdf(string fileFullPath)
Expand Down Expand Up @@ -103,7 +40,7 @@ public static bool FindTextInWord(string fileFullPath, string text)
var extractor = new TextExtractor(fileFullPath);
return extractor.ExtractText().IndexOf(text, StringComparison.OrdinalIgnoreCase) >= 0;
}
catch (Exception e)
catch (Exception)
{
return false;
}
Expand Down Expand Up @@ -136,7 +73,7 @@ public static bool FindTextInExcell(string fileFullPath, string text)
}

}
catch (Exception e)
catch (Exception)
{
return false;
}
Expand Down
6 changes: 3 additions & 3 deletions SimpleFullTextSearcher/FileSearcher/Helpers/IconHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace SimpleFullTextSearcher.FileSearcher.Helpers
public class IconHelper
{
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
private struct SHFILEINFO
private struct Shfileinfo
{
public IntPtr hIcon;
public int iIcon;
Expand All @@ -19,7 +19,7 @@ private struct SHFILEINFO
}

[DllImport("Shell32.dll", EntryPoint = "SHGetFileInfo", SetLastError = true, CharSet = CharSet.Auto)]
private static extern IntPtr SHGetFileInfo(string pszPath, uint dwFileAttributes, ref SHFILEINFO psfi, uint cbFileInfo, uint uFlags);
private static extern IntPtr SHGetFileInfo(string pszPath, uint dwFileAttributes, ref Shfileinfo psfi, uint cbFileInfo, uint uFlags);

[DllImport("User32.dll", EntryPoint = "DestroyIcon")]
private static extern int DestroyIcon(IntPtr hIcon);
Expand Down Expand Up @@ -75,7 +75,7 @@ private enum FileAttributeFlags : uint
/// <returns>Возвращает Icon файла</returns>
public static Icon GetIcon(string fileName)
{
var shfi = new SHFILEINFO();
var shfi = new Shfileinfo();
var res = SHGetFileInfo(fileName,
(uint)FileAttributeFlags.FILE_ATTRIBUTE_NORMAL,
ref shfi,
Expand Down
8 changes: 4 additions & 4 deletions SimpleFullTextSearcher/FormMain.Designer.cs

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

Loading

0 comments on commit 779f3e0

Please sign in to comment.