private void InsertComparisonRecordsSorted(ComparisonRecordInfoWrapper wrappedComparisonRecordInfo) { if (!ComparisonRecords.Any()) { ComparisonRecords.Add(wrappedComparisonRecordInfo); return; } var list = new List <ComparisonRecordInfoWrapper>(ComparisonRecords) { wrappedComparisonRecordInfo }; List <ComparisonRecordInfoWrapper> orderedList = null; if (UseComparisonGrouping) { orderedList = IsSortModeAscending ? list.OrderBy(x => x.WrappedRecordInfo.Game).ThenBy(x => x.WrappedRecordInfo.FirstMetric).ToList() : list.OrderBy(x => x.WrappedRecordInfo.Game).ThenByDescending(x => x.WrappedRecordInfo.FirstMetric).ToList(); } else { orderedList = IsSortModeAscending ? list.OrderBy(x => x.WrappedRecordInfo.FirstMetric).ToList() : list.OrderByDescending(x => x.WrappedRecordInfo.FirstMetric).ToList(); } if (orderedList != null) { var index = orderedList.IndexOf(wrappedComparisonRecordInfo); ComparisonRecords.Insert(index, wrappedComparisonRecordInfo); } }
public void SortComparisonItems() { if (!ComparisonRecords.Any()) { return; } IEnumerable <ComparisonRecordInfoWrapper> comparisonRecordList = null; if (UseComparisonGrouping) { comparisonRecordList = IsSortModeAscending ? ComparisonRecords.ToList() .Select(info => info.Clone()).OrderBy(x => x.WrappedRecordInfo.Game).ThenBy(x => x.WrappedRecordInfo.FirstMetric) : ComparisonRecords.ToList().Select(info => info.Clone()).OrderBy(x => x.WrappedRecordInfo.Game).ThenByDescending(x => x.WrappedRecordInfo.FirstMetric); } else { comparisonRecordList = IsSortModeAscending ? ComparisonRecords.ToList() .Select(info => info.Clone()).OrderBy(x => x.WrappedRecordInfo.FirstMetric) : ComparisonRecords.ToList().Select(info => info.Clone()).OrderByDescending(x => x.WrappedRecordInfo.FirstMetric); } if (comparisonRecordList != null) { ComparisonRecords.Clear(); foreach (var item in comparisonRecordList) { ComparisonRecords.Add(item); } //Draw charts and performance parameter UpdateCharts(); } }