Add icon constant

This commit is contained in:
bao-qian
2016-08-20 01:02:47 +01:00
parent 955ce1dd2d
commit 0c0ec29821
2 changed files with 16 additions and 14 deletions

View File

@@ -18,8 +18,7 @@ namespace Wox.Infrastructure.Image
public static class ImageLoader public static class ImageLoader
{ {
private static readonly ConcurrentDictionary<string, ImageSource> ImageSources = new ConcurrentDictionary<string, ImageSource>(); private static readonly ConcurrentDictionary<string, ImageSource> ImageSources = new ConcurrentDictionary<string, ImageSource>();
private static readonly string DefaultIcon = Path.Combine(Constant.ProgramDirectory, "Images", "app.png");
private static readonly string ErrorIcon = Path.Combine(Constant.ProgramDirectory, "Images", "app_error.png");
private static readonly string[] ImageExtions = private static readonly string[] ImageExtions =
{ {
@@ -59,13 +58,13 @@ namespace Wox.Infrastructure.Image
} }
else else
{ {
return ImageSources[ErrorIcon]; return ImageSources[Constant.ErrorIcon];
} }
} }
catch (System.Exception e) catch (System.Exception e)
{ {
Log.Exception(e); Log.Exception(e);
return ImageSources[ErrorIcon]; return ImageSources[Constant.ErrorIcon];
} }
} }
@@ -90,20 +89,20 @@ namespace Wox.Infrastructure.Image
} }
else else
{ {
return ImageSources[ErrorIcon]; return ImageSources[Constant.ErrorIcon];
} }
} }
catch (System.Exception e) catch (System.Exception e)
{ {
Log.Exception(e); Log.Exception(e);
return ImageSources[ErrorIcon]; return ImageSources[Constant.ErrorIcon];
} }
} }
public static void PreloadImages() public static void PreloadImages()
{ {
foreach (var icon in new[] { DefaultIcon, ErrorIcon }) foreach (var icon in new[] { Constant.DefaultIcon, Constant.ErrorIcon })
{ {
ImageSource img = new BitmapImage(new Uri(DefaultIcon)); ImageSource img = new BitmapImage(new Uri(Constant.DefaultIcon));
img.Freeze(); img.Freeze();
ImageSources[icon] = img; ImageSources[icon] = img;
} }
@@ -129,8 +128,8 @@ namespace Wox.Infrastructure.Image
ImageSource image; ImageSource image;
if (string.IsNullOrEmpty(path)) if (string.IsNullOrEmpty(path))
{ {
image = ImageSources[ErrorIcon]; image = ImageSources[Constant.ErrorIcon];
_cache.Add(ErrorIcon); _cache.Add(Constant.ErrorIcon);
} }
else if (ImageSources.ContainsKey(path)) else if (ImageSources.ContainsKey(path))
{ {
@@ -164,8 +163,8 @@ namespace Wox.Infrastructure.Image
} }
else else
{ {
image = ImageSources[ErrorIcon]; image = ImageSources[Constant.ErrorIcon];
path = ErrorIcon; path = Constant.ErrorIcon;
} }
} }
else else
@@ -177,8 +176,8 @@ namespace Wox.Infrastructure.Image
} }
else else
{ {
image = ImageSources[ErrorIcon]; image = ImageSources[Constant.ErrorIcon];
path = ErrorIcon; path = Constant.ErrorIcon;
} }
} }
ImageSources[path] = image; ImageSources[path] = image;

View File

@@ -22,6 +22,9 @@ namespace Wox.Infrastructure
public const string Issue = "https://github.com/Wox-launcher/Wox/issues/new"; public const string Issue = "https://github.com/Wox-launcher/Wox/issues/new";
public static readonly string Version = FileVersionInfo.GetVersionInfo(Assembly.Location).ProductVersion; public static readonly string Version = FileVersionInfo.GetVersionInfo(Assembly.Location).ProductVersion;
public static readonly string DefaultIcon = Path.Combine(ProgramDirectory, "Images", "app.png");
public static readonly string ErrorIcon = Path.Combine(ProgramDirectory, "Images", "app_error.png");
public static string PythonPath; public static string PythonPath;
public static string EverythingSDKPath; public static string EverythingSDKPath;
} }