private void OnPointerMovedOverBackgroundStackPanel(object sender, PointerRoutedEventArgs args) { if (!IsReadOnly) { var point = args.GetCurrentPoint(m_backgroundStackPanel); float xPosition = (float)point.Position.X; if (SharedHelpers.IsAnimationsEnabled()) { m_sharedPointerPropertySet.InsertScalar("starsScaleFocalPoint", xPosition); var deviceType = args.Pointer.PointerDeviceType; switch (deviceType) { case PointerDeviceType.Touch: m_sharedPointerPropertySet.InsertScalar("pointerScalar", c_touchOverScale); break; default: // mouse, TODO: MSFT distinguish pen later m_sharedPointerPropertySet.InsertScalar("pointerScalar", c_mouseOverScale); break; } } m_mousePercentage = (double)(xPosition) / CalculateActualRatingWidth(); UpdateRatingItemsAppearance(); args.Handled = true; } }
private void EnterGamepadEngagementMode() { double currentValue = Value; m_shouldDiscardValue = true; if (currentValue == c_noValueSetSentinel) { Value = InitialSetValue; // Notify that the Value has changed ValueChanged?.Invoke(this, null); currentValue = InitialSetValue; m_preEngagementValue = -1; } else { currentValue = Value; m_preEngagementValue = currentValue; } if (SharedHelpers.IsRS1OrHigher()) { ElementSoundPlayer.Play(ElementSoundKind.Invoke); } if (SharedHelpers.IsAnimationsEnabled()) { double focalPoint = CalculateStarCenter((int)(currentValue - 1.0)); m_sharedPointerPropertySet.InsertScalar("starsScaleFocalPoint", (float)(focalPoint)); } }
private bool ShouldEnableAnimation() { // In ControlsResourceVersion2, animation is disabled. return // TODO Uno: Move XamlControlsResources to Uno.UI (#if !HAS_UNO !XamlControlsResources.IsUsingControlsResourcesVersion2() && #endif SharedHelpers.IsAnimationsEnabled()); }
private void SetRatingTo(double newRating, bool originatedFromMouse) { double ratingValue = 0.0; double oldRatingValue = Value; ratingValue = Math.Min(newRating, (double)(MaxRating)); ratingValue = Math.Max(ratingValue, 0.0); // The base case, and the you have no rating, and you pressed left case [wherein nothing should happen] if (oldRatingValue > c_noValueSetSentinel || ratingValue != 0.0) { if (!IsClearEnabled && ratingValue <= 0.0) { Value = 1.0; } else if (ratingValue == oldRatingValue && IsClearEnabled && (ratingValue != MaxRating || originatedFromMouse)) { // If you increase the Rating via the keyboard/gamepad when it's maxed, the value should stay stable. // But if you click a star that represents the current Rating value, it should clear the rating. Value = c_noValueSetSentinel; } else if (ratingValue > 0.0) { Value = ratingValue; } else { Value = c_noValueSetSentinel; } if (SharedHelpers.IsRS1OrHigher() && IsFocusEngaged && SharedHelpers.IsAnimationsEnabled()) { double focalPoint = CalculateStarCenter((int)(ratingValue - 1.0)); m_sharedPointerPropertySet.InsertScalar("starsScaleFocalPoint", (float)(focalPoint)); } // Notify that the Value has changed ValueChanged?.Invoke(this, null); } }