From d166e9bfd42a0fe66953d2cbb1fd4e0412c6532f Mon Sep 17 00:00:00 2001 From: happlebao Date: Wed, 18 May 2016 19:38:43 +0100 Subject: [PATCH] Rename --- Plugins/Wox.Plugin.WebSearch/Main.cs | 4 +-- Wox.Core/Plugin/PluginInstaller.cs | 2 +- Wox.Core/Plugin/PluginManager.cs | 6 ++--- Wox.Core/Resource/Resource.cs | 2 +- Wox.Core/Resource/ResourceMerger.cs | 2 +- Wox.Core/Updater.cs | 2 +- Wox.CrashReporter/ReportWindow.xaml.cs | 2 +- Wox.Infrastructure/Image/ImageLoader.cs | 6 ++--- Wox.Infrastructure/Logger/Log.cs | 4 +-- Wox.Infrastructure/Storage/JsonStorage.cs | 4 +-- .../Storage/PluginJsonStorage.cs | 2 +- Wox.Infrastructure/Storage/Storage.cs | 2 +- Wox.Infrastructure/Wox.cs | 15 ++++++----- Wox/App.xaml.cs | 2 +- Wox/MainWindow.xaml.cs | 2 +- Wox/Msg.xaml.cs | 4 +-- Wox/SettingWindow.xaml.cs | 26 +++++++++---------- Wox/ViewModel/MainViewModel.cs | 6 ++--- 18 files changed, 46 insertions(+), 47 deletions(-) diff --git a/Plugins/Wox.Plugin.WebSearch/Main.cs b/Plugins/Wox.Plugin.WebSearch/Main.cs index e99d61529..e06b28dfd 100644 --- a/Plugins/Wox.Plugin.WebSearch/Main.cs +++ b/Plugins/Wox.Plugin.WebSearch/Main.cs @@ -127,9 +127,9 @@ private async Task> Suggestions(string keyword, string subti static Main() { - var plugins = Infrastructure.Wox.Plugins; + var plugins = Infrastructure.Constant.Plugins; 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); } diff --git a/Wox.Core/Plugin/PluginInstaller.cs b/Wox.Core/Plugin/PluginInstaller.cs index adf5f8591..f16a4556f 100644 --- a/Wox.Core/Plugin/PluginInstaller.cs +++ b/Wox.Core/Plugin/PluginInstaller.cs @@ -34,7 +34,7 @@ internal static void Install(string path) return; } - string pluginFolerPath = Infrastructure.Wox.UserDirectory; + string pluginFolerPath = Infrastructure.Constant.UserDirectory; string newPluginName = plugin.Name .Replace("/", "_") diff --git a/Wox.Core/Plugin/PluginManager.cs b/Wox.Core/Plugin/PluginManager.cs index cc68357b4..3dc8156ed 100644 --- a/Wox.Core/Plugin/PluginManager.cs +++ b/Wox.Core/Plugin/PluginManager.cs @@ -33,13 +33,13 @@ public static class PluginManager // todo happlebao, this should not be public, the indicator function should be embeded public static PluginsSettings Settings; private static List _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() { - if (!Directory.Exists(Infrastructure.Wox.UserDirectory)) + if (!Directory.Exists(Infrastructure.Constant.UserDirectory)) { - Directory.CreateDirectory(Infrastructure.Wox.UserDirectory); + Directory.CreateDirectory(Infrastructure.Constant.UserDirectory); } } diff --git a/Wox.Core/Resource/Resource.cs b/Wox.Core/Resource/Resource.cs index c93546a8c..92d779e25 100644 --- a/Wox.Core/Resource/Resource.cs +++ b/Wox.Core/Resource/Resource.cs @@ -8,7 +8,7 @@ public abstract class Resource { 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(); } diff --git a/Wox.Core/Resource/ResourceMerger.cs b/Wox.Core/Resource/ResourceMerger.cs index c5a0791f6..2d14aaab6 100644 --- a/Wox.Core/Resource/ResourceMerger.cs +++ b/Wox.Core/Resource/ResourceMerger.cs @@ -34,7 +34,7 @@ public static void UpdateResource(T t) where T : Core.Resource.Resource internal static void UpdatePluginLanguages() { - RemoveResource(Infrastructure.Wox.Plugins); + RemoveResource(Infrastructure.Constant.Plugins); foreach (var plugin in PluginManager.GetPluginsForInterface()) { var location = Assembly.GetAssembly(plugin.Plugin.GetType()).Location; diff --git a/Wox.Core/Updater.cs b/Wox.Core/Updater.cs index 1f3246852..cb3d0483a 100644 --- a/Wox.Core/Updater.cs +++ b/Wox.Core/Updater.cs @@ -27,7 +27,7 @@ public static async void UpdateApp() // todo 5/9 the return value of UpdateApp() is NULL, fucking useless! using ( var updater = - await UpdateManager.GitHubUpdateManager(Infrastructure.Wox.Github, urlDownloader: downloader)) + await UpdateManager.GitHubUpdateManager(Infrastructure.Constant.Github, urlDownloader: downloader)) { await updater.UpdateApp(); } diff --git a/Wox.CrashReporter/ReportWindow.xaml.cs b/Wox.CrashReporter/ReportWindow.xaml.cs index e16fc09bc..bcfddc5f3 100644 --- a/Wox.CrashReporter/ReportWindow.xaml.cs +++ b/Wox.CrashReporter/ReportWindow.xaml.cs @@ -23,7 +23,7 @@ public ReportWindow(Exception exception) private void SetException(Exception exception) { tbSummary.AppendText(exception.Message); - tbVersion.Text = Infrastructure.Wox.Version; + tbVersion.Text = Infrastructure.Constant.Version; tbDatetime.Text = DateTime.Now.ToString(); tbStackTrace.AppendText(exception.StackTrace); tbSource.Text = exception.Source; diff --git a/Wox.Infrastructure/Image/ImageLoader.cs b/Wox.Infrastructure/Image/ImageLoader.cs index f01b72f31..95b4a4830 100644 --- a/Wox.Infrastructure/Image/ImageLoader.cs +++ b/Wox.Infrastructure/Image/ImageLoader.cs @@ -18,8 +18,8 @@ namespace Wox.Infrastructure.Image public static class ImageLoader { private static readonly ConcurrentDictionary ImageSources = new ConcurrentDictionary(); - 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 @@ public static ImageSource Load(string path) } 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)); diff --git a/Wox.Infrastructure/Logger/Log.cs b/Wox.Infrastructure/Logger/Log.cs index 3057a5353..3cbced217 100644 --- a/Wox.Infrastructure/Logger/Log.cs +++ b/Wox.Infrastructure/Logger/Log.cs @@ -12,7 +12,7 @@ public static class Log 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 @@ static Log() 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; diff --git a/Wox.Infrastructure/Storage/JsonStorage.cs b/Wox.Infrastructure/Storage/JsonStorage.cs index 8a208bcc2..9044c3568 100644 --- a/Wox.Infrastructure/Storage/JsonStorage.cs +++ b/Wox.Infrastructure/Storage/JsonStorage.cs @@ -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(); diff --git a/Wox.Infrastructure/Storage/PluginJsonStorage.cs b/Wox.Infrastructure/Storage/PluginJsonStorage.cs index 707d263ca..9f10327bb 100644 --- a/Wox.Infrastructure/Storage/PluginJsonStorage.cs +++ b/Wox.Infrastructure/Storage/PluginJsonStorage.cs @@ -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; diff --git a/Wox.Infrastructure/Storage/Storage.cs b/Wox.Infrastructure/Storage/Storage.cs index 780ead235..127f8b852 100644 --- a/Wox.Infrastructure/Storage/Storage.cs +++ b/Wox.Infrastructure/Storage/Storage.cs @@ -32,7 +32,7 @@ protected Storage() { DataType = typeof (T); FileName = DataType.Name; - DirectoryPath = Wox.DataPath; + DirectoryPath = Constant.DataDirectory; } protected void ValidateDirectory() diff --git a/Wox.Infrastructure/Wox.cs b/Wox.Infrastructure/Wox.cs index c6353acfb..80a6c27b8 100644 --- a/Wox.Infrastructure/Wox.cs +++ b/Wox.Infrastructure/Wox.cs @@ -5,18 +5,19 @@ 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; } diff --git a/Wox/App.xaml.cs b/Wox/App.xaml.cs index ca20f39d2..93607f3e0 100644 --- a/Wox/App.xaml.cs +++ b/Wox/App.xaml.cs @@ -54,7 +54,7 @@ private void OnStartup(object sender, StartupEventArgs e) PluginManager.InitializePlugins(API); Current.MainWindow = window; - Current.MainWindow.Title = Infrastructure.Wox.Name; + Current.MainWindow.Title = Infrastructure.Constant.Wox; RegisterExitEvents(); diff --git a/Wox/MainWindow.xaml.cs b/Wox/MainWindow.xaml.cs index 1e8f99f33..bc350b537 100644 --- a/Wox/MainWindow.xaml.cs +++ b/Wox/MainWindow.xaml.cs @@ -96,7 +96,7 @@ private void RegisterEvents(MainViewModel vm) 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(); var open = new MenuItem(InternationalizationManager.Instance.GetTranslation("iconTrayOpen")); open.Click += (o, e) => App.API.ShowApp(); diff --git a/Wox/Msg.xaml.cs b/Wox/Msg.xaml.cs index 9873128c4..b47bfba53 100644 --- a/Wox/Msg.xaml.cs +++ b/Wox/Msg.xaml.cs @@ -38,7 +38,7 @@ public Msg() Storyboard.SetTargetProperty(fadeOutAnimation, new PropertyPath(TopProperty)); 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; } @@ -66,7 +66,7 @@ public void Show(string title, string subTitle, string 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 { imgIco.Source = ImageLoader.Load(iconPath); diff --git a/Wox/SettingWindow.xaml.cs b/Wox/SettingWindow.xaml.cs index 31343b777..909667ba1 100644 --- a/Wox/SettingWindow.xaml.cs +++ b/Wox/SettingWindow.xaml.cs @@ -158,7 +158,7 @@ private async void Setting_Loaded(object sender, RoutedEventArgs ev) string activateTimes = string.Format( InternationalizationManager.Instance.GetTranslation("about_activate_times"), _settings.ActivateTimes); ActivatedTimes.Text = activateTimes; - tbVersion.Text = Infrastructure.Wox.Version; + tbVersion.Text = Infrastructure.Constant.Version; #endregion @@ -242,8 +242,7 @@ public static void SetStartup() { using (var key = Registry.CurrentUser.OpenSubKey(StartupPath, true)) { - var executable = Path.Combine(Infrastructure.Wox.ProgramPath, Infrastructure.Wox.Name + ".exe"); - key?.SetValue(Infrastructure.Wox.Name, executable); + key?.SetValue(Infrastructure.Constant.Wox, Infrastructure.Constant.ExecutablePath); } } @@ -251,7 +250,7 @@ private void RemoveStartup() { using (var key = Registry.CurrentUser.OpenSubKey(StartupPath, true)) { - key?.DeleteValue(Infrastructure.Wox.Name, false); + key?.DeleteValue(Infrastructure.Constant.Wox, false); } } @@ -262,8 +261,7 @@ public static bool StartupSet() var path = key?.GetValue("Wox") as string; if (path != null) { - var executable = Path.Combine(Infrastructure.Wox.ProgramPath, Infrastructure.Wox.Name + ".exe"); - return path == executable; + return path == Infrastructure.Constant.ExecutablePath; } else { @@ -454,48 +452,48 @@ private void OnThemeTabSelected() Title = "Wox is an effective launcher for windows", SubTitle = "Wox provide bundles of features let you access infomations quickly.", IcoPath = "Images/app.png", - PluginDirectory = Path.GetDirectoryName(Infrastructure.Wox.ProgramPath) + PluginDirectory = Path.GetDirectoryName(Infrastructure.Constant.ProgramDirectory) }, new Result { Title = "Search applications", SubTitle = "Search applications, files (via everything plugin) and browser bookmarks", IcoPath = "Images/app.png", - PluginDirectory = Path.GetDirectoryName(Infrastructure.Wox.ProgramPath) + PluginDirectory = Path.GetDirectoryName(Infrastructure.Constant.ProgramDirectory) }, new Result { Title = "Search web contents with shortcuts", SubTitle = "e.g. search google with g keyword or youtube keyword)", IcoPath = "Images/app.png", - PluginDirectory = Path.GetDirectoryName(Infrastructure.Wox.ProgramPath) + PluginDirectory = Path.GetDirectoryName(Infrastructure.Constant.ProgramDirectory) }, new Result { Title = "clipboard history ", IcoPath = "Images/app.png", - PluginDirectory = Path.GetDirectoryName(Infrastructure.Wox.ProgramPath) + PluginDirectory = Path.GetDirectoryName(Infrastructure.Constant.ProgramDirectory) }, new Result { Title = "Themes support", SubTitle = "get more themes from http://www.getwox.com/theme", IcoPath = "Images/app.png", - PluginDirectory = Path.GetDirectoryName(Infrastructure.Wox.ProgramPath) + PluginDirectory = Path.GetDirectoryName(Infrastructure.Constant.ProgramDirectory) }, new Result { Title = "Plugins support", SubTitle = "get more plugins from http://www.getwox.com/plugin", IcoPath = "Images/app.png", - PluginDirectory = Path.GetDirectoryName(Infrastructure.Wox.ProgramPath) + PluginDirectory = Path.GetDirectoryName(Infrastructure.Constant.ProgramDirectory) }, new Result { Title = "Wox is an open-source software", SubTitle = "Wox benefits from the open-source community a lot", IcoPath = "Images/app.png", - PluginDirectory = Path.GetDirectoryName(Infrastructure.Wox.ProgramPath) + PluginDirectory = Path.GetDirectoryName(Infrastructure.Constant.ProgramDirectory) } }); @@ -859,7 +857,7 @@ private async void OnCheckUpdates(object sender, RoutedEventArgs e) if (!string.IsNullOrEmpty(version)) { var newVersion = Updater.NumericVersion(version); - var oldVersion = Updater.NumericVersion(Infrastructure.Wox.Version); + var oldVersion = Updater.NumericVersion(Infrastructure.Constant.Version); if (newVersion > oldVersion) { NewVersionTips.Text = string.Format(NewVersionTips.Text, version); diff --git a/Wox/ViewModel/MainViewModel.cs b/Wox/ViewModel/MainViewModel.cs index 8477364f9..cd2214a69 100644 --- a/Wox/ViewModel/MainViewModel.cs +++ b/Wox/ViewModel/MainViewModel.cs @@ -495,7 +495,7 @@ private void DisplayQueryHistory(HistoryItem history) Title = string.Format(executeQueryHistoryTitle, history.Query), SubTitle = string.Format(lastExecuteTime, history.ExecutedDateTime), IcoPath = "Images\\history.png", - PluginDirectory = Infrastructure.Wox.ProgramPath, + PluginDirectory = Infrastructure.Constant.ProgramDirectory, Action = _ => { QueryText = history.Query; @@ -519,7 +519,7 @@ private Result ContextMenuTopMost(Result result) { Title = InternationalizationManager.Instance.GetTranslation("cancelTopMostInThisQuery"), IcoPath = "Images\\down.png", - PluginDirectory = Infrastructure.Wox.ProgramPath, + PluginDirectory = Infrastructure.Constant.ProgramDirectory, Action = _ => { _topMostRecord.Remove(result); @@ -534,7 +534,7 @@ private Result ContextMenuTopMost(Result result) { Title = InternationalizationManager.Instance.GetTranslation("setAsTopMostInThisQuery"), IcoPath = "Images\\up.png", - PluginDirectory = Infrastructure.Wox.ProgramPath, + PluginDirectory = Infrastructure.Constant.ProgramDirectory, Action = _ => { _topMostRecord.AddOrUpdate(result);