private void Stavirutu(double X, double Y, double Fx, double Fy, string mId) { List <PointLatLng> rutice = new List <PointLatLng>(); PointLatLng start = new PointLatLng(X, Y); PointLatLng end = new PointLatLng(Fx, Fy); rutice.Add(start); rutice.Add(end); var r = new GMap.NET.WindowsForms.GMapRoute(rutice, "MyRoute"); r.Name = Convert.ToString(mId); r.Stroke.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash; r.IsHitTestVisible = true; GMapOverlay routesOverlay = new GMapOverlay("routes"); routesOverlay.Routes.Add(r); gMapControl1.Overlays.Add(routesOverlay); gMapControl1.Zoom += 0.1; gMapControl1.Zoom -= 0.1; rute nova_rute = new rute(); nova_rute.start_X = X; nova_rute.tstart_X = X; nova_rute.start_Y = Y; nova_rute.tstart_Y = Y; nova_rute.finish_X = Fx; nova_rute.finish_Y = Fy; idRute_povecaj++; nova_rute.id_rute = idRute_povecaj; nova_rute.ime_markera = mId.ToString(); rutes.Add(nova_rute); }
private void load_Click(object sender, EventArgs e) { int pamtiMarkerPrije = 0; for (int i = 0; i < tocke.Count; i++) { if (tocke[i].marker == "yes") { podaci m = new podaci(); m.id_markera = tocke[i].id_Tocka; m.korX = tocke[i].koord_x; m.korY = tocke[i].koord_y; m.imena = tocke[i].postrojba; m.prezimena = tocke[i].postrojba; m.vrsta = tocke[i].pripadnost; pamtiMarkerPrije = m.id_markera; staviMarker(m.korX, m.korY, m.vrsta, m.prezimena, m.id_markera); } else { rute ruta = new rute(); if (tocke[i].zavrsna == 2) { ruta.id_rute = tocke[i].id_Tocka; ruta.ime_markera = pamtiMarkerPrije.ToString(); ruta.start_X = tocke[i].koord_x; ruta.start_Y = tocke[i].koord_y; ruta.tstart_X = tocke[i].koord_x; ruta.tstart_Y = tocke[i].koord_y; ruta.finish_X = tocke[i + 1].koord_x; ruta.finish_Y = tocke[i + 1].koord_y; ruta.gotovo = 0; Stavirutu(ruta.start_X, ruta.start_Y, ruta.finish_X, ruta.finish_Y, ruta.ime_markera); } } } }
private void gMapControl1_MouseDoubleClick(object sender, MouseEventArgs e) { double X = gMapControl1.FromLocalToLatLng(e.X, e.Y).Lng; double Y = gMapControl1.FromLocalToLatLng(e.X, e.Y).Lat; if (r3.Checked == true) { gMapControl1.Position = new PointLatLng(Y, X); GMarkerGoogle marker; if (r2.Checked == true) { marker = new GMarkerGoogle(gMapControl1.Position, GMarkerGoogleType.pink); } else { marker = new GMarkerGoogle(gMapControl1.Position, GMarkerGoogleType.blue); } int indexOdabranePostrojbe = comboBox1.SelectedIndex + 41; TheChosenOne = indexOdabranePostrojbe.ToString(); marker.ToolTipText = marker_Id.ToString(); overlayOne.Markers.Add(marker); gMapControl1.Overlays.Add(overlayOne); podaci m = new podaci(); m.imena = TheChosenOne; m.prezimena = TheChosenOne; m.id_markera = marker_Id; marker_Id = marker_Id + 1; m.korX = X; m.korY = Y; if (r1.Checked == false) { m.vrsta = "enemy"; } else { m.vrsta = "our_team"; } markeri.Add(m); } else if (r4.Checked == true) { if (marker_ruta == null) { MessageBox.Show("Moraš prvo kreirati barem jedan marker da bi mu mogao dodijeliti rutu..."); } else { rute nova_rute = new rute(); nova_rute.start_X = temporary.korX; nova_rute.tstart_X = temporary.korX; nova_rute.start_Y = temporary.korY; nova_rute.tstart_Y = temporary.korY; nova_rute.finish_X = Y; nova_rute.finish_Y = X; idRute_povecaj++; nova_rute.id_rute = idRute_povecaj; nova_rute.ime_markera = marker_ruta; rutes.Add(nova_rute); List <PointLatLng> rutice = new List <PointLatLng>(); PointLatLng start = new PointLatLng(temporary.korX, temporary.korY); PointLatLng end = new PointLatLng(Y, X); rutice.Add(start); rutice.Add(end); var r = new GMap.NET.WindowsForms.GMapRoute(rutice, "MyRoute"); r.Name = Convert.ToString(marker_ruta); r.Stroke.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash; r.IsHitTestVisible = true; GMapOverlay routesOverlay = new GMapOverlay("routes"); routesOverlay.Routes.Add(r); gMapControl1.Overlays.Add(routesOverlay); gMapControl1.Zoom += 0.1; gMapControl1.Zoom -= 0.1; } } }
private void gMapControl1_MouseDoubleClick(object sender, MouseEventArgs e) { double X = gMapControl1.FromLocalToLatLng(e.X, e.Y).Lng; double Y = gMapControl1.FromLocalToLatLng(e.X, e.Y).Lat; if (mr.Text == "marker") { gMapControl1.Position = new PointLatLng(Y, X); GMarkerGoogle marker; if (strana.Text == "neprijatelj") { marker = new GMarkerGoogle(gMapControl1.Position, GMarkerGoogleType.pink); } else { marker = new GMarkerGoogle(gMapControl1.Position, GMarkerGoogleType.blue); } TheChosenOne = comboBox1.Text; marker.ToolTipText = TheChosenOne; overlayOne.Markers.Add(marker); gMapControl1.Overlays.Add(overlayOne); markeri.Where(podaci => podaci.imena == TheChosenOne).First().korX = X; markeri.Where(podaci => podaci.imena == TheChosenOne).First().korY = Y; if (strana.Text == "neprijatelj") { markeri.Where(podaci => podaci.imena == TheChosenOne).First().vrsta = "enemy"; } else { markeri.Where(podaci => podaci.imena == TheChosenOne).First().vrsta = "our_team"; } } else if (mr.Text == "rute") { if (marker_ruta == null) { MessageBox.Show("Moraš prvo kreirati barem jedan marker da bi mu mogao dodijeliti rutu..."); } else { rute nova_rute = new rute(); nova_rute.start_X = temporary.korY; nova_rute.tstart_X = temporary.korY; nova_rute.start_Y = temporary.korX; nova_rute.tstart_Y = temporary.korX; nova_rute.finish_X = Y; nova_rute.finish_Y = X; idRute_povecaj++; nova_rute.id_rute = idRute_povecaj; nova_rute.ime_markera = marker_ruta; rutes.Add(nova_rute); List <PointLatLng> rutice = new List <PointLatLng>(); PointLatLng start = new PointLatLng(temporary.korY, temporary.korX); PointLatLng end = new PointLatLng(Y, X); rutice.Add(start); rutice.Add(end); var r = new GMap.NET.WindowsForms.GMapRoute(rutice, "MyRoute"); r.Name = Convert.ToString(idRute_povecaj); r.Stroke.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash; r.IsHitTestVisible = true; GMapOverlay routesOverlay = new GMapOverlay("routes"); routesOverlay.Routes.Add(r); gMapControl1.Overlays.Add(routesOverlay); gMapControl1.Zoom += 0.1; gMapControl1.Zoom -= 0.1; } } else { MessageBox.Show("Feel the nope!! Moraš il rute il markere odabrati za postavljanje.. :)"); } }