Exemplo n.º 1
0
        /// <summary>
        /// Loads the line from a file whose name is specified in text box. If the file with this name does not exist, tries to add ".txt" to the file name. If neither exists, shows error message and ends.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnChooseLine_Click(object sender, EventArgs e)
        {
            ResetFront();
            string line = textBoxLine.Text;

            if (line == "")
            {
                MessageBox.Show("Linka neexistuje", "Chybný vstup", MessageBoxButtons.RetryCancel);
                return;
            }
            try
            {
                string[][] initTable = SheetLoader.RowifyTable(SheetLoader.ReadSheetInput(line, '\t'));
                TimeTableF            = new TimeTableParser(initTable, holidayPositive.Text, holidayNegativ.Text);
                btnLoadDistsF.Enabled = true;
            }
            catch (FileNotFoundException)
            {
                line += ".txt";
                try
                {
                    string[][] initTable = SheetLoader.RowifyTable(SheetLoader.ReadSheetInput(line, '\t'));
                    TimeTableF            = new TimeTableParser(initTable, holidayPositive.Text, holidayNegativ.Text);
                    textBoxLine.Text      = line; //Updates the text so exception has not to be catched again
                    btnLoadDistsF.Enabled = true;
                }
                catch (FileNotFoundException)
                {
                    MessageBox.Show("Linka neexistuje", "Chybný vstup", MessageBoxButtons.RetryCancel);
                }
            }
        }
Exemplo n.º 2
0
        private void btnChooseJdfLine_Click(object sender, EventArgs e)
        {
            ResetFront();
            ResetBack();
            object x = cbxVyberLinky.SelectedItem;

            if (x is null)
            {
                MessageBox.Show("Žádná linka není vybrána", "Chybný vstup", MessageBoxButtons.OK);
                return;
            }

            /*/string linkaTxt = (string)x;
             * var spl = linkaTxt.Split(',');
             * (int, int) linka = new ValueTuple<int, int>(int.Parse(spl[0]), int.Parse(spl[1]));/**/
            (int, int)linka = ((int, int))x;

            string[][] tabulka1 = null;
            string[][] tabulka2 = null;
            try
            {
                tabulka1 = Parser.PostavTabulku(linka, true);
            }
            catch (Exception) { }
            if (tabulka1 is null)
            {
                MessageBox.Show("Linku se nepovedlo spravne nacist", "Chybny vstup", MessageBoxButtons.OK);
                return;
            }
            TimeTableF            = new TimeTableParser(tabulka1, holidayPositive.Text, holidayNegativ.Text);
            btnLoadDistsF.Enabled = true;

            try
            {
                tabulka2 = Parser.PostavTabulku(linka, false);
            }
            catch (Exception) { }
            if (tabulka2 is null)
            {
                MessageBox.Show("Linku se nepovedlo spravne nacist", "Chybny vstup", MessageBoxButtons.OK);
                return;
            }

            TimeTableB            = new TimeTableParser(tabulka2, holidayPositive.Text, holidayNegativ.Text);
            btnLoadDistsB.Enabled = true;
        }