2022-10-08 09:52:27 +00:00
|
|
|
|
using Flow.Launcher.Core.Resource;
|
|
|
|
|
|
using Flow.Launcher.Infrastructure.UserSettings;
|
|
|
|
|
|
using System;
|
2022-06-04 05:30:33 +00:00
|
|
|
|
using System.Windows;
|
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Flow.Launcher
|
|
|
|
|
|
{
|
|
|
|
|
|
public partial class CustomShortcutSetting : Window
|
|
|
|
|
|
{
|
|
|
|
|
|
private Settings _settings;
|
2022-10-08 09:52:27 +00:00
|
|
|
|
private bool update = false;
|
2022-06-04 05:30:33 +00:00
|
|
|
|
public string Key { get; set; }
|
|
|
|
|
|
public string Value { get; set; }
|
2022-10-05 11:55:49 +00:00
|
|
|
|
public CustomShortcutModel ShortCut => (Key, Value);
|
2022-10-05 18:20:51 +00:00
|
|
|
|
|
2022-10-08 09:52:27 +00:00
|
|
|
|
public CustomShortcutSetting(Settings settings)
|
2022-06-04 05:30:33 +00:00
|
|
|
|
{
|
2022-10-08 09:52:27 +00:00
|
|
|
|
_settings = settings;
|
2022-06-04 05:30:33 +00:00
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-10-08 09:52:27 +00:00
|
|
|
|
public CustomShortcutSetting((string, string) shortcut, Settings settings)
|
2022-06-04 05:30:33 +00:00
|
|
|
|
{
|
|
|
|
|
|
(Key, Value) = shortcut;
|
2022-10-08 09:52:27 +00:00
|
|
|
|
_settings = settings;
|
|
|
|
|
|
update = true;
|
2022-06-04 05:30:33 +00:00
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void BtnCancel_OnClick(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
DialogResult = false;
|
|
|
|
|
|
Close();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void btnAdd_OnClick(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
2022-10-08 09:52:27 +00:00
|
|
|
|
if (!update && _settings.CustomShortcuts.Contains(new CustomShortcutModel(Key, Value)))
|
2022-10-08 09:01:18 +00:00
|
|
|
|
{
|
|
|
|
|
|
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("dulplicateShortcut"));
|
2022-10-08 09:52:27 +00:00
|
|
|
|
return;
|
2022-10-08 09:01:18 +00:00
|
|
|
|
}
|
2022-10-08 09:52:27 +00:00
|
|
|
|
if (String.IsNullOrEmpty(Key) || String.IsNullOrEmpty(Value))
|
2022-10-08 09:01:18 +00:00
|
|
|
|
{
|
|
|
|
|
|
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("invalidShortcut"));
|
2022-10-08 09:52:27 +00:00
|
|
|
|
return;
|
2022-10-08 09:01:18 +00:00
|
|
|
|
}
|
2022-10-08 09:52:27 +00:00
|
|
|
|
DialogResult = true;
|
2022-06-04 05:30:33 +00:00
|
|
|
|
Close();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void cmdEsc_OnPress(object sender, ExecutedRoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
DialogResult = false;
|
|
|
|
|
|
Close();
|
|
|
|
|
|
}
|
2022-10-08 09:52:27 +00:00
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
}
|
2022-06-04 05:30:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|