Esempio n. 1
0
 public static void UnhookHack()
 {
     if (_windowHandler != null)
     {
         _windowHandler.FocusChanged -= new EventHandler <FocusChangeEventArgs>(WindowFocusChanging);
         //_windowHandler.Activate -= new EventHandler<WindowActivateEventArgs>(WindowActivating);
         _windowHandler.Detach();
         _windowHandler = null;
     }
 }
Esempio n. 2
0
 private static void Current_Exit(object sender, ExitEventArgs e)
 {
     Application.Current.Exit -= new ExitEventHandler(Current_Exit);
     if (_windowHandler != null)
     {
         _windowHandler.FocusChanged -= new EventHandler <FocusChangeEventArgs>(WindowFocusChanging);
         //_windowHandler.Activate -= new EventHandler<WindowActivateEventArgs>(WindowActivating);
         _windowHandler.Detach();
         _windowHandler = null;
     }
 }
        internal static void SetupFocusManagement(DockingManager manager)
        {
            if (_managers.Count == 0)
            {
                //InputManager.Current.EnterMenuMode += new EventHandler(InputManager_EnterMenuMode);
                //InputManager.Current.LeaveMenuMode += new EventHandler(InputManager_LeaveMenuMode);
                _windowHandler = new WindowHookHandler();
                _windowHandler.FocusChanged += new EventHandler<FocusChangeEventArgs>(WindowFocusChanging);
                //_windowHandler.Activate += new EventHandler<WindowActivateEventArgs>(WindowActivating);
                _windowHandler.Attach();

                if (Application.Current != null)
                    Application.Current.Exit += new ExitEventHandler(Current_Exit);
            }

            manager.PreviewGotKeyboardFocus += new KeyboardFocusChangedEventHandler(manager_PreviewGotKeyboardFocus);
            _managers.Add(manager);
        }
Esempio n. 4
0
        internal static void FinalizeFocusManagement(DockingManager manager)
        {
            manager.PreviewGotKeyboardFocus -= new KeyboardFocusChangedEventHandler(manager_PreviewGotKeyboardFocus);
            _managers.Remove(manager);

            if (_managers.Count == 0)
            {
                //InputManager.Current.EnterMenuMode -= new EventHandler(InputManager_EnterMenuMode);
                //InputManager.Current.LeaveMenuMode -= new EventHandler(InputManager_LeaveMenuMode);
                if (_windowHandler != null)
                {
                    _windowHandler.FocusChanged -= new EventHandler <FocusChangeEventArgs>(WindowFocusChanging);
                    //_windowHandler.Activate -= new EventHandler<WindowActivateEventArgs>(WindowActivating);
                    _windowHandler.Detach();
                    _windowHandler = null;
                }
            }
        }
Esempio n. 5
0
        internal static void FinalizeFocusManagement(DockingManager manager)
        {
            manager.PreviewGotKeyboardFocus -= new KeyboardFocusChangedEventHandler(manager_PreviewGotKeyboardFocus);
            _managers.Remove(manager);

            if (_managers.Count == 0)
            {
                //InputManager.Current.EnterMenuMode -= new EventHandler(InputManager_EnterMenuMode);
                //InputManager.Current.LeaveMenuMode -= new EventHandler(InputManager_LeaveMenuMode);
                if (_windowHandler != null)
                {
                    _windowHandler.FocusChanged -= new EventHandler<FocusChangeEventArgs>(WindowFocusChanging);
                    //_windowHandler.Activate -= new EventHandler<WindowActivateEventArgs>(WindowActivating);
                    _windowHandler.Detach();
                    _windowHandler = null;
                }
            }
        }
Esempio n. 6
0
        internal static void SetupFocusManagement(DockingManager manager)
        {
            if (_managers.Count == 0)
            {
                //InputManager.Current.EnterMenuMode += new EventHandler(InputManager_EnterMenuMode);
                //InputManager.Current.LeaveMenuMode += new EventHandler(InputManager_LeaveMenuMode);
                _windowHandler = new WindowHookHandler();
                _windowHandler.FocusChanged += new EventHandler <FocusChangeEventArgs>(WindowFocusChanging);
                _windowHandler.Activate     += new EventHandler <WindowActivateEventArgs>(WindowActivating);
                _windowHandler.Attach();

                /*if (Application.Current != null)
                 *  Application.Current.Exit += new ExitEventHandler(Current_Exit);*/
            }

            manager.PreviewGotKeyboardFocus += new KeyboardFocusChangedEventHandler(manager_PreviewGotKeyboardFocus);
            _managers.Add(manager);
        }
Esempio n. 7
0
        internal static void SetupFocusManagement(DockingManager manager)
        {
            if (_managers.Count == 0)
            {
                //InputManager.Current.EnterMenuMode += new EventHandler(InputManager_EnterMenuMode);
                //InputManager.Current.LeaveMenuMode += new EventHandler(InputManager_LeaveMenuMode);
                _windowHandler = new WindowHookHandler();
                _windowHandler.FocusChanged += new EventHandler <FocusChangeEventArgs>(WindowFocusChanging);
                //_windowHandler.Activate += new EventHandler<WindowActivateEventArgs>(WindowActivating);
                _windowHandler.Attach();
                if (Application.Current != null)
                {
                    //Application.Current.Exit += new ExitEventHandler( Current_Exit );
                    //Application.Current.Dispatcher.Invoke(new Action(() => Application.Current.Exit += new ExitEventHandler(Current_Exit)));
                    var    disp = Application.Current.Dispatcher;
                    Action subscribeToExitAction = new Action(() => Application.Current.Exit += new ExitEventHandler(Current_Exit));
                    if (disp.CheckAccess())
                    {
                        // if we are already on the dispatcher thread we don't need to call Invoke/BeginInvoke
                        subscribeToExitAction();
                    }
                    else
                    {
                        // For resolve issue "System.InvalidOperationException: Cannot perform this operation while dispatcher processing is suspended." make async subscribing instead of sync subscribing.
                        int disableProcessingCount = (int?)typeof(Dispatcher).GetField("_disableProcessingCount", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(disp) ?? 0;

                        if (disableProcessingCount == 0)
                        {
                            disp.Invoke(subscribeToExitAction);
                        }
                        else
                        {
                            disp.BeginInvoke(subscribeToExitAction);
                        }
                    }
                }
            }

            manager.PreviewGotKeyboardFocus += new KeyboardFocusChangedEventHandler(manager_PreviewGotKeyboardFocus);
            _managers.Add(manager);
        }
Esempio n. 8
0
 private static void Current_Exit(object sender, ExitEventArgs e)
 {
     Application.Current.Exit -= new ExitEventHandler(Current_Exit);
     if (_windowHandler != null)
     {
         _windowHandler.FocusChanged -= new EventHandler<FocusChangeEventArgs>(WindowFocusChanging);
         //_windowHandler.Activate -= new EventHandler<WindowActivateEventArgs>(WindowActivating);
         _windowHandler.Detach();
         _windowHandler = null;
     }
 }