コード例 #1
0
        private void BuildAndDisplaySquadForm(string squadName, Squad squad)
        {
            Registry.RemovePilot(squadName);

            var startTour            = squad.GetMinTour(squad);
            var endTour              = squad.GetMaxTour(squad);
            var inException          = false;
            var reloadPilotsRequired = false;

            try
            {
                Registry.GetSquad(squadName).CheckSquadInSync(startTour, endTour);

                var squadBuilder = ServiceLocator.Instance.Resolve <SquadScoreStatsBuilder>();
                for (var tour = startTour; tour <= endTour; tour++)
                {
                    var score = squadBuilder.BuildSquadScoreObject(squad, tour);
                    if (score.TourDetails.Contains("[NO DATA]"))
                    {
                        continue;
                    }

                    var stats         = squadBuilder.BuildSquadStatsObject(squad, tour, ref reloadPilotsRequired);
                    var squadStatsReg = new PilotStats();
                    Registry.AddPilotStatsToRegistry(squadName, squadStatsReg);
                    Registry.ConstructScoresForPilot(score, squadName);
                    Registry.ConstructStatsForPilot(stats, squadName);
                }
            }
            catch (SquadOutOfSyncException ex)
            {
                MessageBox.Show(ex.Text, "Squad out of sync error");
                inException = true;
            }
            catch (SquadDoesNotExistInRegistryException squadEx)
            {
                MessageBox.Show(squadEx.Text, "Squad loading error");
                inException = true;
            }

            if (FindAndDisplayStatsWindow(squadName) || inException)
            {
                return;
            }

            var form = BuildPilotStatsForm(squadName, true);

            form.CompositeObjVsObjDataIncomplete = reloadPilotsRequired;
            form.Show();
        }