/// <summary> /// Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other. /// </summary> /// <param name="x">The first object to compare.</param> /// <param name="y">The second object to compare.</param> /// <returns> /// Value Condition Less than zero<paramref name="x"/> is less than <paramref name="y"/>.Zero<paramref name="x"/> equals <paramref name="y"/>.Greater than zero<paramref name="x"/> is greater than <paramref name="y"/>. /// </returns> protected virtual int Compare(ListViewItem x, ListViewItem y) { int n; if (x == null) { n = -1; } else if (y == null) { n = 1; } else if (_sorter != null) { n = _sorter.Compare(x, y); } else { SmartListViewItem sX = x as SmartListViewItem; SmartListViewItem sY = y as SmartListViewItem; string vX, vY; if (sX != null) { vX = sX.GetValue(AllColumnsIndex); } else if (Index >= 0 && Index < x.SubItems.Count) { vX = x.SubItems[Index].Text; } else { vX = null; } if (sY != null) { vY = sY.GetValue(AllColumnsIndex); } else if (Index >= 0 && Index < y.SubItems.Count) { vY = y.SubItems[Index].Text; } else { vY = null; } n = StringComparer.OrdinalIgnoreCase.Compare(vX, vY); } return(n); }
public void RefreshGroups() { if (DesignMode || VirtualMode || View != View.Details || !SupportsGrouping) { return; } bool inGroups = _inRefreshGroupsAvailable; try { _inRefreshGroupsAvailable = true; if (GroupColumns.Count == 0) { ShowGroups = false; foreach (ListViewGroup grp in Groups) { grp.Items.Clear(); } Groups.Clear(); _groups.Clear(); } else { foreach (ListViewItem i in Items) { i.Group = null; SmartListViewItem si = i as SmartListViewItem; if (si != null) { si.UpdateGroup(); } } FlushGroups(); } } finally { _inRefreshGroupsAvailable = inGroups; } }
protected internal virtual void UpdateGroup(SmartListViewItem item, string[] values) { if (VirtualMode) { return; // Not valid for virtual } StringBuilder sb = new StringBuilder(); foreach (SmartColumn col in GroupColumns) { int c = col.AllColumnsIndex; if (c < values.Length) { if (sb.Length > 0) { sb.Append(GroupSeparator); } sb.Append(values[c]); } } string g = sb.ToString(); if (item.Group != null && item.Group.Name == g) { return; // Nothing to do } item.Group = null; SmartGroup group = (SmartGroup)Groups[g]; if (group == null) { string txt = string.IsNullOrEmpty(g) ? "<Rest>" : g; group = new SmartGroup(this, g, txt); _groups.Add(group, group); Groups.Clear(); Groups.AddRange(new List <ListViewGroup>(_groups.Values).ToArray()); } group.Items.Add(item); RefreshGroupsAvailable(); }
public void SetInfo(List<SvnWorkingCopy> wcs, List<List<PendingChange>> pcs) { wcList.Items.Clear(); for (int i = 0; i < wcs.Count; i++) { SmartListViewItem lvi = new SmartListViewItem(wcList); SvnWorkingCopy wc = wcs[i]; Uri wcRoot = wc.RepositoryRoot; lvi.SetValues( wc.FullPath, pcs[i].Count.ToString(), wcRoot != null ? wcRoot.ToString() : ""); lvi.Checked = (i == 0); lvi.Tag = new List<PendingChange>(pcs[i]); wcList.Items.Add(lvi); } }