2 using System
.Collections
.Generic
;
3 using System
.ComponentModel
;
7 using System
.Windows
.Forms
;
12 public partial class CommitTable
: UserControl
14 protected Commit m_lastCommitInPage
;
15 protected Stack
<Commit
> m_topCommits
= new Stack
<Commit
>();
16 protected Repo m_currentRepo
;
20 InitializeComponent();
23 public void SetRepo(Repo repo
)
26 m_fetchCommits
.Enabled
= true;
27 m_commitsView
.Items
.Clear();
28 m_previousCommits
.Enabled
= false;
29 m_nextCommits
.Enabled
= false;
31 m_lastCommitInPage
= null;
34 private void OnFetchCommits(object sender
, EventArgs e
)
37 if (!m_currentRepo
.GetLog(null, 100, out commits
))
39 MessageBox
.Show("Could not get commits.", "Error", MessageBoxButtons
.OK
, MessageBoxIcon
.Error
);
43 m_topCommits
.Push(commits
[0]);
44 FillCommitList(commits
);
47 private void FillCommitList(List
<Commit
> commits
)
49 m_commitsView
.BeginUpdate();
50 m_commitsView
.Items
.Clear();
51 foreach (Commit c
in commits
)
53 ListViewItem i
= new ListViewItem(new string[] { c.ID, c.AuthorName, c.AuthorEmail, c.Date, c.Subject }
);
55 m_commitsView
.Items
.Add(i
);
57 if (commits
.Count
> 0)
59 m_lastCommitInPage
= commits
[commits
.Count
- 1];
61 m_previousCommits
.Enabled
= m_nextCommits
.Enabled
= commits
.Count
!= 0;
62 if (m_commitsView
.Items
.Count
!= 100)
64 m_nextCommits
.Enabled
= false;
66 if (m_topCommits
.Count
< 2)
68 m_previousCommits
.Enabled
= false;
71 m_commitsView
.EndUpdate();
74 private void OnPreviousCommits(object sender
, EventArgs e
)
77 Commit c
= m_topCommits
.Pop();
78 if (!m_currentRepo
.GetLog(m_topCommits
.Peek(), 100, out commits
))
80 m_nextCommits
.Enabled
= false;
83 if (commits
.Count
< 1)
85 m_previousCommits
.Enabled
= false;
89 FillCommitList(commits
);
93 private void OnNextCommits(object sender
, EventArgs e
)
96 if (!m_currentRepo
.GetLog(m_lastCommitInPage
, 100, out commits
))
98 m_nextCommits
.Enabled
= false;
101 if (commits
.Count
< 1)
103 m_nextCommits
.Enabled
= false;
107 m_topCommits
.Push(commits
[0]);
108 FillCommitList(commits
);
112 private void OnShowCommit(object sender
, EventArgs e
)
114 ListView
.SelectedListViewItemCollection items
= m_commitsView
.SelectedItems
;
115 if (items
.Count
== 1)
117 CommitViewer c
= new CommitViewer((Commit
)items
[0].Tag
);