示例#1
0
        public void findAddress(string address)
        {
            MapPoint.Map map = mainFrm.frmMapPoint.Map.ActiveMap;

            //Call the ShowFindDialog to show the find (modal) dialog
            object result = map.ShowFindDialog(address, MapPoint.GeoFindState.geoFindDefault, (int)mainFrm.Handle, false);

            //See if the result is null
            if (result != null)
            {
                //If the result is a Location type get the
                //Location directly
                if (result is MapPoint.Location)
                {
                    currentLocation = result as MapPoint.Location;
                }
                else if (result is MapPoint.Pushpin)
                {
                    //If this is a Pushpin type, first get the Pushpin
                    MapPoint.Pushpin pushpin = result as MapPoint.Pushpin;
                    //Then get the location
                    currentLocation = pushpin.Location;
                }
                txtDestination.Text = currentLocation.Name;
            }
            else
            {
                MessageBox.Show("No locations found. Please verify the input.");
            }
        }
        private object GetLocation(string postCode)
        {
            if (postCode.StartsWith(">"))
            {
                postCode = postCode.Substring(1);
            }


            MapPoint.FindResults objRes = axMappointControl1.ActiveMap.FindAddressResults("", "", "", "", postCode, MapPoint.GeoCountry.geoCountryUnitedKingdom);


            MapPoint.Location loc = null;

            if (objRes.Count == 0)
            {
                var objCoord = new TaxiDataContext().Gen_Coordinates.FirstOrDefault(c => c.PostCode == postCode);

                if (objCoord != null)
                {
                    loc = axMappointControl1.ActiveMap.GetLocation(Convert.ToDouble(objCoord.Latitude), Convert.ToDouble(objCoord.Longitude), 1.00);
                }
            }
            else
            {
                object item = 1;
                loc = (MapPoint.Location)objRes.get_Item(ref item);
            }


            return((object)loc);
        }
        public void findAddress(string address)
        {
            MapPoint.Map map = mainFrm.frmMapPoint.Map.ActiveMap;

            //Call the ShowFindDialog to show the find (modal) dialog
            object result = map.ShowFindDialog(address, MapPoint.GeoFindState.geoFindDefault, (int)mainFrm.Handle, false);

            //See if the result is null
            if (result != null)
            {
                //If the result is a Location type get the
                //Location directly
                if (result is MapPoint.Location)
                {
                    currentLocation = result as MapPoint.Location;
                }
                else if (result is MapPoint.Pushpin)
                {
                    //If this is a Pushpin type, first get the Pushpin
                    MapPoint.Pushpin pushpin = result as MapPoint.Pushpin;
                    //Then get the location
                    currentLocation = pushpin.Location;
                }
                txtDestination.Text = currentLocation.Name;
            }
            else
            {
                MessageBox.Show("No locations found. Please verify the input.");
            }
        }
示例#4
0
 private void Map_BeforeDblClick(object sender, AxMapPoint._IMappointCtrlEvents_BeforeDblClickEvent e)
 {
     if (GetLocation)
     {
         TempLocation = this.Map.ActiveMap.XYToLocation(e.x, e.y);
         GetLocation  = true;
         mainFrm.frm_obiettivo.setNewLocation(TempLocation);
     }
 }
 public void setNewLocation(MapPoint.Location loc)
 {
     mainFrm.frmMapPoint.SendToBack();
     if (txtDestination.Text != "")
     {
         addNewPOI(txtDestination.Text, Math.Round(loc.Latitude, 6).ToString(), Math.Round(loc.Longitude, 6).ToString());
     }
     else
     {
         addNewPOI(loc.Location.Name, Math.Round(loc.Latitude, 6).ToString(), Math.Round(loc.Longitude, 6).ToString());
     }
 }
        public void findAddress(string Address)
        {
            string[] POS = Address.Split('|');

            MapPoint.Map map = mainFrm.frmMapPoint.Map.ActiveMap;

            object result = null;

            //if(POS[0]=="" || POS[1] == "")
            if (POS.Length == 1)
            {
                result = map.ShowFindDialog(POS[0], MapPoint.GeoFindState.geoFindAddress, (int)mainFrm.Handle, false);
            }
            else if (POS.Length > 1)
            {
                result = map.ShowFindDialog(POS[1] + ";" + POS[2], MapPoint.GeoFindState.geoFindLatLong, (int)mainFrm.Handle, false);
            }

            //See if the result is null
            if (result != null)
            {
                //If the result is a Location type get the
                //Location directly
                if (result is MapPoint.Location)
                {
                    currentLocation = result as MapPoint.Location;
                }
                else if (result is MapPoint.Pushpin)
                {
                    //If this is a Pushpin type, first get the Pushpin
                    MapPoint.Pushpin pushpin = result as MapPoint.Pushpin;
                    //Then get the location
                    currentLocation = pushpin.Location;
                }
                txtDestination.Text = currentLocation.Name;
                addNewPOI(currentLocation.Name, Math.Round(currentLocation.Latitude, 6).ToString(), Math.Round(currentLocation.Longitude, 6).ToString());
            }
            else
            {
                MessageBox.Show("No locations found. Please verify the input.");
            }
        }
示例#7
0
 private void Map_BeforeClick(object sender, AxMapPoint._IMappointCtrlEvents_BeforeClickEvent e)
 {
     if (MeasureDistance)
     {
         if (!p1)
         {
             point1 = Map.ActiveMap.XYToLocation(e.x, e.y);
             p1     = true;
         }
         else
         {
             point2 = Map.ActiveMap.XYToLocation(e.x, e.y);
             Map.ActiveMap.Shapes.AddShape(MapPoint.GeoAutoShapeType.geoShapeOval, point2, 100, 100);
             Map.ActiveMap.Shapes.AddLine(point1, point2);
             double distance = Map.ActiveMap.Distance(point1, point2);
             MessageBox.Show("Distanza rilevata: " + Math.Round(distance, 2) + " Km");
             MeasureDistance  = false;
             Map.MousePointer = MapPoint.GeoPointer.geoPointerArrow;
             p1 = false;
         }
     }
 }
示例#8
0
        private void button1_Click(object sender, EventArgs e)
        {
            MapPoint.Map map = mainFrm.frmMapPoint.Map.ActiveMap;

            map.ActiveRoute.Clear();

            frmDriver frm = new frmDriver();

            frm.loadProfileAutomatic(mainFrm.CURRENT_DRIVER_PROFILE, map.ActiveRoute.DriverProfile);

            MapPoint.Location start = null;


            if (mainFrm.listBox1.SelectedIndex > -1)
            {
                smartrack p = mainFrm.sm_array[mainFrm.listBox1.SelectedIndex];
                start = map.GetLocation(p.Lat, p.Lon, map.Altitude);
            }

            map.ActiveRoute.Waypoints.Add(start, "Partenza");
            map.ActiveRoute.Waypoints.Add(currentLocation, "Arrivo");

            map.ActiveRoute.DriverProfile.IncludeRestStops = true;
            try
            {
                map.ActiveRoute.Calculate();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            if (map.ActiveRoute.IsCalculated)
            {
                addNewPOI(txtDestination.Text);
            }
        }
        private void Map_BeforeClick(object sender, AxMapPoint._IMappointCtrlEvents_BeforeClickEvent e)
        {
            if (MeasureDistance)
            {
                if (!p1)
                {
                    point1 = Map.ActiveMap.XYToLocation(e.x, e.y);
                    p1 = true;
                }
                else
                {
                    point2 = Map.ActiveMap.XYToLocation(e.x, e.y);
                    Map.ActiveMap.Shapes.AddShape(MapPoint.GeoAutoShapeType.geoShapeOval, point2, 100, 100);
                    Map.ActiveMap.Shapes.AddLine(point1, point2);
                    double distance = Map.ActiveMap.Distance(point1, point2);
                    MessageBox.Show("Distanza rilevata: " + Math.Round(distance, 2) + " Km");
                    MeasureDistance = false;
                    Map.MousePointer = MapPoint.GeoPointer.geoPointerArrow;
                    p1 = false;
                }

            }
        }
示例#10
0
 private void Map_BeforeDblClick(object sender, AxMapPoint._IMappointCtrlEvents_BeforeDblClickEvent e)
 {
     if (GetLocation)
     {
         TempLocation = this.Map.ActiveMap.XYToLocation(e.x, e.y);
         GetLocation = true;
         mainFrm.frm_obiettivo.setNewLocation(TempLocation);
     }
 }
        private void button1_Click(object sender, EventArgs e)
        {
            if (olnyAdd == false)
            {
                //***************** associo l'obiettivo al mezzo ******************
                if (mainFrm.listBox1.SelectedIndex == -1)
                {
                    MessageBox.Show("Per associare un bersaglio è necessario selezionare prima il mezzo.");
                    return;
                }
                smartrack sm = mainFrm.searchDevicebyDescription(mainFrm.listBox1.SelectedItem.ToString());
                //sm.Bersaglio = currentLocation;

                string bersaglio = currentLocation.Name + "|" + currentLocation.Latitude + "|" + currentLocation.Longitude;

                sm.SetBersaglio(bersaglio);
                mainFrm.deviceCtrl1.refreshStatus();

                if (MessageBox.Show(this, "Bersaglio associato. Visualizzo anche l'itinerario?", "Info", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    MapPoint.Map map = mainFrm.frmMapPoint.Map.ActiveMap;
                    map.ActiveRoute.Clear();

                    frmDriver frm = new frmDriver();
                    frm.loadProfileAutomatic(mainFrm.CURRENT_DRIVER_PROFILE, map.ActiveRoute.DriverProfile);

                    MapPoint.Location start = null;

                    mainFrm.frmMapPoint.Map.Units = MapPoint.GeoUnits.geoKm;
                    if (mainFrm.listBox1.SelectedIndex > -1)
                    {
                        smartrack p = mainFrm.sm_array[mainFrm.listBox1.SelectedIndex];
                        start = map.GetLocation(p.Lat, p.Lon, map.Altitude);
                    }

                    map.ActiveRoute.Waypoints.Add(start, "Partenza");
                    map.ActiveRoute.Waypoints.Add(currentLocation, "Arrivo");
                    try
                    {
                        map.ActiveRoute.Calculate();
                        map.ActiveRoute.Application.ItineraryVisible = false;

                        string Reso = "Viaggio da: " + start.Name + " a " + currentLocation.Name + "\r\n";

                        Reso += "Totale Km: " + map.ActiveRoute.Distance + ". Durata prevista tragitto: " + Math.Ceiling((map.ActiveRoute.DrivingTime * 24 * 60)) + " minuti.\r\n";
                        Reso += @"Costo totale (stimato in base al profilo di guida): " + Math.Round(map.ActiveRoute.Cost, 2) + "€";
                        if (!String.IsNullOrEmpty(mainFrm.CURRENT_DRIVER_PROFILE))
                        {
                            Reso += "\r\nProfilo di guida selezionato: " + System.IO.Path.GetFileName(mainFrm.CURRENT_DRIVER_PROFILE);
                        }
                        else
                        {
                            Reso += "\r\nProfilo di guida selezionato: nessuno";
                        }

                        if (MessageBox.Show(this, Reso + "\nAssocio l'obiettivo e salvo l'informazione?", "Info", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                            {
                                using (StreamWriter wr = new StreamWriter(saveFileDialog1.FileName, true))
                                {
                                    wr.WriteLine("**************************************");
                                    wr.WriteLine(Reso);
                                    wr.WriteLine("**************************************");
                                }
                            }

                            /* //***************** associo l'obiettivo al mezzo ******************
                             * smartrack sm = mainFrm.searchDevicebyDescription(mainFrm.listBox1.SelectedItem.ToString());
                             * sm.Bersaglio = currentLocation;
                             * mainFrm.deviceCtrl1.refreshStatus();*/
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Impossibile associare il bersaglio. Possibile causa:" + ex.Message);
                    }
                }
                this.Close();
            }
            else
            {
                this.Close();
            }
        }
        public void findAddress(string Address)
        {
            string[] POS = Address.Split('|');

            MapPoint.Map map = mainFrm.frmMapPoint.Map.ActiveMap;

            object result = null;
            //if(POS[0]=="" || POS[1] == "")
            if (POS.Length==1)
                result = map.ShowFindDialog(POS[0], MapPoint.GeoFindState.geoFindAddress, (int)mainFrm.Handle, false);
            else if (POS.Length>1)
                result = map.ShowFindDialog(POS[1] + ";" + POS[2], MapPoint.GeoFindState.geoFindLatLong, (int)mainFrm.Handle, false);

            //See if the result is null
            if (result != null)
            {
                //If the result is a Location type get the
                //Location directly
                if (result is MapPoint.Location)
                {
                    currentLocation = result as MapPoint.Location;
                }
                else if (result is MapPoint.Pushpin)
                {
                    //If this is a Pushpin type, first get the Pushpin
                    MapPoint.Pushpin pushpin = result as MapPoint.Pushpin;
                    //Then get the location
                    currentLocation = pushpin.Location;
                }
                txtDestination.Text = currentLocation.Name;
                addNewPOI(currentLocation.Name, Math.Round(currentLocation.Latitude,6).ToString(), Math.Round(currentLocation.Longitude,6).ToString());
            }
            else
            {
                MessageBox.Show("No locations found. Please verify the input.");
            }
        }