示例#1
0
        private void AddProfileButton(string profilename)
        {
            ProfileButton newProfileButton = new ProfileButton(profilename);

            profilePanel.Controls.Add(newProfileButton);
            ProfileButtons[profilename] = newProfileButton;
            newProfileButton.Click     += profileButton_Clicked;
            SortProfileButtons();
        }
示例#2
0
        private void RemoveProfileButton(string profilename)
        {
            ProfileButton profileButton = ProfileButtons[profilename];

            if (profileButton == null)
            {
                return;
            }
            profilePanel.Controls.Remove(profileButton);
            ProfileButtons.Remove(profilename);
        }
示例#3
0
 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);
 }
示例#4
0
        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);
        }
示例#5
0
        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;
        }
示例#6
0
 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;
 }