コード例 #1
0
ファイル: RoutesViewModel.cs プロジェクト: dkataskin/bstrkr
        public RoutesViewModel(ILiveDataProviderFactory providerFactory)
        {
            _providerFactory = providerFactory;

            this.Routes                   = new ReadOnlyObservableCollection <RoutesListItemViewModel>(_routes);
            this.RefreshCommand           = new MvxCommand <bool>(this.Refresh);
            this.ShowRouteVehiclesCommand = new MvxCommand <RoutesListItemViewModel>(this.ShowRouteDetails, vm => !this.IsBusy);
        }
コード例 #2
0
        public RouteVehiclesViewModel(ILiveDataProviderFactory providerFactory, IUserInteraction userInteraction)
        {
            _providerFactory = providerFactory;
            _userInteraction = userInteraction;

            this.Vehicles = new ReadOnlyObservableCollection <VehicleForecastViewModel>(_vehicles);
            this.ShowVehicleOnMapCommand = new MvxCommand <VehicleForecastViewModel>(this.ShowVehicleOnMap, vm => !this.IsBusy);

            _intervalObservable   = Observable.Interval(TimeSpan.FromMilliseconds(1000));
            _intervalSubscription = _intervalObservable.Subscribe(this.OnNextInterval);
        }
コード例 #3
0
        public RouteStopsViewModel(
            ILiveDataProviderFactory providerFactory,
            IBusTrackerLocationService locationService)
        {
            _providerFactory = providerFactory;
            _locationService = locationService;

            this.Stops = new ReadOnlyObservableCollection <RouteStopsListItemViewModel>(_stops);

            this.RefreshCommand         = new MvxCommand <bool>(this.Refresh, noCache => !this.IsBusy);
            this.ShowStopDetailsCommand = new MvxCommand <RouteStopsListItemViewModel>(this.ShowStopDetails, vm => !this.IsBusy);
        }
コード例 #4
0
        public RouteStopViewModel(
            ILiveDataProviderFactory liveDataProvider,
            IMvxMessenger messenger,
            IUserInteraction userInteraction)
        {
            _messenger               = messenger;
            _userInteraction         = userInteraction;
            _liveDataProviderFactory = liveDataProvider;
            _intervalObservable      = Observable.Interval(TimeSpan.FromMilliseconds(1000));

            this.Forecast = new ReadOnlyObservableCollection <RouteStopForecastViewModel>(_forecast);

            this.ShowOnMapCommand        = new MvxCommand(this.ShowOnMap);
            this.ShowVehicleOnMapCommand = new MvxCommand <RouteStopForecastViewModel>(this.ShowVehicleOnMap);
            this.RefreshCommand          = new MvxCommand(this.Refresh, () => !this.IsBusy);
        }
コード例 #5
0
ファイル: MapViewModel.cs プロジェクト: dkataskin/bstrkr
        private void InitializeStartLiveDataProvider(ILiveDataProviderFactory factory)
        {
            _liveDataProvider = factory.GetCurrentProvider();
            if (_liveDataProvider != null)
            {
                this.MapRouteStopsViewModel.Initialize(_liveDataProvider);
                this.MapVehiclesViewModel.Initialize(_liveDataProvider);

                _liveDataProvider.Start();

                this.MapRouteStopsViewModel.LoadRouteStopsCommand.Execute();
                this.MapVehiclesViewModel.ForceVehicleLocationsUpdateCommand.Execute();

                MvxTrace.Trace(() => "provider started");
            }
        }
コード例 #6
0
ファイル: MapViewModel.cs プロジェクト: dkataskin/bstrkr
        public MapViewModel(
            IBusTrackerLocationService locationService,
            ILiveDataProviderFactory providerFactory,
            IConfigManager configManager,
            IMvxMessenger messenger)
        {
            _providerFactory              = providerFactory;
            _configManager                = configManager;
            _messenger                    = messenger;
            _locationService              = locationService;
            _locationService.AreaChanged += (s, a) =>
            {
                this.DetectedArea = a.Detected;
                this.ChangeArea(a.Area, a.LastLocation);
            };

            _config = _configManager.GetConfig();

            this.MapRouteStopsViewModel = Mvx.IocConstruct <MapRouteStopsViewModel>();
            this.MapRouteStopsViewModel.RouteStopSelected += (s, a) => this.CenterMap(a.RouteStop.Location.Position);

            this.MapVehiclesViewModel = Mvx.IocConstruct <MapVehiclesViewModel>();

            this.SelectRouteStopCommand = new MvxCommand <string>(this.SelectRouteStop);
            this.SelectVehicleCommand   = new MvxCommand <string>(this.SelectVehicle);
            this.ClearSelectionCommand  = new MvxCommand(this.ClearSelection);
            this.UpdateMapCenterCommand = new MvxCommand <Tuple <GeoPoint, bool> >(tuple =>
            {
                if (tuple.Item2)
                {
                    this.MapCenter = tuple.Item1;
                }
                else
                {
                    _mapCenter = tuple.Item1;
                }
            });

            _routeStopInfoSubscriptionToken = _messenger.Subscribe <ShowRouteStopForecastOnMapMessage>(
                message => this.SelectRouteStopCommand.Execute(message.RouteStopId));

            _vehicleInfoSubscriptionToken = _messenger.Subscribe <ShowVehicleForecastOnMapMessage>(
                message => this.SelectVehicleCommand.Execute(message.VehicleId));
        }
コード例 #7
0
        public VehicleForecastViewModel(ILiveDataProviderFactory liveDataProviderFactory, IMvxMessenger messenger)
        {
            _messenger = messenger;
            _liveDataProviderFactory = liveDataProviderFactory;

            this.UpdateForecastCommand = new MvxCommand(
                () => _stateMachine.Fire(RouteVehicleVMTriggers.ForecastRequested),
                () => _stateMachine.CanFire(RouteVehicleVMTriggers.ForecastRequested));

            this.CountdownCommand = new MvxCommand(
                this.Countdown,
                () => _stateMachine.IsInState(RouteVehicleVMStates.ForecastReceived));

            this.ShowOnMapCommand = new MvxCommand(this.ShowOnMap);

            _stateMachine = new StateMachine <RouteVehicleVMStates, RouteVehicleVMTriggers>(RouteVehicleVMStates.Start);
            _stateMachine.OnTransitioned(sm => this.Dispatcher.RequestMainThreadAction(() => this.RaisePropertyChanged(() => this.State)));

            _stateMachine.Configure(RouteVehicleVMStates.Start)
            .Permit(RouteVehicleVMTriggers.ForecastRequested, RouteVehicleVMStates.Loading);

            _stateMachine.Configure(RouteVehicleVMStates.Loading)
            .OnEntry(this.RequestForecast)
            .Permit(RouteVehicleVMTriggers.ForecastReturned, RouteVehicleVMStates.ForecastReceived)
            .Permit(RouteVehicleVMTriggers.NoForecastDataReturned, RouteVehicleVMStates.NoForecast)
            .Permit(RouteVehicleVMTriggers.RequestFailed, RouteVehicleVMStates.NoForecast);

            _stateMachine.Configure(RouteVehicleVMStates.ForecastReceived)
            .Permit(RouteVehicleVMTriggers.ForecastRequested, RouteVehicleVMStates.Loading);

            _stateMachine.Configure(RouteVehicleVMStates.NoForecast)
            .OnEntry(this.PauseAndRequest)
            .Permit(RouteVehicleVMTriggers.ForecastRequested, RouteVehicleVMStates.Loading);

            this.Forecast = new ReadOnlyObservableCollection <VehicleForecastListItemViewModel>(_forecast);
        }