Example #1
0
        private void finishCreateNewStalking()
        {
            string[] nameTable     = new string[lastAmountSpecialTask];
            int[]    bonusesTable  = new int[lastAmountSpecialTask];
            string[] nameTeamTable = new string[lastAmountTeam];
            for (int i = 0; i < lastAmountSpecialTask; i++)
            {
                if (ownNameSpecialTaskCheckBox.IsChecked == true && specialTaskNameTableTextBox[i].Text != "")
                {
                    nameTable[i] = specialTaskNameTableTextBox[i].Text;
                }
                else
                {
                    nameTable[i] = "Zadanie " + (i + 1).ToString();
                }

                bonusesTable[i] = Convert.ToInt32(specialTaskBonusesTableTextBox[i].Text);
            }
            for (int i = 0; i < lastAmountTeam; i++)
            {
                if (teamNamesTableTextBox[i].Text == "")
                {
                    nameTeamTable[i] = "Drużyna " + (i + 1).ToString();
                }
                else
                {
                    nameTeamTable[i] = teamNamesTableTextBox[i].Text;
                }
            }
            PropertiesStalking.numberOfTeam        = Convert.ToInt32(numberOfTeamTextBox.Text);
            PropertiesStalking.numberOfSpecialTask = Convert.ToInt32(numberOfSpecialTaskTextBox.Text);
            PropertiesStalking.penaltiesHint       = Convert.ToInt32(penaltiesHintTextBox.Text);
            PropertiesStalking.penaltiesNextPlace  = Convert.ToInt32(penaltiesNextPlaceTextBox.Text);
            PropertiesStalking.completeBonusesTable(bonusesTable, nameTable, nameTeamTable);
            PropertiesStalking.finishCreateNewStalking = true;
            Close();
        }
Example #2
0
        public static void loadStalking()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog()
            {
                Filter = "Plik podchodów|*.podch",
                Title  = "Otwórz plik podchodów"
            };

            openFileDialog.ShowDialog();
            if (openFileDialog.FileName != "")
            {
                PropertiesStalking.pathLoadFile = Path.GetFullPath(openFileDialog.FileName);
                PropertiesStalking.pathSaveFile = Path.GetFullPath(openFileDialog.FileName);

                string       temp;
                string[]     namesSpecialTask, namesTeam;
                int[]        bonusesSpecialTask;
                string[]     dataTeam;
                StreamReader sr;
                try
                {
                    sr = new StreamReader(PropertiesStalking.pathLoadFile);
                    TeamList.ListOfTeam.Clear();

                    PropertiesStalking.numberOfTeam        = Convert.ToInt32(sr.ReadLine());
                    PropertiesStalking.numberOfSpecialTask = Convert.ToInt32(sr.ReadLine());
                    PropertiesStalking.penaltiesHint       = Convert.ToInt32(sr.ReadLine());
                    PropertiesStalking.penaltiesNextPlace  = Convert.ToInt32(sr.ReadLine());

                    bonusesSpecialTask = new int[PropertiesStalking.numberOfSpecialTask];
                    namesSpecialTask   = new string[PropertiesStalking.numberOfSpecialTask];
                    namesTeam          = new string[PropertiesStalking.numberOfTeam];

                    temp             = sr.ReadLine();
                    namesSpecialTask = temp.Split();

                    for (int i = 0; i < PropertiesStalking.numberOfSpecialTask; i++)
                    {
                        bonusesSpecialTask[i] = Convert.ToInt32(namesSpecialTask[i]);
                        namesSpecialTask[i]   = sr.ReadLine();
                    }
                    for (int i = 0; i < PropertiesStalking.numberOfTeam; i++)
                    {
                        namesTeam[i] = sr.ReadLine();
                        new Team(namesTeam[i]);
                    }
                    PropertiesStalking.completeBonusesTable(bonusesSpecialTask, namesSpecialTask, namesTeam);
                    foreach (Team team in TeamList.ListOfTeam)
                    {
                        temp                              = sr.ReadLine();
                        dataTeam                          = temp.Split();
                        team.StartTime                    = dataTeam[0];
                        team.FinishTime                   = dataTeam[1];
                        team.NumberOfHint                 = Convert.ToInt32(dataTeam[2]);
                        team.NumberOfNextPlace            = Convert.ToInt32(dataTeam[3]);
                        team.AdditionalPenaltiesOrBonuses = Convert.ToInt32(dataTeam[4]);
                        temp                              = sr.ReadLine();
                        dataTeam                          = temp.Split();
                        for (int i = 0; i < PropertiesStalking.numberOfSpecialTask; i++)
                        {
                            if (dataTeam[i] == "True")
                            {
                                team.SpecialTask[i] = true;
                            }
                            else
                            {
                                team.SpecialTask[i] = false;
                            }
                        }
                    }
                    sr.Close();
                    PropertiesStalking.finishLoad = true;
                }
                catch
                {
                    MessageBox.Show("Problem z dostępem do pliku. Wczytywanie nieudane", "Błąd", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }