This commit is contained in:
bao-qian
2016-05-18 19:38:43 +01:00
parent cddfd1b319
commit 937ce34c36
18 changed files with 46 additions and 47 deletions

View File

@@ -18,8 +18,8 @@ namespace Wox.Infrastructure.Image
public static class ImageLoader
{
private static readonly ConcurrentDictionary<string, ImageSource> ImageSources = new ConcurrentDictionary<string, ImageSource>();
private static readonly string DefaultIcon = Path.Combine(Wox.ProgramPath, "Images", "app.png");
private static readonly string ErrorIcon = Path.Combine(Wox.ProgramPath, "Images", "app_error.png");
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 =
{
@@ -174,7 +174,7 @@ namespace Wox.Infrastructure.Image
}
else
{
var defaultDirectoryPath = Path.Combine(Wox.ProgramPath, "Images", Path.GetFileName(path));
var defaultDirectoryPath = Path.Combine(Constant.ProgramDirectory, "Images", Path.GetFileName(path));
if (File.Exists(defaultDirectoryPath))
{
image = new BitmapImage(new Uri(defaultDirectoryPath));

View File

@@ -12,7 +12,7 @@ namespace Wox.Infrastructure.Logger
static Log()
{
var directoryName = "Logs";
var path = Path.Combine(Wox.DataPath, directoryName, Wox.Version);
var path = Path.Combine(Constant.DataDirectory, directoryName, Constant.Version);
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
@@ -21,7 +21,7 @@ namespace Wox.Infrastructure.Logger
var configuration = new LoggingConfiguration();
var target = new FileTarget();
configuration.AddTarget("file", target);
target.FileName = "${specialfolder:folder=ApplicationData}/" + Wox.Name + "/" + directoryName + "/" + Wox.Version + "/${shortdate}.log";
target.FileName = "${specialfolder:folder=ApplicationData}/" + Constant.Wox + "/" + directoryName + "/" + Constant.Version + "/${shortdate}.log";
var rule = new LoggingRule("*", LogLevel.Info, target);
configuration.LoggingRules.Add(rule);
LogManager.Configuration = configuration;

View File

@@ -15,8 +15,8 @@ namespace Wox.Infrastructure.Storage
internal JsonStrorage()
{
FileSuffix = ".json";
DirectoryName = Wox.Settings;
DirectoryPath = Wox.SettingsPath;
DirectoryName = Constant.Settings;
DirectoryPath = Constant.SettingsPath;
FilePath = Path.Combine(DirectoryPath, FileName + FileSuffix);
ValidateDirectory();

View File

@@ -6,7 +6,7 @@ namespace Wox.Infrastructure.Storage
{
public PluginJsonStorage()
{
DirectoryName = Wox.Plugins;
DirectoryName = Constant.Plugins;
// C# releated, add python releated below
var assemblyName = DataType.Assembly.GetName().Name;

View File

@@ -32,7 +32,7 @@ namespace Wox.Infrastructure.Storage
{
DataType = typeof (T);
FileName = DataType.Name;
DirectoryPath = Wox.DataPath;
DirectoryPath = Constant.DataDirectory;
}
protected void ValidateDirectory()

View File

@@ -5,18 +5,19 @@ using System.Reflection;
namespace Wox.Infrastructure
{
public static class Wox
public static class Constant
{
public const string Name = "Wox";
public const string Wox = "Wox";
public const string Plugins = "Plugins";
public const string Settings = "Settings";
private static readonly Assembly Assembly = Assembly.GetExecutingAssembly();
public static readonly string ProgramPath = Directory.GetParent(Assembly.Location).ToString();
public static readonly string DataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Name);
public static readonly string UserDirectory = Path.Combine(DataPath, Plugins);
public static readonly string PreinstalledDirectory = Path.Combine(ProgramPath, Plugins);
public static readonly string SettingsPath = Path.Combine(DataPath, Settings);
public static readonly string ProgramDirectory = Directory.GetParent(Assembly.Location).ToString();
public static readonly string ExecutablePath = Path.Combine(ProgramDirectory, Wox + ".exe");
public static readonly string DataDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Wox);
public static readonly string UserDirectory = Path.Combine(DataDirectory, Plugins);
public static readonly string PreinstalledDirectory = Path.Combine(ProgramDirectory, Plugins);
public static readonly string SettingsPath = Path.Combine(DataDirectory, Settings);
public const string Github = "https://github.com/Wox-launcher/Wox";
public static readonly string Version = FileVersionInfo.GetVersionInfo(Assembly.Location).ProductVersion;
}