private void checkComboboxCommitsOrder(bool shouldReorderRightCombobox) { if (comboBoxLeftCommit.SelectedItem == null || comboBoxRightCommit.SelectedItem == null) { return; } // Left combobox cannot select a commit older than in right combobox (replicating gitlab web ui behavior) CommitComboBoxItem leftItem = (CommitComboBoxItem)(comboBoxLeftCommit.SelectedItem); CommitComboBoxItem rightItem = (CommitComboBoxItem)(comboBoxRightCommit.SelectedItem); Debug.Assert(leftItem.TimeStamp.HasValue); if (rightItem.TimeStamp.HasValue) { // Check if order is broken if (leftItem.TimeStamp.Value <= rightItem.TimeStamp.Value) { if (shouldReorderRightCombobox) { comboBoxRightCommit.SelectedIndex = comboBoxLeftCommit.SelectedIndex; } else { comboBoxLeftCommit.SelectedIndex = comboBoxRightCommit.SelectedIndex; } } } else { // It is ok because a commit w/o timestamp is the oldest one } }
private void addCommitsToComboBoxes(List <Commit> commits, string baseSha, string targetBranch) { var latest = new CommitComboBoxItem(commits[0]) { IsLatest = true }; comboBoxLeftCommit.Items.Add(latest); for (int i = 1; i < commits.Count; i++) { CommitComboBoxItem item = new CommitComboBoxItem(commits[i]); if (comboBoxLeftCommit.Items.Cast <CommitComboBoxItem>().Any(x => x.SHA == item.SHA)) { continue; } comboBoxLeftCommit.Items.Add(item); comboBoxRightCommit.Items.Add(item); } // Add target branch to the right combo-box CommitComboBoxItem targetBranchItem = new CommitComboBoxItem(baseSha, targetBranch + " [Base]", null); comboBoxRightCommit.Items.Add(targetBranchItem); comboBoxLeftCommit.SelectedIndex = 0; comboBoxRightCommit.SelectedIndex = 0; }
private static void setCommitComboboxTooltipText(ComboBox comboBox, ToolTip tooltip) { if (comboBox.SelectedItem == null) { tooltip.SetToolTip(comboBox, String.Empty); return; } CommitComboBoxItem item = (CommitComboBoxItem)(comboBox.SelectedItem); string timestampText = String.Empty; if (item.TimeStamp != null) { timestampText = String.Format("({0})", item.TimeStamp.Value.ToLocalTime().ToString()); } string tooltipText = String.Format("{0} {1} {2}", item.Text, timestampText, (item.IsLatest ? "[Latest]" : String.Empty)); tooltip.SetToolTip(comboBox, tooltipText); }
private static void formatCommitComboboxItem(ListControlConvertEventArgs e) { CommitComboBoxItem item = (CommitComboBoxItem)(e.ListItem); e.Value = item.Text + (item.IsLatest ? " [Latest]" : String.Empty); }