MVVM refactoring for web search plugin, part 1

1. #486
2. fix #778 #763 #742
3. MVVM refactoring
4. remove IMultipleActionKeywords interface, use PluginManager directly
This commit is contained in:
bao-qian
2016-06-21 00:14:32 +01:00
parent 3efeb4a0a6
commit 6e13440f1f
30 changed files with 495 additions and 518 deletions

View File

@@ -1,35 +1,45 @@
<UserControl x:Class="Wox.Plugin.WebSearch.WebSearchesSetting"
<UserControl x:Class="Wox.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"
mc:Ignorable="d"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:vm="clr-namespace:Wox.Plugin.WebSearch"
mc:Ignorable="d"
Background="White"
d:DataContext="{d:DesignInstance vm:SettingsViewModel}"
d:DesignHeight="300" d:DesignWidth="500">
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="42"/>
<RowDefinition/>
<RowDefinition Height="50"/>
<RowDefinition Height="40" />
<RowDefinition />
<RowDefinition Height="40" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Grid.Row="0">
<CheckBox x:Name="cbEnableWebSearchSuggestion" Unchecked="CbEnableWebSearchSuggestion_OnUnchecked" Checked="CbEnableWebSearchSuggestion_OnChecked" Margin="0 10 10 10" Content="{DynamicResource wox_plugin_websearch_enable_suggestion}"></CheckBox>
<ComboBox x:Name="comboBoxSuggestionSource" SelectionChanged="ComboBoxSuggestionSource_OnSelectionChanged" Margin="10">
</ComboBox>
<CheckBox IsChecked="{Binding Settings.EnableSuggestion}"
Margin="0 10 10 10"
Name="EnableSuggestion"
Content="{DynamicResource wox_plugin_websearch_enable_suggestion}" />
<ComboBox ItemsSource="{Binding Settings.Suggestions}"
SelectedItem="{Binding Settings.SelectedSuggestion}"
IsEnabled="{Binding ElementName=EnableSuggestion, Path=IsChecked}" Margin="10" />
<!-- Not sure why binding IsEnabled directly to Settings.EnableWebSaerchSuggestion is not working -->
</StackPanel>
<ListView x:Name="webSearchView" Grid.Row="1">
<ListView ItemsSource="{Binding Settings.SearchSources}"
SelectedItem="{Binding Settings.SelectedSearchSource}"
Grid.Row="1">
<ListView.View>
<GridView>
<GridViewColumn Header="{DynamicResource wox_plugin_websearch_action_keyword}" Width="180">
<GridViewColumn Header="{DynamicResource wox_plugin_websearch_action_keyword}">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding ActionKeyword}"/>
<TextBlock Text="{Binding ActionKeyword}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="{DynamicResource wox_plugin_websearch_url}" Width="500">
<GridViewColumn Header="{DynamicResource wox_plugin_websearch_url}">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Url}"/>
<TextBlock Text="{Binding Url}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
@@ -37,9 +47,12 @@
</ListView.View>
</ListView>
<StackPanel Grid.Row="2" HorizontalAlignment="Right" Orientation="Horizontal">
<Button x:Name="btnDeleteWebSearch" Click="btnDeleteWebSearch_OnClick" Width="100" Margin="10" Content="{DynamicResource wox_plugin_websearch_delete}"/>
<Button x:Name="btnEditWebSearch" Click="btnEditWebSearch_OnClick" Width="100" Margin="10" Content="{DynamicResource wox_plugin_websearch_edit}"/>
<Button x:Name="btnAddWebSearch" Click="btnAddWebSearch_OnClick" Width="100" Margin="10" Content="{DynamicResource wox_plugin_websearch_add}"/>
<Button Click="OnDeleteSearchSearchClick" Width="100" Margin="10"
Content="{DynamicResource wox_plugin_websearch_delete}" />
<Button Click="OnEditSearchSourceClick" Width="100" Margin="10"
Content="{DynamicResource wox_plugin_websearch_edit}" />
<Button Click="OnAddSearchSearchClick" Width="100" Margin="10"
Content="{DynamicResource wox_plugin_websearch_add}" />
</StackPanel>
</Grid>
</UserControl>
</UserControl>