Esempio n. 1
0
        public VirtualDesktopGridManager(SysTrayProcess sysTrayProcess, SettingValues settings)
        {
            this.settings       = settings;
            this.sysTrayProcess = sysTrayProcess;

            foregroundWindowChangedDelegate = new WinAPI.WinEventDelegate(ForegroundWindowChanged);
            fgWindowHook = WinAPI.SetWinEventHook(WinAPI.EVENT_SYSTEM_FOREGROUND, WinAPI.EVENT_SYSTEM_FOREGROUND, IntPtr.Zero, foregroundWindowChangedDelegate, 0, 0, WinAPI.WINEVENT_OUTOFCONTEXT);

            Start();
        }
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var settings = SettingValues.Load();

            using (SysTrayProcess sysTrayProcess = new SysTrayProcess(settings)) {
                using (VirtualDesktopGridManager gridManager =
                           new VirtualDesktopGridManager(sysTrayProcess, settings)) {
                    // Make sure the application runs!
                    Application.Run();
                }
            }
        }
        public VirtualDesktopGridManager(SysTrayProcess sysTrayProcess, SettingValues settings)
        {
            this.settings       = settings;
            this.sysTrayProcess = sysTrayProcess;

            VDMHelper = VdmHelperFactory.CreateInstance();
            VDMHelper.Init();

            foregroundWindowChangedDelegate = new WinAPI.WinEventDelegate(ForegroundWindowChanged);
            fgWindowHook = WinAPI.SetWinEventHook(WinAPI.EVENT_SYSTEM_FOREGROUND, WinAPI.EVENT_SYSTEM_FOREGROUND, IntPtr.Zero, foregroundWindowChangedDelegate, 0, 0, WinAPI.WINEVENT_OUTOFCONTEXT);

            // Create a custom message ID for other processes to trigger actions.
            commandWindowMessage = RegisterWindowMessage("VIRTUALDESKTOPGRIDSWITCHER_COMMAND");
            Application.AddMessageFilter(this);

            Start();
        }