Example #1
0
        private void ListBox_RacerOrSources_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (ListBox_RacerOrSources.SelectedIndex >= 0)
            {
                DataSourceBase ds = null;
                if (inRacerConfigScreen)
                {
                    if (dsOnDisplay.Count > 0)
                    {
                        ds = dsOnDisplay[ListBox_RacerOrSources.SelectedIndex];
                        populateDistanceBox(ds.getSportType());
                    }
                }
                else
                {
                    ds = configuredRacers[ListBox_RacerOrSources.SelectedIndex].dataSource;
                    Button_RacerAddOrFinish.IsEnabled    = true;
                    Button_RacerRemoveOrCancel.IsEnabled = true;
                }

                Image_SelectionImage.Source = RacerInfoPanel.getRaceDisplayBitmap(ds.getSportType());
            }
            else
            {
                Image_SelectionImage.Source = RacerInfoPanel.getRaceDisplayBitmap(racerSportType.Unknown);
                ComboBox_RaceLength.Items.Clear();
            }
        }
Example #2
0
        public bool changeRacerSource(DataSourceBase dsb, double targetVal)
        {
            if (!dsb.Equals(dataSource))
            {
                if (dataSource != null && dataSource.isRunning())
                {
                    return(false);
                }

                if (dsb.isInUse)
                {
                    return(false);
                }

                if (dataSource != null)
                {
                    dataSource.isInUse = false; //Make sure the old one is marked as free
                }
                _dataSource = dsb;
                dsb.isInUse = true;
            }

            targetValue = targetVal;
            racePanel   = new RacerInfoPanel(dataSource.getSportType(), targetVal);
            return(true);
        }
Example #3
0
        private void DisplayRacerList()
        {
            inRacerConfigScreen = false;

            ListBox_RacerOrSources.Items.Clear();
            Button_AddRacer.Visibility     = System.Windows.Visibility.Visible;
            ComboBox_RaceLength.Visibility = System.Windows.Visibility.Hidden;
            Button_Start.Visibility        = System.Windows.Visibility.Visible;
            Label_DisplayTitle.Content     = "Racer List:";

            Binding widthBind = new Binding("ActualWidth");

            widthBind.Source = ListBox_RacerOrSources;

            if (configuredRacers.Count > 0)
            {
                for (int i = 0; i < configuredRacers.Count; ++i)
                {
                    Viewbox vb       = new Viewbox();
                    Label   racerLbl = new Label();
                    vb.SetBinding(Viewbox.WidthProperty, widthBind);
                    vb.Margin = new Thickness(0, 1, 30, 1);
                    vb.Child  = racerLbl;
                    if (configuredRacers[i].racerRecordInfo != null && !String.IsNullOrWhiteSpace(configuredRacers[i].racerRecordInfo.FirstName))
                    {
                        racerLbl.Content = String.Format("{0}: {1} {2}m-{3}", configuredRacers[i].racerRecordInfo.FirstName, configuredRacers[i].dataSource.getSportType(), configuredRacers[i].targetValue, configuredRacers[i].dataSource.getSourceName());
                    }
                    else if (configuredRacers[i].racerRecordInfo != null && !String.IsNullOrWhiteSpace(configuredRacers[i].racerRecordInfo.LastName))
                    {
                        racerLbl.Content = String.Format("{0}: {1} {2}m-{3}", configuredRacers[i].racerRecordInfo.LastName, configuredRacers[i].dataSource.getSportType(), configuredRacers[i].targetValue, configuredRacers[i].dataSource.getSourceName());
                    }
                    else
                    {
                        racerLbl.Content = String.Format("Racer {0}: {1} {2}m-{3}", i + 1, configuredRacers[i].dataSource.getSportType(), configuredRacers[i].targetValue, configuredRacers[i].dataSource.getSourceName());
                    }
                    ListBox_RacerOrSources.Items.Add(vb);
                }
                Button_Start.IsEnabled = true;
            }
            else
            {
                Label_DisplayTitle.Content = "Racer List:";
                Button_Start.IsEnabled     = false;
            }

            Label lbl2 = new Label()
            {
                Content = "Change Racer"
            };
            Viewbox vb2 = new Viewbox()
            {
                Child = lbl2
            };

            Button_RacerAddOrFinish.Content = vb2;
            Label lbl3 = new Label()
            {
                Content = "Remove Racer"
            };
            Viewbox vb3 = new Viewbox()
            {
                Child = lbl3
            };

            Button_RacerRemoveOrCancel.Content = vb3;

            Button_RacerAddOrFinish.IsEnabled    = false;
            Button_RacerRemoveOrCancel.IsEnabled = false;

            if (racerIndexUnderConfig >= 0)
            {
                ListBox_RacerOrSources.SelectedIndex = racerIndexUnderConfig;
            }
            else
            {
                ListBox_RacerOrSources.SelectedIndex = -1;
                Image_SelectionImage.Source          = RacerInfoPanel.getRaceDisplayBitmap(racerSportType.Unknown);
            }
        }