コード例 #1
0
            public void SearchByStop_Completed(object sender, SearchForStopsEventArgs e)
            {
                Debug.Assert(e.error == null);

                if (e.error == null)
                {
                    e.stops.Sort(new StopDistanceComparer(e.location));

                    viewModel.UIAction(() => viewModel.StopsForLocation.Clear());

                    int count = 0;
                    foreach (Stop stop in e.stops)
                    {
                        Stop currentStop = stop;
                        viewModel.UIAction(() => viewModel.StopsForLocation.Add(currentStop));
                        count++;
                    }
                }
                else
                {
                    viewModel.ErrorOccured(this, e.error);
                }

                callback(e.stops, e.error);
                busServiceModel.SearchForStops_Completed -= this.SearchByStop_Completed;

                viewModel.operationTracker.DoneWithOperation("SearchByStop");
            }
コード例 #2
0
            public void SearchByRoute_Completed(object sender, SearchForRoutesEventArgs e)
            {
                Debug.Assert(e.error == null);

                if (e.error == null)
                {
                    e.routes.Sort(new RouteDistanceComparer(e.location));

                    int count = 0;
                    foreach (Route route in e.routes)
                    {
                        if (count > viewModel.maxRoutes)
                        {
                            break;
                        }

                        Route currentRoute = route;
                        count++;
                    }
                }
                else
                {
                    viewModel.ErrorOccured(this, e.error);
                }

                callback(e.routes, e.error);
                busServiceModel.SearchForRoutes_Completed -= new EventHandler <EventArgs.SearchForRoutesEventArgs>(this.SearchByRoute_Completed);

                viewModel.operationTracker.DoneWithOperation("SearchByRoute");
            }