示例#1
0
        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);
        }
示例#3
0
        public void AddUser(GitUser user)
        {
            ValidateGitUser(user);

            if (!Users.Contains(user))
            {
                Users.Add(user);
            }

            SaveToFile();
        }
示例#4
0
        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);
            }
        }
示例#5
0
        void SaveUser(GitUser user)
        {
            try
            {
                gitUserManager.AddUser(user);
            }
            catch (FileNotFoundException fnf)
            {
                MessageBox.Show(fnf.Message);
            }

            RefreshUsersListBox();
            InitializeGitUserEditForm(new NullGitUser());
        }
示例#6
0
        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;
        }
示例#7
0
        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();
            }
        }
示例#8
0
        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()));
 }
示例#10
0
 void ValidateGitUser(GitUser user)
 {
     user.SshKeyHash = fileHasher.HashFile(user.SshKeyPath);
 }
示例#11
0
 public void ConfigureForSingleUser(GitUser user)
 {
     MakeUserActive(user, isPairOrMob: false);
     ConfigureForActiveUsers();
 }
示例#12
0
 string GetEmailForConfig(GitUser primaryUser)
 {
     return(activeUsers.Any() ? string.Join(", ", activeUsers.Select(u => u.Email)) : primaryUser.Email);
 }
示例#13
0
 string GetNameForConfig(GitUser primaryUser)
 {
     return(activeUsers.Any() ? string.Join(", ", activeUsers.Select(u => u.Name)) : primaryUser.Name);
 }
示例#14
0
 bool IsActiveUser(GitUser user)
 {
     return(activeUsers.Contains(user));
 }
示例#15
0
 bool IsKnownUser(GitUser user)
 {
     return(Users.Contains(user));
 }
示例#16
0
 public void RemoveUser(GitUser user)
 {
     Users.Remove(user);
     SaveToFile();
 }