Пример #1
0
 private void btnClose_Click(object sender, EventArgs e)
 {
     Settings settings = new Settings();
     // if settings.Load fails, there are no settings saved for this application. The user will still be able to set them from frmMain but until then they will be unable to access the API.
     if (!settings.Load())
     {
         if (MessageBox.Show("Close without valid settings?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) ==
             DialogResult.No) { return; }
     }
     Close();
 }
Пример #2
0
 private void frmMain_Load(object sender, EventArgs e)
 {
     ClearFeedback();
     EnableFormButtons(false);
     btnLogin.Enabled = false;
     settings = new Settings();
     if (!settings.Load())
     {
         SetSettings();
     }
     else
     {
         btnLogin.Enabled = true;
     }
 }
Пример #3
0
        private bool IsValid(out Settings settings)
        {
            settings = new Settings();
            string testGuid;
            // client id
            if (string.IsNullOrEmpty(txtClientId.Text))
            {
                ShowFeedback("Missing Client Id");
                txtClientId.Focus();
                return false;
            }

            settings.ClientId = txtClientId.Text;

            // client secret
            if (string.IsNullOrEmpty(txtClientSecret.Text))
            {
                ShowFeedback("Missing Client Secret");
                txtClientId.Focus();
                return false;
            }

            settings.ClientSecret = txtClientSecret.Text;

            // redirect Uri
            if (string.IsNullOrEmpty(txtRedirect.Text))
            {
                ShowFeedback("Missing Redirect Uri");
                txtClientSecret.Focus();
                return false;
            }
            try
            {
                settings.RedirectUri = new Uri(txtRedirect.Text);
            }
            catch (UriFormatException ex)
            {
                ShowFeedback(ex.Message);
                txtRedirect.Focus();
                return false;
            }

            settings.Environment = (WebAPIEnvironment)Enum.Parse(typeof(WebAPIEnvironment), cboEnvironment.SelectedItem.ToString());

            return true;
        }
Пример #4
0
        private void frmSettings_Load(object sender, EventArgs e)
        {
            cboEnvironment.DataSource = Enum.GetNames(typeof(WebAPIEnvironment));

            Settings settings = new Settings();
            if (settings.Load())
            {
                txtClientId.Text = settings.ClientId.ToString();
                txtClientSecret.Text = settings.ClientSecret.ToString();
                txtRedirect.Text = settings.RedirectUri.ToString();
                cboEnvironment.SelectedItem = cboEnvironment.Items.OfType<WebAPIEnvironment>().First(env => env == settings.Environment);
            }
            else
            {
                ShowFeedback("These settings must be saved before using the application.");
                cboEnvironment.SelectedIndex = 1; // default to staging
            }
        }
Пример #5
0
 public frmLogin(Settings settings)
 {
     InitializeComponent();
     this.settings = settings;
 }