예제 #1
0
        private void RaceManager_onGotRace(Dictionary <int, Time> results)
        {
            if (Dispatcher.CheckAccess())
            {
                lastRaceList.Children.Clear();
                lastResults = results;
                while (RaceList.Children.Count > 0)
                {
                    UIElement tile = RaceList.Children[0];
                    RaceList.Children.RemoveAt(0);
                    if (tile is CarTile)
                    {
                        int lane = (int)(tile as CarTile).GetValue(Grid.ColumnProperty) + 1;
                        foreach (KeyValuePair <int, Time> result in results)
                        {
                            if (result.Value.Lane == lane)
                            {
                                (tile as CarTile).showTime(result.Value.Place, result.Value.Speed);
                            }
                        }
                    }
                    lastRaceList.Children.Add(tile);
                }

                KeyValuePair <int, Time> winnerCar = new KeyValuePair <int, Time>(-1, new Time(-1, 10, -1));
                foreach (KeyValuePair <int, Time> time in results)
                {
                    if (winnerCar.Value.Speed > time.Value.Speed)
                    {
                        winnerCar = time;
                    }
                }

                StackPanel panel = new StackPanel();
                panel.MaxWidth = 700;

                Label label = new Label();
                label.Content             = "Winner";
                label.FontSize            = 50;
                label.HorizontalAlignment = HorizontalAlignment.Center;
                panel.Children.Add(label);

                CarList listItem = CarList.createListItem(DataManager.Competition.Racers[winnerCar.Key], 1, DataManager.Competition.Racers[winnerCar.Key].getTimeInfo());
                listItem.IsHitTestVisible = false;
                panel.Children.Add(listItem);

                Dialog winDialog = new Dialog(winnerGrid, panel, false, false, 50000);
            }
            else
            {
                Dispatcher.Invoke(new Action(() => RaceManager_onGotRace(results)));
            }
        }
예제 #2
0
        private void addCarListItem(Panel host, Racer racer, int delay)
        {
            CarList listItem = CarList.createListItem(racer);

            listItem.MouseUp += delegate
            {
                RacerDetails.editOldRacer(HostGrid, racer, delegate()
                {
                    updateRacerList();
                }, delegate()
                {
                    forgetRace();
                });
            };
            listItem.Margin = new Thickness(0, 0, 0, 8);
            listItem.AnimateIn(delay);
            host.Children.Add(listItem);
        }