public void Sort(int columnIndex, bool descending, bool hideSortIcon) { base.ThrowIfShutdown("Sort"); int[] ids = this.DoSort(columnIndex, descending); SortListViewCommand command = new SortListViewCommand(); command.ColumnIndex = columnIndex; command.Descending = descending; command.HideSortIcon = hideSortIcon; if (base.Initialized) { ISnapInPlatform snapInPlatform = base.SnapIn.SnapInPlatform; if (snapInPlatform == null) { throw Microsoft.ManagementConsole.Internal.Utility.CreateClassNotInitializedException("MmcListView", "Sort"); } command.ViewInstanceId = base.ViewInstanceId; command.SetIds(ids); snapInPlatform.ProcessCommand(command); } else { this._pendingSortCommand = command; } this.OnSortCompleted(columnIndex, descending); }
internal override void InternalInitialize() { MmcListViewDescription viewDescription = base.ViewDescription as MmcListViewDescription; if (viewDescription == null) { throw new InvalidOperationException(Microsoft.ManagementConsole.Internal.Utility.FormatResourceString("Microsoft.ManagementConsole.ViewDescription.InvalidViewDescription", new object[] { "MmcListView", "MmcListViewDescription" })); } this._options = viewDescription.Options; if (this._mode != MmcListViewMode.Report) { this.SynchronizeMode(this._mode); } if (this._columns != null) { this.SynchronizeColumns(new MmcListViewColumn[] { this._columns[0] }, 0, ColumnCollectionChangeType.Modify); int length = this._columns.Count - 1; if (length > 0) { MmcListViewColumn[] sourceArray = this._columns.ToArray(); MmcListViewColumn[] destinationArray = new MmcListViewColumn[length]; Array.Copy(sourceArray, 1, destinationArray, 0, length); this.SynchronizeColumns(destinationArray, 1, ColumnCollectionChangeType.Add); } } if ((this._resultNodes != null) && (this._resultNodes.Count > 0)) { this.SynchronizeResultNodes(this.ResultNodes.ToArray(), 0, ResultNodeCollectionChangeType.Add); } if (this._pendingSortCommand != null) { bool descending = this._pendingSortCommand.Descending; int[] ids = new int[this.ResultNodes.Count]; for (int i = 0; i < this.ResultNodes.Count; i++) { int index = descending ? ((this.ResultNodes.Count - i) - 1) : i; ids[index] = this.ResultNodes[i].Id; } this._pendingSortCommand.ViewInstanceId = base.ViewInstanceId; this._pendingSortCommand.SetIds(ids); base.SnapIn.SnapInPlatform.ProcessCommand(this._pendingSortCommand); this._pendingSortCommand = null; } }