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();
        }
Example #2
0
        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";;
        }
        public void RemoveAllComparisonItems(bool manageVisibility = true, bool resetSortMode = false)
        {
            if (resetSortMode)
            {
                _comparisonColorManager.FreeAllColors();
            }

            ComparisonRecords.Clear();
            UpdateCharts();

            if (resetSortMode)
            {
                IsSortModeAscending = false;
            }

            if (manageVisibility)
            {
                HasComparisonItems = false;
            }

            // Manage game name header
            HasUniqueGameNames = false;
            CurrentGameName    = string.Empty;

            RemainingRecordingTime = "0.0 s";
            UpdateRangeSliderParameter();
            ComparisonFrametimesModel.InvalidatePlot(true);
        }
Example #4
0
        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 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);
            }
        }
Example #6
0
        private void SetLabelCustomContext()
        {
            if (!CheckDataConsistency())
            {
                return;
            }

            ComparisonRowChartLabels = ComparisonRecords.Select(record =>
            {
                return(GetLabelCustomContext(record, GetMaxCommentAlignment()));
            }).Reverse().ToArray();

            if (IsContextLegendActive)
            {
                if (ComparisonModel.Series.Count == ComparisonRecords.Count)
                {
                    for (int i = 0; i < ComparisonRecords.Count; i++)
                    {
                        var wrappedComparisonInfo = ComparisonRecords[i];
                        var chartTitle            = wrappedComparisonInfo.WrappedRecordInfo.FileRecordInfo.Comment;
                        ComparisonModel.Series[i].Title = chartTitle;
                    }
                }
            }
        }
        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 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 OnComparisonContextChanged()
        {
            ChartLabel[] GetLabels()
            {
                return(ComparisonRecords.Select(record => GetChartLabel(record.WrappedRecordInfo)).ToArray());
            }

            void SetLabels(ChartLabel[] labels)
            {
                ComparisonRowChartLabels = labels.Select(label => GetHasUniqueGameNames() ? label.Context : $"{label.GameName}{Environment.NewLine}{label.Context}").Reverse().ToArray();

                if (IsContextLegendActive)
                {
                    if (ComparisonModel.Series.Count == ComparisonRecords.Count)
                    {
                        for (int i = 0; i < ComparisonRecords.Count; i++)
                        {
                            ComparisonModel.Series[i].Title = labels[i].Context;
                        }
                    }
                }
            }

            if (ComparisonModel == null)
            {
                InitializePlotModel();
            }
            SetLabels(GetLabels());
            ComparisonModel.InvalidatePlot(true);
        }
        private bool CheckListContains(IFileRecordInfo recordInfo)
        {
            var recordInfoWrapper = ComparisonRecords
                                    .FirstOrDefault(info => info.WrappedRecordInfo.FileRecordInfo.Id == recordInfo.Id);

            return(recordInfoWrapper != null && ComparisonRecords.Any());
        }
Example #11
0
        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));
        }
Example #13
0
        private int GetMaxDateTimeAlignment()
        {
            bool hasUniqueGameNames = GetHasUniqueGameNames();

            if (hasUniqueGameNames)
            {
                return(ComparisonRecords.Max(record => record.WrappedRecordInfo.DateTime.Length));
            }
            else
            {
                var maxGameNameLength = ComparisonRecords.Max(record => record.WrappedRecordInfo.Game.Length);
                var maxDateTimeLength = ComparisonRecords.Max(record => record.WrappedRecordInfo.DateTime.Length);

                return(Math.Max(maxGameNameLength, maxDateTimeLength));
            }
        }
Example #14
0
        private int GetMaxGpuAlignment()
        {
            bool hasUniqueGameNames = GetHasUniqueGameNames();

            if (hasUniqueGameNames)
            {
                return(ComparisonRecords.Max(record
                                             => record.WrappedRecordInfo.FileRecordInfo.GraphicCardName.SplitWordWise(PART_LENGTH).Max(part => part.Length)));
            }
            else
            {
                var maxGameNameLength = ComparisonRecords.Max(record => record.WrappedRecordInfo.Game.Length);
                var maxGpuLength      = ComparisonRecords.Max(record
                                                              => record.WrappedRecordInfo.FileRecordInfo.GraphicCardName.SplitWordWise(PART_LENGTH).Max(part => part.Length));

                return(Math.Max(maxGameNameLength, maxGpuLength));
            }
        }
        // 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);
        }
        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 SubscribeToUpdateRecordInfos()
        {
            _eventAggregator.GetEvent <PubSubEvent <ViewMessages.UpdateRecordInfos> >()
            .Subscribe(msg =>
            {
                if (_useEventMessages)
                {
                    var recordInfoWrapper = ComparisonRecords
                                            .FirstOrDefault(info => info.WrappedRecordInfo
                                                            .FileRecordInfo.Id == msg.RecordInfo.Id);

                    if (recordInfoWrapper != null)
                    {
                        RemoveComparisonItem(recordInfoWrapper);
                        AddComparisonItem(msg.RecordInfo);
                    }
                }
            });
        }
Example #18
0
        // 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);
        }
        void IDropTarget.Drop(IDropInfo dropInfo)
        {
            if (dropInfo != null)
            {
                if (dropInfo.VisualTarget is FrameworkElement frameworkElement)
                {
                    if (frameworkElement.Name == "ComparisonRecordItemControl" ||
                        frameworkElement.Name == "ComparisonImage")
                    {
                        if (dropInfo.Data is IFileRecordInfo recordInfo)
                        {
                            AddComparisonItem(recordInfo);
                        }

                        if (dropInfo.Data is ComparisonRecordInfoWrapper wrappedRecordInfo)
                        {
                            // manage sorting
                            int currentIndex = ComparisonRecords.IndexOf(wrappedRecordInfo);

                            if (dropInfo.InsertIndex < ComparisonRecords.Count)
                            {
                                ComparisonRecords.Move(currentIndex, dropInfo.InsertIndex);

                                foreach (var rowSeries in ComparisonRowChartSeriesCollection)
                                {
                                    var chartValueList = (rowSeries.Values as IList <double>).Reverse().ToList();
                                    chartValueList.Move(currentIndex, dropInfo.InsertIndex);
                                    chartValueList.Reverse();
                                    rowSeries.Values.Clear();
                                    rowSeries.Values.AddRange(chartValueList.Select(chartValue => chartValue as object));
                                }

                                var labelList = ComparisonRowChartLabels.Reverse().ToList();
                                labelList.Move(currentIndex, dropInfo.InsertIndex);
                                labelList.Reverse();
                                ComparisonRowChartLabels = labelList.ToArray();
                            }
                        }
                    }
                }
            }
        }
        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);
        }