/// <summary> /// Default constructor /// </summary> public Timer() { timer = StaticExtensionEventInterfaces.TimerEventFactory.NewTimer; Action act = Event; locked = act.LockedAction(); }
/// <summary> /// Creates a form for component properties editor /// </summary> /// <param name="component">The component</param> /// <returns>The result form</returns> public override object CreateForm(INamedComponent component) { if (component is IObjectLabel) { IObjectLabel lab = component as IObjectLabel; // The object of component ICategoryObject obj = lab.Object; if (obj is ITimerEvent) { ITimerEvent timer = obj as ITimerEvent; return(new Forms.FormTimer(obj as ITimerEvent)); } } return(null); }
public void addEventListeners(ITimerEvent item) { int idx = _toRemove.IndexOf(item); if (idx != -1) { _toRemove.RemoveAt(idx); } if (this.listeners.Contains(item)) { return; } this.listeners.Add(item); }
/// <summary> /// Cancel the timer that was created with the given sink object with the given Id. /// </summary> /// <param name="sink">the ITimerEvent that the timer was created with</param> /// <param name="id">the Id of the timer to cancel</param> /// <remarks> /// The complexity of this operation is O(n). We assume it is rarely used. /// </remarks> public void CancelTimer([NotNull] ITimerEvent sink, int id) { bool removed = false; foreach (var pair in m_timers) { var timer = pair.Value.FirstOrDefault(x => x.Id == id && x.Sink == sink); if (timer != null) { removed = pair.Value.Remove(timer); break; } } Debug.Assert(removed); }
// Cancel the timer created by sink_ object with ID equal to id_. public void CancelTimer(ITimerEvent sink, int id) { // Complexity of this operation is O(n). We assume it is rarely used. var foundTimers = new Dictionary <long, TimerInfo>(); foreach (var pair in m_timers) { var timer = pair.Value.FirstOrDefault(x => x.Id == id && x.Sink == sink); if (timer == null) { continue; } if (!foundTimers.ContainsKey(pair.Key)) { foundTimers[pair.Key] = timer; break; } } if (foundTimers.Count > 0) { foreach (var foundTimer in foundTimers) { if (m_timers[foundTimer.Key].Count == 1) { m_timers.Remove(foundTimer.Key); } else { m_timers[foundTimer.Key].Remove(foundTimer.Value); } } } else { // Timer not found. Debug.Assert(false); } }
/// <summary> /// Cancel the timer that was created with the given sink object with the given Id. /// </summary> /// <param name="sink">the ITimerEvent that the timer was created with</param> /// <param name="id">the Id of the timer to cancel</param> /// <remarks> /// The complexity of this operation is O(n). We assume it is rarely used. /// </remarks> public void CancelTimer([NotNull] ITimerEvent sink, int id) { Dictionary <long, TimerInfo> foundTimers = new Dictionary <long, TimerInfo>(); foreach (KeyValuePair <long, List <TimerInfo> > pair in this.m_timers) { TimerInfo timer = pair.Value.FirstOrDefault(x => x.Id == id && x.Sink == sink); if (timer == null) { continue; } if (!foundTimers.ContainsKey(pair.Key)) { foundTimers[pair.Key] = timer; break; } } if (foundTimers.Count > 0) { foreach (KeyValuePair <long, TimerInfo> foundTimer in foundTimers) { if (this.m_timers[foundTimer.Key].Count == 1) { this.m_timers.Remove(foundTimer.Key); } else { this.m_timers[foundTimer.Key].Remove(foundTimer.Value); } } } else { // Timer not found. Debug.Assert(false); } }
public TimerInfo(ITimerEvent sink, int id) { Sink = sink; Id = id; }
/// <summary> /// Create a new TimerInfo object from the given sink and id. /// </summary> /// <param name="sink">an ITimerEvent that acts as a sink for when the timer expires</param> /// <param name="id">an integer id that identifies this timer</param> public TimerInfo([NotNull] ITimerEvent sink, int id) { Sink = sink; Id = id; }
/// <summary> /// Create a new TimerInfo object from the given sink and id. /// </summary> /// <param name="sink">an ITimerEvent that acts as a sink for when the timer expires</param> /// <param name="id">an integer id that identifies this timer</param> public TimerInfo( ITimerEvent sink, int id) { Sink = sink; Id = id; }
/// <summary> /// Cancel the timer that was created with the given sink object with the given Id. /// </summary> /// <param name="sink">the ITimerEvent that the timer was created with</param> /// <param name="id">the Id of the timer to cancel</param> /// <remarks> /// The complexity of this operation is O(n). We assume it is rarely used. /// </remarks> public void CancelTimer( ITimerEvent sink, int id) { var foundTimers = new Dictionary<long, TimerInfo>(); foreach (var pair in m_timers) { var timer = pair.Value.FirstOrDefault(x => x.Id == id && x.Sink == sink); if (timer == null) continue; if (!foundTimers.ContainsKey(pair.Key)) { foundTimers[pair.Key] = timer; break; } } if (foundTimers.Count > 0) { foreach (var foundTimer in foundTimers) { if (m_timers[foundTimer.Key].Count == 1) { m_timers.Remove(foundTimer.Key); } else { m_timers[foundTimer.Key].Remove(foundTimer.Value); } } } else { // Timer not found. Debug.Assert(false); } }
public void removeEventListeners(ITimerEvent item) { _toRemove.Add(item); }
internal FormTimer(ITimerEvent timer) : this() { this.timer = timer; userControlTimer.Timer = timer; }
public TimerEventViewModel(IEventAggregator aggregator, ILocalizationHelper loc, ITimerEvent timerEvent) : base(aggregator, loc, timerEvent) { _eventAggregator = aggregator; DisplayName = loc.GetByKey("TimerEvent"); Model = timerEvent; }
/// <summary> /// Create a new TimerInfo object from the given sink and id. /// </summary> /// <param name="sink">an ITimerEvent that acts as a sink for when the timer expires</param> /// <param name="id">an integer id that identifies this timer</param> public TimerInfo([NotNull] ITimerEvent sink, int id) { this.Sink = sink; this.Id = id; }