Exemplo n.º 1
0
        // /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Construct an EmitterButton from the specified template.
        /// </summary>
        /// <param name="template"></param>
        public EmitterButton(EmitterButtonTemplate template)
            : base(template)
        {
            this.Speed = template.Speed;
            this.StartEmittingDelay = template.StartEmittingDelay;

            CountdownSchedule = new Schedule(DoCountDownEnded, StartEmittingDelay);
            EmitSchedule = new Schedule(DoEmit, Speed);
        }
Exemplo n.º 2
0
        // /////////////////////////////////////////////////////////////////////////////////
        // /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Remove the specified schedule from this component.  The schedule is actually  removed
        /// from the list on the next tick - this ensures that schedules can be added/removed during
        /// another schedule's callback method.
        /// </summary>
        /// <param name="schedule"></param>
        /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="schedule"/> is null.</exception>
        public void RemoveSchedule(Schedule schedule)
        {
            if (schedule == null)
            {
                throw new ArgumentNullException("schedule");
            }

            // Remove the schedule from either the current list of schedules...
            if (scheduleList.Contains(schedule))
            {
                scheduleRemoveList.Add(schedule);
            }
            // ...or the list of schedules waiting to be added
            if (scheduleAddList.Contains(schedule))
            {
                scheduleAddList.Remove(schedule);
            }
        }
Exemplo n.º 3
0
 // /////////////////////////////////////////////////////////////////////////////////
 // /////////////////////////////////////////////////////////////////////////////////
 /// <summary>
 /// Returns true if the specified schedule is currently contained in this component.
 /// </summary>
 /// <param name="schedule"></param>
 /// <returns></returns>
 public bool ContainsSchedule(Schedule schedule)
 {
     if (scheduleList.Contains(schedule) || scheduleAddList.Contains(schedule))
     {
         return true;
     }
     return false;
 }
Exemplo n.º 4
0
        // /////////////////////////////////////////////////////////////////////////////////
        // /////////////////////////////////////////////////////////////////////////////////
        // /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Add a schedule to this component.  All schedule must be reference-unique to this component,
        /// or this method will throw an ArgumentException.  The schedule is actually  added
        /// to the list on the next tick - this ensures that schedules can be added/removed during
        /// another schedule's callback method.
        /// </summary>
        /// <example>
        /// <code>
        /// AddSchedule(new Scheduel(MyCallback,100));
        /// </code>
        /// This will cause the MyCallback method to be called every 100 milliseconds until removed with
        /// RemoveSchedule.  Elsewhere the MyCallback method must be defined as follows:
        /// <code>
        /// void MyCallback()
        /// {
        ///     // insert callback code here
        /// }
        /// </code>
        /// </example>
        /// <param name="schedule"></param>
        /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="schedule"/> is null.</exception>
        /// <exception cref="System.ArgumentException">Thrown when <paramref name="schedule"/> is already
        /// contained by this component</exception>
        public void AddSchedule(Schedule schedule)
        {
            if (schedule == null)
            {
                throw new ArgumentNullException("schedule");
            }

            // Since adding schedules can happen at any time, make sure it has not been added previously
            if (ContainsSchedule(schedule) || scheduleAddList.Contains(schedule))
            {
                throw new ArgumentException("Schedule instances must be unique to this component");
            }

            schedule.Reset();
            scheduleAddList.Add(schedule);
        }