menu performance
This commit is contained in:
@@ -13,11 +13,13 @@ using WpfControls = System.Windows.Controls;
|
||||
|
||||
using static mpvnet.Native;
|
||||
using static mpvnet.Global;
|
||||
using System.Threading;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
public partial class MainForm : Form
|
||||
{
|
||||
public AutoResetEvent MenuAutoResetEvent { get; } = new AutoResetEvent(false);
|
||||
public ElementHost CommandPaletteHost { get; set; }
|
||||
public static MainForm Instance { get; set; }
|
||||
public static IntPtr Hwnd { get; set; }
|
||||
@@ -608,8 +610,6 @@ namespace mpvnet
|
||||
|
||||
public void BuildMenu()
|
||||
{
|
||||
ContextMenu = new WpfControls.ContextMenu();
|
||||
|
||||
string content = File.ReadAllText(Core.InputConfPath);
|
||||
var items = CommandItem.GetItems(content);
|
||||
|
||||
@@ -636,7 +636,10 @@ namespace mpvnet
|
||||
{
|
||||
menuItem.Click += (sender, args) => {
|
||||
try {
|
||||
Core.Command(item.Command);
|
||||
App.RunTask(() => {
|
||||
MenuAutoResetEvent.WaitOne();
|
||||
Core.Command(item.Command);
|
||||
});
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Msg.ShowException(ex);
|
||||
@@ -997,6 +1000,8 @@ namespace mpvnet
|
||||
|
||||
WPF.Init();
|
||||
App.UpdateWpfColors();
|
||||
ContextMenu = new WpfControls.ContextMenu();
|
||||
ContextMenu.Closed += ContextMenu_Closed;
|
||||
BuildMenu();
|
||||
System.Windows.Application.Current.ShutdownMode = System.Windows.ShutdownMode.OnExplicitShutdown;
|
||||
Cursor.Position = new Point(Cursor.Position.X + 1, Cursor.Position.Y);
|
||||
@@ -1008,6 +1013,11 @@ namespace mpvnet
|
||||
WasShown = true;
|
||||
}
|
||||
|
||||
void ContextMenu_Closed(object sender, System.Windows.RoutedEventArgs e)
|
||||
{
|
||||
MenuAutoResetEvent.Set();
|
||||
}
|
||||
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
base.OnResize(e);
|
||||
|
||||
@@ -99,10 +99,7 @@ namespace mpvnet
|
||||
var items = new Dictionary<string, CommandItem>();
|
||||
|
||||
foreach (CommandItem i in CommandItem.Items)
|
||||
if (items.ContainsKey(i.Input) && i.Input != "")
|
||||
Msg.ShowInfo($"Duplicate found:{BR2 + i.Input}: {i.Path + BR2}{items[i.Input].Input}: {items[i.Input].Path + BR2}Please note that you can chain multiple commands in the same line by using a semicolon as separator.", "Duplicate Found");
|
||||
else
|
||||
items[i.Input] = i;
|
||||
items[i.Input] = i;
|
||||
}
|
||||
|
||||
void Window_Loaded(object sender, RoutedEventArgs e) => Keyboard.Focus(SearchControl.SearchTextBox);
|
||||
|
||||
Reference in New Issue
Block a user