/// <summary>
    /// Handles the Click event of the btnOk control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="EventArgs"/> instance containing the
    /// event data.</param>
    private void btnOk_Click(object sender, EventArgs e) {
      string clientId = txtClientID.Text.Trim();
      if (string.IsNullOrEmpty(clientId)) {
        MessageBox.Show("Client ID cannot be empty.");
        return;
      }

      string clientSecret = txtClientSecret.Text.Trim();
      if (string.IsNullOrEmpty(clientSecret)) {
        MessageBox.Show("Client Secret cannot be empty.");
        return;
      }

      if (chkScopes.SelectedItems.Count == 0) {
        MessageBox.Show("You should select at least one scope.");
        return;
      }

      StringBuilder scopeBuilder = new StringBuilder();
      for (int i = 0; i < chkScopes.SelectedItems.Count; i++) {
        scopeBuilder.Append(scopeMap[chkScopes.SelectedItems[i].ToString()] + " ");
      }

      LoginForm loginForm = new LoginForm(clientId, clientSecret, scopeBuilder.ToString().Trim());
      loginForm.ShowDialog();
    }
    /// <summary>
    /// Handles the Click event of the btnOk control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="EventArgs"/> instance containing the
    /// event data.</param>
    private void btnOk_Click(object sender, EventArgs e) {
      string clientId = txtClientID.Text.Trim();
      if (string.IsNullOrEmpty(clientId)) {
        MessageBox.Show("Client ID cannot be empty.");
        return;
      }

      string clientSecret = txtClientSecret.Text.Trim();
      if (string.IsNullOrEmpty(clientSecret)) {
        MessageBox.Show("Client Secret cannot be empty.");
        return;
      }

      List<string> allScopes = new List<string>();
      for (int i = 0; i < chkScopes.SelectedItems.Count; i++) {
        allScopes.Add(scopeMap[chkScopes.SelectedItems[i].ToString()]);
      }

      string[] additionalScopes = txtExtraScopes.Text.Split(new char[] { '\r', '\n' }, 
          StringSplitOptions.RemoveEmptyEntries);

      foreach (string additionalScope in additionalScopes) {
        if (!string.IsNullOrWhiteSpace(additionalScope)) {
          allScopes.Add(additionalScope);
        }
      }

      if (allScopes.Count == 0) {
        MessageBox.Show("You should select at least one scope.");
        return;
      }

      LoginForm loginForm = new LoginForm(clientId, clientSecret, string.Join(" ", allScopes));
      loginForm.ShowDialog();
    }