private void bNext_Click(object sender, EventArgs e)
 {
     if (content.Controls[0] is OAuth2IntroPanel)
     {
         // We are on the first page. Move to the next one.
         content.Controls.Clear();
         bNext.Enabled = false; // Disable the next button as long as no code has been entered.
         var nextPanel = new OAuth2CodePanel(this, AuthorizationUri);
         nextPanel.OnAuthorizationCodeChanged += (textBox, eventArgs) =>
         {
             bNext.Enabled =
                 !string.IsNullOrEmpty(nextPanel.AuthorizationCode);
         };
         nextPanel.OnValidAuthorizationCode += bNext_Click;
         nextPanel.OnAuthorizationError     +=
             (exception, eventArgs) => OnAuthenticationError(exception as Exception);
         content.Controls.Add(nextPanel);
     }
     else if (content.Controls[0] is OAuth2CodePanel)
     {
         AuthorizationCode = ((OAuth2CodePanel)content.Controls[0]).AuthorizationCode;
         Close();
     }
 }
 private void bNext_Click(object sender, EventArgs e)
 {
     if (content.Controls[0] is OAuth2IntroPanel)
     {
         // We are on the first page. Move to the next one.
         content.Controls.Clear();
         bNext.Enabled = false; // Disable the next button as long as no code has been entered.
         var nextPanel = new OAuth2CodePanel(this, AuthorizationUri);
         nextPanel.OnAuthorizationCodeChanged += (textBox, eventArgs) =>
                                                     {
                                                         bNext.Enabled =
                                                             !string.IsNullOrEmpty(nextPanel.AuthorizationCode);
                                                     };
         nextPanel.OnValidAuthorizationCode += bNext_Click;
         nextPanel.OnAuthorizationError +=
             (exception, eventArgs) => OnAuthenticationError(exception as Exception);
         content.Controls.Add(nextPanel);
     }
     else if (content.Controls[0] is OAuth2CodePanel)
     {
         AuthorizationCode = ((OAuth2CodePanel) content.Controls[0]).AuthorizationCode;
         Close();
     }
 }