Flow.Launcher/Flow.Launcher/CustomShortcutSetting.xaml.cs

68 lines
2 KiB
C#
Raw Normal View History

using Flow.Launcher.Core.Resource;
using Flow.Launcher.Infrastructure.UserSettings;
using System;
using System.Windows;
using System.Windows.Input;
namespace Flow.Launcher
{
public partial class CustomShortcutSetting : Window
{
private Settings _settings;
private bool update = false;
public string Key { get; set; }
public string Value { get; set; }
public CustomShortcutModel ShortCut => (Key, Value);
public CustomShortcutSetting(Settings settings)
{
_settings = settings;
InitializeComponent();
}
public CustomShortcutSetting((string, string) shortcut, Settings settings)
{
(Key, Value) = shortcut;
_settings = settings;
update = true;
InitializeComponent();
}
private void BtnCancel_OnClick(object sender, RoutedEventArgs e)
{
DialogResult = false;
Close();
}
private void btnAdd_OnClick(object sender, RoutedEventArgs e)
{
if (!update && _settings.CustomShortcuts.Contains(new CustomShortcutModel(Key, Value)))
2022-10-08 09:01:18 +00:00
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("dulplicateShortcut"));
return;
2022-10-08 09:01:18 +00:00
}
if (String.IsNullOrEmpty(Key) || String.IsNullOrEmpty(Value))
2022-10-08 09:01:18 +00:00
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("invalidShortcut"));
return;
2022-10-08 09:01:18 +00:00
}
DialogResult = true;
Close();
}
private void cmdEsc_OnPress(object sender, ExecutedRoutedEventArgs e)
{
DialogResult = false;
Close();
}
private void BtnTestShortcut_OnClick(object sender, RoutedEventArgs e)
{
App.API.ChangeQuery(tbExpand.Text);
Application.Current.MainWindow.Show();
Application.Current.MainWindow.Opacity = 1;
Application.Current.MainWindow.Focus();
}
}
}