private void InternalUpdateCardReview(CardNameLocation location, List <CardGuess> cardGuesses) { currentCardGuessesByLocation[location] = cardGuesses; var name = GetBestGuessLabelName(location); var myTextBox = (Button)this.FindName(name); myTextBox.Visibility = Visibility.Visible; var commentsButton = (Button)this.FindName(GetSearchButtonName(location)); commentsButton.Visibility = Visibility.Visible; float rating = float.Parse(cardGuesses.Last().Review.AverageRating, CultureInfo.InvariantCulture.NumberFormat); myTextBox.Background = backgroundBrush; myTextBox.Foreground = new SolidColorBrush(Utils.GetMediaColorFromDrawingColor(Utils.GetColorForRating((decimal)rating))); myTextBox.Content = cardGuesses.Last().Review.ToString() + (cardGuesses.Count > 1 ? "*" : ""); Utils.UpdateFontSizeToFit(myTextBox); if (DraftScreen.GetCardNameLocationsAvailable(draftPickNumber).Last().Equals(location)) { latestStoryboardRefreshButton.Stop(this); } }
private void GetAllCardReviews() { if (isPaused) { return; } var rotateImage = (Image)RefreshBtn.Content; rotateImage.RenderTransform = new RotateTransform(); rotateImage.RenderTransformOrigin = new Point(0.5, 0.5); Storyboard storyboard = new Storyboard(); DoubleAnimation rotateAnimation = new DoubleAnimation() { From = 0, To = 360, Duration = new Duration(TimeSpan.FromSeconds(0.6)), RepeatBehavior = RepeatBehavior.Forever }; Storyboard.SetTarget(rotateAnimation, rotateImage); Storyboard.SetTargetProperty(rotateAnimation, new PropertyPath("(UIElement.RenderTransform).(RotateTransform.Angle)")); storyboard.Children.Add(rotateAnimation); latestStoryboardRefreshButton = storyboard; storyboard.Begin(this, true); foreach (var location in DraftScreen.GetCardNameLocationsAvailable(draftPickNumber)) { Task.Run(() => { var cardGuesses = CardRecognitionManager.Instance.ReadCardName(location, ProcessWindowManager.Instance.GetWindowAreaBitmap(location.Rect, true)); if (cardGuesses == null || cardGuesses.Count == 0) { return; } UpdateCardReview(location, cardGuesses); }); } }