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

@@ -127,9 +127,9 @@ namespace Wox.Plugin.WebSearch
static Main() static Main()
{ {
var plugins = Infrastructure.Wox.Plugins; var plugins = Infrastructure.Constant.Plugins;
var assemblyName = typeof(Main).Assembly.GetName().Name; var assemblyName = typeof(Main).Assembly.GetName().Name;
var pluginDirectory = Path.Combine(Infrastructure.Wox.SettingsPath, plugins, assemblyName); var pluginDirectory = Path.Combine(Infrastructure.Constant.SettingsPath, plugins, assemblyName);
ImagesDirectory = Path.Combine(pluginDirectory, Images); ImagesDirectory = Path.Combine(pluginDirectory, Images);
} }

View File

@@ -34,7 +34,7 @@ namespace Wox.Core.Plugin
return; return;
} }
string pluginFolerPath = Infrastructure.Wox.UserDirectory; string pluginFolerPath = Infrastructure.Constant.UserDirectory;
string newPluginName = plugin.Name string newPluginName = plugin.Name
.Replace("/", "_") .Replace("/", "_")

View File

@@ -33,13 +33,13 @@ namespace Wox.Core.Plugin
// todo happlebao, this should not be public, the indicator function should be embeded // todo happlebao, this should not be public, the indicator function should be embeded
public static PluginsSettings Settings; public static PluginsSettings Settings;
private static List<PluginMetadata> _metadatas; private static List<PluginMetadata> _metadatas;
private static readonly string[] Directories = { Infrastructure.Wox.PreinstalledDirectory, Infrastructure.Wox.UserDirectory }; private static readonly string[] Directories = { Infrastructure.Constant.PreinstalledDirectory, Infrastructure.Constant.UserDirectory };
private static void ValidateUserDirectory() private static void ValidateUserDirectory()
{ {
if (!Directory.Exists(Infrastructure.Wox.UserDirectory)) if (!Directory.Exists(Infrastructure.Constant.UserDirectory))
{ {
Directory.CreateDirectory(Infrastructure.Wox.UserDirectory); Directory.CreateDirectory(Infrastructure.Constant.UserDirectory);
} }
} }

View File

@@ -8,7 +8,7 @@ namespace Wox.Core.Resource
{ {
public string DirectoryName { get; protected set; } public string DirectoryName { get; protected set; }
protected string DirectoryPath => Path.Combine(Infrastructure.Wox.ProgramPath, DirectoryName); protected string DirectoryPath => Path.Combine(Infrastructure.Constant.ProgramDirectory, DirectoryName);
public abstract ResourceDictionary GetResourceDictionary(); public abstract ResourceDictionary GetResourceDictionary();
} }

View File

@@ -34,7 +34,7 @@ namespace Wox.Core.Resource
internal static void UpdatePluginLanguages() internal static void UpdatePluginLanguages()
{ {
RemoveResource(Infrastructure.Wox.Plugins); RemoveResource(Infrastructure.Constant.Plugins);
foreach (var plugin in PluginManager.GetPluginsForInterface<IPluginI18n>()) foreach (var plugin in PluginManager.GetPluginsForInterface<IPluginI18n>())
{ {
var location = Assembly.GetAssembly(plugin.Plugin.GetType()).Location; var location = Assembly.GetAssembly(plugin.Plugin.GetType()).Location;

View File

@@ -27,7 +27,7 @@ namespace Wox.Core
// todo 5/9 the return value of UpdateApp() is NULL, fucking useless! // todo 5/9 the return value of UpdateApp() is NULL, fucking useless!
using ( using (
var updater = var updater =
await UpdateManager.GitHubUpdateManager(Infrastructure.Wox.Github, urlDownloader: downloader)) await UpdateManager.GitHubUpdateManager(Infrastructure.Constant.Github, urlDownloader: downloader))
{ {
await updater.UpdateApp(); await updater.UpdateApp();
} }

View File

@@ -23,7 +23,7 @@ namespace Wox.CrashReporter
private void SetException(Exception exception) private void SetException(Exception exception)
{ {
tbSummary.AppendText(exception.Message); tbSummary.AppendText(exception.Message);
tbVersion.Text = Infrastructure.Wox.Version; tbVersion.Text = Infrastructure.Constant.Version;
tbDatetime.Text = DateTime.Now.ToString(); tbDatetime.Text = DateTime.Now.ToString();
tbStackTrace.AppendText(exception.StackTrace); tbStackTrace.AppendText(exception.StackTrace);
tbSource.Text = exception.Source; tbSource.Text = exception.Source;

View File

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

View File

@@ -12,7 +12,7 @@ namespace Wox.Infrastructure.Logger
static Log() static Log()
{ {
var directoryName = "Logs"; 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)) if (!Directory.Exists(path))
{ {
Directory.CreateDirectory(path); Directory.CreateDirectory(path);
@@ -21,7 +21,7 @@ namespace Wox.Infrastructure.Logger
var configuration = new LoggingConfiguration(); var configuration = new LoggingConfiguration();
var target = new FileTarget(); var target = new FileTarget();
configuration.AddTarget("file", target); 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); var rule = new LoggingRule("*", LogLevel.Info, target);
configuration.LoggingRules.Add(rule); configuration.LoggingRules.Add(rule);
LogManager.Configuration = configuration; LogManager.Configuration = configuration;

View File

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

View File

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

View File

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

View File

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

View File

@@ -54,7 +54,7 @@ namespace Wox
PluginManager.InitializePlugins(API); PluginManager.InitializePlugins(API);
Current.MainWindow = window; Current.MainWindow = window;
Current.MainWindow.Title = Infrastructure.Wox.Name; Current.MainWindow.Title = Infrastructure.Constant.Wox;
RegisterExitEvents(); RegisterExitEvents();

View File

@@ -96,7 +96,7 @@ namespace Wox
private void InitializeNotifyIcon() private void InitializeNotifyIcon()
{ {
_notifyIcon = new NotifyIcon { Text = Infrastructure.Wox.Name, Icon = Properties.Resources.app, Visible = true }; _notifyIcon = new NotifyIcon { Text = Infrastructure.Constant.Wox, Icon = Properties.Resources.app, Visible = true };
_notifyIcon.Click += (o, e) => App.API.ShowApp(); _notifyIcon.Click += (o, e) => App.API.ShowApp();
var open = new MenuItem(InternationalizationManager.Instance.GetTranslation("iconTrayOpen")); var open = new MenuItem(InternationalizationManager.Instance.GetTranslation("iconTrayOpen"));
open.Click += (o, e) => App.API.ShowApp(); open.Click += (o, e) => App.API.ShowApp();

View File

@@ -38,7 +38,7 @@ namespace Wox
Storyboard.SetTargetProperty(fadeOutAnimation, new PropertyPath(TopProperty)); Storyboard.SetTargetProperty(fadeOutAnimation, new PropertyPath(TopProperty));
fadeOutStoryboard.Children.Add(fadeOutAnimation); fadeOutStoryboard.Children.Add(fadeOutAnimation);
imgClose.Source = ImageLoader.Load(Path.Combine(Infrastructure.Wox.ProgramPath, "Images\\close.png")); imgClose.Source = ImageLoader.Load(Path.Combine(Infrastructure.Constant.ProgramDirectory, "Images\\close.png"));
imgClose.MouseUp += imgClose_MouseUp; imgClose.MouseUp += imgClose_MouseUp;
} }
@@ -66,7 +66,7 @@ namespace Wox
} }
if (!File.Exists(iconPath)) if (!File.Exists(iconPath))
{ {
imgIco.Source = ImageLoader.Load(Path.Combine(Infrastructure.Wox.ProgramPath, "Images\\app.png")); imgIco.Source = ImageLoader.Load(Path.Combine(Infrastructure.Constant.ProgramDirectory, "Images\\app.png"));
} }
else { else {
imgIco.Source = ImageLoader.Load(iconPath); imgIco.Source = ImageLoader.Load(iconPath);

View File

@@ -158,7 +158,7 @@ namespace Wox
string activateTimes = string.Format( string activateTimes = string.Format(
InternationalizationManager.Instance.GetTranslation("about_activate_times"), _settings.ActivateTimes); InternationalizationManager.Instance.GetTranslation("about_activate_times"), _settings.ActivateTimes);
ActivatedTimes.Text = activateTimes; ActivatedTimes.Text = activateTimes;
tbVersion.Text = Infrastructure.Wox.Version; tbVersion.Text = Infrastructure.Constant.Version;
#endregion #endregion
@@ -242,8 +242,7 @@ namespace Wox
{ {
using (var key = Registry.CurrentUser.OpenSubKey(StartupPath, true)) using (var key = Registry.CurrentUser.OpenSubKey(StartupPath, true))
{ {
var executable = Path.Combine(Infrastructure.Wox.ProgramPath, Infrastructure.Wox.Name + ".exe"); key?.SetValue(Infrastructure.Constant.Wox, Infrastructure.Constant.ExecutablePath);
key?.SetValue(Infrastructure.Wox.Name, executable);
} }
} }
@@ -251,7 +250,7 @@ namespace Wox
{ {
using (var key = Registry.CurrentUser.OpenSubKey(StartupPath, true)) using (var key = Registry.CurrentUser.OpenSubKey(StartupPath, true))
{ {
key?.DeleteValue(Infrastructure.Wox.Name, false); key?.DeleteValue(Infrastructure.Constant.Wox, false);
} }
} }
@@ -262,8 +261,7 @@ namespace Wox
var path = key?.GetValue("Wox") as string; var path = key?.GetValue("Wox") as string;
if (path != null) if (path != null)
{ {
var executable = Path.Combine(Infrastructure.Wox.ProgramPath, Infrastructure.Wox.Name + ".exe"); return path == Infrastructure.Constant.ExecutablePath;
return path == executable;
} }
else else
{ {
@@ -454,48 +452,48 @@ namespace Wox
Title = "Wox is an effective launcher for windows", Title = "Wox is an effective launcher for windows",
SubTitle = "Wox provide bundles of features let you access infomations quickly.", SubTitle = "Wox provide bundles of features let you access infomations quickly.",
IcoPath = "Images/app.png", IcoPath = "Images/app.png",
PluginDirectory = Path.GetDirectoryName(Infrastructure.Wox.ProgramPath) PluginDirectory = Path.GetDirectoryName(Infrastructure.Constant.ProgramDirectory)
}, },
new Result new Result
{ {
Title = "Search applications", Title = "Search applications",
SubTitle = "Search applications, files (via everything plugin) and browser bookmarks", SubTitle = "Search applications, files (via everything plugin) and browser bookmarks",
IcoPath = "Images/app.png", IcoPath = "Images/app.png",
PluginDirectory = Path.GetDirectoryName(Infrastructure.Wox.ProgramPath) PluginDirectory = Path.GetDirectoryName(Infrastructure.Constant.ProgramDirectory)
}, },
new Result new Result
{ {
Title = "Search web contents with shortcuts", Title = "Search web contents with shortcuts",
SubTitle = "e.g. search google with g keyword or youtube keyword)", SubTitle = "e.g. search google with g keyword or youtube keyword)",
IcoPath = "Images/app.png", IcoPath = "Images/app.png",
PluginDirectory = Path.GetDirectoryName(Infrastructure.Wox.ProgramPath) PluginDirectory = Path.GetDirectoryName(Infrastructure.Constant.ProgramDirectory)
}, },
new Result new Result
{ {
Title = "clipboard history ", Title = "clipboard history ",
IcoPath = "Images/app.png", IcoPath = "Images/app.png",
PluginDirectory = Path.GetDirectoryName(Infrastructure.Wox.ProgramPath) PluginDirectory = Path.GetDirectoryName(Infrastructure.Constant.ProgramDirectory)
}, },
new Result new Result
{ {
Title = "Themes support", Title = "Themes support",
SubTitle = "get more themes from http://www.getwox.com/theme", SubTitle = "get more themes from http://www.getwox.com/theme",
IcoPath = "Images/app.png", IcoPath = "Images/app.png",
PluginDirectory = Path.GetDirectoryName(Infrastructure.Wox.ProgramPath) PluginDirectory = Path.GetDirectoryName(Infrastructure.Constant.ProgramDirectory)
}, },
new Result new Result
{ {
Title = "Plugins support", Title = "Plugins support",
SubTitle = "get more plugins from http://www.getwox.com/plugin", SubTitle = "get more plugins from http://www.getwox.com/plugin",
IcoPath = "Images/app.png", IcoPath = "Images/app.png",
PluginDirectory = Path.GetDirectoryName(Infrastructure.Wox.ProgramPath) PluginDirectory = Path.GetDirectoryName(Infrastructure.Constant.ProgramDirectory)
}, },
new Result new Result
{ {
Title = "Wox is an open-source software", Title = "Wox is an open-source software",
SubTitle = "Wox benefits from the open-source community a lot", SubTitle = "Wox benefits from the open-source community a lot",
IcoPath = "Images/app.png", IcoPath = "Images/app.png",
PluginDirectory = Path.GetDirectoryName(Infrastructure.Wox.ProgramPath) PluginDirectory = Path.GetDirectoryName(Infrastructure.Constant.ProgramDirectory)
} }
}); });
@@ -859,7 +857,7 @@ namespace Wox
if (!string.IsNullOrEmpty(version)) if (!string.IsNullOrEmpty(version))
{ {
var newVersion = Updater.NumericVersion(version); var newVersion = Updater.NumericVersion(version);
var oldVersion = Updater.NumericVersion(Infrastructure.Wox.Version); var oldVersion = Updater.NumericVersion(Infrastructure.Constant.Version);
if (newVersion > oldVersion) if (newVersion > oldVersion)
{ {
NewVersionTips.Text = string.Format(NewVersionTips.Text, version); NewVersionTips.Text = string.Format(NewVersionTips.Text, version);

View File

@@ -495,7 +495,7 @@ namespace Wox.ViewModel
Title = string.Format(executeQueryHistoryTitle, history.Query), Title = string.Format(executeQueryHistoryTitle, history.Query),
SubTitle = string.Format(lastExecuteTime, history.ExecutedDateTime), SubTitle = string.Format(lastExecuteTime, history.ExecutedDateTime),
IcoPath = "Images\\history.png", IcoPath = "Images\\history.png",
PluginDirectory = Infrastructure.Wox.ProgramPath, PluginDirectory = Infrastructure.Constant.ProgramDirectory,
Action = _ => Action = _ =>
{ {
QueryText = history.Query; QueryText = history.Query;
@@ -519,7 +519,7 @@ namespace Wox.ViewModel
{ {
Title = InternationalizationManager.Instance.GetTranslation("cancelTopMostInThisQuery"), Title = InternationalizationManager.Instance.GetTranslation("cancelTopMostInThisQuery"),
IcoPath = "Images\\down.png", IcoPath = "Images\\down.png",
PluginDirectory = Infrastructure.Wox.ProgramPath, PluginDirectory = Infrastructure.Constant.ProgramDirectory,
Action = _ => Action = _ =>
{ {
_topMostRecord.Remove(result); _topMostRecord.Remove(result);
@@ -534,7 +534,7 @@ namespace Wox.ViewModel
{ {
Title = InternationalizationManager.Instance.GetTranslation("setAsTopMostInThisQuery"), Title = InternationalizationManager.Instance.GetTranslation("setAsTopMostInThisQuery"),
IcoPath = "Images\\up.png", IcoPath = "Images\\up.png",
PluginDirectory = Infrastructure.Wox.ProgramPath, PluginDirectory = Infrastructure.Constant.ProgramDirectory,
Action = _ => Action = _ =>
{ {
_topMostRecord.AddOrUpdate(result); _topMostRecord.AddOrUpdate(result);