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); } }
private void WorkingTimerTick(object obj, EventArgs args) { switch (state) { case STATES.FinishingSession: { if (seconds_ToTheEnd > 0) { this.GridFinisher.Visibility = Visibility.Visible; MiddleInformer.Content = String.Format("{0} секунд(-ы).", seconds_ToTheEnd); seconds_ToTheEnd--; MinimizeAllWindows(); if (!ProcessManager.IsForegrount()) { this.Topmost = false; this.Topmost = true; InvalidateVisual(); } } else { State = STATES.NotSession; } break; } case STATES.NotSession: { if (this.IsActiveSession) { State = STATES.Session; } else { if (!isLocked) { Lock(); } if (!ProcessManager.IsForegrount()) { this.Topmost = false; this.Topmost = true; InvalidateVisual(); } } break; } case STATES.Session: case STATES.LastFiveMinutes: { if (!this.IsActiveSession) { State = STATES.FinishingSession; } else if (this.IsPaused) { State = STATES.Pause; } else if ( state != STATES.LastFiveMinutes && SessionHandler.LessThenFiveMin()) { State = STATES.LastFiveMinutes; } break; } case STATES.Pause: { if (!this.IsActiveSession) { State = STATES.FinishingSession; } else if (!this.IsPaused) { State = STATES.Session; } break; } case STATES.AdminSession: { if (this.IsActiveSession) { State = STATES.Session; } break; } } }