2025-07-06 13:15:00 +00:00
|
|
|
|
using System.Windows;
|
2021-10-29 23:33:52 +00:00
|
|
|
|
using System.Windows.Controls;
|
2025-07-06 13:15:00 +00:00
|
|
|
|
using System.Windows.Input;
|
2025-04-23 04:43:34 +00:00
|
|
|
|
using Flow.Launcher.Infrastructure.UserSettings;
|
2021-10-29 23:33:52 +00:00
|
|
|
|
|
2020-04-21 09:12:17 +00:00
|
|
|
|
namespace Flow.Launcher
|
2014-02-22 07:52:20 +00:00
|
|
|
|
{
|
2015-01-02 15:07:49 +00:00
|
|
|
|
public partial class CustomQueryHotkeySetting : Window
|
2014-02-22 07:52:20 +00:00
|
|
|
|
{
|
2025-07-06 13:15:00 +00:00
|
|
|
|
public string Hotkey { get; set; } = string.Empty;
|
|
|
|
|
|
public string ActionKeyword { get; set; } = string.Empty;
|
2025-04-23 04:43:34 +00:00
|
|
|
|
|
2025-07-06 13:15:00 +00:00
|
|
|
|
private readonly bool update;
|
|
|
|
|
|
private readonly CustomPluginHotkey originalCustomHotkey;
|
2025-04-23 04:43:34 +00:00
|
|
|
|
|
2025-07-06 13:15:00 +00:00
|
|
|
|
public CustomQueryHotkeySetting()
|
2014-02-22 07:52:20 +00:00
|
|
|
|
{
|
|
|
|
|
|
InitializeComponent();
|
2025-07-10 05:24:07 +00:00
|
|
|
|
tbAdd.Visibility = Visibility.Visible;
|
2014-02-22 07:52:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-06 13:15:00 +00:00
|
|
|
|
public CustomQueryHotkeySetting(CustomPluginHotkey hotkey)
|
2014-02-22 07:52:20 +00:00
|
|
|
|
{
|
2025-07-06 13:15:00 +00:00
|
|
|
|
originalCustomHotkey = hotkey;
|
|
|
|
|
|
update = true;
|
|
|
|
|
|
ActionKeyword = originalCustomHotkey.ActionKeyword;
|
|
|
|
|
|
InitializeComponent();
|
2025-07-10 05:24:07 +00:00
|
|
|
|
tbUpdate.Visibility = Visibility.Visible;
|
2025-07-06 13:15:00 +00:00
|
|
|
|
HotkeyControl.SetHotkey(originalCustomHotkey.Hotkey, false);
|
2014-02-22 07:52:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-06 13:15:00 +00:00
|
|
|
|
private void BtnCancel_OnClick(object sender, RoutedEventArgs e)
|
2014-02-22 07:52:20 +00:00
|
|
|
|
{
|
2025-07-06 13:15:00 +00:00
|
|
|
|
DialogResult = false;
|
2014-02-22 07:52:20 +00:00
|
|
|
|
Close();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-06 13:15:00 +00:00
|
|
|
|
private void btnAdd_OnClick(object sender, RoutedEventArgs e)
|
2014-02-22 07:52:20 +00:00
|
|
|
|
{
|
2025-07-06 13:15:00 +00:00
|
|
|
|
Hotkey = HotkeyControl.CurrentHotkey.ToString();
|
|
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(Hotkey) && string.IsNullOrEmpty(ActionKeyword))
|
2014-02-22 07:52:20 +00:00
|
|
|
|
{
|
2025-07-06 13:15:00 +00:00
|
|
|
|
App.API.ShowMsgBox(App.API.GetTranslation("emptyPluginHotkey"));
|
2014-02-22 07:52:20 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-06 13:15:00 +00:00
|
|
|
|
DialogResult = !update || originalCustomHotkey.Hotkey != Hotkey || originalCustomHotkey.ActionKeyword != ActionKeyword;
|
|
|
|
|
|
Close();
|
2014-02-22 07:52:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void BtnTestActionKeyword_OnClick(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
2016-02-18 12:56:53 +00:00
|
|
|
|
App.API.ChangeQuery(tbAction.Text);
|
2025-02-18 03:32:47 +00:00
|
|
|
|
App.API.ShowMainWindow();
|
2021-07-14 11:04:48 +00:00
|
|
|
|
Application.Current.MainWindow.Focus();
|
2016-02-18 12:56:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-06-19 08:52:11 +00:00
|
|
|
|
private void cmdEsc_OnPress(object sender, ExecutedRoutedEventArgs e)
|
|
|
|
|
|
{
|
2025-07-06 13:15:00 +00:00
|
|
|
|
DialogResult = false;
|
2020-06-19 08:52:11 +00:00
|
|
|
|
Close();
|
|
|
|
|
|
}
|
2021-10-29 23:33:52 +00:00
|
|
|
|
|
|
|
|
|
|
private void window_MouseDown(object sender, MouseButtonEventArgs e) /* for close hotkey popup */
|
|
|
|
|
|
{
|
2024-04-18 05:58:41 +00:00
|
|
|
|
if (Keyboard.FocusedElement is not TextBox textBox) return;
|
|
|
|
|
|
|
|
|
|
|
|
TraversalRequest tRequest = new TraversalRequest(FocusNavigationDirection.Next);
|
|
|
|
|
|
textBox.MoveFocus(tRequest);
|
2021-10-29 23:33:52 +00:00
|
|
|
|
}
|
2014-02-22 07:52:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|