/// <summary> /// Complete the authentication process if we're redirected by the oauth callback. /// </summary> /// <param name="uri"></param> public async void CompleteAuth(Uri uri) { // Only run this function if we don't have an access token. IsolatedStorageSettings isss = IsolatedStorageSettings.ApplicationSettings; if (!isss.Contains("access_token")) { SyncCommand.IsEnabled = false; /* * Set the auth method to null (neither manual nor automatic if we are on a callback. * The reason is that i don't want the page to flash the non-auth when you're redirected from the login page. * This makes sure that neither enter verifier nor start auth process is shown when you just started. * This also means that if getting an access token fails, the user won't have any recourse. I need to fix that. * Potentially by having the auth method return true/false? I can do that now that I can await Executes. */ if (uri.OriginalString.Contains("oauth_callback")) { IsManualAuth = null; var user = await ReadabilityClient.UserEndpoint.CompleteAuth(uri); if (user != null) { User = user; DataStorage.SaveUser(user); await LoadData(); SyncCommand.IsEnabled = true; if (SyncCommand.CanExecute(null)) { SyncCommand.Execute(null); } } } else { // If we are not in the callback, then either we're just starting auth or we're doing a manual auth. IsManualAuth = isss.Contains("oauth_token"); } NotifyPropertyChanged("IsManualAuth"); } }
public AppViewModel() { Title = "Syncurr"; InitTabs(); SelectedTab = Tabs[0]; Timer = new DispatcherTimer(); Timer.Interval = new TimeSpan(0, Properties.Settings.Default.SyncInterval, 0); Timer.Tick += (s, e) => { if (SyncCommand.CanExecute(null)) { SyncCommand.Execute(null); } }; Timer.Start(); if (Properties.Settings.Default.StartMinimized) { HasWindow = false; } }
private void HandleButtonCommand(GameControllerButtonCommand command, GameControllerUpdateNotification notification) { int index; switch (command) { case GameControllerButtonCommand.UnPark: if (notification == GameControllerUpdateNotification.CommandUp) { if (ParkCommand.CanExecute(null)) { if (IsParked) { ParkCommand.Execute(null); } } } break; case GameControllerButtonCommand.ParkToHome: if (notification == GameControllerUpdateNotification.CommandUp) { if (ParkCommand.CanExecute(null)) { if (!IsParked) { ParkCommand.Execute(null); } } } break; case GameControllerButtonCommand.Sync: if (notification == GameControllerUpdateNotification.CommandUp) { if (SyncCommand.CanExecute(null)) { SyncCommand.Execute(null); } } break; case GameControllerButtonCommand.IncrementPreset: index = Settings.SlewRatePresets.IndexOf(Settings.SlewRatePreset); if (index < Settings.SlewRatePresets.Count - 1) { Settings.SlewRatePreset = Settings.SlewRatePresets[index + 1]; } break; case GameControllerButtonCommand.DecrementPreset: index = Settings.SlewRatePresets.IndexOf(Settings.SlewRatePreset); if (index > 0) { Settings.SlewRatePreset = Settings.SlewRatePresets[index - 1]; } break; case GameControllerButtonCommand.EmergencyStop: if (notification == GameControllerUpdateNotification.CommandUp) { if (StopSlewCommand.CanExecute(SlewButton.Stop)) { StopSlewCommand.Execute(SlewButton.Stop); } } break; case GameControllerButtonCommand.North: HandleSlewButton(SlewButton.North, notification); break; case GameControllerButtonCommand.South: HandleSlewButton(SlewButton.South, notification); break; case GameControllerButtonCommand.East: HandleSlewButton(SlewButton.East, notification); break; case GameControllerButtonCommand.West: HandleSlewButton(SlewButton.West, notification); break; case GameControllerButtonCommand.ReverseRA: if (notification == GameControllerUpdateNotification.CommandUp) { Settings.ReverseRA = !Settings.ReverseRA; } break; case GameControllerButtonCommand.ReverseDec: if (notification == GameControllerUpdateNotification.CommandUp) { Settings.ReverseDec = !Settings.ReverseDec; } break; case GameControllerButtonCommand.SiderealRate: HandleStartStopTrackingButton(TrackingMode.Sidereal, notification); break; case GameControllerButtonCommand.LunarRate: HandleStartStopTrackingButton(TrackingMode.Lunar, notification); break; case GameControllerButtonCommand.SolarRate: HandleStartStopTrackingButton(TrackingMode.Solar, notification); break; case GameControllerButtonCommand.CustomRate: HandleStartStopTrackingButton(TrackingMode.Custom, notification); break; case GameControllerButtonCommand.StopTracking: HandleStartStopTrackingButton(TrackingMode.Stop, notification); break; } }
public void CanExecuteIsTrue() { var cmd = new SyncCommand(); Assert.IsTrue(cmd.CanExecute(null)); }