コード例 #1
0
        private void InternalUpdateCardReview(CardNameLocation location, HashSet <CardGuess> cardGuesses)
        {
            currentCardGuessesByLocation[location] = cardGuesses;

            var name      = GetBestGuessLabelName(location);
            var myTextBox = FindName(name) as Button;

            if (myTextBox == null)
            {
                return;
            }
            myTextBox.Visibility = Visibility.Visible;

            if (cardGuesses != null)
            {
                float rating = CardReviewForUiUtils.GetRatingForColor(cardGuesses.Last());
                myTextBox.Background = backgroundBrush;
                myTextBox.Foreground = new SolidColorBrush(Utils.GetMediaColorFromDrawingColor(Utils.GetColorForRating((decimal)rating)));

                myTextBox.Content = CardReviewForUiUtils.GetRatingLabel(cardGuesses);
            }
            else
            {
                myTextBox.Background = backgroundBrush;
                myTextBox.Foreground = new SolidColorBrush(Colors.Red);

                myTextBox.Content = (currentScreen.IsForge() ? "N/A or " : "") + "FAILED RECOGNITION";
            }

            Utils.UpdateFontSizeToFit(myTextBox);

            if (currentScreen.GetCardNameLocationsAvailable(draftPickNumber).Last().Equals(location))
            {
                latestStoryboardRefreshButton.Stop(this);
            }
        }
コード例 #2
0
        private void SearchCardByName(string searchedCardName, bool showBestCard)
        {
            if (string.IsNullOrEmpty(searchedCardName))
            {
                SearchResults.Children.RemoveRange(0, SearchResults.Children.Count);
                return;
            }

            var bestMatches = RecognitionUtils.FindBestCardReviewMatches(searchedCardName);

            if (bestMatches.Count > 1 || !showBestCard)
            {
                SearchResults.Children.RemoveRange(0, SearchResults.Children.Count);
                foreach (var match in bestMatches)
                {
                    TextBlock searchResult = new TextBlock
                    {
                        Text       = match.ReviewByTeam[Team.TDC].Name,
                        Foreground = Brushes.White,
                    };
                    searchResult.PreviewMouseDown += (e, args) =>
                    {
                        SearchCardByName(searchResult.Text, true);
                    };
                    SearchResults.Children.Add(searchResult);
                }
                return;
            }

            var newGuess = bestMatches.Last();

            StackPanel searchedCommentsPanel = FindName("ManualSearchControl") as StackPanel;

            if (searchedCommentsPanel == null)
            {
                searchedCommentsPanel = new StackPanel
                {
                    Name        = "ManualSearchControl",
                    Orientation = Orientation.Vertical,
                    Background  = backgroundBrush,
                    Width       = 210,
                };

                Canvas.SetLeft(searchedCommentsPanel, 1275);
                Canvas.SetTop(searchedCommentsPanel, 420);
                MainCanvas.Children.Add(searchedCommentsPanel);
                MainCanvas.RegisterName(searchedCommentsPanel.Name, searchedCommentsPanel);

                ScrollViewer scrollViewerComments = new ScrollViewer
                {
                    Width  = 210,
                    Height = 300,
                    VerticalScrollBarVisibility = ScrollBarVisibility.Hidden,
                    BorderThickness             = new Thickness(0)
                };

                StackPanel titleCommentsPanel = new StackPanel
                {
                    Background  = Brushes.DarkCyan,
                    Orientation = Orientation.Horizontal,
                    Height      = 30,
                };
                searchedCommentsPanel.Children.Add(titleCommentsPanel);

                TextBox cardTitle = new TextBox
                {
                    VerticalAlignment = VerticalAlignment.Center,
                    Background        = Brushes.DarkCyan,
                    BorderThickness   = new Thickness(0),
                    Foreground        = new SolidColorBrush(Colors.White),
                    Name = "cardTitle_ManualSearchControl",
                    Text = CardReviewForUiUtils.GetRatingLabel(new HashSet <CardGuess>()
                    {
                        newGuess
                    }),
                    FontWeight = FontWeights.Bold,
                    Padding    = new Thickness(5, 5, 5, 5),
                    Width      = 175,
                };
                Utils.MakePanelDraggable(searchedCommentsPanel, HolderCanvas, this, null);
                Utils.UpdateFontSizeToFit(cardTitle);
                titleCommentsPanel.Children.Add(cardTitle);
                searchedCommentsPanel.RegisterName(cardTitle.Name, cardTitle);

                Button closeBtn = new Button()
                {
                    Content             = "X",
                    Height              = 20,
                    Width               = 20,
                    Background          = Brushes.DarkCyan,
                    HorizontalAlignment = HorizontalAlignment.Right,
                    Margin              = new Thickness(10, 0, 10, 0),
                    Foreground          = new SolidColorBrush(Colors.White),
                    Padding             = new Thickness(5, 0, 5, 0),
                };
                titleCommentsPanel.Children.Add(closeBtn);
                closeBtn.Click += (e, args) =>
                {
                    searchedCommentsPanel.Visibility = Visibility.Hidden;
                };

                TextBox comments = new TextBox
                {
                    Width  = 210,
                    Height = 300,
                    HorizontalAlignment = HorizontalAlignment.Left,
                    Padding             = new Thickness(0, 20, 0, 0),
                    TextWrapping        = TextWrapping.Wrap,
                    CaretBrush          = new SolidColorBrush(Colors.Transparent),
                    Background          = backgroundBrush,
                    Foreground          = new SolidColorBrush(Colors.White),
                    BorderThickness     = new Thickness(0),
                    Name = "textbox_ManualSearchControl",
                    Text = CardReviewForUiUtils.GetCommentsText(newGuess),
                };
                scrollViewerComments.Content = comments;

                searchedCommentsPanel.Children.Add(scrollViewerComments);
                searchedCommentsPanel.RegisterName(comments.Name, comments);
            }
            else
            {
                searchedCommentsPanel.Visibility = Visibility.Visible;
                (FindName("textbox_ManualSearchControl") as TextBox).Text   = CardReviewForUiUtils.GetCommentsText(newGuess);
                (FindName("cardTitle_ManualSearchControl") as TextBox).Text = CardReviewForUiUtils.GetRatingLabel(new HashSet <CardGuess>()
                {
                    newGuess
                });
            }
        }
コード例 #3
0
        private void OnMainLabelClick(object sender, RoutedEventArgs e)
        {
            ProcessWindowManager.Instance.ReleaseFocus();

            string name     = ((Button)sender).Name;
            var    location = GetLocationFromBestGuessLabelName(name);

            HashSet <CardGuess> guesses;

            currentCardGuessesByLocation.TryGetValue(location, out guesses);

            if (guesses == null)
            {
                return;
            }

            ScrollViewer commentsScrollViewer = FindName("canvas" + location.ToString() + "comments") as ScrollViewer;

            if (commentsScrollViewer == null)
            {
                commentsScrollViewer = new ScrollViewer
                {
                    Name       = "canvas" + location.ToString() + "comments",
                    Width      = 210,
                    Height     = 300,
                    Background = backgroundBrush,
                    VerticalScrollBarVisibility = ScrollBarVisibility.Hidden,
                    BorderThickness             = new Thickness(0)
                };

                Canvas.SetLeft(commentsScrollViewer, location.Rect.Left - 20);
                Canvas.SetTop(commentsScrollViewer, location.Rect.Top - 175);
                MainCanvas.Children.Add(commentsScrollViewer);
                MainCanvas.RegisterName(commentsScrollViewer.Name, commentsScrollViewer);

                TextBox comments = new TextBox
                {
                    Width  = 210,
                    Height = 300,
                    HorizontalAlignment = HorizontalAlignment.Left,
                    TextWrapping        = TextWrapping.Wrap,
                    CaretBrush          = new SolidColorBrush(Colors.Transparent),
                    Background          = backgroundBrush,
                    Foreground          = new SolidColorBrush(Colors.White),
                    BorderThickness     = new Thickness(0),
                    Name = "textbox" + location.ToString() + "comments",
                    Text = CardReviewForUiUtils.GetCommentsText(guesses.Last())
                };

                commentsScrollViewer.Content = comments;
                commentsScrollViewer.RegisterName(comments.Name, comments);
                ((Control)sender).MouseLeave += (s, args) => { if (!commentsScrollViewer.IsMouseOver)
                                                               {
                                                                   OnMouseLeaveMainLabel(commentsScrollViewer, sender, e);
                                                               }
                };
                comments.MouseLeave += (s, args) => { if (!((Control)sender).IsMouseOver)
                                                      {
                                                          OnMouseLeaveMainLabel(commentsScrollViewer, sender, e);
                                                      }
                };
            }
            else
            {
                commentsScrollViewer.Visibility = commentsScrollViewer.Visibility == Visibility.Visible ? Visibility.Hidden : Visibility.Visible;
                var textBox = (TextBox)commentsScrollViewer.FindName("textbox" + location.ToString() + "comments");
                textBox.Text = CardReviewForUiUtils.GetCommentsText(guesses.Last());
            }

            if (commentsScrollViewer.Visibility == Visibility.Visible)
            {
                ProcessWindowManager.Instance.ForceFocus();
            }
        }