Exemplo n.º 1
0
        private void nuovoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog save = new SaveFileDialog();

            save.Filter = "XML |*.xml";

            DialogResult result = save.ShowDialog();

            if (result == DialogResult.OK)
            {
                if (Makefire.CreateFile(save.FileName))
                {
                    listBox.Items.Clear();
                    markerOverlay.Markers.Clear();
                    MessageBox.Show("File XML creato correttamente.", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    panelOverIncendio.Visible = false;
                    areaTB.Focus();
                }
                else
                {
                    MessageBox.Show("Errore nel creare il file XML.", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    panelOverIncendio.Visible = true;
                }
            }
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 private void StradeSatelliteRadioButtonChange(object sender, EventArgs e)
 {
     if (stradeRB.Checked)
     {
         gMC.MapProvider = GMapProviders.GoogleMap;
         Makefire.InsertTypeMapInComment("Str");
     }
     else if (satelliteRB.Checked)
     {
         gMC.MapProvider = GMapProviders.BingSatelliteMap;
         Makefire.InsertTypeMapInComment("Sat");
     }
 }
Exemplo n.º 4
0
        private void cercaAreaBtn_Click(object sender, EventArgs e)
        {
            if (areaTB.Text != "")
            {
                GeoCoderStatusCode gcsc;

                try
                {
                    gMC.Position = (PointLatLng)GMapProviders.GoogleMap.GetPoint(areaTB.Text, out gcsc);

                    gMC.Zoom = 15;

                    if (!Makefire.InsertAreaInComment(areaTB.Text))
                    {
                        MessageBox.Show("Attenzione non hai ancora creato il file XML oppure non è stato creato correttamente.", "Attenzione", MessageBoxButtons.OK,
                                        MessageBoxIcon.Warning);
                    }
                }
                catch
                {
                    MessageBox.Show("Impossibile Trovare l'area ricercata al momento. Potrebbe essere un problema dei server Google.");
                }
            }
        }
Exemplo n.º 5
0
 private void gMC_OnPositionChanged(PointLatLng point)
 {
     Makefire.InsertPositionInComment(gMC.Position.ToString());
 }
Exemplo n.º 6
0
        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;
            }
        }