Beispiel #1
0
        private async void AuthorizeButton_Click(object sender, RoutedEventArgs e)
        {
            if (!(DataContext is ImgurPreset preset))
            {
                return;
            }

            if (string.IsNullOrWhiteSpace(preset.OAuthToken))
            {
                StatusBand.Warning(LocalizationHelper.Get("S.Options.Upload.Preset.Warning.Token"));
                return;
            }

            try
            {
                ThisPanel.IsEnabled = false;
                StatusBand.Hide();

                if (await Imgur.GetTokens(preset))
                {
                    preset.OAuthToken = null;
                    StatusBand.Info(LocalizationHelper.Get("S.Options.Upload.Preset.Info.Authorized"));
                    return;
                }

                StatusBand.Warning(LocalizationHelper.Get("S.Options.Upload.Preset.Warning.AuthError"));
            }
            catch (Exception ex)
            {
                LogWriter.Log(ex, "Authorizing access - Imgur");

                StatusBand.Error(LocalizationHelper.Get("S.Options.Upload.Preset.Warning.AuthError"), () => new ExceptionViewer(ex).ShowDialog());
            }
            finally
            {
                ThisPanel.IsEnabled = true;
                UpdateAlbumList();
            }
        }