public void priradCiarovuBodkuIfBloku(CiaraBodka mb) { IfBlok blok = null; for (int i = 0; i < ifBloky.Count; i++) { IfBlok tempBlok = ifBloky[i]; if (tempBlok.jeVBloku(mb.getX(), mb.getY())) { if (blok == null) { blok = tempBlok; } else if (mb.getX() - blok.getX() > mb.getX() - tempBlok.getX()) { blok = tempBlok; } } } if (blok != null) { if (!blok.ciaroveBodky.Contains(mb)) { blok.ciaroveBodky.Add(mb); mb.ifBlok = blok; } } else if (mb.ifBlok != null) { mb.ifBlok.ciaroveBodky.Remove(mb); } }
void ResetModul() { click = ""; tahaj = ""; clickRozmery = ""; clickBodka = null; tempCiara = null; clickMalaBodka = null; nastavMenu(); aktualizujOkna(); }
void MainFormKeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Delete) { if (clickMalaBodka != null) { clickMalaBodka.zmaz(); clickMalaBodka = null; } else if (click != "") { modul.objekty[click].zrusEditovaciePrvky(panel1); modul.zmazObjekt(click); click = ""; } else { return; } aktualizujPlochu(); } }
void MainFormMouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { clickX = e.X; clickY = e.Y; clickBodka = null; tempCiara = null; aktualizujPlochu(); return; } if (clickBodka != null) { foreach (var o in modul.objekty.Values) { foreach (var b in o.bodky) { if (clickBodka == b) { continue; } if (b.isClick(e.X, e.Y)) { clickBodka.obj.ciary[clickBodka.id] = new Ciara(tempCiara.bodkaVstup, b, tempCiara.cesta); clickBodka.obj.bodky[clickBodka.id].stav = Brushes.LawnGreen; clickBodka = null; tempCiara = null; aktualizujPlochu(); return; } } if (o.ciary == null) { continue; } foreach (var c in o.ciary) { if (c == null || c.cesta == null) { continue; } for (int i = 0; i < c.cesta.Count; i++) { if (c.cesta[i].isClick(e.X, e.Y)) { for (int j = i; j < c.cesta.Count; j++) { tempCiara.cesta.Add(c.cesta[j]); c.cesta[j].ciary.Add(tempCiara); } tempCiara.bodkaVystup = c.bodkaVystup; clickBodka.obj.ciary[clickBodka.id] = tempCiara; clickBodka.obj.bodky[clickBodka.id].stav = Brushes.LawnGreen; clickBodka = null; tempCiara = null; aktualizujPlochu(); return; } } } } List <Ciara> temp = new List <Ciara> { tempCiara }; CiaraBodka malaBodka = new CiaraBodka(e.X, e.Y, temp); tempCiara.cesta.Add(malaBodka); aktualizujPlochu(); return; } if (clickMalaBodka != null) { clickMalaBodka.prepniAktivnost(); aktualizujPlochu(); modul.priradCiarovuBodkuIfBloku(clickMalaBodka); clickMalaBodka = null; return; } foreach (Objekt o in modul.objekty.Values) { if (o.isClick(e.X, e.Y)) { resetOpVlastnosti(); click = o.id; tahaj = o.id; nastavOpVlastnosti(o); return; } if (o is IfBlok) { IfBlok temp = (IfBlok)o; if (temp.isClick2(e.X, e.Y)) { clickRozmery = o.id; return; } } for (int j = 0; j < o.bodky.Length; j++) { if (o.bodky[j].stav == Brushes.Black) { continue; } if (o.bodky[j].isClick(e.X, e.Y)) { clickBodka = o.bodky[j]; tempCiara = new TempCiara(clickBodka, new Bodka(e.X, e.Y, 4)); return; } } if (o.ciary == null) { continue; } for (int j = 0; j < o.ciary.Length; j++) { if (o.ciary[j] == null) { continue; } if (o.ciary[j].cesta == null) { continue; } for (int k = 0; k < o.ciary[j].cesta.Count; k++) { if (o.ciary[j].cesta[k].isClick(e.X, e.Y)) { clickMalaBodka = o.ciary[j].cesta[k]; clickMalaBodka.prepniAktivnost(); return; } } } } resetOpVlastnosti(); }