void Event_DisplaySettingsChanged(object sender, EventArgs e) { UpdatingDisplaySettings = true; //Console.WriteLine("\nDisplay Settings Changed..."); //ShowScreens (); SnagScreen.Init(Screen.AllScreens); SnagScreen.ShowAll(); UpdatingDisplaySettings = false; }
public void Run(string[] args) { // DPI Awareness API is not available on older OS's, but they work in // physical pixels anyway, so we just ignore if the call fails. try { SetProcessDpiAwareness(PROCESS_DPI_AWARENESS.Process_Per_Monitor_DPI_Aware); } catch (System.DllNotFoundException) { //Console.WriteLine("No SHCore.DLL. No problem."); } // Make sure we catch CTRL-C hard-exit of program. CTRL_C_handler = new ConsoleEventDelegate(ConsoleEventCallback); SetConsoleCtrlHandler(CTRL_C_handler, true); //ShowScreens (); SnagScreen.Init(Screen.AllScreens); SnagScreen.ShowAll(); // Get notified of any screen configuration changes. SystemEvents.DisplaySettingsChanged += Event_DisplaySettingsChanged; //ShowWindow(GetConsoleWindow(), SW_HIDE); // Keep a reference to the delegate, so it does not get garbage collected. MouseHookDelegate = LLMouseHookCallback; LLMouse_hookhand = SetHook(WH_MOUSE_LL, MouseHookDelegate); //Console.WriteLine(""); // This is the one that runs "forever" while the application is alive, and handles // events, etc. This application is ABSOLUTELY ENTIRELY driven by the LLMouseHook // and DisplaySettingsChanged events. Application.Run(); //Console.WriteLine("Exiting!!!"); UnsetHook(ref LLMouse_hookhand); }