private void showMap()
        {
            String name = null;
            foreach (int index in this.listViewMaps.SelectedIndices)
            {
                if (index >= 0)
                {
                    name = this.listViewMaps.Items[index].Text;
                    try
                    {
                        CultureInfo info = null;
                        if (listViewMaps.Items[index].SubItems[1].Text.Contains(","))
                            info = System.Globalization.CultureInfo.CreateSpecificCulture("de-de");//Über LanguageContext regeln
                        else if (listViewMaps.Items[index].SubItems[1].Text.Contains("."))
                            info = System.Globalization.CultureInfo.CreateSpecificCulture("en-us");
                        this._LongLeft = float.Parse(listViewMaps.Items[index].SubItems[1].Text, info);
                        this._LongRight = float.Parse(listViewMaps.Items[index].SubItems[2].Text, info);
                        this._LatBottom = float.Parse(listViewMaps.Items[index].SubItems[4].Text, info);
                        this._LatTop = float.Parse(listViewMaps.Items[index].SubItems[3].Text, info);
                    }
                    catch (Exception)
                    {
                        Cursor.Current = Cursors.Default;
                        throw new GoogleMapsCorruptedException("GPS Data couldn`t be read. Map can`t be displayed!");
                    }
                }
            }

            if (!this.StoredLocalisationIsOnMap()&&!this.ActualLocalisationIsOnMap())
            {
                if (MessageBox.Show("Localisation isn`t on selected map. Do you want to display the map nonetheless?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.No)
                {
                    this._LongLeft = 0;
                    this._LongRight = 0;
                    this._LatBottom = 0;
                    this._LatTop = 0;
                    return;
                }
            }
            if (name != null)
            {
                this.panelData.Visible = false;
                String fileName = this._mapPath + @"\" + name + ".png";
                ShowMapForm mapForm= new ShowMapForm(this._savedGpsLat, this._savedGpsLong,this._actualGpsLat,this._actualGpsLong, this._LatTop, this._LatBottom, this._LongLeft, this._LongRight, fileName, this._showOnly);
                if (mapForm.ShowDialog() == DialogResult.OK)
                {
                    this.GPSLat = mapForm.SavedLat;
                    this.GPSLong = mapForm.SavedLong;
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                    this.DialogResult = DialogResult.Cancel;
            }
        }
Example #2
0
        private void showMap()
        {
            String name = null;

            foreach (int index in this.listViewMaps.SelectedIndices)
            {
                if (index >= 0)
                {
                    name = this.listViewMaps.Items[index].Text;
                    try
                    {
                        CultureInfo info = null;
                        if (listViewMaps.Items[index].SubItems[1].Text.Contains(","))
                        {
                            info = System.Globalization.CultureInfo.CreateSpecificCulture("de-de");//Über LanguageContext regeln
                        }
                        else if (listViewMaps.Items[index].SubItems[1].Text.Contains("."))
                        {
                            info = System.Globalization.CultureInfo.CreateSpecificCulture("en-us");
                        }
                        this._LongLeft  = float.Parse(listViewMaps.Items[index].SubItems[1].Text, info);
                        this._LongRight = float.Parse(listViewMaps.Items[index].SubItems[2].Text, info);
                        this._LatBottom = float.Parse(listViewMaps.Items[index].SubItems[4].Text, info);
                        this._LatTop    = float.Parse(listViewMaps.Items[index].SubItems[3].Text, info);
                    }
                    catch (Exception)
                    {
                        Cursor.Current = Cursors.Default;
                        throw new GoogleMapsCorruptedException("GPS Data couldn`t be read. Map can`t be displayed!");
                    }
                }
            }

            if (!this.StoredLocalisationIsOnMap() && !this.ActualLocalisationIsOnMap())
            {
                if (MessageBox.Show("Localisation isn`t on selected map. Do you want to display the map nonetheless?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.No)
                {
                    this._LongLeft  = 0;
                    this._LongRight = 0;
                    this._LatBottom = 0;
                    this._LatTop    = 0;
                    return;
                }
            }
            if (name != null)
            {
                this.panelData.Visible = false;
                String      fileName = this._mapPath + @"\" + name + ".png";
                ShowMapForm mapForm  = new ShowMapForm(this._savedGpsLat, this._savedGpsLong, this._actualGpsLat, this._actualGpsLong, this._LatTop, this._LatBottom, this._LongLeft, this._LongRight, fileName, this._showOnly);
                if (mapForm.ShowDialog() == DialogResult.OK)
                {
                    this.GPSLat       = mapForm.SavedLat;
                    this.GPSLong      = mapForm.SavedLong;
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    this.DialogResult = DialogResult.Cancel;
                }
            }
        }