Exemplo n.º 1
0
        public SettingsViewModel(ITripTrackerManager manager, IDialogs dialogs)
        {
            this.IsEnabled     = manager.TrackingType == null;
            this.UseAutomotive = manager.TrackingType == TripTrackingType.Automotive;
            this.UseCycling    = manager.TrackingType == TripTrackingType.Cycling;
            this.UseRunning    = manager.TrackingType == TripTrackingType.Running;
            this.UseWalking    = manager.TrackingType == TripTrackingType.Walking;
            this.UseOnFoot     = manager.TrackingType == TripTrackingType.OnFoot;
            this.UseExercise   = manager.TrackingType == TripTrackingType.Exercise;
            this.UseStationary = manager.TrackingType == TripTrackingType.Stationary;

            this.ToggleMonitoring = ReactiveCommand.CreateFromTask
                                    (
                async() =>
            {
                var access = await manager.RequestAccess();
                if (access != AccessState.Available)
                {
                    await dialogs.Alert("Invalid Access - " + access);
                }
                else
                {
                    if (!this.IsEnabled)
                    {
                        await manager.StopTracking();
                    }
                    else
                    {
                        var type = this.GetTrackingType().Value;
                        await manager.StartTracking(type);
                    }
                    this.IsEnabled = !this.IsEnabled;
                    this.RaisePropertyChanged(nameof(this.MonitoringText));
                }
            },
                this.WhenAny(
                    x => x.UseAutomotive,
                    x => x.UseRunning,
                    x => x.UseWalking,
                    x => x.UseCycling,
                    x => x.UseOnFoot,
                    x => x.UseExercise,
                    x => x.UseStationary,
                    (auto, run, walk, cycle, foot, ex, st) => this.GetTrackingType() != null
                    )
                                    );
        }
Exemplo n.º 2
0
 public LogViewModel(ITripTrackerManager manager, IDialogs dialogs) : base(dialogs)
 {
     this.manager = manager;
 }
 public SampleTripTrackerDelegate(ITripTrackerManager manager, AppNotifications notifications)
 {
     this.manager       = manager;
     this.notifications = notifications;
 }