Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using TestAutoLoginAndRememberMe.Properties;
- namespace TestAutoLoginAndRememberMe
- {
- public partial class Form1 : Form
- {
- public static void ShowForm1()
- {
- }
- public Form1()
- {
- InitializeComponent();
- }
- private void startupSetup()
- {
- textBox1.Text = Settings.Default.userName;
- textBox2.Text = Settings.Default.password;
- checkBox1.Checked = Settings.Default.rememberMe;
- checkBox2.Checked = Settings.Default.autoSignIn;
- }
- private void button1_Click(object sender, EventArgs e)
- {
- //if login is ok
- login();
- startupSetup();
- }
- private void login()
- {
- setupLoginOptions();
- Form2 f2 = new Form2();
- f2.form1 = this;
- f2.Show();
- Hide();
- }
- private void setupLoginOptions()
- {
- Settings.Default.rememberMe = (checkBox1.Checked) ? true : false;
- Settings.Default.autoSignIn = (checkBox2.Checked) ? true : false;
- if(Settings.Default.autoSignIn)
- {
- Settings.Default.userName = textBox1.Text;
- Settings.Default.password = textBox2.Text;
- }
- else if(Settings.Default.rememberMe)
- {
- Settings.Default.userName = textBox1.Text;
- Settings.Default.password = "";
- }
- else
- {
- Settings.Default.userName = "";
- Settings.Default.password = "";
- }
- Settings.Default.Save();
- }
- private void Form1_Shown(object sender, EventArgs e)
- {
- startupSetup();
- if (checkBox2.Checked && textBox1.TextLength > 0 && textBox2.TextLength > 0)
- login();
- }
- }
- }
Add Comment
Please, Sign In to add comment