/* private void button1_Click_1(object sender, EventArgs e) * { * Average avg = new Average(); * LoadForm loadstats = new LoadForm(); * loadstats.openstats(); * } */ private void DarkThemeSwitch_CheckedChanged(object sender, EventArgs e) { FilePrep prep = new FilePrep(); IHashService hash; HashService.HashServiceClient client = new HashService.HashServiceClient(); if (client != null) { hash = new HashNonLocal(); } else { hash = new HashLocal(); } if (DarkThemeSwitch.Checked) { BackgroundImage = Properties.Resources.dark1; Properties.Settings.Default.ThemeDark = true; Properties.Settings.Default.Save(); prep.Write(Resource1.UserDataFile, user, hash); } else { BackgroundImage = Properties.Resources.dribbble; Properties.Settings.Default.ThemeDark = false; Properties.Settings.Default.Save(); prep.Write(Resource1.UserDataFile, user, hash); } }
private void LoginButton_Click(object sender, EventArgs e) { bool match = false; FilePrep prep = new FilePrep(); List <User> users = new List <User>(prep.ReadUser(Resource1.UserDataFile)); User user = new User(UsernameTextBox.Text, PasswordTextBox.Text); #if DEBUG HashCode hash = delegate(string pw) { return(HashPw(pw)); }; #endif #if DEBUG_SERVICE HashService.HashServiceClient client = new HashService.HashServiceClient(); HashCode hash = delegate(string pw) { return(client.HashPassword(pw)); }; #endif foreach (User u in users) { if (u.Username == user.Username && Int32.Parse(u.Password) == hash(user.Password)) { MainMenu menu = new MainMenu(u); match = true; menu.Show(); } } if (!match) { MessageBox.Show(Resource1.WrongLoginData); } }
private void Input_Load(object sender, EventArgs e) { FilePrep filePrep = new FilePrep(); bars = filePrep.Read(Resource1.FileName); foreach (Bar bar in bars) { comboBox1.Items.Add(bar.Name); } comboBox1.SelectedIndex = 0; panel2.Hide(); }
private void RegisterButton_Click(object sender, EventArgs e) { FilePrep prep = new FilePrep(); Lazy <List <User> > users = new Lazy <List <User> >(() => new List <User>(prep.ReadUser(Resource1.UserDataFile))); if (checkBox18.Checked) { if (PasswordTextBox.Text == RepeatPassword.Text) { bool match = false; User user = new User(usernameTextBox.Text, PasswordTextBox.Text); foreach (User u in users.Value) { if (u.Username.Equals(user.Username)) { MessageBox.Show(Resource1.UsernameTaken); match = true; break; } } if (!match) { IHashService hash; HashService.HashServiceClient client = new HashService.HashServiceClient(); if (client != null) { hash = new HashNonLocal(); } else { hash = new HashLocal(); } prep.Write(Resource1.UserDataFile, user, hash); MessageBox.Show(Resource1.UserCreated); Close(); } } else { MessageBox.Show(Resource1.PasswordsDontMatch); } } else { MessageBox.Show(Resource1.AgeDenied); } }
private void SaveToFile_Click(object sender, EventArgs e) { FilePrep filePrep = new FilePrep(); filePrep.Write(Resource1.FileName, bars); }