private static void ListBuckets(BucketConfigurationWindow window) { window.Dispatcher.BeginInvoke((DispatcherInvokeNoResultHandler)delegate { window.SetValue(BucketsProperty, null); string accessKeyId = (string)window.GetValue(AccessKeyIdProperty); string secretAccessKey = (string)window.GetValue(SecretAccessKeyProperty); if (accessKeyId != null && secretAccessKey != null) { try { S3 s3 = new S3(accessKeyId, secretAccessKey); window.SetValue(BucketsProperty, s3.ListBuckets()); } catch (S3Exception e) { MessageBox.Show(e.Message); if (e.ErrorCode == "InvalidAccessKeyId") { Validation.MarkInvalid(BindingOperations.GetBindingExpression(window.AccessKeyIdTextBox, TextBox.TextProperty), new ValidationError(new ExceptionValidationRule(), "mandatory")); } else if (e.ErrorCode == "SignatureDoesNotMatch") { Validation.MarkInvalid(BindingOperations.GetBindingExpression(window.SecretAccessKeyIdTextBox, TextBox.TextProperty), new ValidationError(new ExceptionValidationRule(), "mandatory")); } } catch (Exception e) { MessageBox.Show(e.Message); } } }); }
private void ConfigureBucketExecuted(object sender, ExecutedRoutedEventArgs e) { BucketConfigurationWindow bucketConfigurationWindow = new BucketConfigurationWindow(); bucketConfigurationWindow.Owner = this; bucketConfigurationWindow.ShowDialog(); }