protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); DispatcherUnhandledException += (sender, exc) => Log.GetInstance().LogError("Unhandled application error", exc.Exception); // Log any unhandled exception // Context menu System.Windows.Forms.ContextMenu contextMenu = new System.Windows.Forms.ContextMenu(); System.Windows.Forms.MenuItem infoItem = new System.Windows.Forms.MenuItem("Info", delegate { TaskBarNotifier.ShowInfo(MainWindow); }, System.Windows.Forms.Shortcut.F1); System.Windows.Forms.MenuItem openItem = new System.Windows.Forms.MenuItem("AIC öffnen", delegate { OpenMainWindow(); }); openItem.DefaultItem = true; contextMenu.MenuItems.Add(infoItem); contextMenu.MenuItems.Add(openItem); contextMenu.MenuItems.Add("-"); contextMenu.MenuItems.Add("Beenden", delegate { Shutdown(); }); // Notify icon in tray System.Windows.Forms.NotifyIcon notifyIcon = new System.Windows.Forms.NotifyIcon(); notifyIcon.Text = "AIC"; notifyIcon.Icon = UI.Properties.Resources.aic16; notifyIcon.Visible = true; notifyIcon.ContextMenu = contextMenu; notifyIcon.MouseDoubleClick += delegate { OpenMainWindow(); }; TaskBarNotifier.SetNotifyIcon(notifyIcon); }
// Occurs whenever a key has been pressed private void Window_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.F1) { TaskBarNotifier.ShowInfo(this); } else if (e.Key == Key.F5) { bool connectionOk = mAicMessageListener.CheckConnection(); if (connectionOk) { mAicMessageListener.SendRequestAsync(); } else { mAicMessageListener.Disconnect(); } if (!mExistentAlarm && AicSettings.Global.InfoCenterEnabled) { InfoCenterCtrl.LoadData(); } } else if (e.Key == Key.F7) { if (CurrentAlarmCtrl != null) { mSoundHelper.Alarm = CurrentAlarmCtrl.Alarm.BaseAlarm; mSoundHelper.PlayAnnouncement(); } } else if (e.Key == Key.F8) { mSoundHelper.Stop(); } else if (e.Key == Key.F12) { ShowSettings(); } else if (Keyboard.Modifiers == ModifierKeys.Control && e.Key == Key.P) { if (CurrentAlarmCtrl != null) { new PrintWindow(mAlarmPrinter.ServerName, mAlarmPrinter.PrinterName).ShowAndClose(); mAlarmPrinter.Print(CurrentAlarmCtrl.Alarm.BaseAlarm); } } else if (e.Key == Key.Left) { mChangeTabTimer.Stop(); // Restart the timer mChangeTabTimer.Start(); ShowPreviousAlarm(); if (InfoCenterCtrl.IsActive) { InfoCenterCtrl.ShowPreviousPage(); InfoCenterCtrl.ResetTimer(); } } else if (e.Key == Key.Right) { mChangeTabTimer.Stop(); // Restart the timer mChangeTabTimer.Start(); ShowNextAlarm(); if (InfoCenterCtrl.IsActive) { InfoCenterCtrl.ShowNextPage(); InfoCenterCtrl.ResetTimer(); } } }