private void AddComparisonItem(IFileRecordInfo recordInfo) { if (CheckListContains(recordInfo)) { MessageText = $"The list already contains this record and therefore cannot be inserted. " + $"Select a different record for the comparison."; MessageDialogContentIsOpen = true; return; } var comparisonRecordInfo = GetComparisonRecordInfoFromFileRecordInfo(recordInfo); var wrappedComparisonRecordInfo = GetWrappedRecordInfo(comparisonRecordInfo); // Insert into list (sorted) SetMetrics(wrappedComparisonRecordInfo); InsertComparisonRecordsSorted(wrappedComparisonRecordInfo); HasComparisonItems = ComparisonRecords.Any(); // Manage game name header HasUniqueGameNames = GetHasUniqueGameNames(); CurrentGameName = comparisonRecordInfo.Game; // Update height of bar chart control here UpdateBarChartHeight(); UpdateRangeSliderParameter(); //Draw charts and performance parameter UpdateCharts(); }
private bool CheckDataConsistency() { bool check = true; if (ComparisonModel == null) { return(false); } if (ComparisonRecords == null) { return(false); } if (ComparisonModel.Series == null) { return(false); } if (!ComparisonRecords.Any()) { check = false; } return(check); }
private bool CheckListContains(IFileRecordInfo recordInfo) { var recordInfoWrapper = ComparisonRecords .FirstOrDefault(info => info.WrappedRecordInfo.FileRecordInfo.Id == recordInfo.Id); return(recordInfoWrapper != null && ComparisonRecords.Any()); }
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(); } }
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); } }
private void UpdateRangeSliderParameter() { if (ComparisonRecords == null || !ComparisonRecords.Any()) { return; } MaxRecordingTime = double.MinValue; foreach (var record in ComparisonRecords) { if (record.WrappedRecordInfo.Session.Runs.SelectMany(r => r.CaptureData.TimeInSeconds).Last() > MaxRecordingTime) { MaxRecordingTime = record.WrappedRecordInfo.Session.Runs.SelectMany(r => r.CaptureData.TimeInSeconds).Last(); } } _doUpdateCharts = false; FirstSeconds = 0; LastSeconds = MaxRecordingTime; _doUpdateCharts = true; RemainingRecordingTime = ComparisonRecords.Any() ? Math.Round(MaxRecordingTime, 2).ToString(CultureInfo.InvariantCulture) + " s" : "0.0 s";; }
private void UpdateCuttingParameter() { if (ComparisonRecords == null || !ComparisonRecords.Any()) { return; } double minRecordingTime = double.MaxValue; _maxRecordingTime = double.MinValue; foreach (var record in ComparisonRecords) { if (record.WrappedRecordInfo.Session.FrameStart.Last() > _maxRecordingTime) { _maxRecordingTime = record.WrappedRecordInfo.Session.FrameStart.Last(); } if (record.WrappedRecordInfo.Session.FrameStart.Last() < minRecordingTime) { minRecordingTime = record.WrappedRecordInfo.Session.FrameStart.Last(); } } _doUpdateCharts = false; FirstSeconds = 0; LastSeconds = 0; _doUpdateCharts = true; CutLeftSliderMaximum = minRecordingTime / 2 - 0.5; CutRightSliderMaximum = minRecordingTime / 2 + _maxRecordingTime - minRecordingTime - 0.5; RemainingRecordingTime = ComparisonRecords.Any() ? Math.Round(_maxRecordingTime, 2).ToString(CultureInfo.InvariantCulture) + " s" : "0.0 s";; }
private void UpdateAxesMinMax(bool invalidatePlot) { if (ComparisonRecords == null || !ComparisonRecords.Any()) { return; } var xAxis = ComparisonModel.GetAxisOrDefault("xAxis", null); var yAxis = ComparisonModel.GetAxisOrDefault("yAxis", null); if (xAxis == null || yAxis == null) { return; } double xMin = 0; double xMax = 0; double yMin = 0; double yMax = 0; double startTime = FirstSeconds; double endTime = _maxRecordingTime - LastSeconds; var sessionParallelQuery = ComparisonRecords.Select(record => record.WrappedRecordInfo.Session).AsParallel(); xMin = sessionParallelQuery.Min(session => { return(session.GetFrametimePointsTimeWindow(startTime, endTime).First().X); }); xMax = sessionParallelQuery.Max(session => { return(session.GetFrametimePointsTimeWindow(startTime, endTime).Last().X); }); yMin = sessionParallelQuery.Min(session => { return(session.GetFrametimePointsTimeWindow(startTime, endTime).Min(pnt => pnt.Y));; }); yMax = sessionParallelQuery.Max(session => { return(session.GetFrametimePointsTimeWindow(startTime, endTime).Max(pnt => pnt.Y)); }); xAxis.Minimum = xMin; xAxis.Maximum = xMax; yAxis.Minimum = yMin - (yMax - yMin) / 6; yAxis.Maximum = yMax + (yMax - yMin) / 6; if (invalidatePlot) { ComparisonModel.InvalidatePlot(true); } }
private bool GetHasUniqueGameNames() { if (!ComparisonRecords.Any()) { return(false); } var firstName = ComparisonRecords.First().WrappedRecordInfo.Game; return(!ComparisonRecords.Any(record => record.WrappedRecordInfo.Game != firstName)); }
// partial void xyz -> initialize private void OnShowContextLegendChanged() { if (!ComparisonRecords.Any()) { return; } if (!IsContextLegendActive) { ComparisonModel.Series.ForEach(series => series.Title = null); } else { OnComparisonContextChanged(); } ComparisonModel.InvalidatePlot(true); }
// partial void xyz -> initialize private void OnShowContextLegendChanged() { if (!ComparisonRecords.Any()) { return; } if (!IsContextLegendActive) { ComparisonModel.Series.ForEach(series => series.Title = null); } else { switch (_selectedComparisonContext) { case EComparisonContext.DateTime: SetLabelDateTimeContext(); break; case EComparisonContext.CPU: SetLabelCpuContext(); break; case EComparisonContext.GPU: SetLabelGpuContext(); break; case EComparisonContext.SystemRam: SetLabelSystemRamContext(); break; case EComparisonContext.Custom: SetLabelCustomContext(); break; default: SetLabelDateTimeContext(); break; } } ComparisonModel.InvalidatePlot(true); }
public void RemoveComparisonItem(ComparisonRecordInfoWrapper wrappedComparisonRecordInfo) { _comparisonColorManager.FreeColor(wrappedComparisonRecordInfo.Color); ComparisonRecords.Remove(wrappedComparisonRecordInfo); HasComparisonItems = ComparisonRecords.Any(); UpdateRangeSliderParameter(); UpdateCharts(); UpdateBarChartHeight(); // Manage game name header HasUniqueGameNames = GetHasUniqueGameNames(); if (HasUniqueGameNames) { CurrentGameName = ComparisonRecords.First().WrappedRecordInfo.Game; } ComparisonFrametimesModel.InvalidatePlot(true); }
private void UpdateAxesMinMax() { if (ComparisonRecords == null || !ComparisonRecords.Any()) { return; } var xAxis = ComparisonModel.GetAxisOrDefault("xAxis", null); var yAxis = ComparisonModel.GetAxisOrDefault("yAxis", null); if (xAxis == null || yAxis == null) { return; } xAxis.Reset(); double xMin = 0; double xMax = 0; double yMin = 0; double yMax = 0; double startTime = FirstSeconds; double endTime = LastSeconds; var sessionParallelQuery = ComparisonRecords.Select(record => record.WrappedRecordInfo.Session).AsParallel(); xMin = sessionParallelQuery.Min(session => { var window = session.GetFrametimePointsTimeWindow(startTime, endTime, _appConfiguration); if (window.Any()) { return(window.First().X); } else { return(double.MaxValue); } }); xMax = sessionParallelQuery.Max(session => { var window = session.GetFrametimePointsTimeWindow(startTime, endTime, _appConfiguration); if (window.Any()) { return(window.Last().X); } else { return(double.MinValue); } }); yMin = sessionParallelQuery.Min(session => { var window = session.GetFrametimePointsTimeWindow(startTime, endTime, _appConfiguration); if (window.Any()) { return(window.Min(pnt => pnt.Y)); } else { return(double.MaxValue); } }); yMax = sessionParallelQuery.Max(session => { var window = session.GetFrametimePointsTimeWindow(startTime, endTime, _appConfiguration); if (window.Any()) { return(window.Max(pnt => pnt.Y)); } else { return(double.MinValue); } }); xAxis.Minimum = xMin; xAxis.Maximum = xMax; yAxis.Minimum = yMin - (yMax - yMin) / 6; yAxis.Maximum = yMax + (yMax - yMin) / 6; ComparisonModel.InvalidatePlot(true); }