/// <summary> /// Text changed in the destination path, validate it. /// </summary> private void TextBoxRepoPathTextChanged(object sender, EventArgs e) { // Target folder needs to be a valid directory, with or without files in it ClassUtils.DirStatType type = ClassUtils.DirStat(textBoxRepoPath.Text); btOK.Enabled = type == ClassUtils.DirStatType.Empty || type == ClassUtils.DirStatType.Nongit; // Additional checks for clone operations (where CheckTargetDirEmpty is true) if (CheckTargetDirEmpty) { // If the project name is specified, that complete path should not exist if (textBoxProjectName.Text.Trim().Length > 0) { btOK.Enabled &= ClassUtils.DirStat(Destination) == ClassUtils.DirStatType.Invalid; } } }
/// <summary> /// Check and refresh the view for each repo /// This method also enables the form's Close button if all repos are checked OK /// </summary> private void RefreshView() { list.Columns[1].Width = 75; bool enableClosing = true; foreach (ListViewItem item in list.Items) { ClassRepo repo = item.Tag as ClassRepo; item.Text = repo.Path; ClassUtils.DirStatType stat = ClassUtils.DirStat(repo.Path); switch (stat) { case ClassUtils.DirStatType.Invalid: item.SubItems[1].Text = "Non-existing"; enableClosing = false; item.SubItems[0].ForeColor = Color.Red; break; case ClassUtils.DirStatType.Empty: item.SubItems[1].Text = "Empty"; enableClosing = false; break; case ClassUtils.DirStatType.Git: item.SubItems[1].Text = "OK"; item.SubItems[0].ForeColor = Color.DarkOliveGreen; break; case ClassUtils.DirStatType.Nongit: item.SubItems[1].Text = "Non-empty"; enableClosing = false; break; } } btClose.Enabled = enableClosing; }