/// <summary> /// Interrupt should pause after playback /// </summary> private void _scheduleManager_OnInterruptPausePending() { Debug.WriteLine("Interrupt Pause Pending Event", "Schedule"); if (this._interrupting) { // Set Pause Pending on the current Interrupt Layout ScheduleChangeEvent?.Invoke(null, "pause-pending"); } }
/// <summary> /// Interrupt should happen now /// </summary> private void _scheduleManager_OnInterruptNow() { Debug.WriteLine("Interrupt Now Event", "Schedule"); if (!this._interrupting && this._scheduleManager.CurrentInterruptSchedule.Count > 0) { // Remove overlays if (_overlaySchedule != null && _overlaySchedule.Count > 0) { OverlayChangeEvent?.Invoke(new List <ScheduleItem>()); } // Choose the interrupt in position 0 ScheduleChangeEvent?.Invoke(this._scheduleManager.CurrentInterruptSchedule[0], "interrupt"); } }
/// <summary> /// Interrupt Ended /// </summary> private void _scheduleManager_OnInterruptEnd() { Debug.WriteLine("Interrupt End Event", "Schedule"); if (this._interrupting) { // Assume we will stop this._interrupting = false; // Stop interrupting forthwith ScheduleChangeEvent?.Invoke(null, "interrupt-end"); // Bring back overlays OverlayChangeEvent?.Invoke(_overlaySchedule); } }
/// <summary> /// Moves the layout on /// </summary> public void NextLayout() { Debug.WriteLine("NextLayout: called. Interrupting: " + this._interrupting, "Schedule"); // Get the previous layout ScheduleItem previousLayout = (this._interrupting) ? _scheduleManager.CurrentInterruptSchedule[_currentInterruptLayout] : _layoutSchedule[_currentLayout]; // See if the current layout is an action that can be removed. // If it CAN be removed then this will almost certainly result in a change in the current _layoutSchedule // therefore we should return out of this and kick off a schedule manager cycle, which will set the new layout. try { if (_scheduleManager.removeLayoutChangeActionIfComplete(previousLayout)) { _scheduleManager.RunNow(); return; } } catch (Exception e) { Trace.WriteLine(new LogMessage("Schedule", "NextLayout: Unable to check layout change actions. E = " + e.Message), LogType.Error.ToString()); } // Are currently interrupting? ScheduleItem nextLayout; if (this._interrupting) { // We might have fulifilled items in the schedule. List <ScheduleItem> notFulfilled = new List <ScheduleItem>(); foreach (ScheduleItem item in _scheduleManager.CurrentInterruptSchedule) { if (!item.IsFulfilled) { notFulfilled.Add(item); } } // What if we don't have any? // pick the least worst option if (notFulfilled.Count <= 0) { Debug.WriteLine("NextLayout: Interrupting and have run out of not-fulfilled schedules, using the first one.", "Schedule"); nextLayout = _scheduleManager.CurrentInterruptSchedule[0]; } else { // increment the current layout _currentInterruptLayout++; // if the current layout is greater than the count of layouts, then reset to 0 if (_currentInterruptLayout >= notFulfilled.Count) { _currentInterruptLayout = 0; } // Pull out the next Layout nextLayout = notFulfilled[_currentInterruptLayout]; } } else { // increment the current layout _currentLayout++; // if the current layout is greater than the count of layouts, then reset to 0 if (_currentLayout >= _layoutSchedule.Count) { _currentLayout = 0; } nextLayout = _layoutSchedule[_currentLayout]; } Debug.WriteLine(string.Format("NextLayout: {0}, Interrupt: {1}", nextLayout.layoutFile, nextLayout.IsInterrupt()), "Schedule"); // Raise the event ScheduleChangeEvent?.Invoke(nextLayout, (this._interrupting ? "interrupt-next" : "next")); }