protected virtual void OnWindowEvent(WinHookEventArgs e)
 {
     var handler = WindowEvent;
     if (handler != null)
     {
         handler(this, e);
     }
 }
        /// <summary>
        /// Functionality to do with calling the Display Switcher or Window Mover singletons
        /// in order to actually perform functionality. Also contains threading stuff.
        /// </summary>
        private void ProcessWinOpen(object sender, WinHookEventArgs e)
        {
            WriteDebugMessage("Found window: " + e.wName);
            SwitchProfile p = ProfileHandler.GetInstance().FindMatch(e.wName);
            if (p != null)
            {

                CreateDisplaySwitchThread(e, p);
            }
        }
        void CreateDisplaySwitchThread(WinHookEventArgs e, SwitchProfile p)
        {
            switch (e.type)
            {
                case (Interop.ShellEvents.HSHELL_WINDOWCREATED):
                {
                    Thread switchMon;
                    WriteDebugMessage("Window Created. SwitchType: " + p.Type.ToString());
                    switch (p.Type)
                    {
                        case (SwitchProfile.SwitchType.SWITCH_MONITOR):
                        {
                            DisplaySwitcher.GetInstance().RefreshPrimaryDisplay();
                            switchMon = new System.Threading.Thread(() => DisplaySwitcher.GetInstance().SetPrimaryDisplay(p.MonitorToSwitchTo));
                            switchMon.Start();
                            break;
                        }
                        case (SwitchProfile.SwitchType.SWITCH_WINDOW):
                        {
                            switchMon = new System.Threading.Thread(() => MoveWindow(p.WindowTitle, p.MonitorToSwitchTo));
                            switchMon.Start();
                            break;
                        }
                    }

                    break;
                }
                case (Interop.ShellEvents.HSHELL_WINDOWDESTROYED):
                {
                    if (p.Type == SwitchProfile.SwitchType.SWITCH_MONITOR)
                    {
                        Thread processSwitch = new System.Threading.Thread(() => DelayedSwitch(p.Delay, DisplaySwitcher.GetInstance().PrimaryMonitor));
                        processSwitch.Start();
                    }
                    break;
                }
            }
        }