private void Challenge(string url,
Action<IdentityManager.Credential, Exception> callback, IdentityManager.GenerateTokenOptions options)
{
LoginGrid.Visibility = System.Windows.Visibility.Visible;
TitleTextBlock.Text = string.Format("Login to access: \n{0}", url);
if (!challengeAttemptsPerUrl.ContainsKey(url))
challengeAttemptsPerUrl.Add(url, 0);
RoutedEventHandler handleClick = null;
handleClick = (s, e) =>
{
IdentityManager.Current.GenerateCredentialAsync(url, UserTextBox.Text, PasswordTextBox.Text,
(credential, ex) =>
{
challengeAttemptsPerUrl[url]++;
if (ex == null || challengeAttemptsPerUrl[url] == 3)
{
LoginLoadLayerButton.Click -= handleClick;
callback(credential, ex);
}
}, options);
};
LoginLoadLayerButton.Click += handleClick;
System.Windows.Input.KeyEventHandler handleEnterKeyDown = null;
handleEnterKeyDown = (s, e) =>
{
if (e.Key == System.Windows.Input.Key.Enter)
{
PasswordTextBox.KeyDown -= handleEnterKeyDown;
handleClick(null, null);
}
};
PasswordTextBox.KeyDown += handleEnterKeyDown;
}