add message

This commit is contained in:
Hongtao Zhang 2024-04-19 13:59:00 -05:00
parent b5bd37094f
commit 8e6c06d87c
2 changed files with 18 additions and 4 deletions

View file

@ -92,10 +92,7 @@
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="14"
FontWeight="SemiBold"
Foreground="{Binding MessageColor}"
Text="{Binding Message}"
Visibility="{Binding MessageVisibility}" />
FontWeight="SemiBold" />
</StackPanel>
</Border>

View file

@ -2,6 +2,7 @@
using System.Windows;
using System.Windows.Input;
using Flow.Launcher.Core.Resource;
using Flow.Launcher.Helper;
using Flow.Launcher.Infrastructure.Hotkey;
using Flow.Launcher.Plugin;
using ModernWpf.Controls;
@ -26,6 +27,7 @@ public partial class HotkeyControl2Dialog : ContentDialog
public EResultType ResultType { get; private set; } = EResultType.Cancel;
public string ResultValue { get; private set; } = string.Empty;
public string EmptyHotkey => InternationalizationManager.Instance.GetTranslation("none");
public HotkeyControl2Dialog(string hotkey, string windowTitle = "")
{
WindowTitle = windowTitle;
@ -94,6 +96,21 @@ public partial class HotkeyControl2Dialog : ContentDialog
{
KeysToDisplay.Add(key);
}
if (tbMsg == null)
return;
if (!CheckHotkeyAvailability(hotkey.Value, true))
{
tbMsg.Text = InternationalizationManager.Instance.GetTranslation("registerHotkeyFailed");
tbMsg.Visibility = Visibility.Visible;
}
else
{
tbMsg.Visibility = Visibility.Collapsed;
}
}
private static bool CheckHotkeyAvailability(HotkeyModel hotkey, bool validateKeyGesture) =>
hotkey.Validate(validateKeyGesture) && HotKeyMapper.CheckAvailability(hotkey);
}