예제 #1
0
        public DarkSwitchApplicationContext()
        {
            if (AlreadyRunning())
            {
                Application.Exit();
                return;
            }

            #region Register hotkey
            keyBoardManager = new KeyboardHookManager();
            keyBoardManager.Start();
            keyBoardManager.RegisterHotkey(ModifierKeys.WindowsKey, (int)Keys.OemQuestion, ToggleTheme);
            #endregion

            // Save icons
            lightIcon = Resources.LightIcon;
            darkIcon  = lightIcon.Invert();

            var systemUsesLightThemeValue = (int)Registry
                                            .GetValue(registryKey, systemUsesLightTheme, 1) != 0;

            // Initialize Tray Icon
            var contextMenu = new ContextMenuStrip();
            var exit        = contextMenu.Items.Add("Exit");
            exit.Click += Exit;
            trayIcon    = new NotifyIcon()
            {
                Icon             = systemUsesLightThemeValue ? lightIcon : darkIcon,
                ContextMenuStrip = contextMenu,
                Text             = "DarkSwitch",
                Visible          = true,
            };
            trayIcon.MouseClick += new MouseEventHandler(this.Icon_MouseClick);
        }
예제 #2
0
        public Form1()
        {
            InitializeComponent();

            _processor = new LowLevelProcessor(new Sha1HashProvider(), new ExcludingSettings()
            {
                Excluded = {}
            });

            _manager = new KeyboardHookManager();
            _manager.Start();
        }
예제 #3
0
        /// <summary>
        /// This class should be created and passed into Application.Run( ... )
        /// </summary>
        public CustomApplicationContext()
        {
            InitializeContext();
            // set the keyhooker
            var keyboardHookManager = new KeyboardHookManager();

            keyboardHookManager.Start();
            keyboardHookManager.RegisterHotkey(0x60, () =>
            {
                Debug.WriteLine("NumPad0 detected");
            });
            keyboardHookManager.RegisterHotkey(NonInvasiveKeyboardHookLibrary.ModifierKeys.Control | NonInvasiveKeyboardHookLibrary.ModifierKeys.Alt, 0x60, () =>
            {
                Debug.WriteLine("Ctrl+Alt+NumPad0 detected");
            });
        }
예제 #4
0
 public ShortcutManager(KeyboardHookManager keyboardHook)
 {
     _keyboardHook = keyboardHook;
 }