Exemplo n.º 1
0
        private RoutePoint GetNextPointOnRoute(GeoPosition position, Distance maxSkipDistance)
        {
            var last         = GetLastWayPoint();
            var skipDistance = 0d;

            foreach (var routePoint in _route.GetEnumerable(NextWaypoint, NavigationDirection))
            {
                var expectedPosition = MapExtensions.ClosestPositionBetweenPoints(last, routePoint, position);
                skipDistance += last.Distance(routePoint);

                if (VisitedWaypoints.Contains(routePoint) || skipDistance > maxSkipDistance.Miles)
                {
                    break;
                }

                if (IsOnRoute(expectedPosition, position))
                {
                    return(last);
                }

                last = routePoint;
            }

            return(null);
        }
Exemplo n.º 2
0
        public void Configure(IApplicationBuilder builder, IConfiguration configuration)
        {
            builder.UseMultipleErrorHandlerPipelines(app =>
            {
                MapExtensions.Map(
                    app,
                    "/throws",
                    inner =>
                    RunExtensions.Run(
                        inner,
                        async ctx =>
                {
                    await Task.Yield();
                    throw new Exception("Map exception");
                }));

                MvcApplicationBuilderExtensions.UseMvc(
                    app,
                    routes =>
                {
                    MapRouteRouteBuilderExtensions.MapRoute(routes, "custom", "Test/{action=Index}", new { Controller = "MyTest" });
                    MapRouteRouteBuilderExtensions.MapRoute(routes, "default", "{controller=Home}/{action=Index}/{id?}");
                });
            });
        }
        private void start_Click(object sender, EventArgs e)
        {
            ((ApplicationBarIconButton)ApplicationBar.Buttons[0]).IsEnabled = false;
            ((ApplicationBarIconButton)ApplicationBar.Buttons[1]).IsEnabled = true;

            service = new Geolocator();
            service.DesiredAccuracy   = PositionAccuracy.High;
            service.MovementThreshold = 1.0;
            service.PositionChanged  += service_PositionChanged;
            service.StatusChanged    += service_StatusChanged;

            position.Text    = string.Empty;
            status.Text      = service.LocationStatus.ToString();
            mapControl.Pitch = 45.0;

            var startPin = new Pushpin
            {
                GeoCoordinate = marker.GeoCoordinate,
                Content       = "Start"
            };

            MapExtensions.GetChildren(mapControl).Add(startPin);

            routeLine = new MapPolyline
            {
                StrokeColor     = (Color)Resources["PhoneAccentColor"],
                StrokeThickness = (double)Resources["PhoneStrokeThickness"]
            };
            routeLine.Path.Add(marker.GeoCoordinate);
            mapControl.MapElements.Add(routeLine);
        }
Exemplo n.º 4
0
        private MapItemsControl GetMPC()
        {
            ObservableCollection <DependencyObject> children = MapExtensions.GetChildren(theMap);
            var obj = children.FirstOrDefault(x => x.GetType() == typeof(MapItemsControl)) as MapItemsControl;

            return(obj);
        }
Exemplo n.º 5
0
        private void ShowNearStops()
        {
            Dispatcher.BeginInvoke(async() =>
            {
                var vm = this.DataContext as NearStopsViewModel;
                var db = new TransportsNantais.Services.SQLiteService();

                ObservableCollection <MapItem> coll = new ObservableCollection <MapItem>();;

                foreach (var ns in vm.NearStops)
                {
                    var s = await db.GetStopByTanIdAsync(ns.CodeLieu);
                    coll.Add(new MapItem()
                    {
                        Name = s.Name, GeoCoordinate = new GeoCoordinate(s.Latitude, s.Longitude)
                    });
                }

                var itemsColl = MapExtensions.GetChildren(MainMap).OfType <MapItemsControl>().First();

                if (itemsColl.Items.Count > 0)
                {
                    itemsColl.Items.Clear();
                }

                foreach (var c in coll)
                {
                    itemsColl.Items.Add(c);
                }
            });
        }
        private async void mapControl_Hold(object sender, System.Windows.Input.GestureEventArgs e)
        {
            status.Text = "querying for address...";

            var point      = e.GetPosition(mapControl);
            var coordinate = mapControl.ConvertViewportPointToGeoCoordinate(point);

            var pushpin = new Pushpin
            {
                GeoCoordinate = coordinate,
                Content       = ++pinNumber,
            };

            MapExtensions.GetChildren(mapControl).Add(pushpin);

            position.Text = string.Format("Latitude: {0}\nLongitude: {1}\n",
                                          FormatCoordinate(coordinate.Latitude, 'N', 'S'),
                                          FormatCoordinate(coordinate.Longitude, 'E', 'W'));

            ReverseGeocodeQuery query = new ReverseGeocodeQuery {
                GeoCoordinate = coordinate
            };
            IList <MapLocation> results = await query.GetMapLocationsAsync();

            position.Text += string.Format("{0} locations found.\n", results.Count);
            MapLocation location = results.FirstOrDefault();

            if (location != null)
            {
                position.Text += FormatAddress(location.Information.Address);
            }
            status.Text += "complete";
        }
Exemplo n.º 7
0
        /// <summary>
        ///  Give item source to map's pushpins.
        /// </summary>
        public void GetPushpins()
        {
            try
            {
                ObservableCollection <DependencyObject> children = MapExtensions.GetChildren(nokiaMap);
                var obj = children.FirstOrDefault(x => x.GetType() == typeof(MapItemsControl)) as MapItemsControl;

                //current positions
                if (App.ViewModel.CityDetailsViewModel.CurrentLocationCoordinates.Latitude != 0 && App.ViewModel.CityDetailsViewModel.CurrentLocationCoordinates.Longitude != 0)
                {
                    currentLocation = new GeoCoordinate(App.ViewModel.CityDetailsViewModel.CurrentLocationCoordinates.Latitude, App.ViewModel.CityDetailsViewModel.CurrentLocationCoordinates.Longitude);
                    ShowLocation();
                }

                nokiaMap.Center = new GeoCoordinate(App.ViewModel.FullMapViewModel.MapCenterPoint.Latitude, App.ViewModel.FullMapViewModel.MapCenterPoint.Longitude);
                if (obj.ItemsSource == null)
                {
                    obj.ItemsSource = this.lstCityPushpin;// App.ViewModel.FullMapViewModel.CityCategoryPushpinsList;
                }
                else
                {
                    obj.ItemsSource = this.lstCityPushpin;// App.ViewModel.FullMapViewModel.CityCategoryPushpinsList;
                }
                AddPushpins();
            }
            catch (Exception)
            {
                MessageBox.Show(App.ViewModel.FullMapViewModel.MessageDialog);
            }
        }
        //Necessary codes to initiate the toolkit map control
        public void MapExtensionsSetup(Map map)
        {
            ObservableCollection <DependencyObject> children = MapExtensions.GetChildren(map);
            var runtimeFields = this.GetType().GetRuntimeFields();

            foreach (DependencyObject i in children)
            {
                var info = i.GetType().GetProperty("Name");

                if (info != null)
                {
                    string name = (string)info.GetValue(i);

                    if (name != null)
                    {
                        foreach (FieldInfo j in runtimeFields)
                        {
                            if (j.Name == name)
                            {
                                j.SetValue(this, i);
                                break;
                            }
                        }
                    }
                }
            }
        }
        private void PopulateMap(List <Place> placeList)
        {
            //var pushpinTemplate = Resources["PushpinTemplate"] as DataTemplate;
            //var pushpins = new List<Pushpin>();

            foreach (var place in placeList)
            {
                place.LastUpdate = "Updated: " + place.UpdatedAt.ToString("f");
                place.Icon       = GetSource(place);
                place.Coordinate = new GeoCoordinate(place.Latitude, place.Longitude);
                //Pushpin pp = new Pushpin
                //             {
                //                 GeoCoordinate = new GeoCoordinate(place.Latitude, place.Longitude),
                //                 ContentTemplate = pushpinTemplate,
                //                 Content = place.Icon
                //             };
                //pushpins.Add(pp);
            }

            ObservableCollection <DependencyObject> children = MapExtensions.GetChildren(myMap);
            var obj = children.FirstOrDefault(x => x is MapItemsControl) as MapItemsControl;

            if (obj != null)
            {
                obj.ItemsSource = App.ViewModel.Items;
            }
            //var clusterer = new ClustersGenerator(myMap, pushpins, Resources["ClusterTemplate"] as DataTemplate);
            myMap.SetView(new GeoCoordinate(53.510138, -7.865643), 7.0);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Called when the pinned locations change.
        /// </summary>
        private void OnPinnedLocationsChanged()
        {
            var itemsContainer = MapExtensions.GetChildren(LayoutRoot).OfType <MapItemsControl>().ElementAt(0);

            itemsContainer.Items.Clear();
            foreach (var loc in PinnedLocations)
            {
                itemsContainer.Items.Add(loc);
            }

            var coords = PinnedLocations.Select(loc => loc.Position)
                         .Select(p => new GeoCoordinate(p.Latitude, p.Longitude))
                         .ToArray();

            if (coords.Length == 1)
            {
                LayoutRoot.Center         = coords[0];
                Properties.BuildingsLevel = PinnedLocations[0].Floor ?? 0;
            }
            else if (coords.Length > 1)
            {
                LayoutRoot.SetView(LocationRectangle.CreateBoundingRectangle(coords));
                Properties.BuildingsLevel = PinnedLocations[0].Floor ?? 0;
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Constructor
        /// </summary>
        public Map()
        {
            InitializeComponent();

            // Make sure that data context is loaded
            if (!App.ViewModel.IsDataLoaded)
            {
                App.ViewModel.LoadData();
            }

            // Set the data context
            DataContext = App.ViewModel;

            // Set up map view & map pushpin
#if WP8
            MapView                  = new Microsoft.Phone.Maps.Controls.Map();
            MapPushpin               = new Microsoft.Phone.Maps.Toolkit.Pushpin();
            MapPushpin.Name          = "MapPushpin";
            MapPushpin.GeoCoordinate = App.ViewModel.Restaurant.Location;

            ObservableCollection <DependencyObject> children = MapExtensions.GetChildren(MapView);
            children.Add(MapPushpin);
            MapExtensionsSetup(MapView);
#else
            MapView = new Microsoft.Phone.Controls.Maps.Map();
            MapView.ZoomBarVisibility = Visibility.Visible;
            MapPushpin          = new Microsoft.Phone.Controls.Maps.Pushpin();
            MapPushpin.Location = App.ViewModel.Restaurant.Location;
            MapView.Children.Add(MapPushpin);
#endif
            MapView.ZoomLevel = 12;
            MapView.Center    = App.ViewModel.Restaurant.Location;
            ContentPanel.Children.Add(MapView);
        }
Exemplo n.º 12
0
        private static void OnPushPinPropertyChanged(DependencyObject d,
                                                     DependencyPropertyChangedEventArgs e)
        {
            UIElement uie     = (UIElement)d;
            var       pushpin = MapExtensions.GetChildren((Map)uie).OfType <MapItemsControl>().FirstOrDefault();

            pushpin.ItemsSource = (IEnumerable)e.NewValue;
        }
        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            ObservableCollection <DependencyObject> children = MapExtensions.GetChildren(MyMap);
            var obj = children.FirstOrDefault(x => x.GetType() == typeof(MapItemsControl)) as MapItemsControl;

            if (obj.ItemsSource == null)
            {
                obj.ItemsSource = ViewModel.TripPoints;
            }
        }
Exemplo n.º 14
0
        // These helpers enable the Pushpin control from Windows Phone Toolkit
        // to be used in representing the artists and bands on the Map control.
        private void InitializeMap(Map map)
        {
            ObservableCollection <DependencyObject> children = MapExtensions.GetChildren(map);
            IEnumerable <FieldInfo> runtimeFields            = this.GetType().GetRuntimeFields();

            foreach (DependencyObject i in children)
            {
                SetChildItemField(i, runtimeFields);
            }
        }
        private void BindMapItemsControlItemsSource(string name, System.Collections.IEnumerable source)
        {
            // Finds the right control.
            MapItemsControl mapItemsControl = MapExtensions.GetChildren(MapControl)
                                              .OfType <MapItemsControl>()
                                              .First(mic => mic.Name == name);

            // Binds the property.
            mapItemsControl.ItemsSource = source;
        }
Exemplo n.º 16
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            Trip currentTrip = ViewModel.Trip;

            if (currentTrip.IsActif)
            {
                EndStack.Visibility = Visibility.Collapsed;
            }
            else
            {
                EndStack.Visibility = Visibility.Visible;
            }
            //Bind les POI a la map
            ObservableCollection <DependencyObject> children = MapExtensions.GetChildren(statsMap);
            var obj = children.FirstOrDefault(x => x.GetType() == typeof(MapItemsControl)) as MapItemsControl;

            if (obj.ItemsSource != null)
            {
                (obj.ItemsSource as IList).Clear();
                obj.ItemsSource = null;
            }
            obj.ItemsSource = (ViewModel.PointOfInterestList);

            //Ajout du départ
            MapLayer layer1   = new MapLayer();
            Pushpin  pushpin1 = new Pushpin();

            pushpin1.GeoCoordinate = currentTrip.CoordinateDeparture;
            pushpin1.Background    = new SolidColorBrush(Color.FromArgb(255, 105, 105, 105));
            pushpin1.Content       = AppResources.AddTripDeparture;
            MapOverlay overlay1 = new MapOverlay();

            overlay1.Content        = pushpin1;
            overlay1.GeoCoordinate  = currentTrip.CoordinateDeparture;
            overlay1.PositionOrigin = new Point(0, 1);
            layer1.Add(overlay1);
            statsMap.Layers.Add(layer1);

            //Ajout de la destination
            MapLayer layer2   = new MapLayer();
            Pushpin  pushpin2 = new Pushpin();

            pushpin2.GeoCoordinate = currentTrip.CoordinateDestination;
            pushpin2.Content       = AppResources.AddTripArrival;
            pushpin2.Background    = new SolidColorBrush(Color.FromArgb(255, 105, 105, 105));
            MapOverlay overlay2 = new MapOverlay();

            overlay2.Content        = pushpin2;
            overlay2.GeoCoordinate  = currentTrip.CoordinateDestination;
            overlay2.PositionOrigin = new Point(0, 1);
            layer2.Add(overlay2);
            statsMap.Layers.Add(layer2);
        }
Exemplo n.º 17
0
        //crea una capa en mapa y bindea la lista a pushpins
        private void pinchosmapa()
        {
            SystemTray.ProgressIndicator.Text = "Obteniendo locales y eventos cercanos";
            ObservableCollection <DependencyObject> children = MapExtensions.GetChildren(mapacentral);
            var obj = children.FirstOrDefault(x => x.GetType() == typeof(MapItemsControl)) as MapItemsControl;

            localespincho(mapacentral.Center.Latitude, mapacentral.Center.Longitude);
            obj.ItemsSource           = listapinchos;
            listacercanos.DataContext = listapinchos;
            SetProgressindicator(false);
        }
        public MainPage()
        {
            InitializeComponent();
            DataContext = _mainViewModel;

            var control = MapExtensions.GetChildren(MyMap).OfType <MapItemsControl>().FirstOrDefault();

            if (control != null)
            {
                control.ItemsSource = _mainViewModel.Planes;
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// Populates the page with content passed during navigation. Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>.
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session. The state will be null the first time a page is visited.</param>
        private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            if (e.NavigationParameter != null)
            {
                var icon = e.NavigationParameter as MapIcon;

                if (icon != null)
                {
                    CreatePivotItem(MapExtensions.GetValue(icon));
                }
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// Updates list of known places
        /// </summary>
        /// <returns>Asynchronous task</returns>
        private async Task UpdateKnownPlacesAsync()
        {
            if (_monitor != null)
            {
                _app.Places = null;

                PlacesMap.MapElements.Clear();

                if (await CallSensorcoreApiAsync(async() => { _app.Places = await _monitor.GetKnownPlacesAsync(); }))
                {
                    foreach (var p in _app.Places)
                    {
                        System.Diagnostics.Debug.WriteLine("Place {0} radius {1} Latitude {2} Longitude {3} ", p.Kind, p.Radius, p.Position.Latitude, p.Position.Longitude);
                        var icon = new MapIcon();
                        MapExtensions.SetValue(icon, p);

                        icon.NormalizedAnchorPoint = new Windows.Foundation.Point(0.5, 1);
                        icon.Location = new Geopoint(p.Position);
                        icon.Title    = p.Kind.ToString();
                        Color color;

                        switch (p.Kind)
                        {
                        case PlaceKind.Home:
                            color = PlacesColorHome;
                            break;

                        case PlaceKind.Work:
                            color = PlacesColorWork;
                            break;

                        case PlaceKind.Frequent:
                            color = PlacesColorFrequent;
                            break;

                        case PlaceKind.Known:
                            color = PlacesColorKnown;
                            break;

                        default:
                            color = PlacesColorUnknown;
                            break;
                        }

                        PlacesMap.MapElements.Add(icon);
                        CreateGeofence(p.Id.ToString(), p.Position.Latitude, p.Position.Longitude, p.Radius, color);
                    }
                }
            }
            Debug.WriteLine("Known places updated.");
        }
Exemplo n.º 21
0
        private static void OnLayersChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
        {
            var map            = (EpflMap)obj;
            var itemsContainer = MapExtensions.GetChildren(map.LayoutRoot).OfType <MapItemsControl>().ElementAt(1);

            itemsContainer.Items.Clear();
            foreach (var layer in (PocketCampus.Map.Models.MapLayer[])args.NewValue)
            {
                foreach (var item in layer.Items)
                {
                    itemsContainer.Items.Add(item);
                }
            }
        }
Exemplo n.º 22
0
        private void loadData()
        {
            ////Bind les POI a la map
            ObservableCollection <DependencyObject> children = MapExtensions.GetChildren(MyMap);
            var obj = children.FirstOrDefault(x => x.GetType() == typeof(MapItemsControl)) as MapItemsControl;

            if (obj.ItemsSource != null)
            {
                removeTempMapLayer();
                (obj.ItemsSource as IList).Clear();
                obj.ItemsSource = null;
            }
            obj.ItemsSource = ViewModel.PointOfInterestList;
        }
Exemplo n.º 23
0
        /// <summary>
        /// Finds bus stops matching the area specified by center location and radius.
        /// </summary>
        /// <param name="pos">Position</param>
        /// <param name="radius">Rectangular search "radius" in kilometers</param>
        /// <returns>Array of Stop objects</returns>
        public static async Task <Stop[]> FindStopsByLocationAsync(BasicPosition pos, int radius)
        {
            var box      = MapExtensions.GetBoundingBox(pos, radius);
            var left     = (int)(box.MinPoint.Longitude * 3600000);
            var right    = (int)(box.MaxPoint.Longitude * 3600000);
            var top      = (int)(box.MaxPoint.Latitude * 3600000);
            var bottom   = (int)(box.MinPoint.Latitude * 3600000);
            var content  = new StringContent("left=" + left + "&bottom=" + bottom + "&right=" + right + "&top=" + top);
            var response = await _client.PostAsync(_geoUrl, content);

            var locationInfo = await DeserializeAsync <LocationInfo>(response);

            return(locationInfo.Stops);
        }
        public async Task ExceptionHandlerMustSaveExceptionToLogStoreBecauseOfExceptionInRequest()
        {
            using (BitOwinTestEnvironment testEnvironment = new BitOwinTestEnvironment(new TestEnvironmentArgs
            {
                AdditionalDependencies = manager =>
                {
                    manager.RegisterOwinMiddlewareUsing(owinApp =>
                    {
                        MapExtensions.Map((IAppBuilder)owinApp, (string)"/Exception", innerApp =>
                        {
                            AppBuilderUseExtensions.Use <ExceptionThrownMiddleware>(innerApp);
                        });
                    });
                }
            }))
            {
                try
                {
                    TokenResponse token = await testEnvironment.Server.Login("ValidUserName", "ValidPassword", clientId : "TestResOwner");

                    await testEnvironment.Server.GetHttpClient(token)
                    .GetAsync("/Exception");

                    Assert.Fail();
                }
                catch
                {
                    IScopeStatusManager scopeStatusManager = TestDependencyManager.CurrentTestDependencyManager
                                                             .Objects.OfType <IScopeStatusManager>()
                                                             .Last();

                    A.CallTo(() => scopeStatusManager.MarkAsFailed())
                    .MustHaveHappened(Repeated.Exactly.Once);

                    ILogger logger = TestDependencyManager.CurrentTestDependencyManager
                                     .Objects.OfType <ILogger>()
                                     .Last();

                    A.CallTo(() => logger.LogExceptionAsync(A <Exception> .That.Matches(e => e is InvalidOperationException), A <string> .Ignored))
                    .MustHaveHappened(Repeated.Exactly.Once);

                    IEnumerable <LogData> logData = logger.LogData;

                    logData.Single(c => c.Key == "ExceptionType" && ((string)c.Value).Contains("InvalidOperationException"));
                    logData.Single(c => c.Key == nameof(IRequestInformationProvider.HttpMethod) && (string)c.Value == "GET");
                    logData.Single(c => c.Key == "UserId" && (string)c.Value == "ValidUserName");
                }
            }
        }
Exemplo n.º 25
0
        private async void getStopsInfo()
        {
            string errorMessage = null;

            Geopoint bottomLeft = MapExtensions.GetBottomLeftCorner(mapControl);
            Geopoint topRight   = MapExtensions.GetTopRightCorner(mapControl);

            if (mapControl.ZoomLevel >= 16 &&
                (stopsLoadingFailed || lastTopRight == null || lastBottomLeft == null ||
                 bottomLeft.Position.Latitude != lastBottomLeft.Position.Latitude ||
                 bottomLeft.Position.Longitude != lastBottomLeft.Position.Longitude ||
                 topRight.Position.Latitude != lastTopRight.Position.Latitude ||
                 topRight.Position.Longitude != lastTopRight.Position.Longitude))
            {
                lastBottomLeft = bottomLeft;
                lastTopRight   = topRight;

                MapProgressBar.Visibility = Visibility.Visible;

                try
                {
                    string webresponse = await Network.StopsByViewport(bottomLeft, topRight);

                    List <Stop> rootObject = JsonConvert.DeserializeObject <List <Stop> >(webresponse);

                    CurrentStopList.Clear();

                    foreach (Stop s in rootObject)
                    {
                        CurrentStopList.Add(s);
                    }
                    LastBusStopUpdate  = DateTime.Now;
                    stopsLoadingFailed = false;
                }
                catch (Exception ex)
                {
                    errorMessage       = ex.Message;
                    stopsLoadingFailed = true;
                }

                if (errorMessage != null)
                {
                    MessageDialog msg = new MessageDialog("Houve algum problema durante a requisição ao servidor. Por favor, verifique se o aparelho está conectado à internet e tente novamente.", "Você está conectado à internet?");
                    await msg.ShowAsync();
                }

                MapProgressBar.Visibility = Visibility.Collapsed;
            }
        }
Exemplo n.º 26
0
        protected override void OnApplyTemplate()
        #endif
        {
            base.OnApplyTemplate();

            map = GetTemplateChild(PartNames.Map) as Map;

            // Validate the template
            if (map == null)
            {
                throw new InvalidOperationException(string.Format("{0} template is invalid. A {1} named {2} must be supplied.", GetType().Name, typeof(Map).Name, PartNames.Map));
            }

            // Connect credentials
            #if WP7
            map.CredentialsProvider = credentials;
            #endif

            #if WP8
            if (credentials != null)
            {
                MapsSettings.ApplicationContext.ApplicationId       = credentials.ApplicationId;
                MapsSettings.ApplicationContext.AuthenticationToken = credentials.AuthenticationToken;
            }
            #endif

            #if WIN_RT
            map.Credentials = credentials;
            #endif

            // Update the margin
            UpdateMargin();

            // Connect data
            map.DataContext = arItems;
            #if WP8
            // We must use the toolkit to get the child map items controls and set their items source properly
            foreach (var itemsControl in MapExtensions.GetChildren(map).OfType <MapItemsControl>())
            {
                itemsControl.ItemsSource = arItems;
            }
            #endif

            #if WIN_RT
            // Set initial values for properties that can't be data bound in Windows 8
            map.Center    = Location;
            map.ZoomLevel = PercentBingZoomConverter.PercentToMapLevel(ZoomLevel);
            #endif
        }
Exemplo n.º 27
0
        public TEntity Clone(TEntity entity)
        {
            var result = new TEntity();

            foreach (var column in MapExtensions.OwnedColumns(this.configuration.GetMap <TEntity>(), true))
            {
                var prop = this.entityType.GetProperty(column.Name);
                if (column.Type.IsValueType())
                {
                    prop.SetValue(result, prop.GetValue(entity));
                }
                else if (column.Type == typeof(string))
                {
                    var val = prop.GetValue(entity) as string;
                    if (val != null)
                    {
                        val = new string(val.ToCharArray());
                    }

                    prop.SetValue(result, val);
                }
                else if (column.Relationship == RelationshipType.ManyToOne || column.Relationship == RelationshipType.OneToOne)
                {
                    // all we want here is to clone the entity and just leave the primary key on
                    var val = prop.GetValue(entity);
                    if (val != null)
                    {
                        var map        = column.Relationship == RelationshipType.ManyToOne ? column.ParentMap : column.OppositeColumn.Map;
                        var primaryKey = map.GetPrimaryKeyValue(val);
                        var field      = this.entityType.GetField(column.DbName);
                        field.SetValue(result, primaryKey);
                    }
                    else
                    {
                        if (!column.IsNullable)
                        {
                            throw new InvalidOperationException(
                                      string.Format(
                                          "The property {0} on {1} is marked as not nullable. You must add some data for it",
                                          column.Name,
                                          result.GetType()));
                        }
                    }
                }
            }

            return(result);
        }
Exemplo n.º 28
0
        private void refreshLocationsOnMap()
        {
            ObservableCollection <DependencyObject> children = MapExtensions.GetChildren(FrequentLocationsMap);
            var obj = children.FirstOrDefault(x => x.GetType() == typeof(MapItemsControl)) as MapItemsControl;

            if (obj.Items == null || obj.Items.Count == 0)
            {
                obj.ItemsSource = frequentLMLocations;
                //obj.Items.Clear();
            }

            if (MyCoordinates != null && MyCoordinates.Count != 0)
            {
                FrequentLocationsMap.Center = MyCoordinates[MyCoordinates.Count - 1];
                FrequentLocationsMap.SetView(MyCoordinates[MyCoordinates.Count - 1], 10, MapAnimationKind.Linear);
            }
        }
Exemplo n.º 29
0
        private void ToForgeChildren()
        {
            if (children == null)
            {
                children = MapExtensions.GetChildren(myMap);

                marker          = children.FirstOrDefault(x => x.GetType() == typeof(UserLocationMarker)) as UserLocationMarker;
                mapItemsControl = children.FirstOrDefault(x => x.GetType() == typeof(MapItemsControl)) as MapItemsControl;
            }

            marker.GeoCoordinate = position.Coordinate.ToGeoCoordinate();

            if (pushpins.Count != 0)
            {
                mapItemsControl.ItemsSource = pushpins;
            }
        }
Exemplo n.º 30
0
        public HomePage()
        {
            InitializeComponent();

            if ((Visibility)Application.Current.Resources["PhoneDarkThemeVisibility"] == Visibility.Visible)
            {
                LogoLightTheme.Visibility = Visibility.Collapsed;
                LogoDarkTheme.Visibility  = Visibility.Visible;
            }
            else
            {
                LogoLightTheme.Visibility = Visibility.Visible;
                LogoDarkTheme.Visibility  = Visibility.Collapsed;
            }

            // for some reason InitializeComponent doesn't initialize PushPin
            AddressPushPin = MapExtensions.GetChildren(map).FirstOrDefault() as Pushpin;
        }