Ejemplo n.º 1
0
        // sort
        protected override void OnColumnHeaderMouseClick(DataGridViewCellMouseEventArgs e)
        {
            base.OnColumnHeaderMouseClick(e);
            try {
                if (AssetList == null)
                {
                    return;
                }
                if (e.ColumnIndex == prevSortCol_)
                {
                    sortAssending_ = !sortAssending_;
                }
                else
                {
                    sortAssending_ = true;
                    foreach (DataGridViewColumn col in Columns)
                    {
                        col.HeaderCell.SortGlyphDirection = SortOrder.None;
                    }
                }
                var sortOrder = sortAssending_ ? SortOrder.Ascending : SortOrder.Descending;
                Columns[e.ColumnIndex].HeaderCell.SortGlyphDirection = sortOrder;

                prevSortCol_ = e.ColumnIndex;


                if (e.ColumnIndex == cIncluded.Index)
                {
                    AssetList.SortItemsBy(item => item.IsIncludedPending, sortAssending_);
                }
                else if (e.ColumnIndex == cAssetID.Index)
                {
                    AssetList.SortItemsBy(item => item.PublishedFileId.AsUInt64, sortAssending_);
                }
                else if (e.ColumnIndex == cName.Index)
                {
                    AssetList.SortItemsBy(item => item.DisplayText, sortAssending_);
                }
                else if (e.ColumnIndex == cAuthor.Index)
                {
                    AssetList.SortItemsBy(item => item.Author, sortAssending_);
                }
                else if (e.ColumnIndex == cDateUpdated.Index)
                {
                    AssetList.SortItemsBy(item => item.DateUpdatedUTC, sortAssending_);
                }
                else if (e.ColumnIndex == cDateDownloaded.Index)
                {
                    AssetList.SortItemsBy(item => item.DateDownloadedUTC, sortAssending_);
                }
                else if (e.ColumnIndex == cTags.Index)
                {
                    AssetList.SortItemsBy(item => item.StrTags, sortAssending_);
                }
                else if (e.ColumnIndex == cStatus.Index)
                {
                    AssetList.SortItemsBy(item => item.SteamCache?.Status ?? default, sortAssending_);
                }

                Rows.Clear();
                AssetList.FilterItems();
                Refresh();
            } catch (Exception ex) {
                Log.Exception(ex);
            }
        }