Exemple #1
0
        public ReportViewModel(IStatisticProvider frametimeStatisticProvider,
                               IEventAggregator eventAggregator,
                               IAppConfiguration appConfiguration,
                               RecordManager recordManager,
                               ILogger <ReportViewModel> logger)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            _frametimeStatisticProvider = frametimeStatisticProvider;
            _eventAggregator            = eventAggregator;
            _appConfiguration           = appConfiguration;
            _recordManager = recordManager;
            _logger        = logger;

            CopyTableDataCommand                    = new DelegateCommand(OnCopyTableData);
            RemoveAllReportEntriesCommand           = new DelegateCommand(() => ReportInfoCollection.Clear());
            ReportInfoCollection.CollectionChanged += new NotifyCollectionChangedEventHandler
                                                          ((sender, eventArg) =>
            {
                HasNoReportItems = !ReportInfoCollection.Any();
            });

            InitializeReportParameters();
            SubscribeToSelectRecord();

            stopwatch.Stop();
            _logger.LogInformation(this.GetType().Name + " {initializationTime}s initialization time",
                                   Math.Round(stopwatch.ElapsedMilliseconds * 1E-03, 1));
        }
        private void OnCopyTableData()
        {
            if (!ReportInfoCollection.Any())
            {
                return;
            }

            StringBuilder builder = new StringBuilder();

            // Header
            var displayNameGame            = ReflectionExtensions.GetPropertyDisplayName <ReportInfo>(x => x.Game);
            var displayNameResolution      = ReflectionExtensions.GetPropertyDisplayName <ReportInfo>(x => x.Resolution);
            var displayNameDate            = ReflectionExtensions.GetPropertyDisplayName <ReportInfo>(x => x.Date);
            var displayNameTime            = ReflectionExtensions.GetPropertyDisplayName <ReportInfo>(x => x.Time);
            var displayNameNumberOfSamples = ReflectionExtensions.GetPropertyDisplayName <ReportInfo>(x => x.NumberOfSamples);
            var displayNameRecordTime      = ReflectionExtensions.GetPropertyDisplayName <ReportInfo>(x => x.RecordTime);
            var displayNameCpu             = ReflectionExtensions.GetPropertyDisplayName <ReportInfo>(x => x.Cpu);
            var displayNameGraphicCard     = ReflectionExtensions.GetPropertyDisplayName <ReportInfo>(x => x.GraphicCard);
            var displayNameRam             = ReflectionExtensions.GetPropertyDisplayName <ReportInfo>(x => x.Ram);
            var displayNameMaxFps          = ReflectionExtensions.GetPropertyDisplayName <ReportInfo>(x => x.MaxFps);
            var displayNameNinetyNinePercentQuantileFps = ReflectionExtensions.GetPropertyDisplayName <ReportInfo>(x => x.NinetyNinePercentQuantileFps);
            var displayNameNinetyFivePercentQuantileFps = ReflectionExtensions.GetPropertyDisplayName <ReportInfo>(x => x.NinetyFivePercentQuantileFps);
            var displayNameAverageFps                     = ReflectionExtensions.GetPropertyDisplayName <ReportInfo>(x => x.AverageFps);
            var displayNameMedianFps                      = ReflectionExtensions.GetPropertyDisplayName <ReportInfo>(x => x.MedianFps);
            var displayNameFivePercentQuantileFps         = ReflectionExtensions.GetPropertyDisplayName <ReportInfo>(x => x.FivePercentQuantileFps);
            var displayNameOnePercentQuantileFps          = ReflectionExtensions.GetPropertyDisplayName <ReportInfo>(x => x.OnePercentQuantileFps);
            var displayNameOnePercentLowAverageFps        = ReflectionExtensions.GetPropertyDisplayName <ReportInfo>(x => x.OnePercentLowAverageFps);
            var displayNameZeroDotTwoPercentQuantileFps   = ReflectionExtensions.GetPropertyDisplayName <ReportInfo>(x => x.ZeroDotTwoPercentQuantileFps);
            var displayNameZeroDotOnePercentQuantileFps   = ReflectionExtensions.GetPropertyDisplayName <ReportInfo>(x => x.ZeroDotOnePercentQuantileFps);
            var displayNameZeroDotOnePercentLowAverageFps = ReflectionExtensions.GetPropertyDisplayName <ReportInfo>(x => x.ZeroDotOnePercentLowAverageFps);
            var displayNameMinFps         = ReflectionExtensions.GetPropertyDisplayName <ReportInfo>(x => x.MinFps);
            var displayNameAdaptiveSTDFps = ReflectionExtensions.GetPropertyDisplayName <ReportInfo>(x => x.AdaptiveSTDFps);
            var displayNameCpuFpsPerWatt  = ReflectionExtensions.GetPropertyDisplayName <ReportInfo>(x => x.CpuFpsPerWatt);
            //var displayNameGpuFpsPerWatt = ReflectionExtensions.GetPropertyDisplayName<ReportInfo>(x => x.GpuFpsPerWatt);
            var displayNameCustomComment = ReflectionExtensions.GetPropertyDisplayName <ReportInfo>(x => x.CustomComment);

            builder.Append(displayNameGame + "\t" +
                           displayNameResolution + "\t" +
                           displayNameDate + "\t" +
                           displayNameTime + "\t" +
                           displayNameNumberOfSamples + "\t" +
                           displayNameRecordTime + "\t" +
                           displayNameCpu + "\t" +
                           displayNameGraphicCard + "\t" +
                           displayNameRam + "\t" +
                           displayNameMaxFps + "\t" +
                           displayNameNinetyNinePercentQuantileFps + "\t" +
                           displayNameNinetyFivePercentQuantileFps + "\t" +
                           displayNameAverageFps + "\t" +
                           displayNameMedianFps + "\t" +
                           displayNameFivePercentQuantileFps + "\t" +
                           displayNameOnePercentQuantileFps + "\t" +
                           displayNameOnePercentLowAverageFps + "\t" +
                           displayNameZeroDotTwoPercentQuantileFps + "\t" +
                           displayNameZeroDotOnePercentQuantileFps + "\t" +
                           displayNameZeroDotOnePercentLowAverageFps + "\t" +
                           displayNameMinFps + "\t" +
                           displayNameAdaptiveSTDFps + "\t" +
                           displayNameCpuFpsPerWatt + "\t" +
                           //displayNameGpuFpsPerWatt + "\t" +
                           displayNameCustomComment +
                           Environment.NewLine);

            var cultureInfo = CultureInfo.CurrentCulture;

            foreach (var reportInfo in ReportInfoCollection)
            {
                builder.Append(reportInfo.Game + "\t" +
                               reportInfo.Resolution + "\t" +
                               reportInfo.Date.ToString(cultureInfo) + "\t" +
                               reportInfo.Time.ToString(cultureInfo) + "\t" +
                               reportInfo.NumberOfSamples + "\t" +
                               reportInfo.RecordTime.ToString(cultureInfo) + "\t" +
                               reportInfo.Cpu + "\t" +
                               reportInfo.GraphicCard + "\t" +
                               reportInfo.Ram + "\t" +
                               reportInfo.MaxFps.ToString(cultureInfo) + "\t" +
                               reportInfo.NinetyNinePercentQuantileFps.ToString(cultureInfo) + "\t" +
                               reportInfo.NinetyFivePercentQuantileFps.ToString(cultureInfo) + "\t" +
                               reportInfo.AverageFps.ToString(cultureInfo) + "\t" +
                               reportInfo.MedianFps.ToString(cultureInfo) + "\t" +
                               reportInfo.FivePercentQuantileFps.ToString(cultureInfo) + "\t" +
                               reportInfo.OnePercentQuantileFps.ToString(cultureInfo) + "\t" +
                               reportInfo.OnePercentLowAverageFps.ToString(cultureInfo) + "\t" +
                               reportInfo.ZeroDotTwoPercentQuantileFps.ToString(cultureInfo) + "\t" +
                               reportInfo.ZeroDotOnePercentQuantileFps.ToString(cultureInfo) + "\t" +
                               reportInfo.ZeroDotOnePercentLowAverageFps.ToString(cultureInfo) + "\t" +
                               reportInfo.MinFps.ToString(cultureInfo) + "\t" +
                               reportInfo.AdaptiveSTDFps.ToString(cultureInfo) + "\t" +
                               reportInfo.CpuFpsPerWatt.ToString(cultureInfo) + "\t" +
                               //reportInfo.GpuFpsPerWatt.ToString(cultureInfo) + "\t" +
                               reportInfo.CustomComment +
                               Environment.NewLine);
            }

            Clipboard.SetDataObject(builder.ToString(), false);
        }
        public ReportViewModel(IStatisticProvider frametimeStatisticProvider,
                               IEventAggregator eventAggregator,
                               IAppConfiguration appConfiguration, RecordManager recordManager)
        {
            _frametimeStatisticProvider = frametimeStatisticProvider;
            _eventAggregator            = eventAggregator;
            _appConfiguration           = appConfiguration;
            _recordManager       = recordManager;
            CopyTableDataCommand = new DelegateCommand(OnCopyTableData);
            ReportInfoCollection.CollectionChanged += new NotifyCollectionChangedEventHandler
                                                          ((sender, eventArg) => HasNoReportItems = !ReportInfoCollection.Any());

            SubscribeToSelectRecord();
        }