Skip to content

Commit

Permalink
Use absolute path in extractor.
Browse files Browse the repository at this point in the history
  • Loading branch information
oozcitak committed Dec 10, 2018
1 parent d4a7b7d commit 7bf0460
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
28 changes: 24 additions & 4 deletions ImageListView/Extractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
// WIC support coded by Jens

using System;
using System.IO;
using System.Linq;
using System.Reflection;

namespace Manina.Windows.Forms
Expand Down Expand Up @@ -48,21 +50,39 @@ public static IExtractor Instance
{
try
{
Assembly assembly = Assembly.LoadFrom("WPFThumbnailExtractor.dll");
Type type = assembly.GetType("WPFExtractor");
instance = (IExtractor)Activator.CreateInstance(type);
string programFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string pluginFileName = Path.Combine(programFolder, "WPFThumbnailExtractor.dll");
instance = LoadFrom(pluginFileName);
}
catch
catch (Exception e)
{
System.Windows.Forms.MessageBox.Show(e.ToString());
instance = new GDIExtractor();
}
}
}

if (instance == null)
instance = new GDIExtractor();

return instance;
}
}

private static IExtractor LoadFrom(string pluginFileName)
{
Assembly assembly = Assembly.LoadFrom(pluginFileName);
foreach (Type type in assembly.GetTypes())
{
if (type.GetInterfaces().Contains(typeof(IExtractor)) && !type.IsInterface && type.IsClass && !type.IsAbstract)
{
return (IExtractor)Activator.CreateInstance(type, new object[0]);
}
}

return null;
}

public static bool UseWIC
{
get
Expand Down
4 changes: 2 additions & 2 deletions ImageListViewDemo/DemoForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,8 @@ private void PopulateListView(DirectoryInfo path)
}
foreach (FileInfo p in files)
{
if (p.Name.EndsWith(".jpg", StringComparison.OrdinalIgnoreCase) ||
p.Name.EndsWith(".mp4", StringComparison.OrdinalIgnoreCase) ||
if (p.Name.EndsWith(".pdf", StringComparison.OrdinalIgnoreCase) ||
p.Name.EndsWith(".jpg", StringComparison.OrdinalIgnoreCase) ||
p.Name.EndsWith(".png", StringComparison.OrdinalIgnoreCase) ||
p.Name.EndsWith(".bmp", StringComparison.OrdinalIgnoreCase) ||
p.Name.EndsWith(".ico", StringComparison.OrdinalIgnoreCase) ||
Expand Down

0 comments on commit 7bf0460

Please sign in to comment.