Beispiel #1
0
        /// <summary>
        /// New Schedule Available
        /// </summary>
        private void _scheduleManager_OnNewScheduleAvailable()
        {
            Debug.WriteLine("_scheduleManager_OnNewScheduleAvailable: New Schedule Available", "Schedule");
            Debug.WriteLine("_scheduleManager_OnNewScheduleAvailable: " + _scheduleManager.CurrentOverlaySchedule.Count + " overlays", "Schedule");
            Debug.WriteLine("_scheduleManager_OnNewScheduleAvailable: " + _scheduleManager.CurrentSchedule.Count + " normal schedules", "Schedule");

            _overlaySchedule = new List <ScheduleItem>(_scheduleManager.CurrentOverlaySchedule);
            _layoutSchedule  = _scheduleManager.CurrentSchedule;

            // Set the current pointer to 0
            _currentLayout = 0;

            // If we are not interrupting, then update the current schedule
            if (!this._interrupting)
            {
                // Raise a schedule change event
                ScheduleChangeEvent(_layoutSchedule[0], "next");

                // Pass a new set of overlay's to subscribers
                OverlayChangeEvent?.Invoke(_overlaySchedule);
            }
            else
            {
                Debug.WriteLine("_scheduleManager_OnNewScheduleAvailable: Skipping Next Layout Change due to Interrupt", "Schedule");
            }
        }
Beispiel #2
0
        /// <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");
            }
        }
Beispiel #3
0
        /// <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>
        /// A layout file has changed
        /// </summary>
        /// <param name="layoutPath"></param>
        private void LayoutFileModified(string layoutPath)
        {
            Trace.WriteLine(new LogMessage("Schedule", "LayoutFileModified: Layout file changed: " + layoutPath), LogType.Info.ToString());

            // Are we set to expire modified layouts? If not then just return as if
            // nothing had happened.
            // We never force change an interrupt layout
            if (!ApplicationSettings.Default.ExpireModifiedLayouts || this._interrupting)
            {
                return;
            }

            // Determine if we need to reassess the overlays
            bool changeRequired = false;

            foreach (ScheduleItem item in _overlaySchedule)
            {
                if (item.layoutFile == ApplicationSettings.Default.LibraryPath + @"\" + layoutPath)
                {
                    // We should mark this item as being one to remove and re-add.
                    item.Refresh   = true;
                    changeRequired = true;
                }
            }

            if (changeRequired)
            {
                OverlayChangeEvent?.Invoke(_overlaySchedule);
            }

            // If the layout that got changed is the current layout, move on
            try
            {
                if (_layoutSchedule[_currentLayout].layoutFile == ApplicationSettings.Default.LibraryPath + @"\" + layoutPath)
                {
                    // What happens if the action of downloading actually invalidates this layout?
                    bool valid = CacheManager.Instance.IsValidPath(layoutPath);

                    if (valid)
                    {
                        // Check dependents
                        foreach (string dependent in _layoutSchedule[_currentLayout].Dependents)
                        {
                            if (!string.IsNullOrEmpty(dependent) && !CacheManager.Instance.IsValidPath(dependent))
                            {
                                valid = false;
                                break;
                            }
                        }
                    }

                    if (!valid)
                    {
                        Trace.WriteLine(new LogMessage("Schedule - LayoutFileModified", "The current layout is now invalid, refreshing the current schedule."), LogType.Audit.ToString());

                        // We should not force a change and we should tell the schedule manager to run now
                        _scheduleManager.RefreshSchedule = true;
                        _scheduleManager.RunNow();
                    }
                    else
                    {
                        Trace.WriteLine(new LogMessage("Schedule - LayoutFileModified", "Forcing the current layout to change: " + layoutPath), LogType.Audit.ToString());

                        // Run the next layout
                        NextLayout();
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(new LogMessage("fileCollector_LayoutFileChanged", String.Format("Unable to determine current layout with exception {0}", ex.Message)), LogType.Error.ToString());
            }
        }