/// <summary> /// Fires <see cref="ItemsChanging" /> event. /// </summary> /// <param name="index">Index of item being changed.</param> /// <param name="e">Object containing event data.</param> protected virtual void OnItemsChanging(int index, GenericChangeEventArgs <BarItem> e) { if (ItemsChanging != null) { ItemsChanging(index, e); } }
/// <summary> /// Performs additional custom processes before setting a value in the <see cref="T:System.Collections.CollectionBase"></see> instance. /// </summary> /// <param name="index">The zero-based index at which oldValue can be found.</param> /// <param name="oldValue">The value to replace with newValue.</param> /// <param name="newValue">The new value of the element at index.</param> protected override void OnSet(int index, object oldValue, object newValue) { var e = new GenericChangeEventArgs <T>((T)oldValue, (T)newValue); if (Changing != null) { Changing(index, e); if (e.Cancel) { return; } } base.OnSet(index, oldValue, newValue); }
/// <summary> /// Fires <see cref="SelectionChanged" /> event /// </summary> /// <param name="e">Object containing event data.</param> protected virtual void OnSelectionChanging(GenericChangeEventArgs <BarItem> e) { if (SelectionChanging != null) { int indx = -1; for (int i = 0; i < Items.Count; i++) { if (e.NewValue.Equals(Items[i])) { indx = i; break; } } SelectionChanging(indx, e); } }
/// <summary> /// Called when [select item]. /// </summary> /// <param name="item">The item.</param> /// <param name="value">if set to <c>true</c> [value].</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> internal bool OnSelectItem(BarItem item, bool value) { if (value) { var e2 = new GenericChangeEventArgs <BarItem>(SelectedItem, item); OnSelectionChanging(e2); if (e2.Cancel) { return(false); } for (var i = 0; i < items.Count; i++) { if (items[i] != item && items[i].Selected) { items[i].Selected = false; } } var e = new GenericEventArgs <BarItem>(item); OnSelectionChanged(e); return(true); } return(false); }
/// <summary> /// Called when [selection changing]. /// </summary> /// <param name="index">The index.</param> /// <param name="e">The e.</param> private void OnSelectionChanging(int index, GenericChangeEventArgs <BarItem> e) { e.Cancel = true; }