Ejemplo n.º 1
0
        public InitViewModel(
            IAreaPositioningService areaPositioningService,
            IUserInteraction userInteraction)
        {
            _userInteraction = userInteraction;

            _areaPositioningService                     = areaPositioningService;
            _areaPositioningService.AreaLocated        += this.OnAreaLocated;
            _areaPositioningService.AreaLocatingFailed += this.OnAreaLocatingFailed;

            this.SelectManuallyCommand = new MvxCommand(this.SelectManually);
            this.DetectLocationCommand = new MvxCommand(this.DetectLocation);
        }
Ejemplo n.º 2
0
        public BusTrackerLocationService(ILocationService locationService, IAreaPositioningService areaPositioningService)
        {
            _locationService        = locationService;
            _areaPositioningService = areaPositioningService;

            _areaPositioningService.AreaLocated += (s, a) =>
                                                   this.RaiseAreaChangedEvent(
                this.CurrentArea,
                this.DetectedArea,
                this.DetectedArea ? _locationService.GetLastLocation() :
                new GeoPoint(
                    this.CurrentArea.Latitude,
                    this.CurrentArea.Longitude));
        }
Ejemplo n.º 3
0
        public SetAreaViewModel(IConfigManager configManager, IAreaPositioningService locationService)
        {
            _locationService = locationService;

            var areaVMs = configManager.GetConfig()
                          .Areas
                          .Select(a => new AreaViewModel(a, this[string.Format(AppConsts.AreaLocalizedNameStringKeyFormat, a.Id)]))
                          .ToList();

            this.Areas = new ObservableCollection <AreaViewModel>(areaVMs);

            this.SelectAreaCommand = new MvxCommand <int>(this.SelectAreaManually);
            this.CancelCommand     = new MvxCommand(this.Cancel);
        }
Ejemplo n.º 4
0
        public HomeViewModel(
            IMvxMessenger messenger,
            IBusTrackerLocationService busTrackerLocationService,
            IAreaPositioningService areaPositioningService,
            IConfigManager configManager)
        {
            this.MenuItems             = new ReadOnlyObservableCollection <MenuViewModel>(this.CreateMenuViewModels());
            this.SelectMenuItemCommand = new MvxCommand <MenuSection>(this.SelectMenuItem);

            _messenger                    = messenger;
            _configManager                = configManager;
            _areaPositioningService       = areaPositioningService;
            _locationService              = busTrackerLocationService;
            _locationService.AreaChanged += (s, a) => this.UpdateSelectedArea(a.Area);

            _taskChangedMessagesSubscription = _messenger.Subscribe <BackgroundTaskStateChangedMessage>(this.OnBackgroundTaskStateChanged);

            Areas = new ReadOnlyCollection <AreaViewModel>(_areas);

            this.UpdateVehicleLocationsCommand = new MvxCommand(this.UpdateVehicleLocations);
            this.SelectAreaCommand             = new MvxCommand <int>(this.SelectArea);
        }