示例#1
0
 protected override void OnKeyDown(KeyEventArgs e)
 {
     try
     {
         if (isLocked)
         {
             if (IsRequestingOptions_Exit)
             {
                 EnteredPassword      = "";
                 PasswordModeToExit   = true;
                 PasswordModeToUnlock = false;
                 this.PasswordModeInformer.Visibility = Visibility.Visible;
                 this.PasswordModeInformer.Content    = "Password Mode (TO EXIT)";
                 return;
             }
             else
             if (IsRequestingOptions_Unlock)
             {
                 EnteredPassword      = "";
                 PasswordModeToExit   = false;
                 PasswordModeToUnlock = true;
                 this.PasswordModeInformer.Visibility = Visibility.Visible;
                 this.PasswordModeInformer.Content    = "Password Mode (TO UNLOCK)";
                 return;
             }
             else
             if (IsCtrlAltDelete)
             {
                 MessageBox.Show("Ctrl+Alt+Delete");
                 e.Handled = true;
                 return;
             }
             else
             if (e.Key != Key.System &&
                 e.Key != Key.LeftAlt && e.Key != Key.RightAlt &&
                 e.Key != Key.LeftCtrl && e.Key != Key.RightCtrl)
             {
                 if ((PasswordModeToExit || PasswordModeToUnlock) && e.Key == Key.Enter)
                 {
                     if (EnteredPassword.Equals(pass, StringComparison.InvariantCultureIgnoreCase))
                     {
                         if (PasswordModeToUnlock)
                         {
                             State = STATES.AdminSession;
                         }
                         else
                         {
                             ProcessManager.KillProcessByName(Constants.INSPECTOR_APP_NAME);
                             this.reallyCloseWindow = true;
                             this.Close();
                         }
                     }
                     else
                     {
                         EnteredPassword      = "";
                         PasswordModeToExit   = false;
                         PasswordModeToUnlock = false;
                         this.PasswordModeInformer.Visibility = Visibility.Hidden;
                     }
                     return;
                 }
                 else
                 {
                     if ((PasswordModeToExit || PasswordModeToUnlock))
                     {
                         EnteredPassword += e.Key.ToString();
                         return;
                     }
                     else if (state == STATES.FinishingSession && e.Key == Key.R)
                     {
                         seconds_ToTheEnd = AppSettings.FIELDS.KP_TimeWaiting;
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         AppLogger.Error("OnKeyDown()", "key = '" + e.Key + "' Exception: " + ex);
     }
     finally
     {
         base.OnKeyDown(e);
     }
 }