void DeleteButton_Click(object sender, EventArgs e) { GitUser userToDelete = GetSelectedGitUser(); if (userToDelete != null) { gitUserManager.RemoveUser(userToDelete); RefreshUsersListBox(); } }
internal string GetIconFilePathForUser(GitUser gitUser) { var fileName = string.Format("./{0}.jpg", gravatarUrlBuilder.HashEmail(gitUser.Email)); if (!fileHandler.DoesFileExist(fileName)) { iconDownloader.DownloadIcon(gravatarUrlBuilder.GetUrlForEmail(gitUser.Email), fileName); } return(fileName); }
public void AddUser(GitUser user) { ValidateGitUser(user); if (!Users.Contains(user)) { Users.Add(user); } SaveToFile(); }
public void MakeUserActive(GitUser user, bool isPairOrMob) { if (!isPairOrMob || user is NullGitUser) { activeUsers.Clear(); } if (!(user is NullGitUser) && IsKnownUser(user) && !IsActiveUser(user)) { activeUsers.Add(user); } }
void SaveUser(GitUser user) { try { gitUserManager.AddUser(user); } catch (FileNotFoundException fnf) { MessageBox.Show(fnf.Message); } RefreshUsersListBox(); InitializeGitUserEditForm(new NullGitUser()); }
void UpdateCurrentUserFromFrom() { var name = NameTextBox.Text.Trim(); var email = EmailTextBox.Text.Trim(); var sshKeyPath = SshKeyFileTextBox.Text; if (currentUser is NullGitUser) { currentUser = new GitUser(name, email, sshKeyPath); } currentUser.Name = name; currentUser.Email = email; currentUser.SshKeyPath = sshKeyPath; }
void InitializeGitUserEditForm(GitUser user) { currentUser = user; NameTextBox.Text = currentUser.Name; EmailTextBox.Text = currentUser.Email; SshKeyFileTextBox.Text = currentUser.SshKeyPath; SaveButton.Text = currentUser is NullGitUser ? "Save New User" : "Update User"; ErrorsLabel.Text = ""; if (currentUser is NullGitUser) { UsersListBox.ClearSelected(); } }
List <string> GetValidationErrors(GitUser user) { var validationErrors = new List <string>(); if (string.IsNullOrEmpty(user.Name)) { validationErrors.Add("You must provide a name"); } if (string.IsNullOrEmpty(user.Email)) { validationErrors.Add("You must provide an email"); } if (string.IsNullOrEmpty(user.SshKeyPath)) { validationErrors.Add("You must select an SSH key file"); } return(validationErrors); }
public Icon GetIconForUser(GitUser gitUser) { return(Icon.FromHandle(new Bitmap(GetIconFilePathForUser(gitUser)).GetHicon())); }
void ValidateGitUser(GitUser user) { user.SshKeyHash = fileHasher.HashFile(user.SshKeyPath); }
public void ConfigureForSingleUser(GitUser user) { MakeUserActive(user, isPairOrMob: false); ConfigureForActiveUsers(); }
string GetEmailForConfig(GitUser primaryUser) { return(activeUsers.Any() ? string.Join(", ", activeUsers.Select(u => u.Email)) : primaryUser.Email); }
string GetNameForConfig(GitUser primaryUser) { return(activeUsers.Any() ? string.Join(", ", activeUsers.Select(u => u.Name)) : primaryUser.Name); }
bool IsActiveUser(GitUser user) { return(activeUsers.Contains(user)); }
bool IsKnownUser(GitUser user) { return(Users.Contains(user)); }
public void RemoveUser(GitUser user) { Users.Remove(user); SaveToFile(); }