private void dataGridViewOdabraniGradovi_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1)
            {
                return;
            }
            dataGridViewOdabraniGradovi.Rows[e.RowIndex].Selected = true;

            double lat = 0, lon = 0;

            if (dataGridViewOdabraniGradovi.CurrentCell.ColumnIndex.Equals(15) && e.RowIndex != -1)
            {
                int IdGrada    = Convert.ToInt32(dataGridViewOdabraniGradovi.Rows[e.RowIndex].Cells[0].Value.ToString());
                var lLonAndLat = cityRepository.DajLonLat(IdGrada);
                gMapControl.MapProvider = GMapProviders.GoogleMap;

                for (int i = 0; i < lLonAndLat.Count; i++)
                {
                    if (i == 1)
                    {
                        lon = lLonAndLat[i];
                    }
                    else if (i == 0)
                    {
                        lat = lLonAndLat[i];
                    }
                }
                gMapControl.Position = new PointLatLng(lat, lon);
                gMapControl.MinZoom  = 0;
                gMapControl.MaxZoom  = 18;
                gMapControl.Zoom     = 5;

                PointLatLng pointLatLng = new PointLatLng(lat, lon);
                GMapMarker  gMapMarker  = new GMarkerGoogle(pointLatLng, GMarkerGoogleType.red_small);

                GMapOverlay markers = new GMapOverlay("markers");
                markers.Markers.Add(gMapMarker);
                gMapControl.Overlays.Add(markers);

                gMapControl.Show();
            }

            if (dataGridViewOdabraniGradovi.CurrentCell.ColumnIndex.Equals(16) && e.RowIndex != -1)
            {
                int IdGrada = Convert.ToInt32(dataGridViewOdabraniGradovi.Rows[e.RowIndex].Cells[0].Value.ToString());
                FormOdabraniObrisi brisanjeForm = new FormOdabraniObrisi(IdGrada, this);
                brisanjeForm.lblBrisanjeGrada.Text = "Želite li ukloniti " + dataGridViewOdabraniGradovi.Rows[e.RowIndex].Cells[1].Value.ToString() + " iz tablice";
                DataGridViewRow row  = dataGridViewOdabraniGradovi.Rows[e.RowIndex];
                var             grad = new City
                {
                    nCityID     = (int)row.Cells[0].Value,
                    sCityName   = (string)row.Cells[1].Value,
                    sCountryTag = ""
                };
                checkedCity.RemoveAll(x => x.nCityID == grad.nCityID);
                brisanjeForm.ShowDialog();
            }
        }
Example #2
0
        private void dataGridViewPovijestMjerenja_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1)
            {
                return;
            }
            dataGridViewPovijestMjerenja.Rows[e.RowIndex].Selected = true;

            if (dataGridViewPovijestMjerenja.CurrentCell.ColumnIndex.Equals(15) && e.RowIndex != -1)
            {
                double lat = 0, lon = 0;
                int    IdGrada    = Convert.ToInt32(dataGridViewPovijestMjerenja.Rows[e.RowIndex].Cells[1].Value.ToString());
                var    lLonAndLat = cityRepository.DajLonLat(IdGrada);
                GMapHistory.MapProvider = GMapProviders.GoogleMap;

                for (int i = 0; i < lLonAndLat.Count; i++)
                {
                    if (i == 1)
                    {
                        lon = lLonAndLat[i];
                    }
                    else if (i == 0)
                    {
                        lat = lLonAndLat[i];
                    }
                }
                GMapHistory.Position = new PointLatLng(lat, lon);
                GMapHistory.MinZoom  = 0;
                GMapHistory.MaxZoom  = 18;
                GMapHistory.Zoom     = 5;

                PointLatLng pointLatLng = new PointLatLng(lat, lon);
                GMapMarker  gMapMarker  = new GMarkerGoogle(pointLatLng, GMarkerGoogleType.red_small);

                GMapOverlay markers = new GMapOverlay("markers");
                markers.Markers.Add(gMapMarker);
                GMapHistory.Overlays.Add(markers);

                GMapHistory.Show();
            }

            if (dataGridViewPovijestMjerenja.CurrentCell.ColumnIndex.Equals(16) && e.RowIndex != -1)
            {
                int IdMjerenja = Convert.ToInt32(dataGridViewPovijestMjerenja.Rows[e.RowIndex].Cells[0].Value.ToString());
                FormObrisiPovijest brisanjeForm = new FormObrisiPovijest(IdMjerenja, this);
                brisanjeForm.labelBrisanjePovijest.Text = "Želite li obrisati " + dataGridViewPovijestMjerenja.Rows[e.RowIndex].Cells[2].Value.ToString() + " iz povjesti mjerenja?";
                brisanjeForm.lblIdMjerenja.Text         = "Id mjerenja:" + dataGridViewPovijestMjerenja.Rows[e.RowIndex].Cells[0].Value.ToString();
                brisanjeForm.ShowDialog();
            }
        }