private SingleTouchBinding GetBinding(ISingleTouchObserver observer) { foreach (SingleTouchBinding binding in this.Bindings) { if (binding.Observer == observer) { return(binding); } } foreach (SingleTouchBinding binding in this.BindingsToAdd) { if (binding.Observer == observer) { return(binding); } } foreach (SingleTouchBinding binding in this.BindingsToRemove) { if (binding.Observer == observer) { return(binding); } } return(null); }
/// <summary> /// Removes the binding for the observer. /// </summary> /// <param name="observer">The observer to remove.</param> public void Remove(ISingleTouchObserver observer) { SingleTouchBinding binding; binding = this.GetBinding(observer); if (binding != null) { this.RemoveBinding(binding); } }
/// <summary> /// Adds a binding for the observer if one doesn't exist. /// Modifies existing binding otherwise. /// </summary> /// <param name="observer">The observer to add.</param> /// <param name="priority"> /// The priority of the observer. Observers /// with higher priority will receive touch events before observers with /// lower priority. The default value is zero. /// </param> /// <param name="swallowsTouches"> /// The value indicating if the binding should swallow touches. If the value /// is <c>true</c> and the observer's <see cref="ISingleTouchObserver.OnTouchBegan" /> /// method returns <c>true</c>, other observers with lower priority will not receive any /// events for the touch. /// </param> public void Add(ISingleTouchObserver observer, int priority = 0, bool swallowsTouches = true) { SingleTouchBinding binding; binding = this.GetBinding(observer); if (binding == null) { binding = new SingleTouchBinding(); binding.Observer = observer; binding.Priority = priority; binding.SwallowsTouches = swallowsTouches; this.AddBinding(binding); } else if (binding.Priority != priority || binding.SwallowsTouches != swallowsTouches) { binding.Priority = priority; binding.SwallowsTouches = swallowsTouches; this.Dirty = true; } }
public void Remove(ISingleTouchObserver observer) { this.SingleTouchHandler.Remove(observer); }
public void Add(ISingleTouchObserver observer, int priority = 0, bool swallowsTouches = true) { this.SingleTouchHandler.Add(observer, priority, swallowsTouches); }