Example #1
0
        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);
        }
Example #2
0
 /// <summary>
 /// Happens when the application is about to end.
 /// </summary>
 /// <param name="e">ExitEvent arguments.</param>
 protected override void OnExit(ExitEventArgs e)
 {
     TaskBarNotifier.DisposeNotifyIcon();
     base.OnExit(e);
 }
 // 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();
         }
     }
 }
Example #4
0
 /// <summary>
 /// Opens the main application window and show a task bar message that AIC is already running.
 /// </summary>
 /// <param name="args">Command line arguments.</param>
 /// <returns>Always returns true.</returns>
 public bool SignalExternalCommandLineArgs(IList <string> args)
 {
     OpenMainWindow();
     TaskBarNotifier.ShowNotifyMessage("AIC wird bereits ausgeführt.");
     return(true);
 }
 // Hide the window to the tray instead of closing
 protected override void OnClosing(CancelEventArgs e)
 {
     Hide();
     TaskBarNotifier.ShowNotifyMessage("AIC wurde in den Infobereich minimiert.");
     e.Cancel = true;
 }