Skip to content

Commit

Permalink
Rename
Browse files Browse the repository at this point in the history
  • Loading branch information
bao-qian committed May 18, 2016
1 parent 539627b commit d166e9b
Show file tree
Hide file tree
Showing 18 changed files with 46 additions and 47 deletions.
4 changes: 2 additions & 2 deletions Plugins/Wox.Plugin.WebSearch/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ private async Task<IEnumerable<Result>> 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);
}

Expand Down
2 changes: 1 addition & 1 deletion Wox.Core/Plugin/PluginInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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("/", "_")
Expand Down
6 changes: 3 additions & 3 deletions Wox.Core/Plugin/PluginManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<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()
{
if (!Directory.Exists(Infrastructure.Wox.UserDirectory))
if (!Directory.Exists(Infrastructure.Constant.UserDirectory))
{
Directory.CreateDirectory(Infrastructure.Wox.UserDirectory);
Directory.CreateDirectory(Infrastructure.Constant.UserDirectory);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Wox.Core/Resource/Resource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion Wox.Core/Resource/ResourceMerger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static void UpdateResource<T>(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<IPluginI18n>())
{
var location = Assembly.GetAssembly(plugin.Plugin.GetType()).Location;
Expand Down
2 changes: 1 addition & 1 deletion Wox.Core/Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion Wox.CrashReporter/ReportWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions Wox.Infrastructure/Image/ImageLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
{
Expand Down Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions Wox.Infrastructure/Logger/Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions Wox.Infrastructure/Storage/JsonStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion Wox.Infrastructure/Storage/PluginJsonStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Wox.Infrastructure/Storage/Storage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected Storage()
{
DataType = typeof (T);
FileName = DataType.Name;
DirectoryPath = Wox.DataPath;
DirectoryPath = Constant.DataDirectory;
}

protected void ValidateDirectory()
Expand Down
15 changes: 8 additions & 7 deletions Wox.Infrastructure/Wox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion Wox/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion Wox/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions Wox/Msg.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
Expand Down
26 changes: 12 additions & 14 deletions Wox/SettingWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -242,16 +242,15 @@ 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);
}
}

private void RemoveStartup()
{
using (var key = Registry.CurrentUser.OpenSubKey(StartupPath, true))
{
key?.DeleteValue(Infrastructure.Wox.Name, false);
key?.DeleteValue(Infrastructure.Constant.Wox, false);
}
}

Expand All @@ -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
{
Expand Down Expand Up @@ -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)
}
});

Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions Wox/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit d166e9b

Please sign in to comment.