public async override void Start()
        {
            if (await synchronisationService.AuthorizeTokenSynchronisation())
            {
                await Task.Run(RefreshToolRoads);
            }
            else
            {
                Close(this);
                ShowViewModel <LoginViewModel>();
                return;
            }

            base.Start();

            _tokens.Add(_messenger.SubscribeOnThreadPoolThread <LocationMessage>(x => Location   = x.Data, MvxReference.Strong));
            _tokens.Add(_messenger.SubscribeOnThreadPoolThread <StatusMessage>(x => StatusString = x.Data.ToString(), MvxReference.Strong));
            _tokens.Add(_messenger.SubscribeOnThreadPoolThread <MotionMessage>(x => MotionType   = x.Data, MvxReference.Strong));

            _tokens.Add(_messenger.SubscribeOnMainThread <LogUpdated>((s) => LogText = Log._messageLog.ToString(), MvxReference.Strong));
            _tokens.Add(_messenger.SubscribeOnMainThread <GeoWatcherStatusMessage>((s) => IsBound = s.Data, MvxReference.Strong));

            _tokens.Add(_messenger.SubscribeOnMainThread <CurrentTollpointChangedMessage>((s) => CurrentWaypointString = string.Join("\n", s.Data?.Select(x => x.Name)), MvxReference.Strong));
            _tokens.Add(_messenger.SubscribeOnMainThread <TollRoadChangedMessage>((s) => TollRoadString = s.Data?.Name, MvxReference.Strong));

            if (_geoWatcher.Location != null)
            {
                Location = _geoWatcher.Location;
            }

            LogText = Log._messageLog.ToString();

            StatusString   = _track.TollStatus.ToString();
            TollRoadString = Mvx.Resolve <IWaypointChecker>().TollRoad?.Name;
            if (Mvx.Resolve <IWaypointChecker>().TollPointsInRadius != null)
            {
                CurrentWaypointString = string.Join("\n", Mvx.Resolve <IWaypointChecker>().TollPointsInRadius?.Select(x => x.Name));
            }
        }
예제 #2
0
        public async override void Start()
        {
            if (await synchronisationService.AuthorizeTokenSynchronisation())
            {
                await Task.Run(RefreshToolRoads);
            }
            else
            {
                Close(this);
                if (IsBound)
                {
                    _track.StopServices();
                }
                ShowViewModel <LoginViewModel>();
                return;
            }

            base.Start();
            _tokens.Add(_messenger.SubscribeOnMainThread <GeoWatcherStatusMessage>((s) => IsBound       = s.Data, MvxReference.Strong));
            _tokens.Add(_messenger.SubscribeOnThreadPoolThread <LocationMessage>(x => Location          = x.Data, MvxReference.Strong));
            _tokens.Add(_messenger.SubscribeOnThreadPoolThread <StatusMessage>(x => StatusString        = x.Data.ToString(), MvxReference.Strong));
            _tokens.Add(_messenger.SubscribeOnMainThread <TollRoadChangedMessage>((s) => TollRoadString = s.Data?.Name, MvxReference.Strong));

            await synchronisationService.DataSynchronisation();

            StatusString   = _track.TollStatus.ToString();
            TollRoadString = Mvx.Resolve <IWaypointChecker>().TollRoad?.Name;

            if (_geoWatcher.Location != null)
            {
                Location = _geoWatcher.Location;
                Mvx.Resolve <IWaypointChecker>().DetectWeAreInsideSomeTollPoint(Location);
            }

            DistanceToNearestTollpoint = double.Parse(Mvx.Resolve <IWaypointChecker>().DistanceToNearestTollpoint.ToString());
        }