Inheritance: System.Windows.Controls.Control, INotifyPropertyChanged
 /// <summary>
 /// Initializes a new instance of the <see cref="SignInChallengeHandler"/> class.
 /// </summary>
 /// <param name="signInDialog">The underlying SignInDialog that will displayed inside a ContentDialog.</param>
 /// <exception cref="System.ArgumentNullException">signInDialog</exception>
 internal SignInChallengeHandler(SignInDialog signInDialog) // might be public
 {
     if (signInDialog == null)
         throw new ArgumentNullException("signInDialog");
     _signInDialog = signInDialog;
     CredentialSaveOption = CredentialSaveOption.Hidden; // default value
     SetSignInDialogCredentialSaveOption();
 }
Exemple #2
0
        private static Task <IdentityManager.Credential> DoSignInInUIThread(IdentityManager.CredentialRequestInfo credentialRequestInfo)
        {
            // Create the ChildWindow that contains the SignInDialog
            var childWindow = new Window
            {
                ShowInTaskbar         = false,
                WindowStartupLocation = WindowStartupLocation.CenterOwner,
                WindowStyle           = WindowStyle.ToolWindow,
                SizeToContent         = SizeToContent.WidthAndHeight,
                ResizeMode            = ResizeMode.NoResize,
                WindowState           = WindowState.Normal
            };

            if (Application.Current != null && Application.Current.MainWindow != null)
            {
                try
                {
                    childWindow.Owner = Application.Current.MainWindow;
                }
                catch
                {
                    // May fire an exception when used inside an excel or powerpoint addins
                }
            }

            DependencyProperty titleProperty = Window.TitleProperty;

            // Create the SignInDialog with the parameters given as arguments
            var signInDialog = new SignInDialog
            {
                Width = 300
            };

            childWindow.Content = signInDialog;

            // Bind the Title so the ChildWindow Title is the SignInDialog title (that will be initialized later)
            var binding = new Binding("Title")
            {
                Source = signInDialog
            };

            childWindow.SetBinding(titleProperty, binding);
            childWindow.Closed += (s, e) => signInDialog.Cancel();             // be sure the SignInDialog is deactivated when closing the childwindow using the X


            // initialize the task that gets the credential and then close the window
            var ts           = TaskScheduler.FromCurrentSynchronizationContext();
            var doSignInTask = signInDialog.GetCredentialAsync(credentialRequestInfo).ContinueWith(task =>
            {
                childWindow.Close();
                return(task.Result);
            }, ts);

            // Show the window
            childWindow.ShowDialog();

            return(doSignInTask);
        }
			internal CancelCommandImpl(SignInDialog signInDialog)
			{
				_signInDialog = signInDialog;
			}
			internal GenerateCredentialCommandImpl(SignInDialog signInDialog)
			{
				_signInDialog = signInDialog;
			}
		private static Task<IdentityManager.Credential> DoSignInInUIThread(IdentityManager.CredentialRequestInfo credentialRequestInfo)
		{
			// Create the ChildWindow that contains the SignInDialog
			var childWindow = new Window
			{
				ShowInTaskbar = false,
				WindowStartupLocation = WindowStartupLocation.CenterOwner,
				WindowStyle = WindowStyle.ToolWindow,
				SizeToContent = SizeToContent.WidthAndHeight,
				ResizeMode = ResizeMode.NoResize,
				WindowState = WindowState.Normal
			};

			if (Application.Current != null && Application.Current.MainWindow != null)
			{
				try
				{
					childWindow.Owner = Application.Current.MainWindow;
				}
				catch
				{
					// May fire an exception when used inside an excel or powerpoint addins
				}
			}

			DependencyProperty titleProperty = Window.TitleProperty;

			// Create the SignInDialog with the parameters given as arguments
			var signInDialog = new SignInDialog
			{
				Width = 300
			};

			childWindow.Content = signInDialog;

			// Bind the Title so the ChildWindow Title is the SignInDialog title (that will be initialized later)
			var binding = new Binding("Title") { Source = signInDialog };
			childWindow.SetBinding(titleProperty, binding);
			childWindow.Closed += (s, e) => signInDialog.Cancel(); // be sure the SignInDialog is deactivated when closing the childwindow using the X


			// initialize the task that gets the credential and then close the window
			var ts = TaskScheduler.FromCurrentSynchronizationContext();
			var doSignInTask = signInDialog.GetCredentialAsync(credentialRequestInfo).ContinueWith(task =>
			{
				childWindow.Close();
				return task.Result;
			}, ts); 

			// Show the window
			childWindow.ShowDialog();

			return doSignInTask;
		}
Exemple #6
0
 internal CancelCommandImpl(SignInDialog signInDialog)
 {
     _signInDialog = signInDialog;
 }
Exemple #7
0
 internal GenerateCredentialCommandImpl(SignInDialog signInDialog)
 {
     _signInDialog = signInDialog;
 }