private SceneryObject GetSceneryObjectFromComboBox(ref ComboBox cb) { if (((ComboElement)cb.SelectedItem).type == "Fire") { SceneryObject obj = new Fire((cb.SelectedItem as ComboElement).value, Convert.ToDouble(singoloLatTB.Text), Convert.ToDouble(singoloLonTB.Text)); return(obj); } else if (((ComboElement)cb.SelectedItem).type == "Smoke") { SceneryObject obj = new Smoke((cb.SelectedItem as ComboElement).value, Convert.ToDouble(singoloLatTB.Text), Convert.ToDouble(singoloLonTB.Text)); return(obj); } else if (((ComboElement)cb.SelectedItem).type == "Autocisterna") { SceneryObject obj = new Autocisterna(Convert.ToDouble(singoloLatTB.Text), Convert.ToDouble(singoloLonTB.Text)); return(obj); } else { SceneryObject obj = new CustomObject(((ComboElement)cb.SelectedItem).type, ((ComboElement)cb.SelectedItem).value, Convert.ToDouble(singoloLatTB.Text), Convert.ToDouble(singoloLonTB.Text), (GMarkerGoogleType)Enum.Parse(typeof(GMarkerGoogleType), ((ComboElement)cb.SelectedItem).markerColor)); return(obj); } }
private void lineaCreaBtn_Click(object sender, EventArgs e) { double lat1 = 0; double lon1 = 0; double lat2 = 0; double lon2 = 0; lat1 = Convert.ToDouble(lineaLat1TB.Text); lon1 = Convert.ToDouble(lineaLon1TB.Text); lat2 = Convert.ToDouble(lineaLat2TB.Text); lon2 = Convert.ToDouble(lineaLon2TB.Text); SceneryObject f1; // new Fire(lineaEffettoCB.Text, lat1, lon1); SceneryObject f2; //new Fire(lineaEffettoCB.Text, lat2, lon2); switch (((ComboElement)lineaEffettoCB.SelectedItem).type) { case "Fire": f1 = new Fire(((ComboElement)lineaEffettoCB.SelectedItem).value, lat1, lon1); f2 = new Fire(((ComboElement)lineaEffettoCB.SelectedItem).value, lat2, lon2); break; case "Smoke": f1 = new Smoke(((ComboElement)lineaEffettoCB.SelectedItem).value, lat1, lon1); f2 = new Smoke(((ComboElement)lineaEffettoCB.SelectedItem).value, lat2, lon2); break; case "Autocisterna": f1 = new Autocisterna(lat1, lon1); f2 = new Autocisterna(lat2, lon2); break; default: f1 = new CustomObject(((ComboElement)lineaEffettoCB.SelectedItem).type, ((ComboElement)lineaEffettoCB.SelectedItem).value, lat1, lon1, (GMarkerGoogleType)Enum.Parse(typeof(GMarkerGoogleType), ((ComboElement)lineaEffettoCB.SelectedItem).markerColor) ); f2 = new CustomObject(((ComboElement)lineaEffettoCB.SelectedItem).type, ((ComboElement)lineaEffettoCB.SelectedItem).value, lat2, lon2, (GMarkerGoogleType)Enum.Parse(typeof(GMarkerGoogleType), ((ComboElement)lineaEffettoCB.SelectedItem).markerColor) ); break; } List <SceneryObject> objects = Makefire.CreateLineFire(f1, f2); foreach (SceneryObject f in objects) { f.AddToXml(Makefire.filePath); f.AddMarkerToMap(ref markerOverlay); listBox.Items.Add(f); } LineaFieldsClearAll(); EnableSelezionatuttiAndCompilaBGL(); MessageBox.Show("Sono stati aggiunti " + objects.Count + " oggetti correttamente", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void apriToolStripMenuItem_Click(object sender, EventArgs e) { DialogResult result = Makefire.LoadFile(); if (result == DialogResult.OK) { listBox.Items.Clear(); markerOverlay.Markers.Clear(); double lat = 0; double lon = 0; SceneryObject n; foreach (XmlElement el in Makefire.doc.GetElementsByTagName("SceneryObject")) { lat = Convert.ToDouble(el.Attributes["lat"].InnerText.Replace(".", ",")); lon = Convert.ToDouble(el.Attributes["lon"].InnerText.Replace(".", ",")); if (el.FirstChild.Name == "Effect") { if (el.FirstChild.Attributes[0].InnerText.Contains("Fire")) { n = new Fire(el.FirstChild.Attributes[0].InnerText, lat, lon); n.AddMarkerToMap(ref markerOverlay); n.MarkAsAddedToXml(); listBox.Items.Add(n); } else if (el.FirstChild.Attributes[0].InnerText.Contains("moke")) { n = new Smoke(el.FirstChild.Attributes[0].InnerText, lat, lon); n.AddMarkerToMap(ref markerOverlay); n.MarkAsAddedToXml(); listBox.Items.Add(n); } else { XDocument doc = XDocument.Load(Application.StartupPath + Path.Combine(@"\Effetti\Effetti.xml")); foreach (XElement i in doc.Root.Element("EffettiComboSingolo").Elements()) { if (i.Value == el.FirstChild.Attributes[0].Value) { n = new CustomObject(i.Name.ToString(), i.Value, lat, lon, (GMarkerGoogleType)Enum.Parse(typeof(GMarkerGoogleType), i.FirstAttribute.Value)); n.AddMarkerToMap(ref markerOverlay); n.MarkAsAddedToXml(); listBox.Items.Add(n); break; } } foreach (XElement i in doc.Root.Element("EffettiComboLinea").Elements()) { if (i.Value == el.FirstChild.Attributes[0].Value) { n = new CustomObject(i.Name.ToString(), i.Value, lat, lon, (GMarkerGoogleType)Enum.Parse(typeof(GMarkerGoogleType), i.FirstAttribute.Value)); n.AddMarkerToMap(ref markerOverlay); n.MarkAsAddedToXml(); listBox.Items.Add(n); break; } } } } else if (el.FirstChild.Name == "LibraryObject") { n = new Autocisterna(lat, lon); n.AddMarkerToMap(ref markerOverlay); n.MarkAsAddedToXml(); listBox.Items.Add(n); } } foreach (XmlElement el in Makefire.doc.GetElementsByTagName("Waypoint")) { lat = Convert.ToDouble(el.Attributes["lat"].InnerText.Replace(".", ",")); lon = Convert.ToDouble(el.Attributes["lon"].InnerText.Replace(".", ",")); n = new Waypoint(lat, lon); n.AddMarkerToMap(ref markerOverlay); n.MarkAsAddedToXml(); listBox.Items.Add(n); } panelOverIncendio.Visible = false; areaTB.Focus(); } EnableSelezionatuttiAndCompilaBGL(); areaTB.Text = Makefire.GetAreaFromComment().Substring(6); string position = Makefire.GetPositionFromComment().Substring(11); double Lat = 0; double Lng = 0; int index = 16; bool continua = true; do { try { Lat = Convert.ToDouble(position.Substring(5, index)); continua = false; } catch { index--; } } while (continua); continua = true; index = 16; do { try { Lng = Convert.ToDouble(position.Substring(27, index)); continua = false; } catch { index--; } } while (continua); if (areaTB.Text != "") { //gMC.Position = (PointLatLng)GMapProviders.GoogleMap.GetPoint(areaTB.Text, out gcsc); gMC.Position = new PointLatLng(Lat, Lng); gMC.Zoom = 15; } if (Makefire.GetMapTypeFromComment().Contains("Sat")) { gMC.MapProvider = GMapProviders.BingSatelliteMap; satelliteRB.CheckedChanged -= StradeSatelliteRadioButtonChange; satelliteRB.Checked = true; satelliteRB.CheckedChanged += StradeSatelliteRadioButtonChange; /*stradeRB.CheckedChanged -= StradeSatelliteRadioButtonChange; * stradeRB.Checked = false; * stradeRB.CheckedChanged += StradeSatelliteRadioButtonChange;*/ } else if (Makefire.GetMapTypeFromComment().Contains("Str")) { gMC.MapProvider = GMapProviders.GoogleMap; stradeRB.CheckedChanged -= StradeSatelliteRadioButtonChange; stradeRB.Checked = true; stradeRB.CheckedChanged += StradeSatelliteRadioButtonChange; /*satelliteRB.CheckedChanged -= StradeSatelliteRadioButtonChange; * satelliteRB.Checked = false; * satelliteRB.CheckedChanged += StradeSatelliteRadioButtonChange;*/ } else { gMC.MapProvider = GMapProviders.GoogleMap; } }
public Smoke(Smoke s) : base(s.name, s.lat, s.lon) { altitude = s.altitude; }