Ejemplo n.º 1
0
        /// <summary>
        /// Moves the layout on
        /// </summary>
        public void NextLayout()
        {
            int previousLayout = _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(_layoutSchedule[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());
            }

            // 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;
            }

            if (_layoutSchedule.Count == 1 && !_forceChange)
            {
                Debug.WriteLine(new LogMessage("Schedule - NextLayout", "Only 1 layout showing, refreshing it"), LogType.Info.ToString());
            }

            Debug.WriteLine(String.Format("Next layout: {0}", _layoutSchedule[_currentLayout].layoutFile), "Schedule - Next Layout");

            _forceChange = false;

            // Raise the event
            ScheduleChangeEvent(_layoutSchedule[_currentLayout].layoutFile, _layoutSchedule[_currentLayout].scheduleid, _layoutSchedule[_currentLayout].id);
        }
Ejemplo n.º 2
0
        /// <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"));
        }