Flow.Launcher/Plugins/Flow.Launcher.Plugin.WebSearch/SettingsControl.xaml
2021-05-20 12:57:48 +10:00

117 lines
No EOL
6.7 KiB
XML

<UserControl x:Class="Flow.Launcher.Plugin.WebSearch.SettingsControl"
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"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:vm="clr-namespace:Flow.Launcher.Plugin.WebSearch"
mc:Ignorable="d"
Background="White"
d:DataContext="{d:DesignInstance vm:SettingsViewModel}"
d:DesignHeight="300" d:DesignWidth="500">
<UserControl.Resources>
<Style TargetType="TextBox" x:Key="BrowserPathBoxStyle">
<Setter Property="Height" Value="28"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
</Style>
<DataTemplate x:Key="HeaderTemplateArrowUp">
<DockPanel>
<TextBlock HorizontalAlignment="Center" Text="{Binding}"/>
<Path x:Name="arrow"
StrokeThickness = "1"
Fill = "gray"
Data = "M 5,10 L 15,10 L 10,5 L 5,10"/>
</DockPanel>
</DataTemplate>
<DataTemplate x:Key="HeaderTemplateArrowDown">
<DockPanel>
<TextBlock HorizontalAlignment="Center" Text="{Binding }"/>
<Path x:Name="arrow"
StrokeThickness = "1"
Fill = "gray"
Data = "M 5,5 L 10,10 L 15,5 L 5,5"/>
</DockPanel>
</DataTemplate>
</UserControl.Resources>
<Grid Margin="15 0 0 0">
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition Height="48" />
<RowDefinition Height="45" />
<RowDefinition />
<RowDefinition Height="50" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Grid.Row="0">
<CheckBox IsChecked="{Binding Settings.EnableSuggestion}"
Margin="0 0 20 0"
Name="EnableSuggestion"
Content="{DynamicResource flowlauncher_plugin_websearch_enable_suggestion}" />
<ComboBox ItemsSource="{Binding Settings.Suggestions}"
SelectedItem="{Binding Settings.SelectedSuggestion}"
IsEnabled="{Binding ElementName=EnableSuggestion, Path=IsChecked}" />
<!-- Not sure why binding IsEnabled directly to Settings.EnableWebSaerchSuggestion is not working -->
</StackPanel>
<StackPanel Grid.Row="1" HorizontalAlignment="Left" Orientation="Horizontal">
<Label Content="{DynamicResource flowlauncher_plugin_websearch_open_search_in}" Margin="0 15 20 0"/>
<RadioButton Name="NewWindowBrowser" GroupName="OpenSearchBehaviour" Content="{DynamicResource flowlauncher_plugin_websearch_new_window}" Click="OnNewBrowserWindowClick"
Margin="0 0 20 0"/>
<RadioButton Name="NewTabInBrowser" GroupName="OpenSearchBehaviour" Content="{DynamicResource flowlauncher_plugin_websearch_new_tab}" Click="OnNewTabClick" />
</StackPanel>
<StackPanel Grid.Row="2" HorizontalAlignment="Left" Margin="0 3 0 0">
<Label Content="{DynamicResource flowlaucnher_plugin_websearch_set_browser_path}" Margin="0 0 350 0" HorizontalAlignment="Left" Width="140"/>
<TextBox x:Name="browserPathBox" HorizontalAlignment="Left" Margin="160,-22,0,0" TextChanged="OnBrowserPathTextChanged"
Width="214" Style="{StaticResource BrowserPathBoxStyle}"/>
<Button x:Name="viewButton" HorizontalAlignment="Left" Margin="400,-30,0,0"
Click="OnChooseClick" FontSize="13" Content="{DynamicResource flowlauncher_plugin_websearch_choose}" Width="80"/>
</StackPanel>
<ListView ItemsSource="{Binding Settings.SearchSources}"
SelectedItem="{Binding Settings.SelectedSearchSource}"
x:Name="SearchSourcesListView"
Grid.Row="3"
Style="{StaticResource {x:Static GridView.GridViewStyleKey}}"
BorderBrush="DarkGray"
BorderThickness="1"
GridViewColumnHeader.Click="SortByColumn"
MouseDoubleClick="MouseDoubleClickItem">
<ListView.View>
<GridView>
<GridViewColumn Header="{DynamicResource flowlauncher_plugin_websearch_title}"
DisplayMemberBinding="{Binding Title}"
Width="130">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Title}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="{DynamicResource flowlauncher_plugin_websearch_action_keyword}"
DisplayMemberBinding="{Binding ActionKeyword}"
Width="137">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding ActionKeyword}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="{DynamicResource flowlauncher_plugin_websearch_url}"
DisplayMemberBinding="{Binding Url}"
Width="auto">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Url}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
<StackPanel Grid.Row="4" HorizontalAlignment="Right" Orientation="Horizontal">
<Button Click="OnDeleteSearchSearchClick" Width="100" Margin="10"
Content="{DynamicResource flowlauncher_plugin_websearch_delete}" />
<Button Click="OnEditSearchSourceClick" Width="100" Margin="10"
Content="{DynamicResource flowlauncher_plugin_websearch_edit}" />
<Button Click="OnAddSearchSearchClick" Width="100" Margin="10 10 10 10"
Content="{DynamicResource flowlauncher_plugin_websearch_add}" />
</StackPanel>
</Grid>
</UserControl>