namespace FSI.BT.Tools.RadialMenu.Business { using System; using System.Threading; using System.Windows; using FSI.BT.Tools.RadialMenu.Handler; using FSI.Lib.Wpf.ExtensionMethods; internal class Main : IDisposable { private readonly KeyboardInput keyboardInput; private UserInterface.FrmRadialMenu frmRadialMenu; public Main() { keyboardInput = new(); keyboardInput.RegisterHotKey(); keyboardInput.HotKeyPressed += KeyboardInput_HotKeyPressed; frmRadialMenu = new UserInterface.FrmRadialMenu(); } public void Dispose() { keyboardInput.HotKeyPressed -= KeyboardInput_HotKeyPressed; keyboardInput.Dispose(); } private void KeyboardInput_HotKeyPressed() { Thread thread = new(() => { UserInterface.FrmRadialMenu frmRadialMenu = new(); if (Global.Vars.UserRights || Global.Vars.AdminRights) { if (frmRadialMenu.Visibility == Visibility.Collapsed) { frmRadialMenu.ShowCenteredToMouse(); frmRadialMenu.ActivateCenteredToMouse(); } frmRadialMenu.Closed += (sender2, e2) => frmRadialMenu.Dispatcher.InvokeShutdown(); System.Windows.Threading.Dispatcher.Run(); } }); thread.SetApartmentState(ApartmentState.STA); thread.Start(); } } }