Skip to content

Commit a399d24

Browse files
Extract set message logic
1 parent f6e2fe3 commit a399d24

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

Flow.Launcher/HotkeyControl.xaml.cs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,8 @@ public async Task SetHotkeyAsync(HotkeyModel keyModel, bool triggerValidate = tr
7070

7171
if (triggerValidate)
7272
{
73-
CurrentHotkeyAvailable = CurrentHotkey.CharKey != Key.None && CheckHotkeyAvailability();
74-
if (!CurrentHotkeyAvailable)
75-
{
76-
tbMsg.Foreground = new SolidColorBrush(Colors.Red);
77-
tbMsg.Text = InternationalizationManager.Instance.GetTranslation("hotkeyUnavailable");
78-
}
79-
else
80-
{
81-
tbMsg.Foreground = new SolidColorBrush(Colors.Green);
82-
tbMsg.Text = InternationalizationManager.Instance.GetTranslation("success");
83-
}
84-
tbMsg.Visibility = Visibility.Visible;
73+
bool hotkeyAvailable = keyModel.CharKey != Key.None && CheckHotkeyAvailability(keyModel);
74+
SetMessage(hotkeyAvailable);
8575
OnHotkeyChanged();
8676

8777
var token = hotkeyUpdateSource.Token;
@@ -117,5 +107,20 @@ private void ResetMessage()
117107
tbMsg.Text = InternationalizationManager.Instance.GetTranslation("flowlauncherPressHotkey");
118108
tbMsg.SetResourceReference(TextBox.ForegroundProperty, "Color05B");
119109
}
110+
111+
private void SetMessage(bool hotkeyAvailable)
112+
{
113+
if (!hotkeyAvailable)
114+
{
115+
tbMsg.Foreground = new SolidColorBrush(Colors.Red);
116+
tbMsg.Text = InternationalizationManager.Instance.GetTranslation("hotkeyUnavailable");
117+
}
118+
else
119+
{
120+
tbMsg.Foreground = new SolidColorBrush(Colors.Green);
121+
tbMsg.Text = InternationalizationManager.Instance.GetTranslation("success");
122+
}
123+
tbMsg.Visibility = Visibility.Visible;
124+
}
120125
}
121126
}

0 commit comments

Comments
 (0)