private void AddProfileButton(string profilename) { ProfileButton newProfileButton = new ProfileButton(profilename); profilePanel.Controls.Add(newProfileButton); ProfileButtons[profilename] = newProfileButton; newProfileButton.Click += profileButton_Clicked; SortProfileButtons(); }
private void RemoveProfileButton(string profilename) { ProfileButton profileButton = ProfileButtons[profilename]; if (profileButton == null) { return; } profilePanel.Controls.Remove(profileButton); ProfileButtons.Remove(profilename); }
private void loginForm_Callback(string password, ProfileButton button, Profile profile) { if (string.IsNullOrEmpty(password)) { return; } if (!profile.Login(password)) { MessageBox.Show("You entered an incorrect password."); return; } button.Image = Resources.unlocked_icon; SetActiveProfile(profile, button); }
private void profileButton_Clicked(Object sender, EventArgs e) { ProfileButton clickedButton = sender as ProfileButton; // Cast sender object to profile button Profile selectedProfile = _profiles[clickedButton.ProfileName]; // Get profile the button references // If user is not logged in to selected profile, prompt him for a password if (!selectedProfile.LoggedIn) { // I use a callback here with form.Show() instead of just using form.ShowDialog() because I want // the login form to close when you click the main form and with ShowDialog() that causes an // annoying dinging sound when the password input has focus LoginForm loginForm = new LoginForm(clickedButton, selectedProfile, loginForm_Callback); loginForm.Show(); return; } SetActiveProfile(selectedProfile, clickedButton); }
public LoginForm(ProfileButton parentButton, Profile profile, Action <string, ProfileButton, Profile> callback) { InitializeComponent(); passwordInput.Text = null; loggingIntoLabel.Text = "~\\Profiles>login " + profile.ProfileName; _Profile = profile; _Button = parentButton; Callback = callback; FormClosed += LoginForm_FormClosed; Point parentAbsolutePosition = parentButton.PointToScreen(Point.Empty); int x = parentAbsolutePosition.X + 227; int y = parentAbsolutePosition.Y; //loginButton.MouseLeave += loginButton_MouseLeave; //loginButton.MouseEnter += loginButton_MouseEnter; Location = new Point(x, y); passwordInput.PreviewKeyDown += passwordInput_PreviewKeyDown; Paint += Main_Paint; //loginButton.Click +=loginButton_Click; }
private void SetActiveProfile(Profile profile, ProfileButton button) { if (ActiveProfileButton != null) { ActiveProfileButton.BackColor = Color.Lime; // Set previous active button's color to default ActiveProfileButton.FlatAppearance.MouseOverBackColor = Color.LimeGreen; } accountsTable.Rows.Clear(); ActiveProfile = profile; foreach (Database.Account account in profile.GetAccounts()) { DisplayAccount(account.ServiceName, account.Username); } ActiveProfileButton = button; button.BackColor = Color.Gold; button.FlatAppearance.MouseOverBackColor = Color.Goldenrod; ActiveProfile = _profiles[button.ProfileName]; pageTabControl.SelectTab(accountPage); profileNameLabel.Text = profile.ProfileName; }