Esempio n. 1
0
        private void zpracujRadek(string ln, SeznamKouli seznamKouli)
        {
            string[] radek = ln.Split(';');
            Koule    k     = new Koule(Convert.ToDouble(radek[1]), radek[2], Convert.ToUInt32(radek[0]));

            seznamKouli.VlozitKouli(k);
        }
Esempio n. 2
0
File: Form1.cs Progetto: novak55/PDA
        private void button_UpravitKouli_Click(object sender, EventArgs e)
        {
            if (listBox_SeznamKouli.SelectedIndex == -1)
            {
                MessageBox.Show("Nebyla zvolena žádná koule pro úpravy!", "Chybové hlášení", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            selectedInxedKoule = listBox_SeznamKouli.SelectedIndex;
            Koule k = seznamKouli.GetKouleByIndex(selectedInxedKoule);

            textBox_Popis.Text   = k.popis;
            textBox_Cislo.Text   = k.cislo.ToString();
            textBox_Polomer.Text = k.polomer.ToString();
            ZpristupnitPolozkyKoule(false, "Upravit kouli");
        }
Esempio n. 3
0
 internal string ImortujZXml(SeznamKouli seznamKouli, string filePath, string fileName)
 {
     using (XmlReader reader = XmlReader.Create(@Path.Combine(filePath, fileName)))
     {
         while (reader.Read())
         {
             if ((reader.NodeType == XmlNodeType.Element) && (reader.Name == "Koule"))
             {
                 if (reader.HasAttributes)
                 {
                     Koule k = new Koule(Convert.ToDouble(reader.GetAttribute("Polomer")), reader.GetAttribute("Popis"), Convert.ToUInt32(reader.GetAttribute("Cislo")));
                     seznamKouli.VlozitKouli(k);
                 }
             }
         }
     }
     return("Soubor " + fileName + " je naimportován.");
 }
Esempio n. 4
0
        public void VlozitKouli(Koule k)
        {
            bool existuje = false;

            for (int i = 0; i < list_SeznamKouli.Count; i++)
            {
                if (list_SeznamKouli[i].cislo == k.cislo)
                {
                    existuje = true; break;
                }
            }
//            existuje = list_SeznamKouli.Contains(k); // nevím proč ale nefunguje
            if (existuje == false)
            {
                list_SeznamKouli.Add(k);
            }
            else
            {
                throw new MyException_KouleExistujiciCislo("Nelze vložit kouli se stejným pořadovým číslem!");
            }
        }
Esempio n. 5
0
File: Form1.cs Progetto: novak55/PDA
        private void button_PridatKouli_Click(object sender, EventArgs e)
        {
            string popis;
            double polomer;
            uint   cislo;

            if (selectedInxedKoule > -1)
            {
                seznamKouli.OdstranitKouli(selectedInxedKoule);
                ZpristupnitPolozkyKoule(true);
                selectedInxedKoule = -1;
            }
            try
            {
                polomer = Convert.ToDouble(textBox_Polomer.Text);
                cislo   = Convert.ToUInt32(textBox_Cislo.Text);
                popis   = textBox_Popis.Text.Trim();

                if (popis == string.Empty)
                {
                    throw new FormatException("Nebyl zadán žádný popis!");
                }

                Koule k = new Koule(polomer, popis, cislo);
                seznamKouli.VlozitKouli(k);
                refresh_SeznamKouli();
                MessageBox.Show("Koule byla úspěšně vložena", "Informace", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ResetFormulareKoule();
            }
            catch (FormatException ex)
            {
                MessageBox.Show(String.Format("{0}\n{1}", "Chybně zadaná data", ex.Message), "Neúspěšné zadání", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (MyException_KouleExistujiciCislo ex)
            {
                MessageBox.Show(String.Format("{0}\n{1}", "Duplicitně zadaná data", ex.Message), "Neúspěšné zadání", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }