Update context menu font when setting is changed

This commit is contained in:
Jack251970 2025-04-24 22:01:38 +08:00
parent 84b0393fd0
commit 7945292128
2 changed files with 43 additions and 34 deletions

View file

@ -115,7 +115,6 @@ namespace Flow.Launcher.Infrastructure.UserSettings
_settingWindowFont = value;
Application.Current.Resources["SettingWindowFont"] = new FontFamily(value);
Application.Current.Resources["ContentControlThemeFontFamily"] = new FontFamily(value);
// TODO: Context Menu Font
}
}
}

View file

@ -140,7 +140,8 @@ namespace Flow.Launcher
_viewModel.Show();
}
// Show notify icon when flowlauncher is hidden
// Initialize context menu & notify icon
InitializeContextMenu();
InitializeNotifyIcon();
// Initialize color scheme
@ -270,6 +271,9 @@ namespace Flow.Launcher
case nameof(Settings.KeepMaxResults):
SetupResizeMode();
break;
case nameof(Settings.SettingWindowFont):
InitializeContextMenu();
break;
}
};
@ -563,6 +567,44 @@ namespace Flow.Launcher
Icon = Constant.Version == "1.0.0" ? Properties.Resources.dev : Properties.Resources.app,
Visible = !_settings.HideNotifyIcon
};
_notifyIcon.MouseClick += (o, e) =>
{
switch (e.Button)
{
case MouseButtons.Left:
_viewModel.ToggleFlowLauncher();
break;
case MouseButtons.Right:
_contextMenu.IsOpen = true;
// Get context menu handle and bring it to the foreground
if (PresentationSource.FromVisual(_contextMenu) is HwndSource hwndSource)
{
Win32Helper.SetForegroundWindow(hwndSource.Handle);
}
_contextMenu.Focus();
break;
}
};
}
private void UpdateNotifyIconText()
{
var menu = _contextMenu;
((MenuItem)menu.Items[0]).Header = App.API.GetTranslation("iconTrayOpen") +
" (" + _settings.Hotkey + ")";
((MenuItem)menu.Items[1]).Header = App.API.GetTranslation("GameMode");
((MenuItem)menu.Items[2]).Header = App.API.GetTranslation("PositionReset");
((MenuItem)menu.Items[3]).Header = App.API.GetTranslation("iconTraySettings");
((MenuItem)menu.Items[4]).Header = App.API.GetTranslation("iconTrayExit");
}
private void InitializeContextMenu()
{
var menu = _contextMenu;
menu.Items.Clear();
var openIcon = new FontIcon { Glyph = "\ue71e" };
var open = new MenuItem
{
@ -608,38 +650,6 @@ namespace Flow.Launcher
_contextMenu.Items.Add(positionreset);
_contextMenu.Items.Add(settings);
_contextMenu.Items.Add(exit);
_notifyIcon.MouseClick += (o, e) =>
{
switch (e.Button)
{
case MouseButtons.Left:
_viewModel.ToggleFlowLauncher();
break;
case MouseButtons.Right:
_contextMenu.IsOpen = true;
// Get context menu handle and bring it to the foreground
if (PresentationSource.FromVisual(_contextMenu) is HwndSource hwndSource)
{
Win32Helper.SetForegroundWindow(hwndSource.Handle);
}
_contextMenu.Focus();
break;
}
};
}
private void UpdateNotifyIconText()
{
var menu = _contextMenu;
((MenuItem)menu.Items[0]).Header = App.API.GetTranslation("iconTrayOpen") +
" (" + _settings.Hotkey + ")";
((MenuItem)menu.Items[1]).Header = App.API.GetTranslation("GameMode");
((MenuItem)menu.Items[2]).Header = App.API.GetTranslation("PositionReset");
((MenuItem)menu.Items[3]).Header = App.API.GetTranslation("iconTraySettings");
((MenuItem)menu.Items[4]).Header = App.API.GetTranslation("iconTrayExit");
}
#endregion