/// <summary>
 /// Authenticates the user against Rally. This must be called from the UI thread.
 /// </summary>
 /// <param name="authenticationStateChange">The delegate to call when an authentication state change occurs.</param>
 /// <param name="ssoAuthenticationComplete">The delegate to call when an authentication state change occurs due to SSO.</param>
 /// <example>
 /// Opening the login window and passing the two delegates to it.
 /// <code language="C#">
 /// authMgr.ShowUserLoginWindow(authenticationStateChange, ssoAuthenticationComplete);
 /// </code>
 /// </example>
 public virtual void ShowUserLoginWindow(AuthenticationStateChange authenticationStateChange,
                                         SsoAuthenticationComplete ssoAuthenticationComplete)
 {
     AuthenticationStateChange = authenticationStateChange;
     SsoAuthenticationComplete = ssoAuthenticationComplete;
     ShowUserLoginWindowInternal();
 }
        /// <summary>
        /// Opens the window that displays the SSO URL to the user.
        /// </summary>
        protected override void ShowUserLoginWindowInternal()
        {
            if (Api.AuthenticationState == RallyRestApi.AuthenticationResult.PendingSSO)
            {
                PerformLogoutFromRally();
            }

            // If the login control exists, don't open a new one.
            if (loginControl == null)
            {
                loginControl = new LoginWindow();
                loginControl.BuildLayout(this);
                loginControl.Closed += loginControl_Closed;
                LoginWindowSsoAuthenticationComplete += loginControl.SsoAuthenticationComplete;
            }

            loginControl.SetLogo(logoForUi, iconForUi);
            loginControl.UpdateLoginState();

            if (WindowStateChanged != null)
            {
                WindowStateChanged.Invoke(WindowTypeOption.Login, WindowStateOption.Open);
            }

            loginControl.Show();
            loginControl.Focus();
        }
        void loginControl_Closed(object sender, EventArgs e)
        {
            if (WindowStateChanged != null)
            {
                WindowStateChanged.Invoke(WindowTypeOption.Login, WindowStateOption.Closed);
            }

            LoginWindowSsoAuthenticationComplete = null;
            loginControl = null;
        }
		/// <summary>
		/// Opens the window that displays the SSO URL to the user.
		/// </summary>
		protected override void ShowUserLoginWindowInternal()
		{
			// If the login control exists, don't open a new one.
			if (loginControl == null)
			{
				loginControl = new LoginWindow();
				loginControl.BuildLayout(this);
				loginControl.Closed += loginControl_Closed;
				LoginWindowSsoAuthenticationComplete += loginControl.SsoAuthenticationComplete;
			}

			loginControl.SetLogo(logoForUi);
			loginControl.SetFields();
			loginControl.UpdateLoginState();
			loginControl.Show();
			loginControl.Focus();
		}
        /// <summary>
        /// Opens the window that displays the SSO URL to the user.
        /// </summary>
        protected override void ShowUserLoginWindowInternal()
        {
            // If the login control exists, don't open a new one.
            if (loginControl == null)
            {
                loginControl = new LoginWindow();
                loginControl.BuildLayout(this);
                loginControl.Closed += loginControl_Closed;
                LoginWindowSsoAuthenticationComplete += loginControl.SsoAuthenticationComplete;
            }

            loginControl.SetLogo(logoForUi);
            loginControl.SetFields();
            loginControl.UpdateLoginState();
            loginControl.Show();
            loginControl.Focus();
        }
		void loginControl_Closed(object sender, EventArgs e)
		{
			LoginWindowSsoAuthenticationComplete = null;
			loginControl = null;
		}
		/// <summary>
		/// Authenticates the user against Rally. This must be called from the UI thread.
		/// </summary>
		/// <param name="authenticationStateChange">The delegate to call when an authentication state change occurs.</param>
		/// <param name="ssoAuthenticationComplete">The delegate to call when an authentication state change occurs due to SSO.</param>
		/// <example>
		/// Opening the login window and passing the two delegates to it.
		/// <code language="C#">
		/// authMgr.ShowUserLoginWindow(authenticationStateChange, ssoAuthenticationComplete);
		/// </code>
		/// </example>
		public virtual void ShowUserLoginWindow(AuthenticationStateChange authenticationStateChange,
			SsoAuthenticationComplete ssoAuthenticationComplete)
		{
			AuthenticationStateChange = authenticationStateChange;
			SsoAuthenticationComplete = ssoAuthenticationComplete;
			ShowUserLoginWindowInternal();
		}
 void loginControl_Closed(object sender, EventArgs e)
 {
     LoginWindowSsoAuthenticationComplete = null;
     loginControl = null;
 }
		void loginControl_Closed(object sender, EventArgs e)
		{
			if (WindowStateChanged != null)
				WindowStateChanged.Invoke(WindowTypeOption.Login, WindowStateOption.Closed);

			LoginWindowSsoAuthenticationComplete = null;
			loginControl = null;
		}
		/// <summary>
		/// Opens the window that displays the SSO URL to the user.
		/// </summary>
		protected override void ShowUserLoginWindowInternal()
		{
			if (Api.AuthenticationState == RallyRestApi.AuthenticationResult.PendingSSO)
				PerformLogoutFromRally();

			// If the login control exists, don't open a new one.
			if (loginControl == null)
			{
				loginControl = new LoginWindow();
				loginControl.BuildLayout(this);
				loginControl.Closed += loginControl_Closed;
				LoginWindowSsoAuthenticationComplete += loginControl.SsoAuthenticationComplete;
			}

			loginControl.SetLogo(logoForUi, iconForUi);
			loginControl.UpdateLoginState();

			if (WindowStateChanged != null)
				WindowStateChanged.Invoke(WindowTypeOption.Login, WindowStateOption.Open);

			loginControl.Show();
			loginControl.Focus();
		}