Basic Commit viewer.
[Widgit.git] / RepoManager.cs
blob36f9b1baac6d379072fd4c16e249a3674db6324a
1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Drawing;
6 using System.Text;
7 using System.Windows.Forms;
9 namespace Gitrdone
11 public partial class RepoManager : Form
13 internal Prefs m_prefs;
14 protected List<string> m_paths;
16 internal RepoManager(Prefs prefs)
18 InitializeComponent();
19 m_prefs = prefs;
20 m_paths = new List<string>();
21 foreach (string path in m_prefs.Repos)
23 m_paths.Add(path);
25 m_paths.Sort();
26 m_pathsList.Items.AddRange(m_paths.ToArray());
29 private void button1_Click(object sender, EventArgs e)
31 DialogResult r = m_folderChooser.ShowDialog();
32 if (r == DialogResult.OK)
34 if (!Git.Repo.ValidateRepo(m_folderChooser.SelectedPath))
36 MessageBox.Show("The location does not appear to be a git repository.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
38 else if (m_paths.Contains(m_folderChooser.SelectedPath))
40 MessageBox.Show("You have already added " + m_folderChooser.SelectedPath + " to your repositories list",
41 "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
43 else
45 m_paths.Add(m_folderChooser.SelectedPath);
46 m_prefs.Repos.Clear();
47 foreach (string s in m_paths)
49 m_prefs.Repos.Add(s);
51 m_prefs.Save();
52 m_pathsList.Items.Clear();
53 m_pathsList.Items.AddRange(m_paths.ToArray());
58 private void button2_Click(object sender, EventArgs e)
60 if (m_pathsList.SelectedIndex > -1)
62 m_paths.Remove(m_pathsList.SelectedItem.ToString());
63 m_prefs.Repos.Remove(m_pathsList.SelectedItem.ToString());
64 m_prefs.Save();
65 m_pathsList.Items.Remove(m_pathsList.SelectedItem);
69 private void button3_Click(object sender, EventArgs e)
71 Close();