public GitLogListView(GitLogListViewOwner owner) : base(owner) { this.owner = owner; this.Columns.Clear(); this.Columns.AddRange(new ColumnHeader[] { new ColumnHeader() { Text = "Change", Width = 100, }, new ColumnHeader() { Text = "Date", Width = 150, }, new ColumnHeader() { Text = "Author", Width = 250, }, new ColumnHeader() { Text = "Comment", Width = 650, }, }); this.HeaderStyle = ColumnHeaderStyle.Nonclickable; this.contextMenuItems = new ToolStripMenuItem[] { new ToolStripMenuItem("&Diff File", null, ContextMenu_DiffCommit, Keys.Control | Keys.D), new ToolStripMenuItem("Diff with &Head", null, ContextMenu_DiffCommitWithHead, Keys.Control | Keys.H), new ToolStripMenuItem("Diff &Entire Commit", null, ContextMenu_DiffEntireCommit, Keys.Control | Keys.E), new ToolStripMenuItem("&Diff Commit", null, ContextMenu_DiffCommit, Keys.Control | Keys.D), new ToolStripMenuItem("&View Commit", null, ContextMenu_ViewCommit, Keys.Control | Keys.O), new ToolStripMenuItem("&Copy", null, ContextMenu_Copy, Keys.Control | Keys.C), new ToolStripMenuItem("Copy Commit &ID", null, ContextMenu_CopyID, Keys.None), new ToolStripMenuItem("Filter by &Author", null, ContextMenu_FilterByAuthor, Keys.Control | Keys.U), new ToolStripMenuItem("Filter &from Date", null, ContextMenu_FilterFromDate, Keys.Control | Keys.F), new ToolStripMenuItem("Filter &to Date", null, ContextMenu_FilterToDate, Keys.Control | Keys.T), new ToolStripMenuItem("AutoFit Column &Width", null, ContextMenu_AutoFitColumnWidth, Keys.None), new ToolStripMenuItem("Cancel Filter by Author", null, ContextMenu_CancelFilterByAuthor, Keys.Control | Keys.Shift | Keys.U), new ToolStripMenuItem("Cancel Filter from Date", null, ContextMenu_CancelFilterFromDate, Keys.Control | Keys.Shift | Keys.F), new ToolStripMenuItem("Cancel Filter to Date", null, ContextMenu_CancelFilterToDate, Keys.Control | Keys.Shift | Keys.T), }; this.ContextMenuStrip.Items.Clear(); this.ContextMenuStrip.Items.AddRange(this.contextMenuItems); this.ContextMenuStrip.Opening += ContextMenuStrip_Opening; this.DoubleClick += Lv_DoubleClick; this.KeyDown += Lv_KeyDown; this.Disposed += Lv_Disposed; }
public GitLogForm(Repository repo, string path) { InitializeComponent(); var gitLog = new GitLog(repo, path, Constants.MaxCommits); var logOwner = new GitLogListViewOwner(gitLog); var logListView = new GitLogListView(logOwner); this.listView = logListView; this.statusStrip = new StatusStrip(); this.commitCountLabel = new ToolStripStatusLabel(); this.searchBox = new ToolStripTextBox(); this.authorLabel = new ToolStripStatusLabel(); this.fromDateLabel = new ToolStripStatusLabel(); this.toDateLabel = new ToolStripStatusLabel(); this.fillerLabel = new ToolStripStatusLabel(); this.branchComboBox = new ToolStripComboBox(); this.statusStrip.SuspendLayout(); SuspendLayout(); this.Text += $" {path}"; this.Width = 1200; this.Height = 600; this.KeyPreview = true; this.KeyDown += GitLogForm_KeyDown; this.listView.Dock = DockStyle.Fill; this.listView.ListSizeChanged += ListView_ListSizeChanged; this.listView.FilteringByAuthor += ListView_FilteringByAuthor; this.listView.FilteringFromDate += ListView_FilteringFromDate; this.listView.FilteringToDate += ListView_FilteringToDate; this.statusStrip.Items.Add(this.commitCountLabel); this.statusStrip.Items.Add(this.searchBox); this.statusStrip.Items.Add(this.authorLabel); this.statusStrip.Items.Add(this.fromDateLabel); this.statusStrip.Items.Add(this.toDateLabel); this.statusStrip.Items.Add(this.fillerLabel); this.statusStrip.Items.Add(this.branchComboBox); this.statusStrip.TabStop = true; this.statusStrip.ShowItemToolTips = true; this.commitCountLabel.AutoSize = false; this.commitCountLabel.Size = new Size(150, 20); this.commitCountLabel.TextAlign = ContentAlignment.MiddleLeft; this.commitCountLabel.BorderSides = ToolStripStatusLabelBorderSides.Right; this.commitCountLabel.BorderStyle = Border3DStyle.Etched; this.authorLabel.Size = new Size(180, 16); this.authorLabel.ToolTipText = Constants.AuthorLabelToolTipText; this.authorLabel.AutoToolTip = true; this.authorLabel.Click += AuthorLabel_Click; this.fromDateLabel.Size = new Size(150, 16); this.fromDateLabel.ToolTipText = Constants.FromDateLabelToolTipText; this.fromDateLabel.AutoToolTip = true; this.fromDateLabel.Click += FromDateLabel_Click; this.toDateLabel.Size = new Size(150, 16); this.toDateLabel.ToolTipText = Constants.ToDateLabelToolTipText; this.toDateLabel.AutoToolTip = true; this.toDateLabel.Click += ToDateLabel_Click; this.fillerLabel.Spring = true; this.branchComboBox.Size = new Size(240, 16); this.branchComboBox.AutoSize = true; this.branchComboBox.DropDownStyle = ComboBoxStyle.DropDownList; this.branchComboBox.FlatStyle = FlatStyle.Standard; this.branchComboBox.Padding = new Padding(0, 0, 20, 0); this.branchComboBox.Items.AddRange(gitLog.GetLocalBranchNames(out this.selectedBranchIndex)); this.branchComboBox.SelectedIndex = this.selectedBranchIndex; this.branchComboBox.SelectedIndexChanged += BranchComboBox_SelectedIndexChanged; this.searchBox.AutoSize = false; this.searchBox.Font = new Font(Constants.ListViewFontName, 8); this.searchBox.Size = new Size(180, 16); this.searchBox.Padding = new Padding(10, 0, 0, 0); this.searchBox.AutoCompleteMode = AutoCompleteMode.Append; this.searchBox.AutoCompleteSource = AutoCompleteSource.CustomSource; this.searchBox.MaxLength = Constants.SearchBoxMaxLength; this.searchBox.TextBox.SetCueText(Constants.SearchBoxCueText); this.searchBox.TextChanged += SearchBox_TextChanged; this.searchBox.KeyDown += SearchBox_KeyDown; this.searchBox.TextBox.PreviewKeyDown += TextBox_PreviewKeyDown; this.searchBoxTimer = new Timer(); this.searchBoxTimer.Tick += SearchBoxTimer_Tick; this.searchBoxTimer.Interval = Constants.SearchBoxTimerInterval; this.Controls.Add(this.listView); this.Controls.Add(this.statusStrip); this.statusStrip.ResumeLayout(false); this.statusStrip.PerformLayout(); ResumeLayout(false); PerformLayout(); }