Cancel() 개인적인 메소드

private Cancel ( ) : void
리턴 void
예제 #1
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);
        }
		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;
		}
예제 #3
0
 public void Execute(object parameter)
 {
     _signInDialog.Cancel();
 }