diff --git a/RetroBar/App.xaml.cs b/RetroBar/App.xaml.cs
index 76290d29..f2332523 100644
--- a/RetroBar/App.xaml.cs
+++ b/RetroBar/App.xaml.cs
@@ -12,6 +12,8 @@
using System.Reflection;
using ManagedShell.Common.Logging;
using System.Linq;
+using System.Windows.Controls;
+using System.Windows.Input;
namespace RetroBar
{
@@ -57,11 +59,39 @@ private void App_OnStartup(object sender, StartupEventArgs e)
RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
}
+ EventManager.RegisterClassHandler(typeof(ContextMenu), ContextMenu.OpenedEvent, new RoutedEventHandler(MenuOpened));
+ EventManager.RegisterClassHandler(typeof(ContextMenu), UIElement.KeyDownEvent, new KeyEventHandler(MenuOnKeyDown));
+ EventManager.RegisterClassHandler(typeof(MenuItem), MenuItem.ClickEvent, new RoutedEventHandler(MenuItemClicked));
+ EventManager.RegisterClassHandler(typeof(MenuItem), MenuItem.SubmenuOpenedEvent, new RoutedEventHandler(MenuOpened));
_dictionaryManager.SetLanguageFromSettings();
loadTheme();
_windowManager = new WindowManager(_dictionaryManager, _explorerMonitor, _shellManager, _startMenuMonitor, _updater, _hotkeyManager);
}
+ private void MenuOpened(object sender, RoutedEventArgs e)
+ {
+ SoundHelper.PlaySystemSound("MenuPopup");
+ }
+
+ private void MenuItemClicked(object sender, RoutedEventArgs e)
+ {
+ if (sender is MenuItem menuItem && menuItem.StaysOpenOnClick)
+ {
+ return;
+ }
+
+ SoundHelper.PlaySystemSound("MenuCommand");
+ }
+
+ private void MenuOnKeyDown(object sender, KeyEventArgs e)
+ {
+ // don't close if alt is pressed
+ if (e.SystemKey is Key.LeftAlt or Key.RightAlt)
+ {
+ e.Handled = true;
+ }
+ }
+
private void App_OnExit(object sender, ExitEventArgs e)
{
ExitApp();
diff --git a/RetroBar/Controls/TaskButton.xaml b/RetroBar/Controls/TaskButton.xaml
index d5dce3a6..d076332e 100644
--- a/RetroBar/Controls/TaskButton.xaml
+++ b/RetroBar/Controls/TaskButton.xaml
@@ -20,7 +20,8 @@
ContextMenuOpening="AppButton_OnContextMenuOpening"
DragEnter="AppButton_OnDragEnter"
DragLeave="AppButton_OnDragLeave"
- ToolTipService.ShowDuration="60000">
+ ToolTipService.ShowDuration="60000"
+ ContextMenu="{StaticResource TaskButtonContextMenu}">
@@ -44,58 +45,6 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/RetroBar/Controls/TaskButton.xaml.cs b/RetroBar/Controls/TaskButton.xaml.cs
index bd4149c6..b913585c 100644
--- a/RetroBar/Controls/TaskButton.xaml.cs
+++ b/RetroBar/Controls/TaskButton.xaml.cs
@@ -1,5 +1,6 @@
using System;
using System.ComponentModel;
+using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
@@ -103,6 +104,10 @@ private void TaskButton_OnLoaded(object sender, RoutedEventArgs e)
Animate();
}
+ AppButton.ContextMenu.Opened += ContextMenu_OpenedOrClosed;
+ AppButton.ContextMenu.Closed += ContextMenu_OpenedOrClosed;
+ AppButton.ContextMenu.KeyDown += ContextMenu_KeyDown;
+
_isLoaded = true;
}
@@ -158,51 +163,106 @@ private void AppButton_OnContextMenuOpening(object sender, ContextMenuEventArgs
NativeMethods.WindowShowStyle wss = Window.ShowStyle;
int ws = Window.WindowStyles;
- // disable window operations depending on current window state. originally tried implementing via bindings but found there is no notification we get regarding maximized state
- MaximizeMenuItem.IsEnabled = wss != NativeMethods.WindowShowStyle.ShowMaximized && (ws & (int)NativeMethods.WindowStyles.WS_MAXIMIZEBOX) != 0;
- MinimizeMenuItem.IsEnabled = wss != NativeMethods.WindowShowStyle.ShowMinimized && Window.CanMinimize;
- if (RestoreMenuItem.IsEnabled = wss != NativeMethods.WindowShowStyle.ShowNormal)
+ var menuItems = AppButton.ContextMenu.Items.OfType