Merge pull request #302 from kerams/max-results

Make the number of results shown at a time customizable
This commit is contained in:
qianlifeng 2015-07-13 10:17:05 +08:00
commit 298e041b80
5 changed files with 25 additions and 7 deletions

View File

@ -103,6 +103,9 @@ namespace Wox.Infrastructure.Storage.UserSettings
[JsonProperty] [JsonProperty]
public string ProxyPassword { get; set; } public string ProxyPassword { get; set; }
[JsonProperty]
public int MaxResultsToShow { get; set; }
public List<WebSearch> LoadDefaultWebSearches() public List<WebSearch> LoadDefaultWebSearches()
{ {
List<WebSearch> webSearches = new List<WebSearch>(); List<WebSearch> webSearches = new List<WebSearch>();
@ -161,6 +164,7 @@ namespace Wox.Infrastructure.Storage.UserSettings
OpacityMode = OpacityMode.Normal; OpacityMode = OpacityMode.Normal;
LeaveCmdOpen = false; LeaveCmdOpen = false;
HideWhenDeactive = false; HideWhenDeactive = false;
MaxResultsToShow = 6;
return this; return this;
} }

View File

@ -1,4 +1,5 @@
<UserControl x:Class="Wox.ResultPanel" <UserControl x:Class="Wox.ResultPanel"
x:Name="Results"
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"
@ -6,8 +7,7 @@
xmlns:converters="clr-namespace:Wox.Converters" xmlns:converters="clr-namespace:Wox.Converters"
mc:Ignorable="d" d:DesignWidth="100" d:DesignHeight="100"> mc:Ignorable="d" d:DesignWidth="100" d:DesignHeight="100">
<!-- set max height of listbox to allow 6 results showed at once --> <ListBox x:Name="lbResults" MaxHeight="{Binding ElementName=Results, Path=MaxResultsToShow}" HorizontalContentAlignment="Stretch" PreviewMouseDown="LbResults_OnPreviewMouseDown" Style="{DynamicResource BaseListboxStyle}" SelectionChanged ="lbResults_SelectionChanged" Focusable="False" KeyboardNavigation.DirectionalNavigation="Cycle" SelectionMode="Single" VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Standard">
<ListBox x:Name="lbResults" MaxHeight="300" HorizontalContentAlignment="Stretch" PreviewMouseDown="LbResults_OnPreviewMouseDown" Style="{DynamicResource BaseListboxStyle}" SelectionChanged ="lbResults_SelectionChanged" Focusable="False" KeyboardNavigation.DirectionalNavigation="Cycle" SelectionMode="Single" VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Standard">
<ListBox.Resources> <ListBox.Resources>
<!--SelectedItem with focus--> <!--SelectedItem with focus-->
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="{DynamicResource ItemSelectedBackgroundColor}"/> <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="{DynamicResource ItemSelectedBackgroundColor}"/>

View File

@ -1,14 +1,10 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using Wox.Infrastructure.Storage.UserSettings;
using Wox.Helper;
using Wox.Plugin; using Wox.Plugin;
using UserControl = System.Windows.Controls.UserControl;
namespace Wox namespace Wox
{ {
@ -31,6 +27,8 @@ namespace Wox
public bool Dirty { get; set; } public bool Dirty { get; set; }
public int MaxResultsToShow { get { return UserSettingStorage.Instance.MaxResultsToShow * 50; } }
public void AddResults(List<Result> results) public void AddResults(List<Result> results)
{ {

View File

@ -6,6 +6,7 @@
xmlns:woxPlugin="clr-namespace:Wox.Plugin;assembly=Wox.Plugin" xmlns:woxPlugin="clr-namespace:Wox.Plugin;assembly=Wox.Plugin"
xmlns:system="clr-namespace:Wox.Plugin.SystemPlugins;assembly=Wox.Plugin.SystemPlugins" xmlns:system="clr-namespace:Wox.Plugin.SystemPlugins;assembly=Wox.Plugin.SystemPlugins"
xmlns:converters="clr-namespace:Wox.Converters" xmlns:converters="clr-namespace:Wox.Converters"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
Icon="Images\app.png" Icon="Images\app.png"
Title="Wox Settings" Title="Wox Settings"
ResizeMode="NoResize" ResizeMode="NoResize"
@ -31,6 +32,10 @@
<CheckBox x:Name="cbDontPromptUpdateMsg" Margin="10"> <CheckBox x:Name="cbDontPromptUpdateMsg" Margin="10">
Don't show upgrade msg if new version available Don't show upgrade msg if new version available
</CheckBox> </CheckBox>
<StackPanel Orientation="Horizontal" Margin="10">
<ComboBox Name="comboMaxResultsToShow"/>
<Label>Maximum number of results to show at a time</Label>
</StackPanel>
</StackPanel> </StackPanel>
</TabItem> </TabItem>
<TabItem Header="Plugin"> <TabItem Header="Plugin">

View File

@ -66,10 +66,21 @@ namespace Wox
UserSettingStorage.Instance.Save(); UserSettingStorage.Instance.Save();
}; };
comboMaxResultsToShow.SelectionChanged += (o, e) =>
{
UserSettingStorage.Instance.MaxResultsToShow = (int)comboMaxResultsToShow.SelectedItem;
UserSettingStorage.Instance.Save();
MainWindow.pnlResult.lbResults.GetBindingExpression(MaxHeightProperty).UpdateTarget();
};
cbStartWithWindows.IsChecked = File.Exists(woxLinkPath); cbStartWithWindows.IsChecked = File.Exists(woxLinkPath);
cbHideWhenDeactive.IsChecked = UserSettingStorage.Instance.HideWhenDeactive; cbHideWhenDeactive.IsChecked = UserSettingStorage.Instance.HideWhenDeactive;
cbDontPromptUpdateMsg.IsChecked = UserSettingStorage.Instance.DontPromptUpdateMsg; cbDontPromptUpdateMsg.IsChecked = UserSettingStorage.Instance.DontPromptUpdateMsg;
comboMaxResultsToShow.ItemsSource = Enumerable.Range(2, 16);
var maxResults = UserSettingStorage.Instance.MaxResultsToShow;
comboMaxResultsToShow.SelectedItem = maxResults == 0 ? 6 : maxResults;
#endregion #endregion
#region Theme #region Theme