/// <summary> /// This method is raised when an enumerator dispenses a style. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">Information about the event.</param> internal void EnumeratorStyleDispensed(object sender, StyleDispensedEventArgs e) { if (!_ignoreStyleDispensedByEnumerator) { OnEnumeratorStyleDispensed(this, e); } }
/// <summary> /// This method is invoked when one of the related style enumerator's /// dispenses a style. The enumerator checks to see if the style /// dispensed would've been the next style it would have returned. If /// so it updates it's index to the position after the previously /// returned style. /// </summary> /// <param name="sender">The style dispenser.</param> /// <param name="e">Information about the event.</param> internal void StyleDispenserStyleDispensed(object sender, StyleDispensedEventArgs e) { if (!ShouldRetrieveFromParentEnumerator && StylePredicate(e.Style)) { int?nextStyleIndex = GetIndexOfNextSuitableStyle(index ?? 0); if ((nextStyleIndex ?? -1) == e.Index) { index = (e.Index + 1) % StyleDispenser.Styles.Count; } } }
/// <summary> /// Raises the EnumeratorStyleDispensed event. /// </summary> /// <param name="source">The source of the event.</param> /// <param name="args">Information about the event.</param> private void OnEnumeratorStyleDispensed(object source, StyleDispensedEventArgs args) { // Remove this item from the list of dispensed styles. _stylesDispensed.Remove(args); // Add this item to the end of the list of dispensed styles. _stylesDispensed.AddLast(args); foreach (StyleEnumerator enumerator in _styleEnumerators) { enumerator.StyleDispenserStyleDispensed(source, args); } }
/// <summary> /// Raises the style dispensed event. /// </summary> /// <param name="args">Information about the style dispensed.</param> protected virtual void OnStyleDispensed(StyleDispensedEventArgs args) { StyleDispenser.EnumeratorStyleDispensed(this, args); }