public MainForm(RunnerManager runnerManager, StateManager stateManager, RaceManager raceManager, IFileRepository fileRepository) { InitializeComponent(); _runnerManager = runnerManager; _raceManager = raceManager; _fileRepository = fileRepository; _stateManager = stateManager; bttnRunnerAddLap.Enabled = false; bttnRunnerSteppingOut.Enabled = false; SetRowsToDatagrid(); SetRowsToDtGrdVwFinishedRunners(); race = fileRepository.GetRace(); form = new RunnersForm(_runnerManager, _stateManager); }
private void LoadFile() { if (openFileDialog.ShowDialog() == DialogResult.OK) { string strfilename = openFileDialog.InitialDirectory + openFileDialog.FileName; try { _fileRepository.LoadDataFromFile(strfilename); _runnerManager = new RunnerManager(_fileRepository); _raceManager = new RaceManager(_fileRepository); race = _fileRepository.GetRace(); form = new RunnersForm(_runnerManager, _stateManager); if (race.LengthOfLap != 0) { nmrcUpDwnLengthOfLap.Text = race.LengthOfLap.ToString(); nmrcUpDwnNumberOfLaps.Text = race.NumberOfLaps.ToString(); nmrcUpDwnNumberOfWinners.Text = race.NumberOfWinners.ToString(); SetBttnsAndTextAtStartRace(); lblRaceStartTime.Text = _runnerManager.GetDictionaryOFRunners().Values.ElementAt(0).GetFinishedLapsTimeList()[0].ToString(); foreach (var runner in _runnerManager.GetDictionaryOFRunners()) { dtGrdVwMainRaceForm.Rows.Add(_runnerManager.KeyValueToString(runner.Key), runner.Value.GetFinishedLapsTimeList().Last().ToString(), runner.Value.CountTimeTotal().ToString()); } foreach (var runner in _runnerManager.GetDictionaryOFRunners()) { _raceManager.IsFinishedRunnerAddedToWinningDirectory(race.NumberOfLaps, runner.Key, runner.Value); } PopulateDtGrdVwFinishedRunners(); } } catch (InvalidOperationException e) { MessageBox.Show("Could not open the file " + e.Message); } } }
private void runnersToolStripMenuItem_Click(object sender, EventArgs e) { RunnersForm runner = new RunnersForm(); runner.Show(); }