Merge branch 'master' into dev

This commit is contained in:
bao-qian
2016-07-27 19:58:37 +01:00
38 changed files with 281 additions and 350 deletions

View File

@@ -1,23 +1,21 @@
## English ## English
Before you report any bugs try search existing issues Try search existing issues before you open new one
1. Please specify Wox version 1. Wox version / commit number:
- If you checkout from master/dev branch, please specify **commit number** 2. Steps to **reproduce** the bug:
2. Please describe the steps to **reproduce** the bug 3. Windows version:
3. Please provide Windows version 4. Exception:
4. Please provide Exception info if you have. 5. **whole** log file `%APPDATA%\Wox\Logs\version\date.txt`):
5. Please provide **logs** from `%APPDATA%\Wox\Logs` if you have. 6. Screenshot (optional):
6. Please provide screenshot if you have
## 中文 / Chinese ## 中文 / Chinese
报 bug 之前搜索一下已经有的 issue 提问之前搜索一下已经有的 issue
1. 请提供 Wox 版本 1. Wox 版本 / commit number
- 如果你是从 master/dev branch checkout 的,请提供 **commit number** 2. 如何**重现** bug
2. 请提供如何**重现** bug 的步骤 3. Windows 版本:
3. 请提供 Windows 版本 4. Exception
4. 如果有 Exception/Crash Report 的话,请一并提供 5. **整个** log 文件 `%APPDATA%\Wox\Logs\version\date.txt`
5. 如果有 **logs** `%APPDATA%\Wox\Logs`)的话,请一并提供 6. 截图 (可选):
6. 如果有截图的话,请一并提供

View File

@@ -2,7 +2,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib"> xmlns:system="clr-namespace:System;assembly=mscorlib">
<system:String x:Key="wox_plugin_everything_is_not_running">Everything läuft nicht</system:String> <system:String x:Key="wox_plugin_everything_is_not_running">Everything Service läuft nicht</system:String>
<system:String x:Key="wox_plugin_everything_query_error">Everything Plugin hat einen Fehler (drücke Enter zum kopieren der Fehlernachricht)</system:String> <system:String x:Key="wox_plugin_everything_query_error">Everything Plugin hat einen Fehler (drücke Enter zum kopieren der Fehlernachricht)</system:String>
<system:String x:Key="wox_plugin_everything_copied">kopiert</system:String> <system:String x:Key="wox_plugin_everything_copied">kopiert</system:String>
<system:String x:Key="wox_plugin_everything_canot_start">Kann {0} nicht starten</system:String> <system:String x:Key="wox_plugin_everything_canot_start">Kann {0} nicht starten</system:String>

View File

@@ -2,7 +2,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib"> xmlns:system="clr-namespace:System;assembly=mscorlib">
<system:String x:Key="wox_plugin_everything_is_not_running">Everything is not running</system:String> <system:String x:Key="wox_plugin_everything_is_not_running">Everything Service is not running</system:String>
<system:String x:Key="wox_plugin_everything_query_error">Error while querying Everything</system:String> <system:String x:Key="wox_plugin_everything_query_error">Error while querying Everything</system:String>
<system:String x:Key="wox_plugin_everything_copied">Copied</system:String> <system:String x:Key="wox_plugin_everything_copied">Copied</system:String>
<system:String x:Key="wox_plugin_everything_canot_start">Cant start {0}</system:String> <system:String x:Key="wox_plugin_everything_canot_start">Cant start {0}</system:String>

View File

@@ -2,7 +2,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib"> xmlns:system="clr-namespace:System;assembly=mscorlib">
<system:String x:Key="wox_plugin_everything_is_not_running">Program Everything nie jest uruchomiony</system:String> <system:String x:Key="wox_plugin_everything_is_not_running">Everything Service nie jest uruchomiony</system:String>
<system:String x:Key="wox_plugin_everything_query_error">Wystąpił błąd podczas pobierania wyników z Everything</system:String> <system:String x:Key="wox_plugin_everything_query_error">Wystąpił błąd podczas pobierania wyników z Everything</system:String>
<system:String x:Key="wox_plugin_everything_copied">Skopiowano</system:String> <system:String x:Key="wox_plugin_everything_copied">Skopiowano</system:String>
<system:String x:Key="wox_plugin_everything_canot_start">Nie udało się uruchomić {0}</system:String> <system:String x:Key="wox_plugin_everything_canot_start">Nie udało się uruchomić {0}</system:String>

View File

@@ -2,14 +2,14 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib"> xmlns:system="clr-namespace:System;assembly=mscorlib">
<system:String x:Key="wox_plugin_everything_is_not_running">Everything没有运行</system:String> <system:String x:Key="wox_plugin_everything_is_not_running">Everything Service 没有运行</system:String>
<system:String x:Key="wox_plugin_everything_query_error">Everything插件发生了一个错误回车拷贝具体错误信息</system:String> <system:String x:Key="wox_plugin_everything_query_error">Everything 插件发生了一个错误(回车拷贝具体错误信息)</system:String>
<system:String x:Key="wox_plugin_everything_copied">拷贝成功</system:String> <system:String x:Key="wox_plugin_everything_copied">拷贝成功</system:String>
<system:String x:Key="wox_plugin_everything_canot_start">不能启动 {0}</system:String> <system:String x:Key="wox_plugin_everything_canot_start">不能启动 {0}</system:String>
<system:String x:Key="wox_plugin_everything_open_containing_folder">打开所属文件夹</system:String> <system:String x:Key="wox_plugin_everything_open_containing_folder">打开所属文件夹</system:String>
<system:String x:Key="wox_plugin_everything_plugin_name">Everything</system:String> <system:String x:Key="wox_plugin_everything_plugin_name">Everything</system:String>
<system:String x:Key="wox_plugin_everything_plugin_description">利用Everything搜索磁盘文件</system:String> <system:String x:Key="wox_plugin_everything_plugin_description">利用 Everything 搜索磁盘文件</system:String>
<system:String x:Key="wox_plugin_everything_use_location_as_working_dir">使用应用程序的位置为可执行的工作目录</system:String> <system:String x:Key="wox_plugin_everything_use_location_as_working_dir">使用应用程序的位置为可执行的工作目录</system:String>
</ResourceDictionary> </ResourceDictionary>

View File

@@ -2,14 +2,14 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib"> xmlns:system="clr-namespace:System;assembly=mscorlib">
<system:String x:Key="wox_plugin_everything_is_not_running">Everything沒有運行</system:String> <system:String x:Key="wox_plugin_everything_is_not_running">Everything Service 沒有運行</system:String>
<system:String x:Key="wox_plugin_everything_query_error">Everything插件發生了一個錯誤回車拷貝具體錯誤信息</system:String> <system:String x:Key="wox_plugin_everything_query_error">Everything 插件發生了一個錯誤(回車拷貝具體錯誤信息)</system:String>
<system:String x:Key="wox_plugin_everything_copied">拷貝成功</system:String> <system:String x:Key="wox_plugin_everything_copied">拷貝成功</system:String>
<system:String x:Key="wox_plugin_everything_canot_start">不能啟動 {0}</system:String> <system:String x:Key="wox_plugin_everything_canot_start">不能啟動 {0}</system:String>
<system:String x:Key="wox_plugin_everything_open_containing_folder">打開所屬文件夾</system:String> <system:String x:Key="wox_plugin_everything_open_containing_folder">打開所屬文件夾</system:String>
<system:String x:Key="wox_plugin_everything_plugin_name">Everything</system:String> <system:String x:Key="wox_plugin_everything_plugin_name">Everything</system:String>
<system:String x:Key="wox_plugin_everything_plugin_description">利用Everything搜索磁盤文件</system:String> <system:String x:Key="wox_plugin_everything_plugin_description">利用 Everything 搜索磁盤文件</system:String>
<system:String x:Key="wox_plugin_everything_use_location_as_working_dir">使用应用程序的位置为可执行的工作目录</system:String> <system:String x:Key="wox_plugin_everything_use_location_as_working_dir">使用应用程序的位置为可执行的工作目录</system:String>
</ResourceDictionary> </ResourceDictionary>

View File

@@ -142,6 +142,7 @@ namespace Wox.Plugin.Everything
Helper.ValidateDataDirectory(bundledSDKDirectory, sdkDirectory); Helper.ValidateDataDirectory(bundledSDKDirectory, sdkDirectory);
var sdkPath = Path.Combine(sdkDirectory, DLL); var sdkPath = Path.Combine(sdkDirectory, DLL);
Constant.EverythingSDKPath = sdkPath;
LoadLibrary(sdkPath); LoadLibrary(sdkPath);
} }

View File

@@ -1,6 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows; using System.Windows;
using System.Windows.Forms; using System.Windows.Forms;
using Wox.Plugin.Program.ProgramSources;
namespace Wox.Plugin.Program namespace Wox.Plugin.Program
{ {
@@ -9,7 +10,7 @@ namespace Wox.Plugin.Program
/// </summary> /// </summary>
public partial class AddProgramSource public partial class AddProgramSource
{ {
private ProgramSource _editing; private FileSystemProgramSource _editing;
private Settings _settings; private Settings _settings;
public AddProgramSource(Settings settings) public AddProgramSource(Settings settings)
@@ -20,7 +21,7 @@ namespace Wox.Plugin.Program
Directory.Focus(); Directory.Focus();
} }
public AddProgramSource(ProgramSource edit, Settings settings) public AddProgramSource(FileSystemProgramSource edit, Settings settings)
{ {
_editing = edit; _editing = edit;
_settings = settings; _settings = settings;
@@ -51,12 +52,11 @@ namespace Wox.Plugin.Program
if(_editing == null) if(_editing == null)
{ {
var source = new ProgramSource var source = new FileSystemProgramSource
{ {
Location = Directory.Text, Location = Directory.Text,
MaxDepth = max, MaxDepth = max,
Suffixes = Suffixes.Text.Split(ProgramSource.SuffixSeperator), Suffixes = Suffixes.Text.Split(ProgramSource.SuffixSeperator),
Type = "FileSystemProgramSource",
Enabled = true Enabled = true
}; };
_settings.ProgramSources.Add(source); _settings.ProgramSources.Add(source);

View File

@@ -1,33 +1,31 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Wox.Infrastructure.Logger; using Wox.Infrastructure.Logger;
namespace Wox.Plugin.Program namespace Wox.Plugin.Program
{ {
internal class FileChangeWatcher internal static class FileChangeWatcher
{ {
private static bool isIndexing; private static readonly List<string> WatchedPath = new List<string>();
private static List<string> watchedPath = new List<string>();
public static void AddWatch(string path, string[] programSuffixes, bool includingSubDirectory = true) public static void AddWatch(string path, string[] programSuffixes, bool includingSubDirectory = true)
{ {
if (watchedPath.Contains(path)) return; if (WatchedPath.Contains(path)) return;
if (!Directory.Exists(path)) if (!Directory.Exists(path))
{ {
Log.Warn($"FileChangeWatcher: {path} doesn't exist"); Log.Warn($"FileChangeWatcher: {path} doesn't exist");
return; return;
} }
watchedPath.Add(path); WatchedPath.Add(path);
foreach (string fileType in programSuffixes) foreach (string fileType in programSuffixes)
{ {
FileSystemWatcher watcher = new FileSystemWatcher FileSystemWatcher watcher = new FileSystemWatcher
{ {
Path = path, Path = path,
IncludeSubdirectories = includingSubDirectory, IncludeSubdirectories = includingSubDirectory,
Filter = string.Format("*.{0}", fileType), Filter = $"*.{fileType}",
EnableRaisingEvents = true EnableRaisingEvents = true
}; };
watcher.Changed += FileChanged; watcher.Changed += FileChanged;
@@ -39,15 +37,10 @@ namespace Wox.Plugin.Program
private static void FileChanged(object source, FileSystemEventArgs e) private static void FileChanged(object source, FileSystemEventArgs e)
{ {
if (!isIndexing) Task.Run(() =>
{ {
Task.Run(() => Main.IndexPrograms();
{ });
Main.IndexPrograms();
isIndexing = false;
});
}
} }
} }
} }

View File

@@ -14,16 +14,7 @@ namespace Wox.Plugin.Program
{ {
public class Main : ISettingProvider, IPlugin, IPluginI18n, IContextMenu, ISavable public class Main : ISettingProvider, IPlugin, IPluginI18n, IContextMenu, ISavable
{ {
private static object lockObject = new object();
private static List<Program> _programs = new List<Program>(); private static List<Program> _programs = new List<Program>();
private static List<IProgramSource> _sources = new List<IProgramSource>();
private static readonly Dictionary<string, Type> SourceTypes = new Dictionary<string, Type>
{
{"FileSystemProgramSource", typeof(FileSystemProgramSource)},
{"CommonStartMenuProgramSource", typeof(CommonStartMenuProgramSource)},
{"UserStartMenuProgramSource", typeof(UserStartMenuProgramSource)},
{"AppPathsProgramSource", typeof(AppPathsProgramSource)}
};
private PluginInitContext _context; private PluginInitContext _context;
@@ -36,8 +27,15 @@ namespace Wox.Plugin.Program
{ {
_settingsStorage = new PluginJsonStorage<Settings>(); _settingsStorage = new PluginJsonStorage<Settings>();
_settings = _settingsStorage.Load(); _settings = _settingsStorage.Load();
_cacheStorage = new BinaryStorage<ProgramIndexCache>();
_cache = _cacheStorage.Load(); Stopwatch.Debug("Preload programs", () =>
{
_cacheStorage = new BinaryStorage<ProgramIndexCache>();
_cache = _cacheStorage.Load();
_programs = _cache.Programs;
});
Log.Info($"Preload {_programs.Count} programs from cache");
Stopwatch.Debug("Program Index", IndexPrograms);
} }
public void Save() public void Save()
@@ -50,29 +48,35 @@ namespace Wox.Plugin.Program
{ {
var results = _programs.AsParallel() var results = _programs.AsParallel()
.Where(p => Score(p, query.Search) > 0) .Where(p => Score(p, query.Search) > 0)
.Select(ScoreFilter)
.OrderByDescending(p => p.Score) .OrderByDescending(p => p.Score)
.Select(p => new Result .Select(ResultFromProgram)
{ .ToList();
Title = p.Title,
SubTitle = p.Path,
IcoPath = p.IcoPath,
Score = p.Score,
ContextData = p,
Action = e =>
{
var info = new ProcessStartInfo
{
FileName = p.Path,
WorkingDirectory = p.Directory
};
var hide = StartProcess(info);
return hide;
}
}).ToList();
return results; return results;
} }
public Result ResultFromProgram(Program p)
{
var result = new Result
{
Title = p.Title,
SubTitle = p.Path,
IcoPath = p.IcoPath,
Score = p.Score,
ContextData = p,
Action = e =>
{
var info = new ProcessStartInfo
{
FileName = p.Path,
WorkingDirectory = p.Directory
};
var hide = StartProcess(info);
return hide;
}
};
return result;
}
private int Score(Program program, string query) private int Score(Program program, string query)
{ {
var score1 = StringMatcher.Score(program.Title, query); var score1 = StringMatcher.Score(program.Title, query);
@@ -86,101 +90,83 @@ namespace Wox.Plugin.Program
public void Init(PluginInitContext context) public void Init(PluginInitContext context)
{ {
_context = context; _context = context;
Stopwatch.Debug("Preload programs", () =>
{
_programs = _cache.Programs;
});
Log.Info($"Preload {_programs.Count} programs from cache");
Stopwatch.Debug("Program Index", IndexPrograms);
} }
public static void IndexPrograms() public static void IndexPrograms()
{ {
// todo why there is a lock?? var sources = ProgramSources();
lock (lockObject)
{
var sources = DefaultProgramSources();
if (_settings.ProgramSources != null &&
_settings.ProgramSources.Count(o => o.Enabled) > 0)
{
sources.AddRange(_settings.ProgramSources);
}
_sources = sources.AsParallel() var programs = sources.AsParallel()
.Where(s => s.Enabled && SourceTypes.ContainsKey(s.Type)) .SelectMany(s => s.LoadPrograms())
.Select(s => // filter duplicate program
{ .GroupBy(x => new { ExecutePath = x.Path, ExecuteName = x.ExecutableName })
var sourceClass = SourceTypes[s.Type]; .Select(g => g.First());
var constructorInfo = sourceClass.GetConstructor(new[] { typeof(ProgramSource) }); programs = programs.Select(ScoreFilter);
var programSource = constructorInfo?.Invoke(new object[] { s }) as IProgramSource;
return programSource;
})
.Where(s => s != null).ToList();
_programs = _sources.AsParallel() _programs = programs.ToList();
.SelectMany(s => s.LoadPrograms()) _cache.Programs = _programs;
// filter duplicate program
.GroupBy(x => new { ExecutePath = x.Path, ExecuteName = x.ExecutableName })
.Select(g => g.First())
.ToList();
_cache.Programs = _programs;
}
} }
/// <summary> private static List<ProgramSource> ProgramSources()
/// Load program sources that wox always provide
/// </summary>
private static List<ProgramSource> DefaultProgramSources()
{ {
var list = new List<ProgramSource> var sources = new List<ProgramSource>
{ {
new ProgramSource new CommonStartMenuProgramSource
{ {
BonusPoints = 0, BonusPoints = 0,
Enabled = _settings.EnableStartMenuSource, Enabled = _settings.EnableStartMenuSource,
Type = "CommonStartMenuProgramSource"
}, },
new ProgramSource new UserStartMenuProgramSource
{ {
BonusPoints = 0, BonusPoints = 0,
Enabled = _settings.EnableStartMenuSource, Enabled = _settings.EnableStartMenuSource,
Type = "UserStartMenuProgramSource"
}, },
new ProgramSource new AppPathsProgramSource
{ {
BonusPoints = -10, BonusPoints = -10,
Enabled = _settings.EnableRegistrySource, Enabled = _settings.EnableRegistrySource,
Type = "AppPathsProgramSource"
} }
}; };
return list;
if (_settings.ProgramSources.Count(o => o.Enabled) > 0)
{
sources.AddRange(_settings.ProgramSources);
}
return sources;
} }
private Program ScoreFilter(Program p) private static Program ScoreFilter(Program p)
{ {
p.Score += p.Source.BonusPoints; p.Score += p.Source.BonusPoints;
var start = new[] { "启动", "start" };
var doc = new[] { "帮助", "help", "文档", "documentation" };
var uninstall = new[] { "卸载", "uninstall" };
if (p.Title.Contains("启动") || p.Title.ToLower().Contains("start")) var contained = start.Any(s => p.Title.ToLower().Contains(s));
if (contained)
{
p.Score += 10; p.Score += 10;
}
if (p.Title.Contains("帮助") || p.Title.ToLower().Contains("help") || p.Title.Contains("文档") || p.Title.ToLower().Contains("documentation")) contained = doc.Any(d => p.Title.ToLower().Contains(d));
if (contained)
{
p.Score -= 10; p.Score -= 10;
}
if (p.Title.Contains("卸载") || p.Title.ToLower().Contains("uninstall")) contained = uninstall.Any(u => p.Title.ToLower().Contains(u));
if (contained)
{
p.Score -= 20; p.Score -= 20;
}
return p; return p;
} }
#region ISettingProvider Members
public Control CreateSettingPanel() public Control CreateSettingPanel()
{ {
return new ProgramSetting(_context, _settings); return new ProgramSetting(_context, _settings);
} }
#endregion
public string GetTranslatedPluginTitle() public string GetTranslatedPluginTitle()
{ {
return _context.API.GetTranslation("wox_plugin_program_plugin_name"); return _context.API.GetTranslation("wox_plugin_program_plugin_name");

View File

@@ -2,6 +2,7 @@ using System;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading; using System.Threading;
using Wox.Infrastructure; using Wox.Infrastructure;
using Wox.Plugin.Program.ProgramSources;
namespace Wox.Plugin.Program namespace Wox.Plugin.Program
{ {
@@ -14,6 +15,6 @@ namespace Wox.Plugin.Program
public string Directory { get; set; } public string Directory { get; set; }
public string ExecutableName { get; set; } public string ExecutableName { get; set; }
public int Score { get; set; } public int Score { get; set; }
public IProgramSource Source { get; set; } public ProgramSource Source { get; set; }
} }
} }

View File

@@ -2,6 +2,7 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using Wox.Plugin.Program.ProgramSources;
namespace Wox.Plugin.Program namespace Wox.Plugin.Program
{ {
@@ -50,7 +51,7 @@ namespace Wox.Plugin.Program
private void btnDeleteProgramSource_OnClick(object sender, RoutedEventArgs e) private void btnDeleteProgramSource_OnClick(object sender, RoutedEventArgs e)
{ {
ProgramSource selectedProgramSource = programSourceView.SelectedItem as ProgramSource; var selectedProgramSource = programSourceView.SelectedItem as FileSystemProgramSource;
if (selectedProgramSource != null) if (selectedProgramSource != null)
{ {
string msg = string.Format(context.API.GetTranslation("wox_plugin_program_delete_program_source"), selectedProgramSource.Location); string msg = string.Format(context.API.GetTranslation("wox_plugin_program_delete_program_source"), selectedProgramSource.Location);
@@ -70,7 +71,7 @@ namespace Wox.Plugin.Program
private void btnEditProgramSource_OnClick(object sender, RoutedEventArgs e) private void btnEditProgramSource_OnClick(object sender, RoutedEventArgs e)
{ {
ProgramSource selectedProgramSource = programSourceView.SelectedItem as ProgramSource; var selectedProgramSource = programSourceView.SelectedItem as FileSystemProgramSource;
if (selectedProgramSource != null) if (selectedProgramSource != null)
{ {
var add = new AddProgramSource(selectedProgramSource, _settings); var add = new AddProgramSource(selectedProgramSource, _settings);
@@ -119,10 +120,9 @@ namespace Wox.Plugin.Program
{ {
if (Directory.Exists(s)) if (Directory.Exists(s))
{ {
_settings.ProgramSources.Add(new ProgramSource _settings.ProgramSources.Add(new FileSystemProgramSource
{ {
Location = s, Location = s,
Type = "FileSystemProgramSource",
Enabled = true Enabled = true
}); });

View File

@@ -1,24 +0,0 @@
using System;
using System.Collections.Generic;
namespace Wox.Plugin.Program
{
[Serializable]
public class ProgramSource
{
public string Location { get; set; }
public string Type { get; set; }
public int BonusPoints { get; set; }
public bool Enabled { get; set; }
// happlebao todo: temp hack for program suffixes
public string[] Suffixes { get; set; } = {"bat", "appref-ms", "exe", "lnk"};
public const char SuffixSeperator = ';';
public int MaxDepth { get; set; }
public Dictionary<string, string> Meta { get; set; }
public override string ToString()
{
return (Type ?? "") + ":" + Location ?? "";
}
}
}

View File

@@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.IO; using System.IO;
using Microsoft.Win32; using Microsoft.Win32;
using Wox.Infrastructure.Logger; using Wox.Infrastructure.Logger;
@@ -8,24 +7,19 @@ using Wox.Infrastructure.Logger;
namespace Wox.Plugin.Program.ProgramSources namespace Wox.Plugin.Program.ProgramSources
{ {
[Serializable] [Serializable]
[Browsable(false)] public class AppPathsProgramSource : ProgramSource
public class AppPathsProgramSource : AbstractProgramSource
{ {
public AppPathsProgramSource() public AppPathsProgramSource()
{ {
BonusPoints = -10; BonusPoints = -10;
} }
public AppPathsProgramSource(ProgramSource source) : this()
{
BonusPoints = source.BonusPoints;
}
public override List<Program> LoadPrograms() public override List<Program> LoadPrograms()
{ {
var list = new List<Program>(); var list = new List<Program>();
ReadAppPaths(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths", list); ReadAppPaths(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths", list);
ReadAppPaths(@"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\App Paths", list); //TODO: need test more on 64-bit ReadAppPaths(@"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\App Paths", list);
//TODO: need test more on 64-bit
return list; return list;
} }
@@ -40,12 +34,12 @@ namespace Wox.Plugin.Program.ProgramSources
{ {
using (var key = root.OpenSubKey(item)) using (var key = root.OpenSubKey(item))
{ {
string path = key.GetValue("") as string; var path = key.GetValue("") as string;
if (string.IsNullOrEmpty(path)) continue; if (string.IsNullOrEmpty(path)) continue;
// fix path like this ""\"C:\\folder\\executable.exe\""" // fix path like this ""\"C:\\folder\\executable.exe\"""
const int begin = 0; const int begin = 0;
int end = path.Length - 1; var end = path.Length - 1;
const char quotationMark = '"'; const char quotationMark = '"';
if (path[begin] == quotationMark && path[end] == quotationMark) if (path[begin] == quotationMark && path[end] == quotationMark)
{ {
@@ -66,10 +60,5 @@ namespace Wox.Plugin.Program.ProgramSources
} }
} }
} }
public override string ToString()
{
return typeof(AppPathsProgramSource).Name;
}
} }
} }

View File

@@ -1,40 +1,30 @@
using System; using System;
using System.ComponentModel;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
namespace Wox.Plugin.Program.ProgramSources namespace Wox.Plugin.Program.ProgramSources
{ {
[Serializable] [Serializable]
[Browsable(false)] public sealed class CommonStartMenuProgramSource : FileSystemProgramSource
public class CommonStartMenuProgramSource : FileSystemProgramSource
{ {
private const int CSIDL_COMMON_PROGRAMS = 0x17;
// todo happlebao how to pass location before loadPrograms
public CommonStartMenuProgramSource()
{
Location = getPath();
}
[DllImport("shell32.dll")] [DllImport("shell32.dll")]
static extern bool SHGetSpecialFolderPath(IntPtr hwndOwner, [Out] StringBuilder lpszPath, int nFolder, bool fCreate); private static extern bool SHGetSpecialFolderPath(IntPtr hwndOwner, [Out] StringBuilder lpszPath, int nFolder,
const int CSIDL_COMMON_PROGRAMS = 0x17; bool fCreate);
private static string getPath() private static string getPath()
{ {
StringBuilder commonStartMenuPath = new StringBuilder(560); var commonStartMenuPath = new StringBuilder(560);
SHGetSpecialFolderPath(IntPtr.Zero, commonStartMenuPath, CSIDL_COMMON_PROGRAMS, false); SHGetSpecialFolderPath(IntPtr.Zero, commonStartMenuPath, CSIDL_COMMON_PROGRAMS, false);
return commonStartMenuPath.ToString(); return commonStartMenuPath.ToString();
} }
public CommonStartMenuProgramSource(string[] suffixes)
: base(getPath(), suffixes)
{
}
public CommonStartMenuProgramSource(ProgramSource source)
: this(source.Suffixes)
{
BonusPoints = source.BonusPoints;
}
public override string ToString()
{
return typeof(CommonStartMenuProgramSource).Name;
}
} }
} }

View File

@@ -8,35 +8,17 @@ using Wox.Infrastructure.Logger;
namespace Wox.Plugin.Program.ProgramSources namespace Wox.Plugin.Program.ProgramSources
{ {
[Serializable] [Serializable]
public class FileSystemProgramSource : AbstractProgramSource public class FileSystemProgramSource : ProgramSource
{ {
private string _baseDirectory; public string Location { get; set; } = "";
private int _maxDepth;
private string[] _suffixes;
public FileSystemProgramSource(string baseDirectory, int maxDepth, string[] suffixes)
{
_baseDirectory = baseDirectory;
_maxDepth = maxDepth;
_suffixes = suffixes;
}
public FileSystemProgramSource(string baseDirectory, string[] suffixes)
: this(baseDirectory, -1, suffixes) {}
public FileSystemProgramSource(ProgramSource source)
: this(source.Location, source.MaxDepth, source.Suffixes)
{
BonusPoints = source.BonusPoints;
}
public override List<Program> LoadPrograms() public override List<Program> LoadPrograms()
{ {
List<Program> list = new List<Program>(); var list = new List<Program>();
if (Directory.Exists(_baseDirectory)) if (Directory.Exists(Location))
{ {
GetAppFromDirectory(_baseDirectory, list); GetAppFromDirectory(Location, list);
FileChangeWatcher.AddWatch(_baseDirectory, _suffixes); FileChangeWatcher.AddWatch(Location, Suffixes);
} }
return list; return list;
} }
@@ -48,17 +30,17 @@ namespace Wox.Plugin.Program.ProgramSources
private void GetAppFromDirectory(string path, List<Program> list, int depth) private void GetAppFromDirectory(string path, List<Program> list, int depth)
{ {
if(_maxDepth != -1 && depth > _maxDepth) if (MaxDepth != -1 && depth > MaxDepth)
{ {
return; return;
} }
try try
{ {
foreach (string file in Directory.GetFiles(path)) foreach (var file in Directory.GetFiles(path))
{ {
if (_suffixes.Any(o => file.EndsWith("." + o))) if (Suffixes.Any(o => file.EndsWith("." + o)))
{ {
Program p = CreateEntry(file); var p = CreateEntry(file);
p.Source = this; p.Source = this;
list.Add(p); list.Add(p);
} }
@@ -75,10 +57,10 @@ namespace Wox.Plugin.Program.ProgramSources
Log.Exception(woxPluginException); Log.Exception(woxPluginException);
} }
} }
public override string ToString() public override string ToString()
{ {
return typeof(FileSystemProgramSource).Name + ":" + _baseDirectory; var display = GetType().Name + Location;
return display;
} }
} }
} }

View File

@@ -3,20 +3,20 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
namespace Wox.Plugin.Program namespace Wox.Plugin.Program.ProgramSources
{ {
public interface IProgramSource
{
List<Program> LoadPrograms();
int BonusPoints { get; set; }
}
[Serializable] [Serializable]
public abstract class AbstractProgramSource : IProgramSource public abstract class ProgramSource
{ {
public abstract List<Program> LoadPrograms(); public const char SuffixSeperator = ';';
public int BonusPoints { get; set; } = 0;
public bool Enabled { get; set; } = true;
// happlebao todo: temp hack for program suffixes
public string[] Suffixes { get; set; } = {"bat", "appref-ms", "exe", "lnk"};
public int MaxDepth { get; set; } = -1;
public int BonusPoints { get; set; } public abstract List<Program> LoadPrograms();
protected Program CreateEntry(string file) protected Program CreateEntry(string file)
{ {
@@ -34,16 +34,18 @@ namespace Wox.Plugin.Program
p.ExecutableName = Path.GetFileName(file); p.ExecutableName = Path.GetFileName(file);
try try
{ {
FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(file); var versionInfo = FileVersionInfo.GetVersionInfo(file);
if (!string.IsNullOrEmpty(versionInfo.FileDescription)) if (!string.IsNullOrEmpty(versionInfo.FileDescription))
{ {
p.Title = versionInfo.FileDescription; p.Title = versionInfo.FileDescription;
} }
} }
catch (Exception) { } catch (Exception)
{
}
break; break;
} }
return p; return p;
} }
} }
} }

View File

@@ -1,26 +1,14 @@
using System; using System;
using System.ComponentModel;
namespace Wox.Plugin.Program.ProgramSources namespace Wox.Plugin.Program.ProgramSources
{ {
[Serializable] [Serializable]
[Browsable(false)] public sealed class UserStartMenuProgramSource : FileSystemProgramSource
public class UserStartMenuProgramSource : FileSystemProgramSource
{ {
public UserStartMenuProgramSource(string[] suffixes) public UserStartMenuProgramSource()
: base(Environment.GetFolderPath(Environment.SpecialFolder.Programs), suffixes)
{ {
} Location = Environment.GetFolderPath(Environment.SpecialFolder.Programs);
public UserStartMenuProgramSource(ProgramSource source)
: this(source.Suffixes)
{
BonusPoints = source.BonusPoints;
}
public override string ToString()
{
return typeof(UserStartMenuProgramSource).Name;
} }
} }
} }

View File

@@ -1,5 +1,6 @@
using System.Windows; using System.Windows;
using System.Linq; using System.Linq;
using Wox.Plugin.Program.ProgramSources;
namespace Wox.Plugin.Program namespace Wox.Plugin.Program
{ {

View File

@@ -1,12 +1,12 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using Wox.Plugin.Program.ProgramSources;
namespace Wox.Plugin.Program namespace Wox.Plugin.Program
{ {
public class Settings public class Settings
{ {
public List<ProgramSource> ProgramSources { get; set; } = new List<ProgramSource>(); public List<FileSystemProgramSource> ProgramSources { get; set; } = new List<FileSystemProgramSource>();
public string[] ProgramSuffixes { get; set; } = {"bat", "appref-ms", "exe", "lnk"}; public string[] ProgramSuffixes { get; set; } = {"bat", "appref-ms", "exe", "lnk"};
public bool EnableStartMenuSource { get; set; } = true; public bool EnableStartMenuSource { get; set; } = true;

View File

@@ -61,7 +61,6 @@
<DependentUpon>AddProgramSource.xaml</DependentUpon> <DependentUpon>AddProgramSource.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="FileChangeWatcher.cs" /> <Compile Include="FileChangeWatcher.cs" />
<Compile Include="IProgramSource.cs" />
<Compile Include="SuffixesConverter.cs" /> <Compile Include="SuffixesConverter.cs" />
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="ProgramIndexCache.cs" /> <Compile Include="ProgramIndexCache.cs" />
@@ -69,7 +68,7 @@
<Compile Include="ProgramSetting.xaml.cs"> <Compile Include="ProgramSetting.xaml.cs">
<DependentUpon>ProgramSetting.xaml</DependentUpon> <DependentUpon>ProgramSetting.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="ProgramSource.cs" /> <Compile Include="ProgramSources\ProgramSource.cs" />
<Compile Include="ProgramSources\AppPathsProgramSource.cs" /> <Compile Include="ProgramSources\AppPathsProgramSource.cs" />
<Compile Include="ProgramSources\CommonStartMenuProgramSource.cs" /> <Compile Include="ProgramSources\CommonStartMenuProgramSource.cs" />
<Compile Include="ProgramSources\FileSystemProgramSource.cs" /> <Compile Include="ProgramSources\FileSystemProgramSource.cs" />

View File

@@ -5,6 +5,7 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Windows; using System.Windows;
using WindowsInput; using WindowsInput;
using WindowsInput.Native;
using Wox.Infrastructure.Hotkey; using Wox.Infrastructure.Hotkey;
using Wox.Infrastructure.Logger; using Wox.Infrastructure.Logger;
using Wox.Infrastructure.Storage; using Wox.Infrastructure.Storage;
@@ -12,19 +13,19 @@ using Application = System.Windows.Application;
using Control = System.Windows.Controls.Control; using Control = System.Windows.Controls.Control;
using Keys = System.Windows.Forms.Keys; using Keys = System.Windows.Forms.Keys;
namespace Wox.Plugin.CMD namespace Wox.Plugin.Shell
{ {
public class CMD : IPlugin, ISettingProvider, IPluginI18n, IContextMenu, ISavable public class Main : IPlugin, ISettingProvider, IPluginI18n, IContextMenu, ISavable
{ {
private const string Image = "Images/shell.png"; private const string Image = "Images/shell.png";
private PluginInitContext context; private PluginInitContext _context;
private bool WinRStroked; private bool _winRStroked;
private readonly KeyboardSimulator keyboardSimulator = new KeyboardSimulator(new InputSimulator()); private readonly KeyboardSimulator _keyboardSimulator = new KeyboardSimulator(new InputSimulator());
private readonly Settings _settings; private readonly Settings _settings;
private readonly PluginJsonStorage<Settings> _storage; private readonly PluginJsonStorage<Settings> _storage;
public CMD() public Main()
{ {
_storage = new PluginJsonStorage<Settings>(); _storage = new PluginJsonStorage<Settings>();
_settings = _storage.Load(); _settings = _storage.Load();
@@ -104,14 +105,14 @@ namespace Wox.Plugin.CMD
{ {
if (m.Key == cmd) if (m.Key == cmd)
{ {
result.SubTitle = string.Format(context.API.GetTranslation("wox_plugin_cmd_cmd_has_been_executed_times"), m.Value); result.SubTitle = string.Format(_context.API.GetTranslation("wox_plugin_cmd_cmd_has_been_executed_times"), m.Value);
return null; return null;
} }
var ret = new Result var ret = new Result
{ {
Title = m.Key, Title = m.Key,
SubTitle = string.Format(context.API.GetTranslation("wox_plugin_cmd_cmd_has_been_executed_times"), m.Value), SubTitle = string.Format(_context.API.GetTranslation("wox_plugin_cmd_cmd_has_been_executed_times"), m.Value),
IcoPath = Image, IcoPath = Image,
Action = c => Action = c =>
{ {
@@ -130,7 +131,7 @@ namespace Wox.Plugin.CMD
{ {
Title = cmd, Title = cmd,
Score = 5000, Score = 5000,
SubTitle = context.API.GetTranslation("wox_plugin_cmd_execute_through_shell"), SubTitle = _context.API.GetTranslation("wox_plugin_cmd_execute_through_shell"),
IcoPath = Image, IcoPath = Image,
Action = c => Action = c =>
{ {
@@ -148,7 +149,7 @@ namespace Wox.Plugin.CMD
.Select(m => new Result .Select(m => new Result
{ {
Title = m.Key, Title = m.Key,
SubTitle = string.Format(context.API.GetTranslation("wox_plugin_cmd_cmd_has_been_executed_times"), m.Value), SubTitle = string.Format(_context.API.GetTranslation("wox_plugin_cmd_cmd_has_been_executed_times"), m.Value),
IcoPath = Image, IcoPath = Image,
Action = c => Action = c =>
{ {
@@ -165,7 +166,7 @@ namespace Wox.Plugin.CMD
command = Environment.ExpandEnvironmentVariables(command); command = Environment.ExpandEnvironmentVariables(command);
ProcessStartInfo info; ProcessStartInfo info;
if (_settings.Shell == Shell.CMD) if (_settings.Shell == Shell.Cmd)
{ {
var arguments = _settings.LeaveShellOpen ? $"/k \"{command}\"" : $"/c \"{command}\" & pause"; var arguments = _settings.LeaveShellOpen ? $"/k \"{command}\"" : $"/c \"{command}\" & pause";
info = new ProcessStartInfo info = new ProcessStartInfo
@@ -268,7 +269,7 @@ namespace Wox.Plugin.CMD
public void Init(PluginInitContext context) public void Init(PluginInitContext context)
{ {
this.context = context; this._context = context;
context.API.GlobalKeyboardEvent += API_GlobalKeyboardEvent; context.API.GlobalKeyboardEvent += API_GlobalKeyboardEvent;
} }
@@ -278,13 +279,14 @@ namespace Wox.Plugin.CMD
{ {
if (keyevent == (int)KeyEvent.WM_KEYDOWN && vkcode == (int)Keys.R && state.WinPressed) if (keyevent == (int)KeyEvent.WM_KEYDOWN && vkcode == (int)Keys.R && state.WinPressed)
{ {
WinRStroked = true; _winRStroked = true;
OnWinRPressed(); OnWinRPressed();
return false; return false;
} }
if (keyevent == (int)KeyEvent.WM_KEYUP && WinRStroked && vkcode == (int)Keys.LWin) if (keyevent == (int)KeyEvent.WM_KEYUP && _winRStroked && vkcode == (int)Keys.LWin)
{ {
WinRStroked = false; _winRStroked = false;
_keyboardSimulator.ModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.CONTROL);
return false; return false;
} }
} }
@@ -293,7 +295,7 @@ namespace Wox.Plugin.CMD
private void OnWinRPressed() private void OnWinRPressed()
{ {
context.API.ChangeQuery($"{context.CurrentPluginMetadata.ActionKeywords[0]}{Plugin.Query.TermSeperater}"); _context.API.ChangeQuery($"{_context.CurrentPluginMetadata.ActionKeywords[0]}{Plugin.Query.TermSeperater}");
Application.Current.MainWindow.Visibility = Visibility.Visible; Application.Current.MainWindow.Visibility = Visibility.Visible;
} }
@@ -304,12 +306,12 @@ namespace Wox.Plugin.CMD
public string GetTranslatedPluginTitle() public string GetTranslatedPluginTitle()
{ {
return context.API.GetTranslation("wox_plugin_cmd_plugin_name"); return _context.API.GetTranslation("wox_plugin_cmd_plugin_name");
} }
public string GetTranslatedPluginDescription() public string GetTranslatedPluginDescription()
{ {
return context.API.GetTranslation("wox_plugin_cmd_plugin_description"); return _context.API.GetTranslation("wox_plugin_cmd_plugin_description");
} }
public List<Result> LoadContextMenus(Result selectedResult) public List<Result> LoadContextMenus(Result selectedResult)
@@ -318,7 +320,7 @@ namespace Wox.Plugin.CMD
{ {
new Result new Result
{ {
Title = context.API.GetTranslation("wox_plugin_cmd_run_as_administrator"), Title = _context.API.GetTranslation("wox_plugin_cmd_run_as_administrator"),
Action = c => Action = c =>
{ {
Execute(selectedResult.Title, true); Execute(selectedResult.Title, true);

View File

@@ -1,10 +1,10 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace Wox.Plugin.CMD namespace Wox.Plugin.Shell
{ {
public class Settings public class Settings
{ {
public Shell Shell { get; set; } = Shell.CMD; public Shell Shell { get; set; } = Shell.Cmd;
public bool ReplaceWinR { get; set; } = true; public bool ReplaceWinR { get; set; } = true;
public bool LeaveShellOpen { get; set; } public bool LeaveShellOpen { get; set; }
public Dictionary<string, int> Count = new Dictionary<string, int>(); public Dictionary<string, int> Count = new Dictionary<string, int>();
@@ -24,7 +24,7 @@ namespace Wox.Plugin.CMD
public enum Shell public enum Shell
{ {
CMD = 0, Cmd = 0,
Powershell = 1, Powershell = 1,
RunCommand = 2, RunCommand = 2,

View File

@@ -1,4 +1,4 @@
<UserControl x:Class="Wox.Plugin.CMD.CMDSetting" <UserControl x:Class="Wox.Plugin.Shell.CMDSetting"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

View File

@@ -1,7 +1,7 @@
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
namespace Wox.Plugin.CMD namespace Wox.Plugin.Shell
{ {
public partial class CMDSetting : UserControl public partial class CMDSetting : UserControl
{ {

View File

@@ -96,11 +96,10 @@ namespace Wox.Plugin.WebSearch
private void EditSearchSource() private void EditSearchSource()
{ {
var keyword = _searchSource.ActionKeyword; var newKeyword = _searchSource.ActionKeyword;
if (!PluginManager.ActionKeywordRegistered(keyword)) var oldKeyword = _oldSearchSource.ActionKeyword;
if (!PluginManager.ActionKeywordRegistered(newKeyword) || oldKeyword == newKeyword)
{ {
var newKeyword = keyword;
var oldKeyword = _oldSearchSource.ActionKeyword;
var id = _context.CurrentPluginMetadata.ID; var id = _context.CurrentPluginMetadata.ID;
PluginManager.ReplaceActionKeyword(id, oldKeyword, newKeyword); PluginManager.ReplaceActionKeyword(id, oldKeyword, newKeyword);

View File

@@ -5,6 +5,7 @@ WoX
[![Build status](https://ci.appveyor.com/api/projects/status/bfktntbivg32e103)](https://ci.appveyor.com/project/happlebao/wox) [![Build status](https://ci.appveyor.com/api/projects/status/bfktntbivg32e103)](https://ci.appveyor.com/project/happlebao/wox)
[![Github All Releases](https://img.shields.io/github/downloads/Wox-launcher/Wox/total.svg)](https://github.com/Wox-launcher/Wox/releases) [![Github All Releases](https://img.shields.io/github/downloads/Wox-launcher/Wox/total.svg)](https://github.com/Wox-launcher/Wox/releases)
[![Issue Stats](http://issuestats.com/github/Wox-launcher/Wox/badge/pr)](http://issuestats.com/github/Wox-launcher/Wox) [![Issue Stats](http://issuestats.com/github/Wox-launcher/Wox/badge/pr)](http://issuestats.com/github/Wox-launcher/Wox)
[![RamenBless](https://cdn.rawgit.com/LunaGao/BlessYourCodeTag/master/tags/ramen.svg)](https://github.com/LunaGao/BlessYourCodeTag)
**WoX** is a launcher for Windows that simply works. It's an alternative to [Alfred](https://www.alfredapp.com/) and [Launchy](http://www.launchy.net/). You can call it Windows omni-eXecutor if you want a long name. **WoX** is a launcher for Windows that simply works. It's an alternative to [Alfred](https://www.alfredapp.com/) and [Launchy](http://www.launchy.net/). You can call it Windows omni-eXecutor if you want a long name.

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using Wox.Infrastructure;
using Wox.Infrastructure.Exception; using Wox.Infrastructure.Exception;
using Wox.Infrastructure.Logger; using Wox.Infrastructure.Logger;
using Wox.Infrastructure.UserSettings; using Wox.Infrastructure.UserSettings;
@@ -113,6 +114,7 @@ namespace Wox.Core.Plugin
return new List<PluginPair>(); return new List<PluginPair>();
} }
} }
Constant.PythonPath = filename;
var plugins = metadatas.Select(metadata => new PluginPair var plugins = metadatas.Select(metadata => new PluginPair
{ {
Plugin = new PythonPlugin(filename), Plugin = new PythonPlugin(filename),

View File

@@ -59,7 +59,7 @@ namespace Wox.Core.Resource
// Exception of FindResource can't be cathed if global exception handle is set // Exception of FindResource can't be cathed if global exception handle is set
var isBlur = Application.Current.TryFindResource("ThemeBlurEnabled"); var isBlur = Application.Current.TryFindResource("ThemeBlurEnabled");
if (isBlur is bool) if (isBlur is bool && Environment.OSVersion.Version >= new Version(6, 2))
{ {
SetBlurForWindow(Application.Current.MainWindow, (bool)isBlur); SetBlurForWindow(Application.Current.MainWindow, (bool)isBlur);
} }

View File

@@ -24,54 +24,52 @@ namespace Wox.Infrastructure.Exception
sb.AppendLine(); sb.AppendLine();
sb.AppendLine("```"); sb.AppendLine("```");
var exlist = new List<StringBuilder>(); var exlist = new List<StringBuilder>();
while (ex != null) while (ex != null)
{
var exsb = new StringBuilder();
exsb.Append(ex.GetType().FullName);
exsb.Append(": ");
exsb.AppendLine(ex.Message);
if (ex.Source != null)
{ {
var exsb = new StringBuilder(); exsb.Append(" Source: ");
exsb.Append(ex.GetType().FullName); exsb.AppendLine(ex.Source);
exsb.Append(": ");
exsb.AppendLine(ex.Message);
if (ex.Source != null)
{
exsb.Append(" Source: ");
exsb.AppendLine(ex.Source);
}
if (ex.TargetSite != null)
{
exsb.Append(" TargetAssembly: ");
exsb.AppendLine(ex.TargetSite.Module.Assembly.ToString());
exsb.Append(" TargetModule: ");
exsb.AppendLine(ex.TargetSite.Module.ToString());
exsb.Append(" TargetSite: ");
exsb.AppendLine(ex.TargetSite.ToString());
}
exsb.AppendLine(ex.StackTrace);
exlist.Add(exsb);
ex = ex.InnerException;
} }
if (ex.TargetSite != null)
foreach (var result in exlist.Select(o => o.ToString()).Reverse())
{ {
sb.AppendLine(result); exsb.Append(" TargetAssembly: ");
exsb.AppendLine(ex.TargetSite.Module.Assembly.ToString());
exsb.Append(" TargetModule: ");
exsb.AppendLine(ex.TargetSite.Module.ToString());
exsb.Append(" TargetSite: ");
exsb.AppendLine(ex.TargetSite.ToString());
} }
sb.AppendLine("```"); exsb.AppendLine(ex.StackTrace);
sb.AppendLine(); exlist.Add(exsb);
ex = ex.InnerException;
}
foreach (var result in exlist.Select(o => o.ToString()).Reverse())
{
sb.AppendLine(result);
}
sb.AppendLine("```");
sb.AppendLine();
sb.AppendLine("## Environment"); sb.AppendLine("## Environment");
sb.AppendLine(); sb.AppendLine($"* Command Line: {Environment.CommandLine}");
sb.Append("* Command Line: "); sb.AppendLine($"* Timestamp: {DateTime.Now.ToString(CultureInfo.InvariantCulture)}");
sb.AppendLine(Environment.CommandLine); sb.AppendLine($"* Wox version: {Constant.Version}");
sb.Append("* Timestamp: "); sb.AppendLine($"* OS Version: {Environment.OSVersion.VersionString}");
sb.AppendLine(DateTime.Now.ToString(CultureInfo.InvariantCulture)); sb.AppendLine($"* IntPtr Length: {IntPtr.Size}");
sb.Append("* IntPtr Length: "); sb.AppendLine($"* x64: {Environment.Is64BitOperatingSystem}");
sb.AppendLine(IntPtr.Size.ToString()); sb.AppendLine($"* Python Path: {Constant.PythonPath}");
sb.Append("* System Version: "); sb.AppendLine($"* Everything SDK Path: {Constant.EverythingSDKPath}");
sb.AppendLine(Environment.OSVersion.VersionString); sb.AppendLine($"* CLR Version: {Environment.Version}");
sb.Append("* CLR Version: "); sb.AppendLine($"* Installed .NET Framework: ");
sb.AppendLine(Environment.Version.ToString());
sb.AppendLine("* Installed .NET Framework: ");
foreach (var result in GetFrameworkVersionFromRegistry()) foreach (var result in GetFrameworkVersionFromRegistry())
{ {
sb.Append(" * "); sb.Append(" * ");

View File

@@ -21,5 +21,8 @@ namespace Wox.Infrastructure
public const string Github = "https://github.com/Wox-launcher/Wox"; public const string Github = "https://github.com/Wox-launcher/Wox";
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 string PythonPath;
public static string EverythingSDKPath;
} }
} }

View File

@@ -70,9 +70,6 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.Calculator", "Plugins\Wox.Plugin.Calculator\Wox.Plugin.Calculator.csproj", "{59BD9891-3837-438A-958D-ADC7F91F6F7E}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.Calculator", "Plugins\Wox.Plugin.Calculator\Wox.Plugin.Calculator.csproj", "{59BD9891-3837-438A-958D-ADC7F91F6F7E}"
EndProject EndProject
Global Global
GlobalSection(Performance) = preSolution
HasPerformanceSessions = true
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64 Debug|x64 = Debug|x64

View File

@@ -60,10 +60,7 @@ namespace Wox
AutoStartup(); AutoStartup();
AutoUpdates(); AutoUpdates();
if (!_settings.HideOnStartup) mainVM.MainWindowVisibility = _settings.HideOnStartup ? Visibility.Hidden : Visibility.Visible;
{
mainVM.MainWindowVisibility = Visibility.Visible;
}
}); });
} }
@@ -102,7 +99,7 @@ namespace Wox
} }
/// <summary> /// <summary>
/// let exception throw as normal is better for Debug /// let exception throw as normal is better for Debug
/// </summary> /// </summary>
[Conditional("RELEASE")] [Conditional("RELEASE")]
private void RegisterDispatcherUnhandledException() private void RegisterDispatcherUnhandledException()
@@ -113,7 +110,7 @@ namespace Wox
/// <summary> /// <summary>
/// let exception throw as normal is better for Debug /// let exception throw as normal is better for Debug
/// </summary> /// </summary>
[Conditional("RELEASE")] [Conditional("RELEASE")]
private static void RegisterAppDomainExceptions() private static void RegisterAppDomainExceptions()

View File

@@ -17,6 +17,7 @@
Icon="Images\app.png" Icon="Images\app.png"
AllowsTransparency="True" AllowsTransparency="True"
Loaded="OnLoaded" Loaded="OnLoaded"
Initialized="OnInitialized"
Closing="OnClosing" Closing="OnClosing"
Drop="OnDrop" Drop="OnDrop"
SizeChanged="OnSizeChanged" SizeChanged="OnSizeChanged"

View File

@@ -46,11 +46,16 @@ namespace Wox
_viewModel.Save(); _viewModel.Save();
} }
private void OnInitialized(object sender, EventArgs e)
{
// show notify icon when wox is hided
InitializeNotifyIcon();
}
private void OnLoaded(object sender, RoutedEventArgs _) private void OnLoaded(object sender, RoutedEventArgs _)
{ {
WindowIntelopHelper.DisableControlBox(this); WindowIntelopHelper.DisableControlBox(this);
ThemeManager.Instance.ChangeTheme(_settings.Theme); ThemeManager.Instance.ChangeTheme(_settings.Theme);
InitializeNotifyIcon();
InitProgressbarAnimation(); InitProgressbarAnimation();
_viewModel.PropertyChanged += (o, e) => _viewModel.PropertyChanged += (o, e) =>
@@ -230,7 +235,11 @@ namespace Wox
private void OnTextChanged(object sender, TextChangedEventArgs e) private void OnTextChanged(object sender, TextChangedEventArgs e)
{ {
QueryTextBox.CaretIndex = QueryTextBox.Text.Length; if (_viewModel.QueryTextCursorMovedToEnd)
{
QueryTextBox.CaretIndex = QueryTextBox.Text.Length;
_viewModel.QueryTextCursorMovedToEnd = false;
}
} }
} }
} }

View File

@@ -36,12 +36,12 @@ namespace Wox
public void ChangeQuery(string query, bool requery = false) public void ChangeQuery(string query, bool requery = false)
{ {
_mainVM.QueryText = query; _mainVM.ChangeQueryText(query);
} }
public void ChangeQueryText(string query, bool selectAll = false) public void ChangeQueryText(string query, bool selectAll = false)
{ {
_mainVM.QueryText = query; _mainVM.ChangeQueryText(query);
} }
[Obsolete] [Obsolete]

View File

@@ -34,6 +34,10 @@ namespace Wox
StringBuilder content = new StringBuilder(); StringBuilder content = new StringBuilder();
content.AppendLine($"Wox version: {Constant.Version}"); content.AppendLine($"Wox version: {Constant.Version}");
content.AppendLine($"OS Version: {Environment.OSVersion.VersionString}"); content.AppendLine($"OS Version: {Environment.OSVersion.VersionString}");
content.AppendLine($"IntPtr Length: {IntPtr.Size}");
content.AppendLine($"x64: {Environment.Is64BitOperatingSystem}");
content.AppendLine($"Python Path: {Constant.PythonPath}");
content.AppendLine($"Everything SDK Path: {Constant.EverythingSDKPath}");
content.AppendLine($"Date: {DateTime.Now.ToString(CultureInfo.InvariantCulture)}"); content.AppendLine($"Date: {DateTime.Now.ToString(CultureInfo.InvariantCulture)}");
content.AppendLine("Exception:"); content.AppendLine("Exception:");
content.AppendLine(exception.Source); content.AppendLine(exception.Source);

View File

@@ -205,7 +205,19 @@ namespace Wox.ViewModel
Query(); Query();
} }
} }
/// <summary>
/// we need move cursor to end when we manually changed query
/// but we don't want to move cursor to end when query is updated from TextBox
/// </summary>
/// <param name="queryText"></param>
public void ChangeQueryText(string queryText)
{
QueryTextCursorMovedToEnd = true;
QueryText = queryText;
}
public bool QueryTextSelected { get; set; } public bool QueryTextSelected { get; set; }
public bool QueryTextCursorMovedToEnd { get; set; }
private ResultsViewModel _selectedResults; private ResultsViewModel _selectedResults;
private ResultsViewModel SelectedResults private ResultsViewModel SelectedResults
@@ -218,7 +230,7 @@ namespace Wox.ViewModel
{ {
ContextMenu.Visbility = Visibility.Collapsed; ContextMenu.Visbility = Visibility.Collapsed;
History.Visbility = Visibility.Collapsed; History.Visbility = Visibility.Collapsed;
QueryText = _queryTextBeforeLeaveResults; ChangeQueryText(_queryTextBeforeLeaveResults);
} }
else else
{ {
@@ -325,7 +337,7 @@ namespace Wox.ViewModel
Action = _ => Action = _ =>
{ {
SelectedResults = Results; SelectedResults = Results;
QueryText = h.Query; ChangeQueryText(h.Query);
return false; return false;
} }
}; };
@@ -547,7 +559,7 @@ namespace Wox.ViewModel
{ {
if (ShouldIgnoreHotkeys()) return; if (ShouldIgnoreHotkeys()) return;
MainWindowVisibility = Visibility.Visible; MainWindowVisibility = Visibility.Visible;
QueryText = hotkey.ActionKeyword; ChangeQueryText(hotkey.ActionKeyword);
}); });
} }
} }