상속: System.ComponentModel.AsyncCompletedEventArgs
 static void query_QueryCompleted(object sender, QueryCompletedEventArgs <IList <MapLocation> > e)
 {
     if (QueryComplete != null)
     {
         QueryComplete(sender, e);
     }
 }
예제 #2
0
 /// <summary>
 /// Called when the queue failed ban query has completed.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">A <see cref="QueryCompletedEventArgs"/> object containing the event data.</param>
 private void OnQueueBanQueryCompleted(object sender, QueryCompletedEventArgs e)
 {
     if (!e.Success)
     {
         this.LogError("Failed to record ban in the local backup database.");
     }
 }
예제 #3
0
        /// <summary>
        /// Called when the query for the list of admin users is completed.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">A <see cref="QueryCompletedEventArgs"/> object containing the event data.</param>
        private void OnAdminsQuery(object sender, QueryCompletedEventArgs e)
        {
            var bundle      = (Dictionary <string, object>)e.Data;
            var groups      = (Dictionary <int, GroupInfo>)bundle["groups"];
            var adminGroups = (Dictionary <int, List <GroupInfo> >)bundle["adminGroups"];

            foreach (DataRow row in e.Results.Rows)
            {
                if (!int.TryParse(row.ItemArray.GetValue(0).ToString(), out var id))
                {
                    continue;
                }

                var identity = row.ItemArray.GetValue(1).ToString();
                var flags    = row.ItemArray.GetValue(2).ToString();
                int.TryParse(row.ItemArray.GetValue(3).ToString(), out var immunity);

                if (adminGroups.ContainsKey(id))
                {
                    foreach (var group in adminGroups[id])
                    {
                        flags   += group.Flags;
                        immunity = Math.Max(immunity, group.Immunity);
                    }
                }

                AdminManager.AddAdmin(identity, immunity, flags);
            }
        }
예제 #4
0
        void geoQ_QueryCompleted(object sender, QueryCompletedEventArgs <Route> e)
        {
            Debug.WriteLine("Route query, error: " + e.Error);
            Debug.WriteLine("Route query, cancelled: " + e.Cancelled);
            Debug.WriteLine("Route query, cancelled: " + e.UserState);

            if (LastRutte != null)
            {
                map1.RemoveRoute(LastRutte);
                LastRutte = null;
            }

            Route myRutte = e.Result;


            for (var i = 0; i < myRutte.Legs.Count(); i++)
            {
                // you could also access each leg separately, and add markers etc into the map for them.
            }
            LastRutte = new MapRoute(myRutte);

            map1.AddRoute(LastRutte);
            map1.SetView(e.Result.BoundingBox);

            MessageBox.Show("Distance: " + (myRutte.LengthInMeters / 1000) + " km, Estimated traveltime: " + myRutte.EstimatedDuration);
        }
예제 #5
0
        /// <summary>
        /// Called when the admin groups query has completed.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">A <see cref="QueryCompletedEventArgs"/> object containing the event data.</param>
        private void OnGroupsQueryCompleted(object sender, QueryCompletedEventArgs e)
        {
            if (!e.Success)
            {
                this.adminRetryTimer          = new Timer(this.retryTime.AsFloat * 1000);
                this.adminRetryTimer.Elapsed += this.OnAdminRetryTimerElapsed;
                this.adminRetryTimer.Enabled  = true;
                return;
            }

            var groups = new Dictionary <string, GroupInfo>();

            foreach (DataRow row in e.Results.Rows)
            {
                var name = row.ItemArray.GetValue(0).ToString();
                if (string.IsNullOrEmpty(name))
                {
                    continue;
                }

                var flags = row.ItemArray.GetValue(1).ToString();
                int.TryParse(row.ItemArray.GetValue(2).ToString(), out var immunity);

                groups.Add(name, new GroupInfo(name, immunity, flags));
            }

            var prefix         = this.databasePrefix.AsString;
            var queryLastLogin = this.requireSiteLogin.AsBool ? "lastvisit IS NOT NULL AND lastvisit != '' AND " : string.Empty;

            this.database.TQuery($"SELECT authid, (SELECT name FROM {prefix}_srvgroups WHERE name = srv_group AND flags != '') AS srv_group, srv_flags, immunity FROM {prefix}_admins_servers_groups AS asg LEFT JOIN {prefix}_admins AS a ON a.aid = asg.admin_id WHERE {queryLastLogin}server_id = {this.serverId.AsInt} OR srv_group_id = ANY(SELECT group_id FROM {prefix}_servers_groups WHERE server_id = {this.serverId.AsInt}) GROUP BY aid, authid, srv_password, srv_group, srv_flags, user", groups).QueryCompleted += this.OnAdminsQueryCompleted;
        }
        private void GeocodeQuery_QueryCompleted(object sender, QueryCompletedEventArgs<IList<MapLocation>> e)
        {
            if (e.Error == null)
            {
                if (e.Result.Count > 0)
                {
                    if (_isRouteSearch) // Query is made to locate the destination of a route
                    {

                    }
                    else // Query is made to search the map for a keyword
                    {
                        // Add all results to MyCoordinates for drawing the map markers
                        for (int i = 0; i < e.Result.Count; i++)
                        {
                            MyCoordinates.Add(e.Result[i].GeoCoordinate);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("No match found. Narrow your search e.g. Seattle WA.");
                }
            }
        }
예제 #7
0
        /// <summary>
        /// Called when the admin users query has completed.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">A <see cref="QueryCompletedEventArgs"/> object containing the event data.</param>
        private void OnAdminsQueryCompleted(object sender, QueryCompletedEventArgs e)
        {
            if (!e.Success)
            {
                this.adminRetryTimer          = new Timer(this.retryTime.AsFloat * 1000);
                this.adminRetryTimer.Elapsed += this.OnAdminRetryTimerElapsed;
                this.adminRetryTimer.Enabled  = true;
                return;
            }

            var groups = (Dictionary <string, GroupInfo>)e.Data;
            var admins = new List <SBCache.Admin>();

            foreach (DataRow row in e.Results.Rows)
            {
                var identity  = row.ItemArray.GetValue(0).ToString();
                var groupName = row.ItemArray.GetValue(1).ToString();
                var flags     = row.ItemArray.GetValue(2).ToString();
                int.TryParse(row.ItemArray.GetValue(3).ToString(), out var immunity);

                if (groups.TryGetValue(groupName, out var group))
                {
                    flags   += group.Flags;
                    immunity = Math.Max(immunity, group.Immunity);
                }

                admins.Add(new SBCache.Admin(identity, flags, immunity));
                AdminManager.AddAdmin(identity, immunity, flags);
            }

            this.cache.SetAdminList(admins, 60 * 5);
        }
예제 #8
0
 public async void query_QueryCompleted(object sender, QueryCompletedEventArgs <IList <MapLocation> > e)
 {
     try
     {
         if (e.Error == null)
         {
             var    a      = e.Result;
             string comuna = a[0].Information.Address.City;
             string calle  = a[0].Information.Address.Street;
             string numero = a[0].Information.Address.HouseNumber;
             await speechSynth.SpeakTextAsync("Usted se encuentra en la comuna de " + comuna + ". En la calle: " + calle + ", Número aproximado : " + numero);
         }
         else
         {
             await speechSynth.SpeakTextAsync("No se ha encontrado su ubicación actual");
         }
     }
     catch (System.Threading.Tasks.TaskCanceledException)
     {
     }
     catch
     {
         error3();
     }
 }
예제 #9
0
        private void ReverseGeocodeQueryCompleted(object sender, QueryCompletedEventArgs <System.Collections.Generic.IList <MapLocation> > e)
        {
            var reverseGeocode = sender as ReverseGeocodeQuery;

            try
            {
                if (reverseGeocode != null)
                {
                    reverseGeocode.QueryCompleted -= ReverseGeocodeQueryCompleted;
                }

                Addresses.Clear();

                if (!e.Cancelled)
                {
                    foreach (var address in e.Result.Select(adrInfo => adrInfo.Information.Address))
                    {
                        Addresses.Add(string.Format("{0} {1} {2} {3} {4}", address.Street, address.HouseNumber, address.PostalCode,
                                                    address.City, address.Country).Trim());
                        Address = address.HouseNumber + " " + address.Street + " " + address.City + " " + address.State + " " + address.PostalCode;
                    }
                }

                btnalert.IsEnabled = true;

                prog.IsVisible       = false;
                prog.IsIndeterminate = false;
                SendTextAlert();
            }
            catch (Exception)
            {
            }
        }
예제 #10
0
        void geoQ_QueryCompleted(object sender, QueryCompletedEventArgs <IList <MapLocation> > e)
        {
            //Debug.WriteLine("Geo query, error: " + e.Error);
            //Debug.WriteLine("Geo query, cancelled: " + e.Cancelled);
            //Debug.WriteLine("Geo query, cancelled: " + e.UserState.ToString());
            //Debug.WriteLine("Geo query, Result.Count(): " + e.Result.Count());


            if (e.Result.Count() > 0)
            {
                string showString = e.Result[0].Information.Name;
                showString = showString + "";
                showString = showString + "" + e.Result[0].Information.Address.HouseNumber + " " + e.Result[0].Information.Address.Street;
                showString = showString + "" + e.Result[0].Information.Address.PostalCode + " " + e.Result[0].Information.Address.City;
                showString = showString + "" + e.Result[0].Information.Address.Country + " " + e.Result[0].Information.Address.CountryCode;
                //showString = showString + "\nDescription: ";
                //showString = showString + "\n" + e.Result[0].Information.Description.ToString();

                //MessageBox.Show(showString);
                if (nameOfTxtbox.Equals("Start"))
                {
                    txtboxStart.Text = showString;
                    nameOfTxtbox     = "End";
                }
                else
                {
                    txtboxEnd.Text = showString;
                }
                //txtboxStart.Text = showString;
                //return showString;
            }
            //this.Cursor = Cursors.None;
            //return "null";
            mapPostItinerary.IsEnabled = true;
        }
예제 #11
0
        /// <summary>
        /// Called when the query for the admin users-to-groups relationships is completed.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">A <see cref="QueryCompletedEventArgs"/> object containing the event data.</param>
        private void OnAdminGroupsQuery(object sender, QueryCompletedEventArgs e)
        {
            var bundle = (Dictionary <string, object>)e.Data;
            var groups = (Dictionary <int, GroupInfo>)bundle["groups"];

            var adminGroups = new Dictionary <int, List <GroupInfo> >();

            foreach (DataRow row in e.Results.Rows)
            {
                if (int.TryParse(row.ItemArray.GetValue(0).ToString(), out var adminId) && int.TryParse(row.ItemArray.GetValue(1).ToString(), out var groupId))
                {
                    if (!groups.ContainsKey(groupId))
                    {
                        continue;
                    }

                    if (!adminGroups.ContainsKey(adminId))
                    {
                        adminGroups.Add(adminId, new List <GroupInfo>());
                    }

                    adminGroups[adminId].Add(groups[groupId]);
                }
            }

            bundle["adminGroups"] = adminGroups;
            e.Database.TQuery("SELECT id, identity, flags, immunity FROM sm_admins", bundle).QueryCompleted += this.OnAdminsQuery;
        }
예제 #12
0
        /// <summary>
        /// Called when the query for the list of groups is completed.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">A <see cref="QueryCompletedEventArgs"/> object containing the event data.</param>
        private void OnGroupsQuery(object sender, QueryCompletedEventArgs e)
        {
            var groups = new Dictionary <int, GroupInfo>();

            foreach (DataRow row in e.Results.Rows)
            {
                if (!int.TryParse(row.ItemArray.GetValue(0).ToString(), out var id))
                {
                    continue;
                }

                var name = row.ItemArray.GetValue(1).ToString();
                if (string.IsNullOrEmpty(name))
                {
                    continue;
                }

                var flags = row.ItemArray.GetValue(2).ToString();
                int.TryParse(row.ItemArray.GetValue(3).ToString(), out var immunity);

                groups.Add(id, new GroupInfo(name, immunity, flags));
            }

            var bundle = new Dictionary <string, object>
            {
                ["groups"] = groups,
            };

            e.Database.TQuery("SELECT admin_id, group_id FROM sm_admins_groups", bundle).QueryCompleted += this.OnAdminGroupsQuery;
        }
 private void query_QueryCompleted(object sender, QueryCompletedEventArgs <Route> e)
 {
     (sender as RouteQuery).QueryCompleted -= query_QueryCompleted;
     map.SetView(e.Result.BoundingBox);
     map.AddRoute(new MapRoute(e.Result));
     vm.TrackLength = (int)(e.Result.LengthInMeters / 1609);
 }
예제 #14
0
        /// <summary>
        /// Route Query completed event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void myRouteQuery_QueryCompleted(object sender, QueryCompletedEventArgs <Route> e)
        {
            if (e.Error == null)
            {
                Route MyRoute = e.Result;

                MapRoute MyMapRoute = new MapRoute(MyRoute);

                myMap.AddRoute(MyMapRoute);

                foreach (RouteLeg leg in MyRoute.Legs)
                {
                    foreach (RouteManeuver maneuver in leg.Maneuvers)
                    {
                        textBoxDirections.Text += maneuver.InstructionText + Environment.NewLine;
                    }
                }

                myRouteQuery.Dispose();
            }
            else
            {
                MessageBox.Show("Unable to generate route.");
            }
        }
예제 #15
0
        private void query_QueryCompleted(object sender, QueryCompletedEventArgs <IList <MapLocation> > e)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Vulcan Geocoding results...");
            foreach (var item in e.Result)
            {
                sb.AppendLine(item.GeoCoordinate.ToString());
                sb.AppendLine(item.Information.Name);
                sb.AppendLine(item.Information.Description);
                sb.AppendLine(item.Information.Address.BuildingFloor);
                sb.AppendLine(item.Information.Address.BuildingName);
                sb.AppendLine(item.Information.Address.BuildingRoom);
                sb.AppendLine(item.Information.Address.BuildingZone);
                sb.AppendLine(item.Information.Address.City);
                sb.AppendLine(item.Information.Address.Continent);
                sb.AppendLine(item.Information.Address.Country);
                sb.AppendLine(item.Information.Address.CountryCode);
                sb.AppendLine(item.Information.Address.County);
                sb.AppendLine(item.Information.Address.District);
                sb.AppendLine(item.Information.Address.HouseNumber);
                sb.AppendLine(item.Information.Address.Neighborhood);
                sb.AppendLine(item.Information.Address.PostalCode);
                sb.AppendLine(item.Information.Address.Province);
                sb.AppendLine(item.Information.Address.State);
                sb.AppendLine(item.Information.Address.StateCode);
                sb.AppendLine(item.Information.Address.Street);
                sb.AppendLine(item.Information.Address.Township);
            }
            MessageBox.Show(sb.ToString());
        }
 void query_QueryCompleted(object sender, QueryCompletedEventArgs <IList <MapLocation> > e)
 {
     if (e.Error == null)
     {
         ObservableCollection <MapLocation> Results = new ObservableCollection <MapLocation>(e.Result);
     }
 }
예제 #17
0
        private void ReverseGeocodeQuery_QueryCompleted(object sender, QueryCompletedEventArgs <IList <MapLocation> > e)
        {
            if (e.Error == null)
            {
                if (e.Result.Count > 0)
                {
                    MapAddress address = e.Result[0].Information.Address;
                    if (address.District == "")
                    {
                        ubicacion.Text   = "" + address.Street + " #" + address.HouseNumber + ", \n" + address.City + ", " + address.City;
                        auxMensajeCalle  = address.Street;
                        auxMensajeAltura = address.HouseNumber;
                        auxMensajeComuna = address.City;
                    }
                    else
                    {
                        ubicacion.Text   = "" + address.Street + " #" + address.HouseNumber + ", \n" + address.District + ", " + address.City;
                        auxMensajeCalle  = address.Street;
                        auxMensajeAltura = address.HouseNumber;
                        auxMensajeComuna = address.District;
                        //auxMensajeCiudad = address.City;
                    }


                    #region

                    /*"Street: "+ address.Street +
                     * "\n House Number: "+address.HouseNumber +
                     * "\n District: " +address.District +
                     * "\n BuildingFloor:  " + address.BuildingFloor +
                     * "\n BuildingName: " + address.BuildingName +
                     * "\n BuildingRoom: " + address.BuildingRoom +
                     * "\n BuildingZone: " + address.BuildingZone +
                     * "\n City: " + address.City +
                     * "\n Continent: " + address.Continent +
                     * "\n Country: " + address.Country +
                     * "\n CountryCode: " + address.CountryCode +
                     * "\n County: " + address.County +
                     * "\n District: " + address.District +
                     * "\n houseNumber: " + address.HouseNumber +
                     * "\n Neighborhood: " + address.Neighborhood +
                     * "\n PostalCode: " + address.PostalCode +
                     * "\n Province: " + address.Province +
                     * "\n State: " + address.State +
                     * "\n StateCode: " + address.StateCode +
                     * "\n Street: " + address.Street +
                     * "\n TownShip: " + address.Township;
                     * "\n  " +address. +*/
                    #endregion
                    //if (address.District==null)
                    //{
                    //    auxMensajeComuna = address.City;
                    //    return;
                    //}

                    //crearDoc();
                }
            }
        }
예제 #18
0
 private void QueryCompleted(object sender, QueryCompletedEventArgs e)
 {
     if (e.Rows.Count == 0)
     {
         var input = FindName("NewTodoBox") as TextBox;
         input.Focus();
     }
 }
예제 #19
0
        private void MyGeocodeQuery_QueryCompleted(object sender, QueryCompletedEventArgs <IList <MapLocation> > e)
        {
            if (e.Error == null)
            {
                Ellipse myCircle = new Ellipse();
                myCircle.Fill    = new SolidColorBrush(Colors.Blue);
                myCircle.Height  = 20;
                myCircle.Width   = 20;
                myCircle.Opacity = 50;


                MapOverlay mo = new MapOverlay();
                mo.Content        = myCircle;
                mo.PositionOrigin = new Point(0.5, 0.5);
                mo.GeoCoordinate  = g;
                Microsoft.Phone.Maps.Controls.MapLayer ml = new Microsoft.Phone.Maps.Controls.MapLayer();
                ml.Add(mo);
                map.Layers.Add(ml);


                p_text.Text    = String.Format("City: {0},\n Street: {1},\n House number: {2}", e.Result[0].Information.Address.City, e.Result[0].Information.Address.Street, e.Result[0].Information.Address.HouseNumber);
                myPopup.IsOpen = true;



                Duration duration = new Duration(TimeSpan.FromSeconds(2));

                // Create two DoubleAnimations and set their properties.
                DoubleAnimation myDoubleAnimation1 = new DoubleAnimation();
                DoubleAnimation myDoubleAnimation2 = new DoubleAnimation();

                myDoubleAnimation1.Duration = duration;
                myDoubleAnimation2.Duration = duration;

                Storyboard sb = new Storyboard();
                sb.Duration = duration;

                sb.Children.Add(myDoubleAnimation1);
                sb.Children.Add(myDoubleAnimation2);

                Storyboard.SetTarget(myDoubleAnimation1, po_stack);
                Storyboard.SetTarget(myDoubleAnimation2, po_stack);

                // Set the attached properties of Canvas.Left and Canvas.Top
                // to be the target properties of the two respective DoubleAnimations.
                Storyboard.SetTargetProperty(myDoubleAnimation1, new PropertyPath("(Canvas.Left)"));
                Storyboard.SetTargetProperty(myDoubleAnimation2, new PropertyPath("(Canvas.Top)"));

                myDoubleAnimation1.To = 200;
                myDoubleAnimation2.To = 200;

                // Make the Storyboard a resource.
                po_stack.Resources.Add("unique_id", sb);

                // Begin the animation.
                sb.Begin();
            }
        }
예제 #20
0
        void geoRev_QueryCompleted(object sender, QueryCompletedEventArgs <IList <MapLocation> > e)
        {
            GeoProgress1.IsEnabled       = false;
            GeoProgress1.IsIndeterminate = false;
            GeoProgress2.IsEnabled       = false;
            GeoProgress2.IsIndeterminate = false;

            Debug.WriteLine("Geo query, error: " + e.Error);
            Debug.WriteLine("Geo query, cancelled: " + e.Cancelled);
            Debug.WriteLine("Geo query, cancelled: " + e.UserState.ToString());
            Debug.WriteLine("Geo query, Result.Count(): " + e.Result.Count());

            String GeoStuff = "";

            if (e.Result.Count() > 0)
            {
                if (e.Result[0].Information.Address.Street.Length > 0)
                {
                    GeoStuff = GeoStuff + e.Result[0].Information.Address.Street;

                    if (e.Result[0].Information.Address.HouseNumber.Length > 0)
                    {
                        GeoStuff = GeoStuff + " " + e.Result[0].Information.Address.HouseNumber;
                    }
                }

                if (e.Result[0].Information.Address.City.Length > 0)
                {
                    if (GeoStuff.Length > 0)
                    {
                        GeoStuff = GeoStuff + ",";
                    }

                    GeoStuff = GeoStuff + " " + e.Result[0].Information.Address.City;

                    if (e.Result[0].Information.Address.Country.Length > 0)
                    {
                        GeoStuff = GeoStuff + " " + e.Result[0].Information.Address.Country;
                    }
                }
                else if (e.Result[0].Information.Address.Country.Length > 0)
                {
                    if (GeoStuff.Length > 0)
                    {
                        GeoStuff = GeoStuff + ",";
                    }
                    GeoStuff = GeoStuff + " " + e.Result[0].Information.Address.Country;
                }
            }
            if (DestinationRevGeoNow == true)
            {
                DestinationTitle.Text = GeoStuff;
            }
            else
            {
                OriginTitle.Text = GeoStuff;
            }
        }
예제 #21
0
파일: ServiceHelper.cs 프로젝트: jjg0519/OA
        private void FBService_QueryCompleted(object sender, QueryCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                CommonFunction.ShowErrorMessage("操作失败, " + e.Error.Message);
            }

            OnQueryCompleted(e);
        }
예제 #22
0
 void geoQuery_QueryCompleted(object sender, QueryCompletedEventArgs<IList<MapLocation>> e)
 {
     if (e.Error == null)
     {
         map.Center = e.Result[0].GeoCoordinate;
         map.ZoomLevel = 9;
         geoQuery.Dispose();
     }
 }
예제 #23
0
파일: Page1.xaml.cs 프로젝트: scuh/WS6C
 private void setCountryPosition(object sender, QueryCompletedEventArgs<IList<MapLocation>> e)
 {
     var r = e.Result;
     MapLocation loc = r.First();
     var test = loc.Information;
     var test2 = loc.BoundingBox;
     map.ZoomLevel = 6;
     map.Center = loc.GeoCoordinate;
 }
예제 #24
0
 void geoQuery_QueryCompleted(object sender, QueryCompletedEventArgs <IList <MapLocation> > e)
 {
     if (e.Error == null)
     {
         map.Center    = e.Result[0].GeoCoordinate;
         map.ZoomLevel = 9;
         geoQuery.Dispose();
     }
 }
예제 #25
0
파일: Page1.xaml.cs 프로젝트: scuh/WS6C
        private void setCountryPosition(object sender, QueryCompletedEventArgs <IList <MapLocation> > e)
        {
            var         r     = e.Result;
            MapLocation loc   = r.First();
            var         test  = loc.Information;
            var         test2 = loc.BoundingBox;

            map.ZoomLevel = 6;
            map.Center    = loc.GeoCoordinate;
        }
예제 #26
0
 private void MyQuery_QueryCompleted(object sender, QueryCompletedEventArgs <Route> e)
 {
     if (e.Error == null)
     {
         Route    MyRoute    = e.Result;
         MapRoute MyMapRoute = new MapRoute(MyRoute);
         map.AddRoute(MyMapRoute);
         map.SetView(MyRoute.BoundingBox, MapAnimationKind.Parabolic);
         MyQuery.Dispose();
     }
 }
예제 #27
0
 //averigua la direccion postal
 private void ReverseGeocodeQuery_QueryCompleted(object sender, QueryCompletedEventArgs <IList <MapLocation> > e)
 {
     if (e.Error == null)
     {
         if (e.Result.Count > 0)
         {
             MapAddress address = e.Result[0].Information.Address;
             Textodireccion.Text = "Estas en " + address.Street + " " + address.HouseNumber + " " + address.City;
         }
     }
 }
 private void pesquisa_QueryCompleted(object sender, QueryCompletedEventArgs <IList <MapLocation> > e)
 {
     if (e.Result.Count > 0)
     {
         GeoCoordinate coordenadas = e.Result.First().GeoCoordinate;
         MarcarPosicaoNoMapa(coordenadas.Latitude, coordenadas.Longitude, Colors.Blue);
     }
     else
     {
         MessageBox.Show("Desculpe, mas o endereço não foi encontrado.");
     }
 }
예제 #29
0
 void Mygeocodequery_QueryCompleted(object sender, QueryCompletedEventArgs <IList <MapLocation> > e)
 {
     if (e.Error == null)
     {
         MyQuery = new RouteQuery();
         MyCoordinates.Add(e.Result[0].GeoCoordinate);
         MyQuery.Waypoints       = MyCoordinates;
         MyQuery.QueryCompleted += MyQuery_QueryCompleted;
         MyQuery.QueryAsync();
         Mygeocodequery.Dispose();
     }
 }
예제 #30
0
        private void OnQueryCompleted(object sender, QueryCompletedEventArgs <IList <MapLocation> > e)
        {
            _systemTrayService.Hide();

            DispatcherHelper.RunAsync(() =>
            {
                if (e.Error != null || e.Result.Count == 0)
                {
                    _messageBoxService.Show("Unable to retrieve information for the selected location", "Error");

                    return;
                }

                var locationInfo = e.Result[0].Information.Address;

                var locationInfoText = string.Empty;

                if (!string.IsNullOrEmpty(locationInfo.City))
                {
                    if (!string.IsNullOrEmpty(locationInfo.District))
                    {
                        locationInfoText += locationInfo.City + ", " + locationInfo.District + "\n";
                    }
                    else
                    {
                        locationInfoText += locationInfo.City + "\n";
                    }
                }
                else if (!string.IsNullOrEmpty(locationInfo.District))
                {
                    locationInfoText += locationInfo.District + "\n";
                }

                if (!string.IsNullOrEmpty(locationInfo.Country))
                {
                    locationInfoText += locationInfo.Country + "\n";
                }

                if (!string.IsNullOrEmpty(locationInfo.Continent))
                {
                    locationInfoText += locationInfo.Continent + "\n";
                }

                if (string.IsNullOrEmpty(locationInfoText))
                {
                    _messageBoxService.Show("Unable to retrieve information for the selected location", "Error");

                    return;
                }

                _messageBoxService.Show(locationInfoText, "Location Info");
            });
        }
예제 #31
0
 void reverseGeocode_QueryCompleted(object sender, QueryCompletedEventArgs <IList <MapLocation> > e)
 {
     if (e.Error == null)
     {
         if (e.Result.Count > 0)
         {
             MapAddress geoAddress = e.Result[0].Information.Address;
             String     city       = geoAddress.City;
             getLocationData(city);
         }
     }
 }
 private void ReverseGeocodeQuery_QueryCompleted(object sender, QueryCompletedEventArgs<IList<MapLocation>> e)
 {
     if (e.Error == null)
     {
         if (e.Result.Count > 0)
         {
             MapAddress address = e.Result[0].Information.Address;
             textBoxPostalCode.Text = address.PostalCode;
             LocationProgressBar.Visibility = System.Windows.Visibility.Collapsed;
         }
     }
 }
예제 #33
0
파일: ServiceHelper.cs 프로젝트: jjg0519/OA
 protected virtual void OnQueryCompleted(QueryCompletedEventArgs e)
 {
     if (e.Error != null)
     {
         CommonFunction.ShowErrorMessage(e.Error.ToString());
         return;
     }
     if (QueryCompleted != null)
     {
         QueryCompleted(this, e);
     }
 }
예제 #34
0
 private void Mygeocodequery_QueryCompleted(object sender, QueryCompletedEventArgs<IList<MapLocation>> e)
 {
     if (e.Error == null)
     {
         MyQuery = new RouteQuery();
         MyCoordinates.Add(e.Result[0].GeoCoordinate);
         MyQuery.Waypoints = MyCoordinates;
         MyQuery.QueryCompleted += MyQuery_QueryCompleted;
         MyQuery.QueryAsync();
         Mygeocodequery.Dispose();
     }
 }
예제 #35
0
 void routeQuery_QueryCompleted(object sender, QueryCompletedEventArgs <Route> e)
 {
     if (null == e.Error)
     {
         Route    MyRoute    = e.Result;
         MapRoute MyMapRoute = new MapRoute(MyRoute);
         mapItineraryDetails.AddRoute(MyMapRoute);
         //length of route
         //time = route / v trung binh(hang so)
         //MessageBox.Show("Distance: " + MyMapRoute.Route.LengthInMeters.ToString());
         routeQuery.Dispose();
     }
 }
예제 #36
0
        void routeQuery_QueryCompleted(object sender, QueryCompletedEventArgs<Route> e)
        {
            if (null == e.Error)
            {
                Route MyRoute = e.Result;
                MapRoute MyMapRoute = new MapRoute(MyRoute);
                mapItineraryDetails.AddRoute(MyMapRoute);

                //length of route
                //time = route / v trung binh(hang so)
                //MessageBox.Show("Distance: " + MyMapRoute.Route.LengthInMeters.ToString());
                routeQuery.Dispose();
            }
        }
예제 #37
0
 /// <summary>
 /// Direction Route completed
 /// add cross points to polyline
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void routeQuery_QueryCompleted(object sender, QueryCompletedEventArgs<Route> e)
 {
     LocationCollection loCollect = new LocationCollection();
     for (int i = 0; i < e.Result.Geometry.Count; i++)
     {
         loCollect.Add(e.Result.Geometry[i]);
     }
     MapPolyline routeline = new MapPolyline()
     {
         StrokeThickness=8,
         Locations=loCollect,
         Stroke=new SolidColorBrush(Colors.Red)
     };
     OnRouteChanged("RouteChanged", routeline);
 }
        static private async void GeoQ_HowToGetQueryCompleted(object sender, QueryCompletedEventArgs<IList<MapLocation>> e)
        {
            if (e.Result.Any())
            {
                var result = e.Result.First();

                var latitude = result.GeoCoordinate.Latitude.ToString(CultureInfo.InvariantCulture);
                var longitude = result.GeoCoordinate.Longitude.ToString(CultureInfo.InvariantCulture);
                var uri = string.Concat("directions://v2.0/route/destination/?latlon=", latitude, ",", longitude);

                await Launcher.LaunchUriAsync(new Uri(uri));
            }
            else if (e.UserState is GeocodeQuery)
            {
                MessageBox.Show("No results for " + (e.UserState as GeocodeQuery).SearchTerm);
            }
        }
예제 #39
0
 private static async void reverseGeocode_QueryCompleted(object sender, QueryCompletedEventArgs<IList<MapLocation>> e)
 {
     if (e.Result.Count > 0)
     {
         MapAddress geoAddress = e.Result[0].Information.Address;
         CurrentCity.CityName = geoAddress.City;        
         CurrentCity.CountryName = geoAddress.Country;
         CurrentCity.CountryCode = geoAddress.CountryCode;
         WeatherViewModel WVM = WeatherViewModel.GetInstanse();
         if (!WVM.IsCityExists(CurrentCity,true))
         {
             CurrentCity.IsCurrentCity = true;
             CurrentCity.CityCurrentWeather = await WeatherManager.GetCityCurrentWeather(CurrentCity);
             CurrentCity.FLickrImageURL = await FlickrServiceManager.GetCityWeatherPhoto(CurrentCity);
             CurrentCity.CityWeatherWeeklyForecast = await WeatherManager.GetCityWeatherWeeklyForecast(CurrentCity);
             CurrentCity.CityWeatherDailyForecast = await WeatherManager.GetCityWeatherHourlyForecast(CurrentCity);
             WVM.CityCollection.Add(CurrentCity);
             AppTilesManager.UpdateAppPrimaryTile();
         }
     }
 }
예제 #40
0
        void geoQ_QueryCompleted(object sender, QueryCompletedEventArgs<Microsoft.Phone.Maps.Services.Route> e)
        {

            if (LastRutte != null)
            {
                map1.RemoveRoute(LastRutte);
                LastRutte = null;
            }

            try
            {
                Microsoft.Phone.Maps.Services.Route myRutte = e.Result;
                LastRutte = new MapRoute(myRutte);

                map1.AddRoute(LastRutte);
                map1.SetView(e.Result.BoundingBox);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #41
0
        void geoQ_QueryCompleted(object sender, QueryCompletedEventArgs<Route> e)
        {
            Debug.WriteLine("Route query, error: " + e.Error);
            Debug.WriteLine("Route query, cancelled: " + e.Cancelled);
            Debug.WriteLine("Route query, cancelled: " + e.UserState);
            /*
            if (LastRutte != null)
            {
                MapView.RemoveRoute(LastRutte);
                LastRutte = null;
            }
            */
            if (e.Error == null)
            {
                Route myRutte = e.Result;
                LastRutte = new MapRoute(myRutte);

                // myRutte.Legs.Count();

                MapView.AddRoute(LastRutte);
                MapView.SetView(e.Result.BoundingBox);
            }
        }
예제 #42
0
        private void MyQuery_QueryCompleted(object sender, QueryCompletedEventArgs<Route> e)
        {
            if (e.Error == null)
            {
                Route MyRoute = e.Result;
                MapRoute MyMapRoute = new MapRoute(MyRoute);
                MyMap.AddRoute(MyMapRoute);

                List<string> RouteList = new List<string>();
                foreach (RouteLeg leg in MyRoute.Legs)
                {
                    foreach (RouteManeuver maneuver in leg.Maneuvers)
                    {
                        RouteList.Add(maneuver.InstructionText);
                    }
                }

                RouteLLS.ItemsSource = RouteList;

                MyQuery.Dispose();
            }


        }
예제 #43
0
        //private bool _isRouteSearch = false;    // it is true when route is being searched, false otherwise!!
        private void GeocodeQuery_QueryCompleted(object sender, QueryCompletedEventArgs<IList<MapLocation>> e)
        {
            if(e.Error==null)
            {
                if(e.Result.Count>0)
                {
                    if (_isRouteSearch)
                    {

                    }
                    else
                    {
                        for(int i=0;i<e.Result.Count;i++)
                        {
                            MyCoordinates.Add(e.Result[i].GeoCoordinate);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("No match found. Narrow your search e.g. Izmir TR.");
                }
            }
        }
        void Utility_QueryComplete(object sender, QueryCompletedEventArgs<IList<MapLocation>> e)
        {
            try
            {
                if (!String.IsNullOrEmpty(NameTextBox.Text) && e.Result.Count == 0)
                {
                    MessageBox.Show(string.Format(AppResources.InvalideSearch, NameTextBox.Text), AppResources.Warning, MessageBoxButton.OK);
                    return;
                }

                GeoCoordinate coord = new GeoCoordinate();
                foreach (var item in e.Result)
                {
                    coord = item.GeoCoordinate;
                    NameTextBox.Text = Utils.Utility.getCompleteAddress(item.Information.Address);
                }

                MapLayer pinLayout = new MapLayer();
                Pushpin MyPushpin = new Pushpin();
                MapOverlay pinOverlay = new MapOverlay();
                if (myMap.Layers.Count > 0)
                    myMap.Layers.RemoveAt(myMap.Layers.Count - 1);

                myMap.Layers.Add(pinLayout);

                MyPushpin.GeoCoordinate = coord;

                pinOverlay.Content = MyPushpin;
                pinOverlay.GeoCoordinate = MyPushpin.GeoCoordinate;
                pinOverlay.PositionOrigin = new Point(0, 1);
                pinLayout.Add(pinOverlay);
                MyPushpin.Content = AppResources.MyTour;

                ViewModel.Tour.Latitude = coord.Latitude;
                ViewModel.Tour.Longitude = coord.Longitude;
            }
            catch (Exception ex) { throw ex; }
        }
        void geoQ_QueryCompleted(object sender, QueryCompletedEventArgs<IList<MapLocation>> e)
        {
            // The result is a GeocodeResponse object
            resList = e.Result;

            Debug.WriteLine("Geo query, error: " + e.Error);
            Debug.WriteLine("Geo query, cancelled: " + e.Cancelled);
            Debug.WriteLine("Geo query, cancelled: " + e.UserState.ToString());
            Debug.WriteLine("Geo query, Result.Count(): " + resList.Count());

            System.Collections.Generic.List<Model.SearchResultItem> items =
                    new System.Collections.Generic.List<Model.SearchResultItem>();

            if (resList.Count() > 0)
            {
                for (int i = 0; i < resList.Count(); i++)
                {
                    String addressTxt = "";
                    MapAddress address = resList[i].Information.Address;

                    Debug.WriteLine("Result no.: " + i);
                    if (!"".Equals(address.HouseNumber))
                    {
                        addressTxt += ", " + address.HouseNumber;
                    }
                    if (!"".Equals(address.BuildingRoom))
                    {
                        addressTxt += address.BuildingRoom;
                    }

                    if (!"".Equals(address.BuildingFloor))
                    {
                        addressTxt += ", " + address.BuildingFloor;
                    }
                    if (!"".Equals(address.BuildingName))
                    {
                        addressTxt += ", " + address.BuildingName;
                    }
                    if (!"".Equals(address.BuildingZone))
                    {
                        addressTxt += ", " + address.BuildingZone;
                    }
                    if (!"".Equals(address.Neighborhood))
                    {
                        addressTxt += ", " + address.Neighborhood;
                    }
                    if (!"".Equals(address.Province))
                    {
                        addressTxt += ", " + address.Province;
                    }

                    if (!"".Equals(address.Street))
                    {
                        addressTxt += ", " + address.Street;
                    }
                    if (!"".Equals(address.District))
                    {
                        addressTxt += ", " + address.District;
                    }
                    if (!"".Equals(address.City))
                    {
                        addressTxt += ", " + address.City;
                    }
                    if (!"".Equals(address.State))
                    {
                        addressTxt += ", " + address.State;
                    }
                    if (!"".Equals(address.Country))
                    {
                        addressTxt += ", " + address.Country;
                    }
                    if (!"".Equals(address.Continent))
                    {
                        addressTxt += ", " + address.Continent;
                    }
                    if (!"".Equals(address.PostalCode))
                    {
                        addressTxt += ", " + address.PostalCode;
                    }
                    if (!"".Equals(address.Township))
                    {
                        addressTxt += ", " + address.Township;
                    }
                    if (addressTxt.StartsWith(","))
                    {
                        addressTxt = addressTxt.Substring(1);
                    }

                    Model.SearchResultItem searchResultItem = new Model.SearchResultItem(addressTxt, resList[i].GeoCoordinate.Latitude, resList[i].GeoCoordinate.Longitude);
                    items.Add(searchResultItem);
                    Debug.WriteLine(addressTxt);
                    /* Debug.WriteLine("Name: " + resList[i].Information.Name);
                     Debug.WriteLine("Address.ToString: " + resList[i].Information.Address.ToString());
                     Debug.WriteLine("Address.District: " + resList[i].Information.Address.District);
                     Debug.WriteLine("Address.Country: " + resList[i].Information.Address.CountryCode + ": " + resList[i].Information.Address.Country);
                     Debug.WriteLine("Address.County: " + resList[i].Information.Address.County);
                     Debug.WriteLine("Address.Neighborhood: " + resList[i].Information.Address.Neighborhood);
                     Debug.WriteLine("Address.Street: " + resList[i].Information.Address.Street);
                     Debug.WriteLine("Address.PostalCode: " + resList[i].Information.Address.PostalCode);
                     Debug.WriteLine("Address.Continent: " + resList[i].Information.Address.Continent);

                     Debug.WriteLine("GeoCoordinate.Latitude: " + resList[i].GeoCoordinate.Latitude.ToString());
                     Debug.WriteLine("GeoCoordinate.Longitude: " + resList[i].GeoCoordinate.Longitude.ToString());
                     */
                    string numNum = "0" + i;
                    if (i > 9)
                    {
                        numNum = "" + i;
                    }
                    GroupedList.ItemsSource = items;
                }
            }
        }
예제 #46
0
        /// <summary>
        /// Event handler for geocode query completed.
        /// </summary>
        /// <param name="e">Results of the geocode query - list of locations</param>
        private void GeocodeQuery_QueryCompleted(object sender, QueryCompletedEventArgs<IList<MapLocation>> e)
        {
            HideProgressIndicator();
            if (e.Error == null)
            {
                if (e.Result.Count > 0)
                {
                    if (_isRouteSearch) // Query is made to locate the destination of a route
                    {
                        // Only store the destination for drawing the map markers
                        MyCoordinates.Add(e.Result[0].GeoCoordinate);

                        // Route from current location to first search result
                        List<GeoCoordinate> routeCoordinates = new List<GeoCoordinate>();
                        routeCoordinates.Add(MyCoordinate);
                        routeCoordinates.Add(e.Result[0].GeoCoordinate);
                        CalculateRoute(routeCoordinates);
                    }
                    else // Query is made to search the map for a keyword
                    {
                        // Add all results to MyCoordinates for drawing the map markers.
                        for (int i = 0; i < e.Result.Count; i++)
                        {
                            MyCoordinates.Add(e.Result[i].GeoCoordinate);
                        }

                        // Center on the first result.
                        MyMap.SetView(e.Result[0].GeoCoordinate, 10, MapAnimationKind.Parabolic);
                         
                    }
                }
                else
                {
                    MessageBox.Show(AppResources.NoMatchFoundMessageBoxText, AppResources.ApplicationTitle, MessageBoxButton.OK);
                }

                MyGeocodeQuery.Dispose();
            }
            DrawMapMarkers(false);
        }
예제 #47
0
        /// <summary>
        /// Event handler for route query completed.
        /// </summary>
        /// <param name="e">Results of the geocode query - the route</param>
        private void RouteQuery_QueryCompleted(object sender, QueryCompletedEventArgs<Route> e)
        {
            HideProgressIndicator();
            if (e.Error == null)
            {
                MyRoute = e.Result;
                MyMapRoute = new MapRoute(MyRoute);
                MyMap.AddRoute(MyMapRoute);

                // Update route information and directions
                DestinationText.Text = SearchTextBox.Text;
                double distanceInKm = (double)MyRoute.LengthInMeters / 1000;
                DestinationDetailsText.Text = distanceInKm.ToString("0.0") + " km, "
                                              + MyRoute.EstimatedDuration.Hours + " hrs "
                                              + MyRoute.EstimatedDuration.Minutes + " mins.";

                List<string> routeInstructions = new List<string>();
                foreach (RouteLeg leg in MyRoute.Legs)
                {
                    for (int i = 0; i < leg.Maneuvers.Count; i++)
                    {
                        RouteManeuver maneuver = leg.Maneuvers[i];
                        string instructionText = maneuver.InstructionText;
                        distanceInKm = 0;

                        if (i > 0)
                        {
                            distanceInKm = (double)leg.Maneuvers[i - 1].LengthInMeters / 1000;
                            instructionText += " (" + distanceInKm.ToString("0.0") + " km)";
                        }
                        routeInstructions.Add(instructionText);
                    }
                }
                RouteLLS.ItemsSource = routeInstructions;

                AppBarDirectionsMenuItem.IsEnabled = true;

                if (_isDirectionsShown)
                {
                    // Center map on the starting point (phone location) and zoom quite close
                    MyMap.SetView(MyCoordinate, 16, MapAnimationKind.Parabolic);
                }
                else
                {
                    // Center map and zoom so that whole route is visible
                    MyMap.SetView(MyRoute.Legs[0].BoundingBox, MapAnimationKind.Parabolic);
                }
                MyRouteQuery.Dispose();
            }
            DrawMapMarkers(false);
        }
 private void Query_QueryCompleted(object sender, QueryCompletedEventArgs<IList<MapLocation>> e)
 {
     MapLocation local = e.Result.First();
     if(local != null)
     {
         TracarRota(_clienteSelecionado.Nome, local.GeoCoordinate.Latitude, local.GeoCoordinate.Longitude);
     }
 }
예제 #49
0
파일: ServiceHelper.cs 프로젝트: JuRogn/OA
        private void FBService_QueryCompleted(object sender, QueryCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                CommonFunction.ShowErrorMessage("操作失败, " + e.Error.Message);
            }

            OnQueryCompleted(e);
        }
예제 #50
0
 /// <summary>
 /// Translates current location into a two letter ISO country code used
 /// by MixRadio API. Makes the inital requests to MixRadio API.
 /// </summary>
 /// <param name="sender">ReverseGeocodeQuery</param>
 /// <param name="e">Event arguments</param>
 private void ReverseGeocodeQuery_QueryCompleted(
     object sender, 
     QueryCompletedEventArgs<IList<MapLocation>> e)
 {
     if (e.Error == null)
     {
         if (e.Result.Count > 0)
         {
             MapAddress address = e.Result[0].Information.Address;
             string twoLetterCountryCode = 
                 CountryCodes.TwoLetterFromThreeLetter(address.CountryCode);
             InitializeMixRadioApi(twoLetterCountryCode);
         }
     }
 }
예제 #51
0
            /// <summary>
        /// Event handler for reverse geocode query.
        /// </summary>
        /// <param name="e">Results of the reverse geocode query - list of locations</param>
        private void ReverseGeocodeQuery_QueryCompleted(object sender, QueryCompletedEventArgs<IList<MapLocation>> e)
        {
            if (e.Error == null)
            {
                if (e.Result.Count > 0)
                {
                    Debug.WriteLine("ReverseGeocodeQuery_QueryCompleted():- 1> Start Reverse Geocoding");
                    String addressTxt="";
                    MapAddress address = e.Result[0].Information.Address;
                     if (!"".Equals( address.BuildingRoom))
                    {
                        addressTxt += address.BuildingRoom;
                    }

                    if (!"".Equals(address.BuildingFloor))
                    {
                        addressTxt += ", " +address.BuildingFloor;
                    }
                     if(!"".Equals( address.BuildingName))
                    {
                        addressTxt += ", "+address.BuildingName;
                    }
                     if (!"".Equals(address.BuildingName))
                    {
                        addressTxt += ", " + address.BuildingName;
                    }
                    if (!"".Equals(address.Street))
                    {
                        addressTxt += ", " + address.Street;
                    }
                    if (!"".Equals(address.District))
                    {
                        addressTxt += ", " + address.District;
                    }
                     if (!"".Equals(address.City))
                    {
                        addressTxt += ", " + address.City;
                    }                 
                     if (!"".Equals(address.State))
                    {
                        addressTxt += ", " + address.State;
                    }
                     if (!"".Equals(address.Country))
                    {
                        addressTxt += ", " + address.Country;
                    }
                     if (addressTxt.StartsWith(","))
                     {
                         addressTxt = addressTxt.Substring(1);
                     }                     
                    txtBlockLocation.Text = addressTxt.Trim();
                    progressbarCurentLocation.IsIndeterminate = false;
                    LocationAddress = addressTxt;
                }

                Debug.WriteLine("ReverseGeocodeQuery_QueryCompleted():- 1> Completed Reverse Geocoding");
            }
        }
 void routeQuery_QueryCompleted(object sender, QueryCompletedEventArgs<Route> e)
 {
     if (null == e.Error)
     {
         Route MyRoute = e.Result;
         MapRoute MyMapRoute = new MapRoute(MyRoute);
         MyMapControl.AddRoute(MyMapRoute);
         MyMapControl.SetView(MyMapRoute.Route.BoundingBox);
     }
     else
         MessageBox.Show("Error occured:\n" + e.Error.Message);
 }
예제 #53
0
 /// <summary>
 /// DataGrid分页完成隐藏等待图片
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void Queryer_QueryCompleted(object sender, QueryCompletedEventArgs e)
 {
     this.CloseProcess();
 }
        /// <summary>
        /// Route Query completed event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void myRouteQuery_QueryCompleted(object sender, QueryCompletedEventArgs<Route> e)
        {

            if (e.Error == null)
            {

                Route MyRoute = e.Result;

                MapRoute MyMapRoute = new MapRoute(MyRoute);

                myMap.AddRoute(MyMapRoute);

                foreach (RouteLeg leg in MyRoute.Legs)
                {

                    foreach (RouteManeuver maneuver in leg.Maneuvers)
                    {
                        textBoxDirections.Text += maneuver.InstructionText + Environment.NewLine;
                    }
                }

                myRouteQuery.Dispose();
            }
            else
            {
                MessageBox.Show("Unable to generate route.");
            }
        }
예제 #55
0
 void routeQuery_QueryCompleted(object sender, QueryCompletedEventArgs<Route> e)
 {
     if (e.Error == null)
     {
         Route route = e.Result;
         MapRoute mapRoute = new MapRoute(route);
         myMap.AddRoute(mapRoute);
         string routeContent = "";
         foreach (RouteLeg leg in route.Legs)
         {
             foreach (RouteManeuver routeManeuver in leg.Maneuvers)
             {
                 routeContent += routeManeuver.InstructionText;
                 Debug.WriteLine(routeManeuver.InstructionText);
             }
         }
         MessageBox.Show(routeContent);
     }
     else
     {
         MessageBox.Show("无法查到路线");
     }
 }
예제 #56
0
        void geocodeQuery_QueryCompleted(object sender, QueryCompletedEventArgs<IList<MapLocation>> e)
        {
            if (e.Error == null)
            {
                GeoCoordinate geoCoordinate = e.Result[0].GeoCoordinate;
                myMap.Center = e.Result[0].GeoCoordinate;
                List<GeoCoordinate> geoCoordinates=new List<GeoCoordinate>();
                geoCoordinates.Add(e.Result[0].GeoCoordinate);
                geoCoordinates.Add(e.Result[1].GeoCoordinate);

                RouteQuery routeQuery = new RouteQuery();
                routeQuery.Waypoints = geoCoordinates;
                routeQuery.QueryCompleted += routeQuery_QueryCompleted;
                routeQuery.QueryAsync();
            }
        }
예제 #57
0
        private void OnRouteQueryCompleted(object sender, QueryCompletedEventArgs<Route> e)
        {
            if (e.Error == null)
            {
                var geometry = e.Result.Legs[0].Geometry;
                var start = geometry[0];
                var end = geometry[geometry.Count - 1];
                var center = new GeoCoordinate((start.Latitude + end.Latitude) / 2, (start.Longitude + end.Longitude) / 2);
                var map = new Map
                {
                    IsEnabled = false,
                    Center = center,
                    ZoomLevel = 20,
                    PedestrianFeaturesEnabled = true,
                    LandmarksEnabled = true,
                };
                map.Loaded += delegate
                {
                    MapsSettings.ApplicationContext.ApplicationId = AppMetadata.Current.AppId.ToString("D");
                    MapsSettings.ApplicationContext.AuthenticationToken = AppMetadata.Current.MapAuthenticationToken;
                };
                var mapLayer = new MapLayer();
                mapLayer.Add(new MapOverlay
                {
                    GeoCoordinate = start,
                    PositionOrigin = new Point(0, 1),
                    Content = new Pushpin
                    {
                        Content = "Me",
                    }
                });
                mapLayer.Add(new MapOverlay
                {
                    GeoCoordinate = end,
                    PositionOrigin = new Point(0, 1),
                    Content = new Pushpin
                    {
                        Content = departuresAndArrivalsTable.Station.Name + " Station",
                    }
                });
                map.Layers.Add(mapLayer);

                map.AddRoute(new MapRoute(e.Result));

                var pivotItem = new PivotItem
                {
                    Header = "Directions",
                    Content = map
                };
                pivotItem.Tap += delegate
                {
                    ErrorReporting.Log("OnMapClick");
                    new DirectionsRouteDestinationTask
                    {
                        Origin = start,
                        Destination = end,
                        Mode = RouteMode.Pedestrian,
                    }.Show();
                };
                pivot.Items.Add(pivotItem);
                bool mapCentered = false;
                pivot.SelectionChanged += delegate
                {
                    if (!mapCentered && pivot.SelectedIndex == mapIndex)
                    {
                        map.SetView(e.Result.BoundingBox);
                        mapCentered = true;
                    }
                };
            }
        }
예제 #58
0
 /// <summary>
 /// Event handler for reverse geocode query.
 /// </summary>
 /// <param name="e">Results of the reverse geocode query - list of locations</param>
 private void ReverseGeocodeQuery_QueryCompleted(object sender, QueryCompletedEventArgs<IList<MapLocation>> e)
 {
     if (e.Error == null)
     {
         if (e.Result.Count > 0)
         {
             MapAddress address = e.Result[0].Information.Address;
             String msgBoxText = "";
             if (address.Street.Length > 0)
             {
                 msgBoxText += "\n" + address.Street;
                 if (address.HouseNumber.Length > 0) msgBoxText += " " + address.HouseNumber;
             }
             if (address.PostalCode.Length > 0) msgBoxText += "\n" + address.PostalCode;
             if (address.City.Length > 0) msgBoxText += "\n" + address.City;
             if (address.Country.Length > 0) msgBoxText += "\n" + address.Country;
             MessageBox.Show(msgBoxText, AppResources.ApplicationTitle, MessageBoxButton.OK);
         }
         else
         {
             MessageBox.Show(AppResources.NoInfoMessageBoxText, AppResources.ApplicationTitle, MessageBoxButton.OK);
         }
         MyReverseGeocodeQuery.Dispose();
     }
 }
예제 #59
0
파일: ServiceHelper.cs 프로젝트: JuRogn/OA
 protected virtual void OnQueryCompleted(QueryCompletedEventArgs e)
 {
     if (e.Error != null)
     {
         CommonFunction.ShowErrorMessage(e.Error.ToString());
         return;
     }
     if (QueryCompleted != null)
     {
         QueryCompleted(this, e);
     }
 }
        /// <summary>
        /// Geo Code Query completed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void mygeocodeQuery_QueryCompleted(object sender, QueryCompletedEventArgs<IList<MapLocation>> e)
        {

            if (e.Error == null)
            {
                try
                {
                    myRouteQuery = new RouteQuery();

                    myRouteCoordinates.Add(e.Result[0].GeoCoordinate);

                    myRouteQuery.Waypoints = myRouteCoordinates;

                    myRouteQuery.QueryCompleted += myRouteQuery_QueryCompleted;

                    myRouteQuery.QueryAsync();

                    mygeocodeQuery.Dispose();
                }
                catch (Exception)
                {

                }

            }

        }