Example #1
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public ViewModel(Snackbar Snackbar)
        {
            this._SnackbarAdd = Snackbar;

            this._AutoStart = Settings.GetAutoStart();
            this._Processes = new ObservableCollection <ProcessInfos>();
            this._keys      = new List <Key>();
            this._KListener = new KeyboardListener();

            Settings.LoadWhitelist(this._Processes);

            // Start process listener thread
            WindowHandler.StartListener(this.Processes);

            // Keys events
            KListener.KeyDown += new RawKeyEventHandler(KListener_KeyDown);
            KListener.KeyUp   += new RawKeyEventHandler(KListener_KeyUp);
        }
Example #2
0
        /// <summary>
        /// KeyDown event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        void KListener_KeyDown(object sender, RawKeyEventArgs args)
        {
            try
            {
                SetKeyDown(args.Key);

                // Ctrl + F11 (Action on foreground app)
                if (IsKeyDown(Key.LeftCtrl) && IsKeyDown(Key.F11))
                {
                    WindowHandler.ChangeBorderStyle(WindowLib.GetForegroundWindow());
                }
                // Ctrl + F12 (Adds / Removes foreground app to / from list)
                else if (IsKeyDown(Key.LeftCtrl) && IsKeyDown(Key.F12))
                {
                    ProcessInfos.AddOrRemove(this.Processes);
                }
            }
            catch { }
        }