Пример #1
0
 public void SetOrToggleSortColumn(string columnName)
 {
     if (SortColumns.ContainsKey(columnName))
     {
         SortColumns[columnName] = SortColumns[columnName].Toggle();
     }
     else
     {
         SortColumns.Clear();
         SortColumns.Add(columnName, SortDirection.Ascending());
     }
 }
Пример #2
0
        protected override void OnColumnClick(ColumnClickEventArgs e)
        {
            if (!DesignMode && View == View.Details && !VirtualMode)
            {
                ColumnHeader column = Columns[e.Column];

                SmartColumn sc = column as SmartColumn;
                if (sc != null && sc.Sortable)
                {
                    bool extend = (Control.ModifierKeys & Keys.Control) != 0;

                    if (!extend)
                    {
                        if (SortColumns.Count == 1 && SortColumns[0] == sc)
                        {
                            sc.ReverseSort = !sc.ReverseSort;
                        }
                        else
                        {
                            SortColumns.Clear();
                            SortColumns.Add(sc);
                            sc.ReverseSort = false;
                        }
                    }
                    else
                    {
                        if (SortColumns.Contains(sc))
                        {
                            sc.ReverseSort = !sc.ReverseSort;
                        }
                        else
                        {
                            sc.ReverseSort = false;
                            SortColumns.Add(sc);
                        }
                    }
                    Sort();
                    UpdateSortGlyphs();
                }
            }
            base.OnColumnClick(e);
        }
Пример #3
0
        private void InitializeColumns()
        {
            AllColumns.Clear();
            SortColumns.Clear();
            Columns.Clear();
            _nameColumn = new SmartColumn(this, "&Name", characterWidth * NameColumnNumberOfCharacters, "Name");
            SmartColumn modified       = new SmartColumn(this, "&Modified", characterWidth * 15, "Modified");
            SmartColumn type           = new SmartColumn(this, "&Type", characterWidth * 20, "Type");
            SmartColumn change         = new SmartColumn(this, "&Change", characterWidth * 15, "Change");
            SmartColumn locked         = new SmartColumn(this, "&Locked", characterWidth * 8, "Locked");
            SmartColumn revision       = new SmartColumn(this, "&Revision", characterWidth * 8, "Revision");
            SmartColumn lastChangeTime = new SmartColumn(this, "Last C&hange", characterWidth * 20, "LastChange");
            SmartColumn lastRev        = new SmartColumn(this, "Last Re&vision", characterWidth * 8, "LastRevision");
            SmartColumn lastAuthor     = new SmartColumn(this, "Last &Author", characterWidth * 8, "LastAuthor");
            SmartColumn contStatus     = new SmartColumn(this, "&Content Status", characterWidth * 15, "ContentStatus");
            SmartColumn propStatus     = new SmartColumn(this, "&Property Status", characterWidth * 15, "PropertyStatus");
            SmartColumn isCopied       = new SmartColumn(this, "C&opied", characterWidth * 6, "Copied");
            SmartColumn isConficted    = new SmartColumn(this, "Co&nflicted", characterWidth * 6, "Conflicted");
            SmartColumn fullPath       = new SmartColumn(this, "Fu&ll Path", characterWidth * 60, "FullPath");

            _nameColumn.Sorter = new SortWrapper(
                delegate(FileSystemListViewItem x, FileSystemListViewItem y)
            {
                if (x.IsDirectory ^ y.IsDirectory)
                {
                    return(x.IsDirectory ? -1 : 1);
                }

                return(StringComparer.OrdinalIgnoreCase.Compare(x.Text, y.Text));
            });

            modified.Sorter = new SortWrapper(
                delegate(FileSystemListViewItem x, FileSystemListViewItem y)
            {
                return(x.Modified.CompareTo(y.Modified));
            });

            lastChangeTime.Sorter = new SortWrapper(
                delegate(FileSystemListViewItem x, FileSystemListViewItem y)
            {
                return(x.SvnItem.Status.LastChangeTime.CompareTo(y.SvnItem.Status.LastChangeTime));
            });

            AllColumns.Add(_nameColumn);
            AllColumns.Add(modified);
            AllColumns.Add(type);
            AllColumns.Add(change);
            AllColumns.Add(locked);
            AllColumns.Add(revision);
            AllColumns.Add(lastChangeTime);
            AllColumns.Add(lastRev);
            AllColumns.Add(lastAuthor);
            AllColumns.Add(contStatus);
            AllColumns.Add(propStatus);
            AllColumns.Add(isCopied);
            AllColumns.Add(isConficted);
            AllColumns.Add(fullPath);

            Columns.AddRange(
                new ColumnHeader[]
            {
                _nameColumn,
                modified,
                type,
                change,
                locked,
                revision
            });

            SortColumns.Add(_nameColumn);
            FinalSortColumn = _nameColumn;
            UpdateSortGlyphs();
        }