diff --git a/Flow.Launcher.Infrastructure/Constant.cs b/Flow.Launcher.Infrastructure/Constant.cs
index 7a95b52d5..8a95ee79f 100644
--- a/Flow.Launcher.Infrastructure/Constant.cs
+++ b/Flow.Launcher.Infrastructure/Constant.cs
@@ -7,6 +7,7 @@ namespace Flow.Launcher.Infrastructure
public static class Constant
{
public const string FlowLauncher = "Flow.Launcher";
+ public const string FlowLauncherFullName = "Flow Launcher";
public const string Plugins = "Plugins";
public const string PluginMetadataFileName = "plugin.json";
diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs
index 503704046..d7df5a23b 100644
--- a/Flow.Launcher/MainWindow.xaml.cs
+++ b/Flow.Launcher/MainWindow.xaml.cs
@@ -27,6 +27,8 @@ using System.Media;
using static Flow.Launcher.ViewModel.SettingWindowViewModel;
using DataObject = System.Windows.DataObject;
using System.Windows.Media;
+using System.Windows.Interop;
+using System.Runtime.InteropServices;
namespace Flow.Launcher
{
@@ -34,11 +36,14 @@ namespace Flow.Launcher
{
#region Private Fields
+ [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
+ public static extern IntPtr SetForegroundWindow(IntPtr hwnd);
+
private readonly Storyboard _progressBarStoryboard = new Storyboard();
private bool isProgressBarStoryboardPaused;
private Settings _settings;
private NotifyIcon _notifyIcon;
- private ContextMenu contextMenu;
+ private ContextMenuStrip contextMenu;
private MainViewModel _viewModel;
private bool _animating;
MediaPlayer animationSound = new MediaPlayer();
@@ -258,11 +263,11 @@ namespace Flow.Launcher
private void UpdateNotifyIconText()
{
var menu = contextMenu;
- ((MenuItem)menu.Items[0]).Header = InternationalizationManager.Instance.GetTranslation("iconTrayOpen") + " (" + _settings.Hotkey + ")";
- ((MenuItem)menu.Items[1]).Header = InternationalizationManager.Instance.GetTranslation("GameMode");
- ((MenuItem)menu.Items[2]).Header = InternationalizationManager.Instance.GetTranslation("PositionReset");
- ((MenuItem)menu.Items[3]).Header = InternationalizationManager.Instance.GetTranslation("iconTraySettings");
- ((MenuItem)menu.Items[4]).Header = InternationalizationManager.Instance.GetTranslation("iconTrayExit");
+ //((MenuItem)menu.Items[0]).Header = InternationalizationManager.Instance.GetTranslation("iconTrayOpen") + " (" + _settings.Hotkey + ")";
+ //((MenuItem)menu.Items[1]).Header = InternationalizationManager.Instance.GetTranslation("GameMode");
+ //((MenuItem)menu.Items[2]).Header = InternationalizationManager.Instance.GetTranslation("PositionReset");
+ //((MenuItem)menu.Items[3]).Header = InternationalizationManager.Instance.GetTranslation("iconTraySettings");
+ //((MenuItem)menu.Items[4]).Header = InternationalizationManager.Instance.GetTranslation("iconTrayExit");
}
@@ -270,12 +275,12 @@ namespace Flow.Launcher
{
_notifyIcon = new NotifyIcon
{
- Text = Infrastructure.Constant.FlowLauncher,
+ Text = Infrastructure.Constant.FlowLauncherFullName,
Icon = Properties.Resources.app,
Visible = !_settings.HideNotifyIcon
};
- contextMenu = new ContextMenu();
+ var contextMenu = new ContextMenu();
var openIcon = new FontIcon
{
@@ -283,7 +288,8 @@ namespace Flow.Launcher
};
var open = new MenuItem
{
- Header = InternationalizationManager.Instance.GetTranslation("iconTrayOpen") + " (" + _settings.Hotkey + ")", Icon = openIcon
+ Header = InternationalizationManager.Instance.GetTranslation("iconTrayOpen") + " (" + _settings.Hotkey + ")",
+ Icon = openIcon
};
var gamemodeIcon = new FontIcon
{
@@ -291,7 +297,8 @@ namespace Flow.Launcher
};
var gamemode = new MenuItem
{
- Header = InternationalizationManager.Instance.GetTranslation("GameMode"), Icon = gamemodeIcon
+ Header = InternationalizationManager.Instance.GetTranslation("GameMode"),
+ Icon = gamemodeIcon
};
var positionresetIcon = new FontIcon
{
@@ -299,7 +306,8 @@ namespace Flow.Launcher
};
var positionreset = new MenuItem
{
- Header = InternationalizationManager.Instance.GetTranslation("PositionReset"), Icon = positionresetIcon
+ Header = InternationalizationManager.Instance.GetTranslation("PositionReset"),
+ Icon = positionresetIcon
};
var settingsIcon = new FontIcon
{
@@ -307,7 +315,8 @@ namespace Flow.Launcher
};
var settings = new MenuItem
{
- Header = InternationalizationManager.Instance.GetTranslation("iconTraySettings"), Icon = settingsIcon
+ Header = InternationalizationManager.Instance.GetTranslation("iconTraySettings"),
+ Icon = settingsIcon
};
var exitIcon = new FontIcon
{
@@ -315,7 +324,8 @@ namespace Flow.Launcher
};
var exit = new MenuItem
{
- Header = InternationalizationManager.Instance.GetTranslation("iconTrayExit"), Icon = exitIcon
+ Header = InternationalizationManager.Instance.GetTranslation("iconTrayExit"),
+ Icon = exitIcon
};
open.Click += (o, e) => _viewModel.ToggleFlowLauncher();
@@ -333,7 +343,6 @@ namespace Flow.Launcher
contextMenu.Items.Add(settings);
contextMenu.Items.Add(exit);
- _notifyIcon.ContextMenuStrip = new ContextMenuStrip(); // it need for close the context menu. if not, context menu can't close.
_notifyIcon.MouseClick += (o, e) =>
{
switch (e.Button)
@@ -341,9 +350,15 @@ namespace Flow.Launcher
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)
+ {
+ _ = SetForegroundWindow(hwndSource.Handle);
+ }
+ contextMenu.Focus();
break;
}
};
diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml
index 96f80f0c5..00de0512c 100644
--- a/Flow.Launcher/SettingWindow.xaml
+++ b/Flow.Launcher/SettingWindow.xaml
@@ -67,6 +67,20 @@
+