merge master

This commit is contained in:
bao-qian
2015-11-26 06:57:12 +00:00
15 changed files with 67 additions and 81 deletions

View File

@@ -176,7 +176,8 @@ namespace Wox.Plugin.CMD
private void OnWinRPressed()
{
context.API.ShowApp();
context.API.ChangeQuery(">");
// todo don't hardcode action keywords.
context.API.ChangeQuery($">{Plugin.Query.TermSeperater}");
}
public Control CreateSettingPanel()

View File

@@ -227,8 +227,6 @@ namespace Wox.Plugin.Everything.Everything
yield break;
}
Everything_SortResultsByPath();
const int bufferSize = 4096;
StringBuilder buffer = new StringBuilder(bufferSize);
for (int idx = 0; idx < Everything_GetNumResults(); ++idx)

View File

@@ -47,12 +47,6 @@ namespace Wox.Plugin.Everything
try
{
var searchList = api.Search(keyword, maxCount: ContextMenuStorage.Instance.MaxSearchCount).ToList();
var fuzzyMather = FuzzyMatcher.Create(keyword);
searchList.Sort(
(x, y) =>
fuzzyMather.Evaluate(Path.GetFileName(y.FullPath)).Score -
fuzzyMather.Evaluate(Path.GetFileName(x.FullPath)).Score);
foreach (var s in searchList)
{
var path = s.FullPath;

View File

@@ -30,24 +30,24 @@ namespace Wox.Plugin.Program
{
var fuzzyMather = FuzzyMatcher.Create(query.Search);
List<Program> returnList = programs.Where(o => MatchProgram(o, fuzzyMather)).ToList();
returnList.ForEach(ScoreFilter);
returnList = returnList.OrderByDescending(o => o.Score).ToList();
return returnList.Select(c => new Result()
{
Title = c.Title,
SubTitle = c.ExecutePath,
IcoPath = c.IcoPath,
Score = c.Score,
ContextData = c,
Action = (e) =>
{
context.API.HideApp();
context.API.ShellRun(c.ExecutePath);
return true;
}
}).ToList();
var results = programs.Where(o => MatchProgram(o, fuzzyMather)).
Select(ScoreFilter).
OrderByDescending(o => o.Score)
.Select(c => new Result()
{
Title = c.Title,
SubTitle = c.ExecutePath,
IcoPath = c.IcoPath,
Score = c.Score,
ContextData = c,
Action = (e) =>
{
context.API.HideApp();
context.API.ShellRun(c.ExecutePath);
return true;
}
}).ToList();
return results;
}
static string ResolveShortcut(string filePath)
@@ -60,12 +60,10 @@ namespace Wox.Plugin.Program
private bool MatchProgram(Program program, FuzzyMatcher matcher)
{
if ((program.Score = matcher.Evaluate(program.Title).Score) > 0) return true;
if ((program.Score = matcher.Evaluate(program.PinyinTitle).Score) > 0) return true;
if (program.AbbrTitle != null && (program.Score = matcher.Evaluate(program.AbbrTitle).Score) > 0) return true;
if (program.ExecuteName != null && (program.Score = matcher.Evaluate(program.ExecuteName).Score) > 0) return true;
return false;
var scores = new List<string> { program.Title, program.PinyinTitle, program.AbbrTitle, program.ExecuteName };
program.Score = scores.Select(s => matcher.Evaluate(s ?? string.Empty).Score).Max();
if (program.Score > 0) return true;
else return false;
}
public void Init(PluginInitContext context)
@@ -161,7 +159,7 @@ namespace Wox.Plugin.Program
return list;
}
private void ScoreFilter(Program p)
private Program ScoreFilter(Program p)
{
p.Score += p.Source.BonusPoints;
@@ -173,6 +171,7 @@ namespace Wox.Plugin.Program
if (p.Title.Contains("卸载") || p.Title.ToLower().Contains("uninstall"))
p.Score -= 20;
return p;
}
#region ISettingProvider Members

View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@@ -11,7 +11,8 @@ namespace Wox.Plugin.WebSearch
{
public partial class WebSearchSetting : Window
{
private string _defaultWebSearchImageDirectory = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Images\\websearch");
private const string _imageDirectoryName = "Images";
private string _pluginDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
private readonly WebSearchesSetting _settingWindow;
private bool _isUpdate;
private WebSearch _updateWebSearch;
@@ -50,7 +51,7 @@ namespace Wox.Plugin.WebSearch
private void ShowIcon(string path)
{
imgIcon.Source = new BitmapImage(new Uri($"{_defaultWebSearchImageDirectory}\\{path}", UriKind.Absolute));
imgIcon.Source = new BitmapImage(new Uri(Path.Combine(_pluginDirectory, path), UriKind.Absolute));
}
private void BtnCancel_OnClick(object sender, RoutedEventArgs e)
@@ -126,15 +127,15 @@ namespace Wox.Plugin.WebSearch
private void BtnSelectIcon_OnClick(object sender, RoutedEventArgs e)
{
if (!Directory.Exists(_defaultWebSearchImageDirectory))
if (!Directory.Exists(_pluginDirectory))
{
_defaultWebSearchImageDirectory =
_pluginDirectory =
Path.GetDirectoryName(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
}
var dlg = new OpenFileDialog
{
InitialDirectory = _defaultWebSearchImageDirectory,
InitialDirectory = Path.Combine(_pluginDirectory, _imageDirectoryName),
Filter = "Image files (*.jpg, *.jpeg, *.gif, *.png, *.bmp) |*.jpg; *.jpeg; *.gif; *.png; *.bmp"
};
@@ -142,8 +143,11 @@ namespace Wox.Plugin.WebSearch
if (result == true)
{
string filename = dlg.FileName;
tbIconPath.Text = Path.GetFileName(filename);
ShowIcon(tbIconPath.Text);
if (filename != null)
{
tbIconPath.Text = Path.Combine(_imageDirectoryName, Path.GetFileName(filename));
ShowIcon(tbIconPath.Text);
}
}
}
}

View File

@@ -41,7 +41,7 @@ namespace Wox.Plugin.WebSearch
{
Title = "Google",
ActionKeyword = "g",
IconPath = @"google.png",
IconPath = @"Images\google.png",
Url = "https://www.google.com/search?q={q}",
Enabled = true
};
@@ -52,7 +52,7 @@ namespace Wox.Plugin.WebSearch
{
Title = "Wikipedia",
ActionKeyword = "wiki",
IconPath = @"wiki.png",
IconPath = @"Images\wiki.png",
Url = "http://en.wikipedia.org/wiki/{q}",
Enabled = true
};
@@ -62,7 +62,7 @@ namespace Wox.Plugin.WebSearch
{
Title = "FindIcon",
ActionKeyword = "findicon",
IconPath = @"pictures.png",
IconPath = @"Images\pictures.png",
Url = "http://findicons.com/search/{q}",
Enabled = true
};

View File

@@ -66,7 +66,13 @@
<Compile Include="WebSearchStorage.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Images\websearch\pictures.png">
<None Include="Images\google.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Images\pictures.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Images\wiki.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<Content Include="Languages\en.xaml">
@@ -114,16 +120,6 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Include="Images\websearch\google.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Include="Images\websearch\wiki.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.