Exemplo n.º 1
0
        private void but_login_Click(object sender, EventArgs e)
        {
            if (!checkBox_remember.Checked)
            {
                try
                {
                    if (System.IO.File.Exists(path))
                    {
                        System.IO.File.Delete(path);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }

            access_key = text_sAPI_Key.Text;
            secret_key = text_sAPI_Secret.Text;
            ApiData apiData = new ApiData(access_key, secret_key);

            Program.Accesskey = access_key;
            Program.Secretkey = secret_key;
            int ret = apiData.checkApiKey();

            if (ret < 0)
            {
                MessageBox.Show("Invalid API key, check keys");
                return;
            }

            if (checkBox_remember.Checked)
            {
                try
                {
                    System.IO.File.WriteAllText(path, "");
                    System.IO.File.AppendAllText(path, text_sAPI_Key.Text + Environment.NewLine);
                    System.IO.File.AppendAllText(path, text_sAPI_Secret.Text + Environment.NewLine);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }

            isGood = true;
            Close();
        }