Skip to content

Commit

Permalink
Add option for double-click to open (#409)
Browse files Browse the repository at this point in the history
Closes #409
  • Loading branch information
srwi committed Aug 19, 2023
1 parent faea27a commit 57cf5bb
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 4 deletions.
3 changes: 2 additions & 1 deletion EverythingToolbar/Controls/SearchResultsView.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<UserControl x:Class="EverythingToolbar.Controls.SearchResultsView"
<UserControl x:Class="EverythingToolbar.Controls.SearchResultsView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Expand Down Expand Up @@ -58,6 +58,7 @@
</UserControl.Resources>

<ListView Name="SearchResultsListView"
SelectionMode="Single"
BorderThickness="0"
HorizontalContentAlignment="Stretch"
Background="{DynamicResource SearchResultsViewBackground}"
Expand Down
19 changes: 18 additions & 1 deletion EverythingToolbar/Controls/SearchResultsView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ private void RegisterItemContainerStyleProperties(object sender, ResourcesChange
SearchResultsListView.ItemContainerStyle.Setters.Add(new EventSetter
{
Event = PreviewMouseLeftButtonUpEvent,
Handler = new MouseButtonEventHandler(Open)
Handler = new MouseButtonEventHandler(SingleClickSearchResult)
});
SearchResultsListView.ItemContainerStyle.Setters.Add(new EventSetter
{
Event = PreviewMouseDoubleClickEvent,
Handler = new MouseButtonEventHandler(DoubleClickSearchResult)
});
SearchResultsListView.ItemContainerStyle.Setters.Add(new EventSetter
{
Expand Down Expand Up @@ -292,6 +297,18 @@ private void CopyFile(object sender, RoutedEventArgs e)
EverythingSearch.Instance.Reset();
}

private void SingleClickSearchResult(object sender, MouseEventArgs e)
{
if (!Settings.Default.isDoubleClickToOpen)
Open(sender, e);
}

private void DoubleClickSearchResult(object sender, MouseEventArgs e)
{
if (Settings.Default.isDoubleClickToOpen)
Open(sender, e);
}

private void Open(object sender, RoutedEventArgs e)
{
OpenSelectedSearchResult();
Expand Down
3 changes: 3 additions & 0 deletions EverythingToolbar/Controls/SettingsControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@
<MenuItem IsCheckable="True"
Header="{x:Static properties:Resources.SettingsSelectFirstResult}"
IsChecked="{Binding Source={x:Static properties:Settings.Default}, Path=isAutoSelectFirstResult, Mode=TwoWay}" />
<MenuItem IsCheckable="True"
Header="{x:Static properties:Resources.SettingsDoubleClickToOpen}"
IsChecked="{Binding Source={x:Static properties:Settings.Default}, Path=isDoubleClickToOpen, Mode=TwoWay}" />
<MenuItem IsCheckable="True"
Header="{x:Static properties:Resources.SettingsShowResultsCount}"
IsChecked="{Binding Source={x:Static properties:Settings.Default}, Path=isShowResultsCount, Mode=TwoWay}" />
Expand Down
9 changes: 9 additions & 0 deletions EverythingToolbar/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions EverythingToolbar/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -486,4 +486,7 @@
<data name="SettingsSelectFirstResult" xml:space="preserve">
<value>Select first result</value>
</data>
<data name="SettingsDoubleClickToOpen" xml:space="preserve">
<value>Double-click to open</value>
</data>
</root>
15 changes: 14 additions & 1 deletion EverythingToolbar/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion EverythingToolbar/Properties/Settings.settings
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="EverythingToolbar.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
Expand Down Expand Up @@ -95,5 +95,8 @@
<Setting Name="isForceCenterAlignment" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="isDoubleClickToOpen" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>
3 changes: 3 additions & 0 deletions EverythingToolbar/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@
<setting name="isForceCenterAlignment" serializeAs="String">
<value>False</value>
</setting>
<setting name="isDoubleClickToOpen" serializeAs="String">
<value>False</value>
</setting>
</EverythingToolbar.Properties.Settings>
</userSettings>
<System.Windows.Forms.ApplicationConfigurationSection>
Expand Down

0 comments on commit 57cf5bb

Please sign in to comment.