Ejemplo n.º 1
0
        public static int Main(string[] args)
        {
            if (SingleApplicationInstance.IsAlreadyRunning())
                return 1;

            Application.SetCompatibleTextRenderingDefault(true);
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.ThrowException, true);
            Application.EnableVisualStyles();

            using (_keyboardHook = new KeyboardHook())
            {
                _capsHook = _keyboardHook.CreateKeyHook(Keys.CapsLock);
                _capsHook.SuppressInput = true;
                _capsHook.KeyDown += new KeyEventHandler(OnCapsKeyDown);
                _capsHook.KeyUp += new KeyEventHandler(OnCapsKeyUp);

                EnsureCapsLockDisabled();

                var thisAssembly = Assembly.GetExecutingAssembly();
                var assemblyCatalog = new AssemblyCatalog(thisAssembly);
                var coreCatalog = new AssemblyCatalog(typeof(ICommand).Assembly);
                var catalog = new AggregateCatalog(assemblyCatalog, coreCatalog);
                var container = new CompositionContainer(catalog);

                // Todo: Hack: Forcing creation of command factories.
                container.GetExportedValues<ICommandFactory>();
                _commandProvider = container.GetExportedValue<ICommandProvider>();

                NotificationForm.Show("Ephemeral");

                Application.Run();
            }

            EnsureCapsLockDisabled();

            return 0;
        }
Ejemplo n.º 2
0
        public KeyHook CreateKeyHook(Keys key)
        {
            var events = new InternalKeyEvents();
            var hook = new KeyHook(events, key);

            _hooks[key] = new KeyHookSettings
            {
                Hook = hook,
                Events = events
            };

            return hook;
        }