コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:Locator.Portable.ViewModels.MapPageViewModel"/> class.
        /// </summary>
        /// <param name="navigation">Navigation.</param>
        /// <param name="geolocator">Geolocator.</param>
        /// <param name="commandFactory">Command factory.</param>
        /// <param name="geocodingWebServiceController">Geocoding repository.</param>
        public MapPageViewModel(INavigationService navigation, IGeolocator geolocator, Func <Action, ICommand> commandFactory,
                                IGeocodingWebServiceController geocodingWebServiceController) : base(navigation)
        {
            _geolocator = geolocator;
            _geocodingWebServiceController = geocodingWebServiceController;

            _nearestAddressCommand = commandFactory(() => FindNearestSite());
            _geolocationCommand    = commandFactory(() =>
            {
                if (_geolocationUpdating)
                {
                    geolocator.Stop();
                }
                else
                {
                    geolocator.Start();
                }

                GeolocationButtonTitle = _geolocationUpdating ? "Start" : "Stop";
                _geolocationUpdating   = !_geolocationUpdating;
            });

            _positions = new List <IPosition> ();

            LocationUpdates = new Subject <IPosition> ();
            ClosestUpdates  = new Subject <IPosition> ();
        }