Skip to content

Commit

Permalink
Fix issue#32
Browse files Browse the repository at this point in the history
  • Loading branch information
qianlifeng committed Mar 2, 2014
1 parent 13ed55a commit 7ae98ca
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
10 changes: 6 additions & 4 deletions Wox.Plugin.System/Programs.cs
Expand Up @@ -27,7 +27,6 @@ public class Programs : BaseSystemPlugin

List<Program> installedList = new List<Program>();


[DllImport("shell32.dll")]
static extern bool SHGetSpecialFolderPath(IntPtr hwndOwner,[Out] StringBuilder lpszPath, int nFolder, bool fCreate);
const int CSIDL_COMMON_STARTMENU = 0x16; // \Windows\Start Menu\Programs
Expand All @@ -40,6 +39,10 @@ protected override List<Result> QueryInternal(Query query)
var fuzzyMather = FuzzyMatcher.Create(query.RawQuery);
List<Program> returnList = installedList.Where(o => MatchProgram(o, fuzzyMather)).ToList();
returnList.ForEach(ScoreFilter);
//return ordered list instead of return the score, because programs scores will affect other
//plugins, the weight of program should be less than the plugins when they showed at the same time.
returnList = returnList.OrderByDescending(o => o.Score).ToList();
returnList.ForEach(o=>o.Score = 0);

return returnList.Select(c => new Result()
{
Expand Down Expand Up @@ -112,7 +115,6 @@ private void GetAppFromDirectory(string path)
{
Title = getAppNameFromAppPath(file),
IcoPath = file,
Score = 10,
ExecutePath = file
};
installedList.Add(p);
Expand All @@ -129,11 +131,11 @@ private void ScoreFilter(Program p)
{
if (p.Title.Contains("启动") || p.Title.ToLower().Contains("start"))
{
p.Score += 10;
p.Score += 1;
}
if (p.Title.Contains("卸载") || p.Title.ToLower().Contains("uninstall"))
{
p.Score -= 5;
p.Score -= 1;
}
}

Expand Down
2 changes: 1 addition & 1 deletion Wox.Plugin.System/Setting.cs
Expand Up @@ -16,7 +16,7 @@ protected override List<Result> QueryInternal(Query query)
results.Add(new Result()
{
Title = "Wox Setting",
Score = 100,
Score = 40,
IcoPath = "Images/app.png",
Action = (contenxt) =>
{
Expand Down
1 change: 1 addition & 0 deletions Wox.Plugin.System/WebSearchPlugin.cs
Expand Up @@ -25,6 +25,7 @@ protected override List<Result> QueryInternal(Query query)
results.Add(new Result()
{
Title = string.Format("Search {0} for \"{1}\"", webSearch.Title, keyword),
Score = 6,
IcoPath = webSearch.IconPath,
Action = (c) =>
{
Expand Down
2 changes: 1 addition & 1 deletion Wox/ResultPanel.xaml
Expand Up @@ -40,7 +40,7 @@
<RowDefinition></RowDefinition>
<RowDefinition Height="Auto" x:Name="SubTitleRowDefinition"></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Style="{DynamicResource ItemTitleStyle}" ToolTip="{Binding Title}" x:Name="tbTitle" Text="{Binding Title}"></TextBlock>
<TextBlock Style="{DynamicResource ItemTitleStyle}" VerticalAlignment="Center" ToolTip="{Binding Title}" x:Name="tbTitle" Text="{Binding Title}"></TextBlock>
<TextBlock Style="{DynamicResource ItemSubTitleStyle}" Visibility="{Binding SubTitle, Converter={wox:StringNullOrEmptyToVisibilityConverter}}" Grid.Row="1" x:Name="tbSubTitle" Text="{Binding SubTitle}"></TextBlock>
</Grid>
</Grid>
Expand Down

0 comments on commit 7ae98ca

Please sign in to comment.