2019-08-02 11:18:38 +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
|
|
|
{
|
2019-08-02 11:18:38 +08:00
|
|
|
if (_settings.SelectedSearchSource != null)
|
2014-03-29 16:13:36 +08:00
|
|
|
{
|
2019-08-02 11:18:38 +08:00
|
|
|
var selected = _settings.SelectedSearchSource;
|
|
|
|
var warning = _context.API.GetTranslation("wox_plugin_websearch_delete_warning");
|
|
|
|
var formated = string.Format(warning, selected.Title);
|
|
|
|
|
|
|
|
var result = MessageBox.Show(formated, string.Empty, MessageBoxButton.YesNo);
|
|
|
|
if (result == MessageBoxResult.Yes)
|
|
|
|
{
|
|
|
|
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
|
|
|
{
|
2019-08-02 11:18:38 +08:00
|
|
|
if (_settings.SelectedSearchSource != null)
|
|
|
|
{
|
|
|
|
var webSearch = new SearchSourceSettingWindow
|
2016-06-21 07:18:35 +08:00
|
|
|
(
|
2019-08-02 11:18:38 +08:00
|
|
|
_settings.SearchSources, _context, _settings.SelectedSearchSource
|
2016-06-21 07:18:35 +08:00
|
|
|
);
|
2019-08-02 11:18:38 +08:00
|
|
|
|
|
|
|
webSearch.ShowDialog();
|
|
|
|
}
|
2014-07-21 22:27:57 +08:00
|
|
|
}
|
2014-03-29 16:13:36 +08:00
|
|
|
}
|
2019-08-02 11:18:38 +08:00
|
|
|
}
|