Пример #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            { //delete when done
                int hour = DateTime.Now.Hour;
                int min = DateTime.Now.Minute;
                const int SEC = 0;
                TimeSpan NOW = new TimeSpan(hour, min, SEC);
                TimeSpan n = new TimeSpan(12, 40, 0);
                if (NOW >= n)
                {
                    ShutDown();
                }
            }

            lblError.Text = "";
            txtPassword.Focus();
            try
            {
                StreamReader sr = new StreamReader("config.txt");
                sr.Close();
            }
            catch (FileNotFoundException)
            {
                MessageBox.Show("Seems like this is the first time you've used this program, let's get you set up", "Restrictor~~~");
                CreateLogin dataCreation = new CreateLogin();
                dataCreation.ShowDialog();
                dataCreation.Focus();
            }
        }
Пример #2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            #region load password
            try
            {
                StreamReader sr = new StreamReader("config.txt");
                string textToEncrypt = sr.ReadToEnd();
                textToEncrypt = Encoding.Unicode.GetString(Convert.FromBase64String( textToEncrypt));
                string[] fileContents = textToEncrypt.Split('~');

                _userPW = fileContents[0];
                sr.Close();
            }
            catch (FileNotFoundException)
            {
                CreateLogin dataCreation = new CreateLogin();
                dataCreation.ShowDialog();
                dataCreation.Focus();
            }
            #endregion

            if (txtPassword.Text == _userPW)
            {
                System.Diagnostics.Process.Start("CMD.exe", CMD_CANCEL);
                MessageBox.Show("Welcome to Restrictor~~~", "Welcome");
                ControlForm ctrl = new ControlForm();
                lblError.Text = "";
                ctrl.ShowDialog();
            }
            else
            {
                lblError.Text = "Wrong password, good try";
                txtPassword.Focus();
            }
            txtPassword.Clear();
        }
Пример #3
0
 private void lnkChangePW_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     CreateLogin newPW = new CreateLogin();
     newPW.ShowDialog();
     //need to load streamreader/writer on button click event, instead of on load.
 }