This commit is contained in:
bao-qian
2016-06-21 00:18:35 +01:00
parent 91e9d7431a
commit cf5ab0ddef
7 changed files with 189 additions and 189 deletions

View File

@@ -50,7 +50,7 @@ namespace Wox.Plugin.WebSearch
SubTitle = string.Empty, SubTitle = string.Empty,
IcoPath = searchSource.IconPath IcoPath = searchSource.IconPath
}; };
return new List<Result> { result }; return new List<Result> {result};
} }
else else
{ {
@@ -127,7 +127,7 @@ namespace Wox.Plugin.WebSearch
static Main() static Main()
{ {
var plugins = Constant.Plugins; var plugins = Constant.Plugins;
var assemblyName = typeof(Main).Assembly.GetName().Name; var assemblyName = typeof (Main).Assembly.GetName().Name;
var pluginDirectory = Path.Combine(Constant.SettingsPath, plugins, assemblyName); var pluginDirectory = Path.Combine(Constant.SettingsPath, plugins, assemblyName);
ImagesDirectory = Path.Combine(pluginDirectory, Images); ImagesDirectory = Path.Combine(pluginDirectory, Images);
} }

View File

@@ -21,6 +21,7 @@ namespace Wox.Plugin.WebSearch
[NotNull] [NotNull]
[JsonIgnore] [JsonIgnore]
internal string IconPath => Path.Combine(Main.ImagesDirectory, Icon); internal string IconPath => Path.Combine(Main.ImagesDirectory, Icon);
[JsonIgnore] [JsonIgnore]
public ImageSource Image => ImageLoader.Load(IconPath); public ImageSource Image => ImageLoader.Load(IconPath);

View File

@@ -24,12 +24,14 @@
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBlock Margin="10" FontSize="14" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" <TextBlock Margin="10" FontSize="14" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center"
HorizontalAlignment="Right" Text="{DynamicResource wox_plugin_websearch_title}" /> HorizontalAlignment="Right" Text="{DynamicResource wox_plugin_websearch_title}" />
<TextBox Text="{Binding SearchSource.Title}" Margin="10" Grid.Row="0" Width="300" Grid.Column="1" VerticalAlignment="Center" <TextBox Text="{Binding SearchSource.Title}" Margin="10" Grid.Row="0" Width="300" Grid.Column="1"
VerticalAlignment="Center"
HorizontalAlignment="Left" /> HorizontalAlignment="Left" />
<TextBlock Margin="10" FontSize="14" Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" <TextBlock Margin="10" FontSize="14" Grid.Row="1" Grid.Column="0" VerticalAlignment="Center"
HorizontalAlignment="Right" Text="{DynamicResource wox_plugin_websearch_url}" /> HorizontalAlignment="Right" Text="{DynamicResource wox_plugin_websearch_url}" />
<TextBox Text="{Binding SearchSource.Url}" Margin="10" Grid.Row="1" Width="300" Grid.Column="1" VerticalAlignment="Center" <TextBox Text="{Binding SearchSource.Url}" Margin="10" Grid.Row="1" Width="300" Grid.Column="1"
VerticalAlignment="Center"
HorizontalAlignment="Left" /> HorizontalAlignment="Left" />
<TextBlock Margin="10" FontSize="14" Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" <TextBlock Margin="10" FontSize="14" Grid.Row="2" Grid.Column="0" VerticalAlignment="Center"
@@ -39,7 +41,8 @@
<TextBlock Margin="10" FontSize="14" Grid.Row="3" Grid.Column="0" VerticalAlignment="Center" <TextBlock Margin="10" FontSize="14" Grid.Row="3" Grid.Column="0" VerticalAlignment="Center"
HorizontalAlignment="Right" Text="{DynamicResource wox_plugin_websearch_enable}" /> HorizontalAlignment="Right" Text="{DynamicResource wox_plugin_websearch_enable}" />
<CheckBox IsChecked="{Binding SearchSource.Enabled}" Margin="10" Grid.Row="3" Grid.Column="1" VerticalAlignment="Center" /> <CheckBox IsChecked="{Binding SearchSource.Enabled}" Margin="10" Grid.Row="3" Grid.Column="1"
VerticalAlignment="Center" />
<TextBlock Margin="10" FontSize="14" Grid.Row="4" Grid.Column="0" VerticalAlignment="Center" <TextBlock Margin="10" FontSize="14" Grid.Row="4" Grid.Column="0" VerticalAlignment="Center"
HorizontalAlignment="Right" Text="{DynamicResource wox_plugin_websearch_icon}" /> HorizontalAlignment="Right" Text="{DynamicResource wox_plugin_websearch_icon}" />

View File

@@ -20,13 +20,13 @@ namespace Wox.Plugin.WebSearch
public SearchSourceSettingWindow(IList<SearchSource> sources, PluginInitContext context, SearchSource old) public SearchSourceSettingWindow(IList<SearchSource> sources, PluginInitContext context, SearchSource old)
{ {
_oldSearchSource = old; _oldSearchSource = old;
_viewModel = new SearchSourceViewModel { SearchSource = old.DeepCopy() }; _viewModel = new SearchSourceViewModel {SearchSource = old.DeepCopy()};
Initilize(sources, context, Action.Edit); Initilize(sources, context, Action.Edit);
} }
public SearchSourceSettingWindow(IList<SearchSource> sources, PluginInitContext context) public SearchSourceSettingWindow(IList<SearchSource> sources, PluginInitContext context)
{ {
_viewModel = new SearchSourceViewModel { SearchSource = new SearchSource() }; _viewModel = new SearchSourceViewModel {SearchSource = new SearchSource()};
Initilize(sources, context, Action.Add); Initilize(sources, context, Action.Add);
} }
@@ -48,7 +48,6 @@ namespace Wox.Plugin.WebSearch
private void OnConfirmButtonClick(object sender, RoutedEventArgs e) private void OnConfirmButtonClick(object sender, RoutedEventArgs e)
{ {
if (string.IsNullOrEmpty(_searchSource.Title)) if (string.IsNullOrEmpty(_searchSource.Title))
{ {
var warning = _api.GetTranslation("wox_plugin_websearch_input_title"); var warning = _api.GetTranslation("wox_plugin_websearch_input_title");
@@ -123,7 +122,7 @@ namespace Wox.Plugin.WebSearch
{ {
var directory = Path.Combine(Main.ImagesDirectory, Main.Images); var directory = Path.Combine(Main.ImagesDirectory, Main.Images);
const string filter = "Image files (*.jpg, *.jpeg, *.gif, *.png, *.bmp) |*.jpg; *.jpeg; *.gif; *.png; *.bmp"; const string filter = "Image files (*.jpg, *.jpeg, *.gif, *.png, *.bmp) |*.jpg; *.jpeg; *.gif; *.png; *.bmp";
var dialog = new OpenFileDialog { InitialDirectory = directory, Filter = filter }; var dialog = new OpenFileDialog {InitialDirectory = directory, Filter = filter};
var result = dialog.ShowDialog(); var result = dialog.ShowDialog();
if (result == true) if (result == true)

View File

@@ -15,6 +15,7 @@ namespace Wox.Plugin.WebSearch
SelectedSearchSource = SearchSources[0]; SelectedSearchSource = SearchSources[0];
} }
} }
public ObservableCollection<SearchSource> SearchSources { get; set; } = new ObservableCollection<SearchSource> public ObservableCollection<SearchSource> SearchSources { get; set; } = new ObservableCollection<SearchSource>
{ {
new SearchSource new SearchSource
@@ -206,10 +207,7 @@ namespace Wox.Plugin.WebSearch
/// </summary> /// </summary>
public string Suggestion public string Suggestion
{ {
get get { return SelectedSuggestion.ToString(); }
{
return SelectedSuggestion.ToString();
}
set set
{ {
foreach (var s in Suggestions) foreach (var s in Suggestions)
@@ -221,6 +219,5 @@ namespace Wox.Plugin.WebSearch
} }
} }
} }
} }
} }