2016-06-21 07:14:32 +08:00
|
|
|
|
using System.Windows;
|
2014-03-29 16:13:36 +08:00
|
|
|
|
using System.Windows.Controls;
|
2016-06-21 07:14:32 +08:00
|
|
|
|
using Wox.Core.Plugin;
|
2014-03-29 16:13:36 +08:00
|
|
|
|
|
2015-01-03 15:20:34 +08:00
|
|
|
|
namespace Wox.Plugin.WebSearch
|
2014-03-29 16:13:36 +08:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Interaction logic for WebSearchesSetting.xaml
|
|
|
|
|
/// </summary>
|
2016-06-21 07:14:32 +08:00
|
|
|
|
public partial class SettingsControl : UserControl
|
2014-03-29 16:13:36 +08:00
|
|
|
|
{
|
2016-06-21 07:14:32 +08:00
|
|
|
|
private readonly Settings _settings;
|
|
|
|
|
private readonly PluginInitContext _context;
|
2015-01-07 18:45:55 +08:00
|
|
|
|
|
2016-06-21 07:14:32 +08:00
|
|
|
|
public SettingsControl(PluginInitContext context, SettingsViewModel viewModel)
|
2014-03-29 16:13:36 +08:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2016-06-21 07:14:32 +08:00
|
|
|
|
_context = context;
|
|
|
|
|
_settings = viewModel.Settings;
|
|
|
|
|
DataContext = viewModel;
|
2014-03-29 16:13:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-06-21 07:14:32 +08:00
|
|
|
|
private void OnAddSearchSearchClick(object sender, RoutedEventArgs e)
|
2014-03-29 16:13:36 +08:00
|
|
|
|
{
|
2016-06-21 07:14:32 +08:00
|
|
|
|
var setting = new SearchSourceSettingWindow(_settings.SearchSources, _context);
|
2016-04-26 09:40:23 +08:00
|
|
|
|
setting.ShowDialog();
|
2014-03-29 16:13:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-06-21 07:14:32 +08:00
|
|
|
|
private void OnDeleteSearchSearchClick(object sender, RoutedEventArgs e)
|
2014-03-29 16:13:36 +08:00
|
|
|
|
{
|
2016-06-21 07:14:32 +08:00
|
|
|
|
var selected = _settings.SelectedSearchSource;
|
|
|
|
|
var warning = _context.API.GetTranslation("wox_plugin_websearch_delete_warning");
|
|
|
|
|
var formated = string.Format(warning, selected.Title);
|
2015-11-09 11:20:02 +08:00
|
|
|
|
|
2016-06-21 07:14:32 +08:00
|
|
|
|
var result = MessageBox.Show(formated, string.Empty, MessageBoxButton.YesNo);
|
|
|
|
|
if (result == MessageBoxResult.Yes)
|
2014-03-29 16:13:36 +08:00
|
|
|
|
{
|
2016-06-21 07:14:32 +08:00
|
|
|
|
var id = _context.CurrentPluginMetadata.ID;
|
|
|
|
|
PluginManager.RemoveActionKeyword(id, selected.ActionKeyword);
|
|
|
|
|
_settings.SearchSources.Remove(selected);
|
2014-03-29 16:13:36 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-21 07:14:32 +08:00
|
|
|
|
private void OnEditSearchSourceClick(object sender, RoutedEventArgs e)
|
2014-03-29 16:13:36 +08:00
|
|
|
|
{
|
2016-06-21 07:14:32 +08:00
|
|
|
|
var selected = _settings.SelectedSearchSource;
|
|
|
|
|
var webSearch = new SearchSourceSettingWindow
|
|
|
|
|
(
|
|
|
|
|
_settings.SearchSources, _context, selected
|
|
|
|
|
);
|
|
|
|
|
webSearch.ShowDialog();
|
2014-07-21 22:27:57 +08:00
|
|
|
|
}
|
2014-03-29 16:13:36 +08:00
|
|
|
|
}
|
2016-06-21 07:14:32 +08:00
|
|
|
|
}
|