Beispiel #1
0
 private void button6_Click(object sender, EventArgs e)
 {
     MapPoint.ApplicationClass mapPoint = new MapPoint.ApplicationClass();
     MapPoint.Map         map           = mapPoint.ActiveMap;
     MapPoint.FindResults findResults   = map.FindPlaceResults(this.textBox1.Text);
     var a = findResults[0];
 }
Beispiel #2
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 void latlng_Click(object sender, EventArgs e)
        {
            MapPoint.Map objMap = null;
            objMap = MPC.NewMap(MapPoint.GeoMapRegion.geoMapEurope);
            object obj1 = 1;

            objMap.ActiveRoute.Waypoints.Add(objMap.FindResults(FromTextBox.Text).get_Item(ref obj1), "");
            objMap.ActiveRoute.Waypoints.Add(objMap.FindResults(ToTextBox.Text).get_Item(ref obj1), "");
            objMap.ActiveRoute.Calculate();
            distance.Text = (objMap.ActiveRoute.Distance) * 3600 / 10000 + "  meters";
        }
Beispiel #4
0
        public MapPointCall(DistEvaluator distEvaluator)
        {
            this.mDistEvaluator = distEvaluator;
            this.mMapPoint      = new MapPoint.ApplicationClass();
            this.mMapPoint.Application.Units = MapPoint.GeoUnits.geoKm;
            this.mMapPoint.Visible           = false;
            this.mMapPoint.UserControl       = true;

            //Configure l'application
            mMap   = this.mMapPoint.ActiveMap;
            mRoute = mMap.ActiveRoute;

            mMap.Parent.PaneState = MapPoint.GeoPaneState.geoPaneRoutePlanner;
        }
        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.");
            }
        }
Beispiel #6
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 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();
            }
        }
Beispiel #8
0
        public MapPointCall(DistEvaluator distEvaluator)
        {
            this.mDistEvaluator = distEvaluator;
            this.mMapPoint = new MapPoint.ApplicationClass();
            this.mMapPoint.Application.Units = MapPoint.GeoUnits.geoKm;
            this.mMapPoint.Visible = false;
            this.mMapPoint.UserControl = true;

            //Configure l'application
            mMap = this.mMapPoint.ActiveMap;
            mRoute = mMap.ActiveRoute;

            mMap.Parent.PaneState = MapPoint.GeoPaneState.geoPaneRoutePlanner;
        }