Beispiel #1
0
        private void createCarTiles(Panel host, List <Racer> racers)
        {
            int i = 0;

            foreach (Racer racer in racers)
            {
                i++;
                CarTile tile = CarTile.createTile(racer, true, delegate()
                {
                    addRacer(DataManager.Competition.Racers.IndexOf(racer));
                });
                tile.MouseUp += delegate
                {
                    RacerDetails.editOldRacer(HostGrid, racer, delegate()
                    {
                        updateRacerList();
                    }, delegate()
                    {
                        lastResults = null;
                        lastRaceList.Children.Clear();
                        forgetRace();
                    });
                };
                tile.Cursor = Cursors.Hand;
                tile.Margin = new Thickness(8, 8, 0, 0);
                tile.AnimateIn(i * 250);
                host.Children.Add(tile);
            }
        }
Beispiel #2
0
        private static CarTile createTile(Racer racer, bool keepSize, bool haveAdd, addToRaceHandler addHandler)
        {
            CarTile tile = new CarTile();

            tile.tbCarName.Text     = racer.Car.Name;
            tile.tbCreatorName.Text = racer.Maker.Name;
            tile.onAddToRace       += addHandler;

            if (!racer.PassedInspection)
            {
                tile.disabled.Visibility = Visibility.Visible;
            }

            if (!haveAdd || !racer.PassedInspection)
            {
                tile.addHolder.Visibility = System.Windows.Visibility.Collapsed;
            }

            if (!keepSize)
            {
                //make unsized
                tile.MainGrid.Width = tile.MainGrid.Height = Double.NaN;
            }

            try
            {
                tile.imgCarImage.Source = DataManager.loadImage(DataManager.getAbsoluteUri(racer.Car.ImageUri));
            }
            catch (Exception ex1)
            {
                DataManager.MessageProvider.showError("Could Not Load Car's Picture. Falling Back to defalt.", ex1.Message);
                try
                {
                    tile.imgCarImage.Source = new BitmapImage(DataManager.getAbsoluteUri(DataManager.Settings.DefaltCarImageUri));
                }
                catch (Exception ex2)
                {
                    DataManager.MessageProvider.showError("Could Not Load Defalt Car's Picture.", ex2.Message);
                }
            }

            try
            {
                tile.imgCreatorPicture.Source = DataManager.loadImage(DataManager.getAbsoluteUri(racer.Maker.ImageUri));
            }
            catch (Exception ex1)
            {
                DataManager.MessageProvider.showError("Could Not Load Creator's Picture. Falling Back to defalt.", ex1.Message);
                try
                {
                    tile.imgCreatorPicture.Source = new BitmapImage(DataManager.getAbsoluteUri(DataManager.Settings.DefaltMakerImageUri));
                }
                catch (Exception ex2)
                {
                    DataManager.MessageProvider.showError("Could Not Load Defalt Creator's Picture", ex2.Message);
                }
            }

            return(tile);
        }
Beispiel #3
0
        private void addRacer(int index)
        {
            if (DataManager.readyForRace)
            {
                RaceManager.MakeNextReturn result = DataManager.RaceManager.makeNext_CarLane(index);

                if (result == RaceManager.MakeNextReturn.Added)
                {
                    //listBox1.Items.Add(DataManager.Competition.Racers[index].Car.Name);

                    try
                    {
                        CarTile tile = CarTile.createTile(DataManager.Competition.Racers[index], false);
                        tile.SetValue(Grid.ColumnProperty, DataManager.RaceManager.nextOpenLane - 2);
                        tile.Margin = new Thickness(8, 8, 8, 0);
                        tile.AnimateIn();
                        RaceList.Children.Add(tile);
                    }
                    catch (Exception ex)
                    {
                        DataManager.MessageProvider.showError("Could Not Add Racer", ex.Message);
                    }
                } //error handling
                else if (result == RaceManager.MakeNextReturn.CallBackUsed)
                {
                    DataManager.MessageProvider.showMessage("Duplicate Racer", DataManager.Competition.Racers[index].Car.Name + " has allready been entered into this race");
                }
                else if (result == RaceManager.MakeNextReturn.RaceFull)
                {
                    DataManager.MessageProvider.showMessage("Race is full", "Cannot enter more than " + DataManager.RaceManager.NumberOfLanes + " racers into a race");
                }
                else if (result == RaceManager.MakeNextReturn.NotPassed)
                {
                    DataManager.MessageProvider.showMessage("Racer Has Not Passed Inspection", DataManager.Competition.Racers[index].Car.Name + " has not passed inspection, and cannot race.");
                }
            }
            else
            {
                DataManager.MessageProvider.showMessage("Not Ready To Add Racer", "The track timer does not seem to be connected. Please try to reconnect to the track timer.");
            }
        }
Beispiel #4
0
        private static CarTile createTile(Racer racer, bool keepSize, bool haveAdd, addToRaceHandler addHandler)
        {
            CarTile tile = new CarTile();
            tile.tbCarName.Text = racer.Car.Name;
            tile.tbCreatorName.Text = racer.Maker.Name;
            tile.onAddToRace += addHandler;

            if (!racer.PassedInspection)
            {
                tile.disabled.Visibility = Visibility.Visible;
            }

            if (!haveAdd || !racer.PassedInspection)
            {
                tile.addHolder.Visibility = System.Windows.Visibility.Collapsed;
            }

            if (!keepSize)
            {
                //make unsized
                tile.MainGrid.Width = tile.MainGrid.Height = Double.NaN;
            }

            try
            {
                tile.imgCarImage.Source = DataManager.loadImage(DataManager.getAbsoluteUri(racer.Car.ImageUri));
            }
            catch (Exception ex1)
            {
                DataManager.MessageProvider.showError("Could Not Load Car's Picture. Falling Back to defalt.", ex1.Message);
                try
                {
                    tile.imgCarImage.Source = new BitmapImage(DataManager.getAbsoluteUri(DataManager.Settings.DefaltCarImageUri));
                }
                catch (Exception ex2)
                {
                    DataManager.MessageProvider.showError("Could Not Load Defalt Car's Picture.", ex2.Message);
                }
            }

            try
            {
                tile.imgCreatorPicture.Source = DataManager.loadImage(DataManager.getAbsoluteUri(racer.Maker.ImageUri));
            }
            catch (Exception ex1)
            {
                DataManager.MessageProvider.showError("Could Not Load Creator's Picture. Falling Back to defalt.", ex1.Message);
                try
                {
                    tile.imgCreatorPicture.Source = new BitmapImage(DataManager.getAbsoluteUri(DataManager.Settings.DefaltMakerImageUri));
                }
                catch (Exception ex2)
                {
                    DataManager.MessageProvider.showError("Could Not Load Defalt Creator's Picture", ex2.Message);
                }
            }

            return tile;
        }