/// <summary> /// Vytvori okno pro pridani nove cache /// </summary> public AddCache(string cacheFile) { InitializeComponent(); // Vytvori XML dokument gpxDoc = new Gpx(cacheFile); // Layout ArrayList list1 = new ArrayList(); list1.Add("Deg°"); list1.Add("Deg°Min'"); list1.Add("Deg°Min'Sec\""); comboBox1.DataSource = list1; textBox2.Text = "00.000000"; textBox3.Text = "00.000000"; ArrayList list2 = new ArrayList(); list2.Add("Traditional Cache"); list2.Add("Multi-cache"); list2.Add("Unknown Cache"); list2.Add("Letterbox Hybrid"); list2.Add("Wherigo Cache"); list2.Add("Earthcache"); list2.Add("Virtual Cache"); list2.Add("Webcam Cache"); list2.Add("Event Cache"); list2.Add("Cache In Trash Out Event"); list2.Add("Mega-Event Cache"); list2.Add("Other"); comboBox2.DataSource = list2; ArrayList list3 = new ArrayList(); list3.Add("Micro"); list3.Add("Small"); list3.Add("Regular"); list3.Add("Large"); list3.Add("Other"); comboBox3.DataSource = list3; ArrayList list4 = new ArrayList(); for (int i = 1; i <= 5; i++ ) list4.Add(i); comboBox4.DataSource = list4; ArrayList list5 = new ArrayList(); for (int i = 1; i <= 5; i++) list5.Add(i); comboBox5.DataSource = list5; }
/// <summary> /// Tlacitko pro odstraneni cache z databaze /// </summary> private void pictureBox14_Click(object sender, EventArgs e) { if (listBox1.SelectedIndex != -1) { string message = "Do you really want to remove selected cache from GPX database file?"; string caption = "Delete cache"; DialogResult result; result = MessageBox.Show(message, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (result == DialogResult.Yes) { selectedCache = SelectedCache(); Cache selected = (Cache)caches[selectedCache]; Gpx gpxDoc = new Gpx(settings[0]); try { gpxDoc.CacheDelete(selected.Code); } catch (System.IO.FileNotFoundException) { message = "Database file " + gpxDoc.GpxFile + " doesn't exist!"; caption = "Error"; MessageBox.Show(message, caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); DatabaseDeselect(); } catch { string message2 = "Error! Cannot remove database data!"; string caption2 = "Error"; MessageBox.Show(message2, caption2, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); DatabaseDeselect(); } DatabaseLoad(); } } }
/// <summary> /// Tlacitko pro pridani cache do databaze /// </summary> private void pictureBox13_Click(object sender, EventArgs e) { // Neni vybran zadny GPX soubor if (settings[0] == "") { settings[0] = path + "\\default.xml"; // Vytvori novy GPX soubor if (!File.Exists(settings[0])) { Gpx gpxDoc = new Gpx(settings[0]); gpxDoc.CreateGpx(); } } AddCache form = new AddCache(settings[0]); form.ShowDialog(); if (form.DialogResult == DialogResult.OK) DatabaseLoad(); }
/// <summary> /// Nacte databazi cache z GPX souboru /// </summary> private void DatabaseLoad() { // Vyprazdneni seznamu caches.Clear(); listBox1.Items.Clear(); // Nastaveni formularovych prvku label3.Text = "no cache"; label4.Text = ""; if (settings[0] != "") label6.Text = settings[0]; else label6.Text = "no file"; label8.Text = ""; HintBox(); webBrowser1.DocumentText = "<html><head></head><body bgcolor='black' text='white'>no cache</body></html>"; selectedCache = -1; // Nacteni cache a odfiltrovani if (settings[0] != "") // GPX soubor existuje { Gpx gpxDoc = new Gpx(settings[0]); try { gpxDoc.CacheLoad(caches); UseFilter(); } catch (System.IO.FileNotFoundException) { string message = "Database file " + gpxDoc.GpxFile + " doesn't exist!"; string caption = "Error"; MessageBox.Show(message, caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); DatabaseDeselect(); } catch { string message = "Error! Cannot load database data!"; string caption = "Error"; MessageBox.Show(message, caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); DatabaseDeselect(); } } /* // Kontrolni vypis StringBuilder sb = new StringBuilder(); foreach (Cache element in caches) sb.AppendFormat(@"{0}<br/>{1}<br/>{2}<br/>{3}<br/>{4}<br/>{5}<br/>{6}<br/>{7}<br/>{8}<br/>{9}<br/>{10}<br/><hr/>", element.Name, element.Latitude, element.Longitude, element.Code, element.Available, element.Archived, element.Type, element.Container, element.Difficulty, element.Terrain, element.View); webBrowser1.DocumentText = sb.ToString(); */ }
/// <summary> /// Nacte veskere informace o vybrane cache /// </summary> private void UpdateCache() { bool err = false; if (listBox1.SelectedIndex != -1) { selectedCache = SelectedCache(); Cache selected = (Cache)caches[selectedCache]; Gpx gpxDoc = new Gpx(settings[0]); // Vypis info na horni listu label3.Text = selected.Name; label4.Text = Cache.TypeStr(selected.Type)[0] + " " + Cache.ContainerStr(selected.Container)[0] + " " + selected.Difficulty.ToString() + " " + selected.Terrain.ToString(); // Vypis hintu try { label8.Text = gpxDoc.GetElementContent(selected.Code, "groundspeak:encoded_hints"); } catch { err = true; } HintBox(); // Vypis kompletni info o kesi string latitude = ""; string longitude = ""; switch (settings[3]) { case "degmin": latitude = "" + new Deg2DegMin(selected.Latitude, (int)orientation.LAT); longitude = "" + new Deg2DegMin(selected.Longitude, (int)orientation.LON); break; case "degminsec": latitude = "" + new Deg2DegMinSec(selected.Latitude, (int)orientation.LAT); longitude = "" + new Deg2DegMinSec(selected.Longitude, (int)orientation.LON); break; default: latitude = "" + new Deg2Deg(selected.Latitude, (int)orientation.LAT); longitude = "" + new Deg2Deg(selected.Longitude, (int)orientation.LON); break; } // Vypis HTML string head = "<b>" + selected.Name + "</b><br/><hr/>" + "Latitude: " + latitude + "<br/>Longitude: " + longitude + "<br/>"; try { webBrowser1.DocumentText = "<html><head></head><body bgcolor='black' text='white'>" + head + gpxDoc.CacheInfo(selected.Code, settings, settingsShow) + "</body></html>"; } catch { err = true; } // Error - GPX soubor neexistuje nebo je chybny if (err) { string message = "Error! Cannot load database data!"; string caption = "Error"; MessageBox.Show(message, caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); DatabaseDeselect(); } } }