public void SaveCredentials(ITwitterCredentials credentials) { if (credentials == null) { return; } _settingsController.Settings.AccessTokenSecret = credentials.AccessTokenSecret; _settingsController.Settings.AccessToken = credentials.AccessToken; _settingsController.Save(); }
private async void Start() { await Task.Delay(3000); try { await Stream.StartStreamMatchingAllConditionsAsync().ConfigureAwait(false); _globalVariables.IsLoggedIn = true; } catch (TwitterInvalidCredentialsException) { _globalVariables.IsLoggedIn = false; _settingsController.Settings.AccessToken = null; _settingsController.Settings.AccessTokenSecret = null; _settingsController.Settings.Autologin = false; _globalVariables.IsLoggedIn = false; _settingsController.Save(); MessageBox.Show("Click Login again!", "Login Error", MessageBoxButton.OK, MessageBoxImage.Error); Stream?.StopStream(); } catch (TwitterException tw) { _globalVariables.IsLoggedIn = false; MessageBox.Show(tw.TwitterDescription, "Twitter Error", MessageBoxButton.OK, MessageBoxImage.Error); Stream?.StopStream(); } catch (ArgumentException ar) { _globalVariables.IsLoggedIn = false; _settingsController.Settings.AccessToken = null; _settingsController.Settings.AccessTokenSecret = null; _settingsController.Settings.Autologin = false; _globalVariables.IsLoggedIn = false; _settingsController.Save(); MessageBox.Show(ar.Message, "Argument Error", MessageBoxButton.OK, MessageBoxImage.Error); Stream?.StopStream(); } catch (Exception) { _globalVariables.IsLoggedIn = false; Stream?.StopStream(); } }