mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-15 12:09:18 +08:00
977d21c929
SelectedSearchSource will be null if the user clicks on Edit or Delete after finishing with previous edit and not highlighting the search source again.
61 lines
2.0 KiB
C#
61 lines
2.0 KiB
C#
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using Wox.Core.Plugin;
|
|
|
|
namespace Wox.Plugin.WebSearch
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for WebSearchesSetting.xaml
|
|
/// </summary>
|
|
public partial class SettingsControl : UserControl
|
|
{
|
|
private readonly Settings _settings;
|
|
private readonly PluginInitContext _context;
|
|
|
|
public SettingsControl(PluginInitContext context, SettingsViewModel viewModel)
|
|
{
|
|
InitializeComponent();
|
|
_context = context;
|
|
_settings = viewModel.Settings;
|
|
DataContext = viewModel;
|
|
}
|
|
|
|
private void OnAddSearchSearchClick(object sender, RoutedEventArgs e)
|
|
{
|
|
var setting = new SearchSourceSettingWindow(_settings.SearchSources, _context);
|
|
setting.ShowDialog();
|
|
}
|
|
|
|
private void OnDeleteSearchSearchClick(object sender, RoutedEventArgs e)
|
|
{
|
|
if (_settings.SelectedSearchSource != null)
|
|
{
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void OnEditSearchSourceClick(object sender, RoutedEventArgs e)
|
|
{
|
|
if (_settings.SelectedSearchSource != null)
|
|
{
|
|
var webSearch = new SearchSourceSettingWindow
|
|
(
|
|
_settings.SearchSources, _context, _settings.SelectedSearchSource
|
|
);
|
|
|
|
webSearch.ShowDialog();
|
|
}
|
|
}
|
|
}
|
|
}
|