示例#1
0
		/// <summary>
		/// Sets up stars when Maximun properties changed
		/// Will only show up to the number of stars requested (up to Maximum)
		/// </summary>
		/// <param name="starRating"></param>
		private static void SetupStars(StarRating starRating)
		{
			Double value = starRating.Value;

			starRating.spStars.Children.Clear();
			for (int i = 0; i < starRating.Maximum; i++)
			{
				Star star = new Star();
				star.Tag = i;
				star.StarBackground = starRating.StarBackground;
				star.StarForeground = starRating.StarForeground;
				star.StarOutlineColor = starRating.StarOutlineColor;
				star.Value = value;

				starRating.spStars.Children.Insert(i, star);
			}
		}
示例#2
0
		/// <summary>
		/// Refresh stars when Value property changed
		/// </summary>
		/// <param name="starRating"></param>
		private static void RefreshStar(StarRating starRating, object e)
		{
			Double value = (Double)e;

			foreach (Star star in starRating.spStars.Children)
			{
				if (value > 1)
					star.Value = 1.0;
				else if (value > 0)
				{
					star.Value = value;
				}
				else
				{
					star.Value = 0.0;
				}

				value -= 1.0;
			}
		}
示例#3
0
		/// <summary>
		/// Coerces the Value value.
		/// </summary>
		private static Double CoerceValue(StarRating starRating, object value)
		{
			Double current = (Double)value;

			if (current < (Double)0.0)
				current = (Double)0.0;

			if (current > starRating.Maximum)
				current = starRating.Maximum;

			return current;
		}