コード例 #1
0
        private void SavePreButton_OnClick(object sender, RoutedEventArgs e)
        {
            int noRounds = 0;
            int noLaps   = int.Parse(NoLapsBox.Text);

            PenaltyCost = int.Parse(PenaltyBox.Text);

            int minLapTime = int.Parse(TimeLimitBox.Text);

            Settings.Default.minLapTime = minLapTime;
            Settings.Default.Save();

            foreach (var pilot in Pilots)
            {
                noRounds = Math.Max(noRounds, pilot.AssignedRound);
            }

            for (int i = 0; i < noRounds; i++)
            {
                var round = new CRound()
                {
                    RoundNo     = i + 1,
                    RoundPilots = (from t in Pilots where t.AssignedRound == (i + 1) select t).ToList(),
                    NoLaps      = noLaps,
                };
                Rounds.Add(round);
            }
            this.Close();
        }
コード例 #2
0
        private void PrevButton_OnClick(object sender, RoutedEventArgs e)
        {
            if (Rounds.Count >= currRound.RoundNo && currRound.RoundNo > 1)
            {
                currRound = Rounds[currRound.RoundNo - 2];
                if (Rounds.Count > currRound.RoundNo)
                {
                    nextRound = Rounds[currRound.RoundNo];
                }

                SetupRound(currRound);
            }
        }
コード例 #3
0
        private void SetupRound(CRound rnd)
        {
            RoundNoLabel.Content = rnd.RoundNo;

            RaceDataGrid.ItemsSource = currRound.PilotsLaps;

            if (Rounds.Count > currRound.RoundNo)
            {
                nextPilotDataGrid.ItemsSource = nextRound.PilotsLaps;
            }
            else
            {
                nextPilotDataGrid.ItemsSource = Rounds[0].PilotsLaps;
            }
        }
コード例 #4
0
        public CRound(CRound copy, DateTime t, int heat)
        {
            NoLaps      = copy.NoLaps;
            RoundNo     = copy.RoundNo;
            RoundPilots = new List <CPilot>();
            HeatNo      = heat;
            foreach (var pilot in copy.RoundPilots)
            {
                RoundPilots.Add(pilot.Clone());
            }

            RoundTime  = t;
            PilotsLaps = new List <CPilotRound>();
            foreach (var lap in copy.PilotsLaps)
            {
                PilotsLaps.Add(lap.Clone());
            }
        }
コード例 #5
0
        public MainWindow()
        {
            InitializeComponent();

            nextTimer = new Timer();

            //var googleSearchText = File.ReadAllText("c:\\fril.json");


            //JObject googleSearch = JObject.Parse(googleSearchText);

            // get JSON result objects into a list
            //IList<JToken> results = googleSearch["data"].Children().ToList();

            // serialize JSON results into .NET objects
            //IList<CRaceJSONData> searchResults = new List<CRaceJSONData>();
            //foreach (JToken result in results)
            //{
            //   CRaceJSONData searchResult = JsonConvert.DeserializeObject<CRaceJSONData>(result.ToString());
            //   searchResults.Add(searchResult);
            //}

            var pre = new PreWindow();

            pre.ShowDialog();

            int minTime = Settings.Default.minLapTime;

            lapMinTime = new TimeSpan(0, 0, minTime);

            RaceType = (RaceTypeEnum)pre.RaceType;

            if (pre.PilotList.Count == 0)
            {
                Close();
            }

            if (pre.PilotList != null)
            {
                Pilots = pre.PilotList;
            }

            if (pre.RoundList != null)
            {
                Rounds = pre.RoundList;
            }

            penalty = pre.PenaltyCost;

            totalLaps = int.Parse(pre.NoLapsBox.Text);

            foreach (var round in Rounds)
            {
                foreach (CPilot pilotInRound in round.RoundPilots)
                {
                    var pilotRound = new CPilotRound();
                    pilotRound.Pilot = pilotInRound;

                    round.PilotsLaps.Add(pilotRound);
                    pilotRound.Active = true;
                }
            }

            if (Pilots != null && Rounds != null && Rounds.Count > 0)
            {
                currRound = Rounds[0];
                nextRound = Rounds[1];
                SetupRound(currRound);
            }

            switch (RaceType)
            {
            case RaceTypeEnum.BestLap:
                DescLabel.Content       = "Race Type: Best Lap";
                penalty                 = 0;
                totalTimeCol.Visibility = Visibility.Collapsed;
                TopPilotLabel.Content   = "Top Pilots - By Best Lap";

                break;

            case RaceTypeEnum.TotalTime:
                DescLabel.Content     = "Race Type: Total Time, In " + pre.NoLapsBox.Text + " Laps";
                TopPilotLabel.Content = "Top Pilots - By Best Total Time";

                break;
            }
        }