// This happens every minute private void oneMinuteTimer_Tick(object sender, EventArgs e) { // Try to turn on the screen if there is an alarm. This must be performed on the UI thread if (mPublicDisplayControl == null && mExistentAlarm) { ScreenPower.TurnOn(this); } // Turn on/off the public screen at defined hours if (mPublicDisplayControl != null && !mExistentAlarm) { var now = DateTime.Now.TimeOfDay; if (Math.Abs((now - AicSettings.Global.PublicDisplayTurnScreenOnTime).TotalMinutes) < 1) { mPublicDisplayControl.TurnOn(); } else if (Math.Abs((now - AicSettings.Global.PublicDisplayTurnScreenOffTime).TotalMinutes) < 1) { mPublicDisplayControl.TurnOff(); } } // Check system in background if (!mCheckSystemWorker.IsBusy) { mCheckSystemWorker.RunWorkerAsync(); } }
// Turns the local screens off after a defined timespan private void mTurnScreenOffTimer_Tick(object sender, EventArgs e) { if (AicSettings.Global.TurnScreenOffDelayMinutes > 0) { ScreenPower.TurnOff(this); } }
private void OnScreenPowerMgmtEvent(ScreenPowerMgmtEventArgs args) { ScreenPower?.Invoke(this, args); }
// Removes, updates, and adds alarms private void RefreshAlarms(ICollection <Alarm> alarms) { // Show that several concurrent alarms exist AlarmGrid.Visibility = Visibility.Visible; NoAlarmPnl.Visibility = Visibility.Hidden; InfoCenterCtrl.Visibility = Visibility.Hidden; InfoCenterCtrl.Stop(); MultiAlarmGrid.Visibility = alarms.Count > 1 ? Visibility.Visible : Visibility.Collapsed; // Remove finished alarms, refresh existing alarms, show new alarms var removeIds = mAlarmId2Ctrl.Keys.Except(alarms.Select(a => a.Id)).ToList(); int numberOfRemovedAlarms = RemoveAlarms(removeIds); UpdateAlarms(alarms); var newAlarms = AddAlarms(alarms); // Ensure that an alarm is shown if (newAlarms.Count == 0 && numberOfRemovedAlarms > 0) { ShowNextAlarm(); } #region Turn screen on, bring window to front, play sound if (newAlarms.Count > 0) { // Turn on screen try { if (mPublicDisplayControl != null) { mPublicDisplayControl.TurnOn(); } else { // Stop turning off screen if (mTurnScreenOffTimer != null) { mTurnScreenOffTimer.Stop(); } ScreenPower.TurnOn(this); } } catch (Exception ex) { Log.GetInstance().LogError("Error in turning on screen.", ex); } // Bring the AIC window to front ShowAndActivate(); // Play a sound if (!Starting) { try { mSoundHelper.Alarm = newAlarms.Last(); if (AicSettings.Global.PlayAlarmSound && !AicSettings.Global.PlayAnnouncement) { mSoundHelper.PlayAlarmSound(); } else if (AicSettings.Global.PlayAnnouncement) { mSoundHelper.PlaySequence(AicSettings.Global.PlayAlarmSound, AicSettings.Global.AnnouncementIntervals); } } catch (Exception ex) { Log.GetInstance().LogError("Could not play sound.", ex); } } } #endregion }