private Rectangle GetPreciseClipArea(RatingBaseVisualElement element, Point point) { int width = element.Size.Width; int height = element.Size.Height; if (this.ElementOrientation == Orientation.Horizontal) { switch (this.Direction) { case RatingDirection.Standard: return(new Rectangle(0, 0, point.X, height)); case RatingDirection.Reversed: return(new Rectangle(width - point.X, 0, width, height)); default: throw new InvalidEnumArgumentException(); } } else { switch (this.Direction) { case RatingDirection.Standard: return(new Rectangle(0, height - point.Y, width, height)); case RatingDirection.Reversed: return(new Rectangle(0, 0, width, point.Y)); default: throw new InvalidEnumArgumentException(); } } }
private Rectangle GetCurrentElementClipArea( RatingBaseVisualElement element, Point point) { switch (this.SelectionMode) { case RatingSelectionMode.Precise: if (!this.Value.HasValue && element is ValueRatingVisualElement) { return(element.EmptyArea); } return(this.GetPreciseClipArea(element, point)); case RatingSelectionMode.FullItem: double?nullable1 = this.Value; double minimum1 = this.Minimum; if (((nullable1.GetValueOrDefault() != minimum1 ? 0 : (nullable1.HasValue ? 1 : 0)) != 0 || !this.Value.HasValue) && element is ValueRatingVisualElement) { return(element.EmptyArea); } return(element.FullArea); case RatingSelectionMode.HalfItem: double?nullable2 = this.Value; double minimum2 = this.Minimum; if (((nullable2.GetValueOrDefault() != minimum2 ? 0 : (nullable2.HasValue ? 1 : 0)) != 0 || !this.Value.HasValue) && element is ValueRatingVisualElement) { return(element.EmptyArea); } return(this.GetHalfItemClipArea(element, point)); default: throw new InvalidEnumArgumentException(); } }
protected virtual Point GetRelativePoint( int elementIndex, RatingBaseVisualElement currentVisualElement, double?value) { double num1 = (this.Maximum - this.Minimum) / (double)this.Items.Count; double normalizedValue = this.GetNormalizedValue(value); double num2 = this.ElementOrientation == Orientation.Horizontal && this.Direction == RatingDirection.Reversed || this.ElementOrientation == Orientation.Vertical && this.Direction == RatingDirection.Standard ? normalizedValue - num1 * (double)(this.Items.Count - (elementIndex + 1)) : normalizedValue - num1 * (double)elementIndex; return(new Point((int)(num2 / num1 * (double)currentVisualElement.Size.Width), (int)(num2 / num1 * (double)currentVisualElement.Size.Height))); }
private Rectangle GetHalfItemClipArea(RatingBaseVisualElement element, Point point) { int width = element.Size.Width; int height = element.Size.Height; if (this.ElementOrientation == Orientation.Horizontal) { if (point.X > width / 2) { return(element.FullArea); } switch (this.Direction) { case RatingDirection.Standard: return(new Rectangle(0, 0, width / 2, height)); case RatingDirection.Reversed: return(new Rectangle(width / 2, 0, width, height)); default: throw new InvalidEnumArgumentException(); } } else { if (point.Y > height / 2) { return(element.FullArea); } switch (this.Direction) { case RatingDirection.Standard: return(new Rectangle(0, height / 2, width, height)); case RatingDirection.Reversed: return(new Rectangle(0, 0, width, height / 2)); default: throw new InvalidEnumArgumentException(); } } }
private Rectangle GetElementClipArea( RatingBaseVisualElement element, bool elementIsBeforeCurrentElement) { if (!this.Value.HasValue && element is ValueRatingVisualElement) { return(element.EmptyArea); } if (this.Direction == RatingDirection.Standard && this.ElementOrientation == Orientation.Horizontal || this.Direction == RatingDirection.Reversed && this.ElementOrientation == Orientation.Vertical) { if (elementIsBeforeCurrentElement) { return(element.FullArea); } return(element.EmptyArea); } if (elementIsBeforeCurrentElement) { return(element.EmptyArea); } return(element.FullArea); }