/// <summary> /// Update the visual state of the control. /// </summary> /// <param name="useTransitions"> /// A value indicating whether to automatically generate transitions to /// the new state, or instantly transition to the new state. /// </param> /// <remarks> /// UpdateVisualState works differently than the rest of the injected /// functionality. Most of the other events are overridden by the /// calling class which calls Allow, does what it wants, and then calls /// Base. UpdateVisualState is the opposite because a number of the /// methods in InteractionHelper need to trigger it in the calling /// class. We do this using the IUpdateVisualState internal interface. /// </remarks> private void UpdateVisualState(bool useTransitions) { if (_updateVisualState != null) { _updateVisualState.UpdateVisualState(useTransitions); } }
/// <summary> /// Updates the hover states of the rating items. /// </summary> private void UpdateHoverStates() { if (HoveredRatingItem != null && !IsReadOnly) { IList <RatingItem> ratingItems = GetRatingItems().ToList(); int indexOfItem = ratingItems.IndexOf(HoveredRatingItem); double total = ratingItems.Count(); double filled = indexOfItem + 1; DisplayValue = filled / total; for (int cnt = 0; cnt < ratingItems.Count; cnt++) { RatingItem ratingItem = ratingItems[cnt]; if (cnt <= indexOfItem && SelectionMode == RatingSelectionMode.Continuous) { VisualStates.GoToState(ratingItem, true, VisualStates.StateMouseOver); } else { IUpdateVisualState updateVisualState = ratingItem; updateVisualState.UpdateVisualState(true); } } } else { DisplayValue = Value.GetValueOrDefault(); foreach (IUpdateVisualState updateVisualState in GetRatingItems().OfType <IUpdateVisualState>()) { updateVisualState.UpdateVisualState(true); } } }
/// <summary> /// Updates the hover states of the rating items. /// </summary> private void UpdateHoverStates() { if (HoveredRatingItem != null && IsEnabled) { IList <RatingItem> ratingItems = GetRatingItems().ToList(); int indexOfItem = ratingItems.IndexOf(HoveredRatingItem); double total = ratingItems.Count(); double filled = indexOfItem + 1; this.DisplayValue = filled / total; for (int cnt = 0; cnt < ratingItems.Count; cnt++) { RatingItem ratingItem = ratingItems[cnt]; if (cnt <= indexOfItem && this.SelectionMode == RatingSelectionMode.Continuous) { VisualStates.GoToState(ratingItem, true, VisualStates.StatePointerOver); } else { IUpdateVisualState updateVisualState = (IUpdateVisualState)ratingItem; updateVisualState.UpdateVisualState(true); } } } else { this.DisplayValue = this.Value; foreach (IUpdateVisualState updateVisualState in GetRatingItems().OfType <IUpdateVisualState>()) { updateVisualState.UpdateVisualState(true); } } }
/// <summary> /// Update the visual state of the control. /// </summary> /// <param name="useTransitions"> /// A value indicating whether to automatically generate transitions to /// the new state, or instantly transition to the new state. /// </param> /// <remarks> /// UpdateVisualState works differently than the rest of the injected /// functionality. Most of the other events are overridden by the /// calling class which calls Allow, does what it wants, and then calls /// Base. UpdateVisualState is the opposite because a number of the /// methods in InteractionHelper need to trigger it in the calling /// class. We do this using the IUpdateVisualState internal interface. /// </remarks> void UpdateVisualState(bool useTransitions) { _updateVisualState?.UpdateVisualState(useTransitions); }