示例#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();
        }
        /// <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;
 }