private void KeyHandler(object sender, KeyEventArgs e)
        {
            ICommand command = null;

            if (e.Key == Key.Escape)
            {
                command = new TogleVisibilityCommand();
            }
            else if (e.Key == Key.Enter)
            {
                string processFound = "";
                foreach (string item in SearchBox.AutoSuggestionList)
                {
                    if (item.StartsWith(SearchBox.Text))
                    {
                        processFound = item;
                    }
                }
                if (string.IsNullOrEmpty(processFound))
                {
                    command = new StartApplicationCommand();
                }
                else
                {
                    command = new SetFocusCommand();
                }


                viewModelBase.TogleVisible.Execute(this);
            }
            if (command != null)
            {
                command.Execute(this);
            }
        }
Exemple #2
0
 public ViewModelBase()
 {
     this.MainWindow  = Application.Current.MainWindow as MainWindow;
     TogleVisible     = new TogleVisibilityCommand();
     WakeUp           = new WakeUpCommand();
     SetFocus         = new SetFocusCommand();
     StartApplication = new StartApplicationCommand();
 }