public override void ViewDidLoad() { base.ViewDidLoad(); View.AutoresizingMask = UIViewAutoresizing.FlexibleDimensions; View.BackgroundColor = UIColor.White; var ratingConfig = new RatingConfig(emptyImage: UIImage.FromBundle(ratingStyle + "/empty"), filledImage: UIImage.FromBundle(ratingStyle + "/filled"), chosenImage: UIImage.FromBundle(ratingStyle + "/chosen")); ratingConfig.ScaleSize = 10; // [Optional] Put a little space between the rating items. ratingConfig.ItemPadding = 5f; var ratingFrame = new CGRect(CGPoint.Empty, new CGSize(View.Bounds.Width, 125f));; ratingView = new PDRatingView(ratingFrame, ratingConfig); // [Optional] Set the current rating to display. decimal rating = 3.58m; //decimal halfRoundedRating = Math.Round(rating * 2m, MidpointRounding.AwayFromZero) / 2m; //decimal wholeRoundedRating = Math.Round(rating, MidpointRounding.AwayFromZero); ratingView.AverageRating = rating; // [Optional] Make it read-only to keep the user from setting a rating. //StarRating.UserInteractionEnabled = false; // [Optional] Attach to the rating event to do something with the chosen value. ratingView.RatingChosen += (sender, e) => { (new UIAlertView("Rated!", e.Rating.ToString() + " " + ratingStyle, null, "Ok")).Show(); }; View.Add(ratingView); }
public SampleTableViewControllerCell() : base(UITableViewCellStyle.Value1, Key) { AutoresizingMask = UIViewAutoresizing.FlexibleDimensions; BackgroundColor = UIColor.White; var ratingConfig = new RatingConfig(emptyImage: UIImage.FromBundle("Stars/empty"), filledImage: UIImage.FromBundle("Stars/filled"), chosenImage: UIImage.FromBundle("Stars/chosen")); ratingView = new PDRatingView(new CGRect(CGPoint.Empty, ContentView.Bounds.Size), ratingConfig); ratingView.UserInteractionEnabled = false; ContentView.Add(ratingView); }
public PDRatingView(RatingConfig config) { StarRatingConfig = config; StarViews = new List <RatingItemView>(); ButtonsAndHandlers = new Dictionary <UIButton, EventHandler>(); Enumerable.Range(0, StarRatingConfig.ScaleSize).ToList().ForEach(i => { int starRating = i + 1; RatingItemView starView = new RatingItemView(emptyImage: StarRatingConfig.EmptyImage, filledImage: StarRatingConfig.FilledImage, chosenImage: StarRatingConfig.ChosenImage); StarViews.Add(starView); EventHandler handler = (s, e) => { ChosenRating = starRating; RatingChosen(this, new RatingChosenEventArgs(ChosenRating.Value)); }; ButtonsAndHandlers.Add(starView, handler); Add(starView); }); AssignHandlers(); }
public override void ViewDidLoad() { base.ViewDidLoad(); View.AutoresizingMask = UIViewAutoresizing.FlexibleDimensions; View.BackgroundColor = UIColor.White; var ratingConfig = new RatingConfig(emptyImage: UIImage.FromBundle("Stars/empty"), filledImage: UIImage.FromBundle("Stars/filled"), chosenImage: UIImage.FromBundle("Stars/chosen")); // [Optional] Put a little space between the rating items. ratingConfig.ItemPadding = 5f; backgroundButton = UIButton.FromType(UIButtonType.RoundedRect); backgroundButton.SetBackgroundImage(UIImage.FromBundle("Background/background").StretchableImage(0, 0), UIControlState.Normal); backgroundButton.Frame = new CGRect(new CGPoint(24f, 24f), new CGSize(View.Bounds.Width - (2f * 24f), 125f)); var ratingFrame = backgroundButton.Bounds; ratingView = new PDRatingView(ratingFrame, ratingConfig); // [Optional] Set the current rating to display. decimal rating = 3.58m; //decimal halfRoundedRating = Math.Round(rating * 2m, MidpointRounding.AwayFromZero) / 2m; //decimal wholeRoundedRating = Math.Round(rating, MidpointRounding.AwayFromZero); ratingView.AverageRating = rating; // [Optional] Make it read-only to keep the user from setting a rating. //StarRating.UserInteractionEnabled = false; // [Optional] Attach to the rating event to do something with the chosen value. ratingView.RatingChosen += (sender, e) => { (new UIAlertView("Rated!", e.Rating.ToString() + " stars", null, "Ok")).Show(); }; backgroundButton.Add(ratingView); View.Add(backgroundButton); }
public PDRatingView(RatingConfig config, decimal averageRating) : this(config) { AverageRating = averageRating; }
public PDRatingView(RectangleF frame, RatingConfig config, decimal averageRating) : this(config, averageRating) { Frame = frame; }
public PDRatingView(RectangleF frame, RatingConfig config) : this(frame, config, 0m) { }