Пример #1
0
        public MainPage()
        {
            Settings = AppSettings.Current;

            MovementSource = new MovementSource();
            MovementSource.GeoStatusChanged += MovementSource_GeoStatusChanged;
            MovementSource.PropertyChanged  += MovementSource_PropertyChanged;

            DataContext = this;

            SwitchMapStatusCommand = new RelayCommand(ExecuteSwitchMapStatusCommand, CanExecuteSwitchMapStatusCommand);
            SwitchMapStatusCommand.BindToPropertyChange(this, "MapStatus");
            SwitchWindscreenModeCommand = new RelayCommand(ExecuteSwitchWindscreenModeCommand);
            SwitchSpeedAlertCommand     = new RelayCommand(ExecuteSwitchSpeedAlertCommand);
            SwitchUnitsCommand          = new RelayCommand(ExecuteSwitchUnitsCommand);
            SwitchLocationAccessCommand = new RelayCommand(ExecuteSwitchLocationAccessCommand);
            AboutCommand = new RelayCommand(ExecuteAboutCommand);

            SpeedAlert = new SpeedAlert(MovementSource, SpeedAlert.SoundProvider);

            InitializeComponent();
            ShowWarnings();

            // no idling here
            PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;

            UpdateLocationAccess();
        }
Пример #2
0
        public SpeedAlert(MovementSource source, INotificationProvider provider)
        {
            this.source          = source;
            NotificationProvider = provider;

            timer = new DispatcherTimer {
                Interval = TimeSpan.FromSeconds(5)
            };
            timer.Tick += Timer_Tick;

            source.PropertyChanged += Source_PropertyChanged;
        }
Пример #3
0
 private void UpdateLocationAccess()
 {
     if (Settings.AllowLocationAccess)
     {
         IsLocating = true;
         MovementSource.Start();
     }
     else
     {
         MovementSource.Stop();
         GpsStatus = GpsStatus.Inaccessible;
         MapStatus = MapStatus.Disabled;
     }
 }