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
;
18 public ListView
.SelectedListViewItemCollection SelectedItems { get { return m_commitsView.SelectedItems; }
}
20 protected Treeish m_treeish
;
21 public Treeish Treeish { get { return m_treeish; }
set { m_treeish = value; }
}
25 InitializeComponent();
28 public void SetRepo(Repo repo
)
31 m_fetchCommits
.Enabled
= true;
32 m_commitsView
.Items
.Clear();
33 m_previousCommits
.Enabled
= false;
34 m_nextCommits
.Enabled
= false;
36 m_lastCommitInPage
= null;
39 private void OnFetchCommits(object sender
, EventArgs e
)
44 public void RepopulateTable()
47 if (!m_currentRepo
.GetLog(m_treeish
, 100, out commits
))
49 MessageBox
.Show("Could not get commits.", "Error", MessageBoxButtons
.OK
, MessageBoxIcon
.Error
);
53 m_topCommits
.Push(commits
[0]);
54 FillCommitList(commits
);
57 private void FillCommitList(List
<Commit
> commits
)
59 m_commitsView
.BeginUpdate();
60 m_commitsView
.Items
.Clear();
61 foreach (Commit c
in commits
)
63 ListViewItem i
= new ListViewItem(new string[] { c.ID, c.AuthorName, c.AuthorEmail, c.Date, c.Subject }
);
65 m_commitsView
.Items
.Add(i
);
67 if (commits
.Count
> 0)
69 m_lastCommitInPage
= commits
[commits
.Count
- 1];
71 m_previousCommits
.Enabled
= m_nextCommits
.Enabled
= commits
.Count
!= 0;
72 if (m_commitsView
.Items
.Count
!= 100)
74 m_nextCommits
.Enabled
= false;
76 if (m_topCommits
.Count
< 2)
78 m_previousCommits
.Enabled
= false;
81 m_commitsView
.EndUpdate();
84 private void OnPreviousCommits(object sender
, EventArgs e
)
87 Commit c
= m_topCommits
.Pop();
88 if (!m_currentRepo
.GetLog(m_topCommits
.Peek(), 100, out commits
))
90 m_nextCommits
.Enabled
= false;
93 if (commits
.Count
< 1)
95 m_previousCommits
.Enabled
= false;
99 FillCommitList(commits
);
103 private void OnNextCommits(object sender
, EventArgs e
)
105 List
<Commit
> commits
;
106 if (!m_currentRepo
.GetLog(m_lastCommitInPage
, 100, out commits
))
108 m_nextCommits
.Enabled
= false;
111 if (commits
.Count
< 1)
113 m_nextCommits
.Enabled
= false;
117 m_topCommits
.Push(commits
[0]);
118 FillCommitList(commits
);
122 private void OnShowCommit(object sender
, EventArgs e
)
124 ListView
.SelectedListViewItemCollection items
= m_commitsView
.SelectedItems
;
125 if (items
.Count
== 1)
127 CommitViewer c
= new CommitViewer((Commit
)items
[0].Tag
);