/// <summary> /// Invoked when an entry in <see cref="Bindings"/> completes. /// </summary> /// <param name="entry">The entry that completed.</param> private void Completed(PriorityBindingEntry entry) { Bindings.Remove(entry); if (entry.Index >= ActiveBindingIndex) { ActivateFirstBinding(); } }
/// <summary> /// Invoked when an entry in <see cref="Bindings"/> changes value. /// </summary> /// <param name="entry">The entry that changed.</param> public void Changed(PriorityBindingEntry entry) { if (entry.Index >= ActiveBindingIndex) { if (entry.Value != PerspexProperty.UnsetValue) { Value = entry.Value; ActiveBindingIndex = entry.Index; _owner.LevelValueChanged(this); } else { ActivateFirstBinding(); } } }
/// <summary> /// Invoked when an entry in <see cref="Bindings"/> changes value. /// </summary> /// <param name="entry">The entry that changed.</param> private void Changed(PriorityBindingEntry entry) { if (_mode == LevelPrecedenceMode.Latest || entry.Index >= ActiveBindingIndex) { if (entry.Value != PerspexProperty.UnsetValue) { Value = entry.Value; ActiveBindingIndex = entry.Index; _changed(this); } else { ActivateFirstBinding(); } } }
/// <summary> /// Adds a binding. /// </summary> /// <param name="binding">The binding to add.</param> /// <returns>A disposable used to remove the binding.</returns> public IDisposable Add(IObservable <object> binding) { Contract.Requires <ArgumentNullException>(binding != null); var entry = new PriorityBindingEntry(_nextIndex++); var node = Bindings.AddFirst(entry); entry.Start(binding, Changed, Completed); return(Disposable.Create(() => { Bindings.Remove(node); if (entry.Index >= ActiveBindingIndex) { ActivateFirstBinding(); } })); }
/// <summary> /// Adds a binding. /// </summary> /// <param name="binding">The binding to add.</param> /// <returns>A disposable used to remove the binding.</returns> public IDisposable Add(IObservable<object> binding) { Contract.Requires<ArgumentNullException>(binding != null); var entry = new PriorityBindingEntry(_nextIndex++); var node = Bindings.AddFirst(entry); entry.Start(binding, Changed, Completed); return Disposable.Create(() => { Bindings.Remove(node); if (entry.Index >= ActiveBindingIndex) { ActivateFirstBinding(); } }); }
/// <summary> /// Invoked when an entry in <see cref="Bindings"/> encounters a recoverable error. /// </summary> /// <param name="entry">The entry that completed.</param> /// <param name="error">The error.</param> public void Error(PriorityBindingEntry entry, BindingError error) { _owner.LevelError(this, error); }