예제 #1
0
        void SortByMultipleColumns(IList <TreeViewItem> rows)
        {
            var sortedColumns = multiColumnHeader.state.sortedColumns;

            if (sortedColumns.Length == 0)
            {
                return;
            }

            var columnAscending = new bool[sortedColumns.Length];

            for (var i = 0; i < sortedColumns.Length; i++)
            {
                columnAscending[i] = multiColumnHeader.IsSortedAscending(sortedColumns[i]);
            }

            var root  = new ItemTree(null, m_Desc);
            var stack = new Stack <ItemTree>();

            stack.Push(root);
            foreach (var row in rows)
            {
                var r = row as IssueTableItem;
                if (r == null)
                {
                    continue;
                }

                var activeParentDepth = stack.Peek().Depth;

                while (row.depth <= activeParentDepth)
                {
                    stack.Pop();
                    activeParentDepth = stack.Peek().Depth;
                }

                if (row.depth > activeParentDepth)
                {
                    var t = new ItemTree(r, m_Desc);
                    stack.Peek().AddChild(t);
                    stack.Push(t);
                }
            }

            root.Sort(sortedColumns, columnAscending);

            // convert back to rows
            var newRows = new List <TreeViewItem>(rows.Count);

            root.ToList(newRows);
            rows.Clear();
            foreach (var treeViewItem in newRows)
            {
                rows.Add(treeViewItem);
            }
        }
예제 #2
0
        void SortByMultipleColumns(IList <TreeViewItem> rows)
        {
            int[] sortedColumns = multiColumnHeader.state.sortedColumns;
            if (sortedColumns.Length == 0)
            {
                return;
            }

            bool[] columnAscending = new bool[sortedColumns.Length];
            for (int i = 0; i < sortedColumns.Length; i++)
            {
                columnAscending[i] = multiColumnHeader.IsSortedAscending(sortedColumns[i]);
            }

            ItemTree         root  = new ItemTree(null);
            Stack <ItemTree> stack = new Stack <ItemTree>();

            stack.Push(root);
            foreach (TreeViewItem row in rows)
            {
                ConformObjectTreeViewItem r = row as ConformObjectTreeViewItem;
                if (r == null)
                {
                    continue;
                }
                int activeParentDepth = stack.Peek().Depth;

                while (row.depth <= activeParentDepth)
                {
                    stack.Pop();
                    activeParentDepth = stack.Peek().Depth;
                }

                if (row.depth > activeParentDepth)
                {
                    ItemTree t = new ItemTree(r);
                    stack.Peek().AddChild(t);
                    stack.Push(t);
                }
            }

            root.Sort(sortedColumns, columnAscending);

            // convert back to rows
            List <TreeViewItem> newRows = new List <TreeViewItem>(rows.Count);

            root.ToList(newRows);
            rows.Clear();
            foreach (TreeViewItem treeViewItem in newRows)
            {
                rows.Add(treeViewItem);
            }
        }