public MainViewModel()
        {
            // Maps FPS to brushes for grid
            _heatProvider = new HeatProvider(0, 60);

            var testNameColumn = new DataGridTextColumn {
                Binding = new Binding("TestName"), Header = "Test Name"
            };

            _columns.Add(testNameColumn);

            // Gets the Charting Providers (which test groups to run)
            _chartProviders = TestSetup.GetChartProviders();

            // Create columns
            foreach (var chartingProvider in _chartProviders)
            {
                // On result, bind the cell background to output of _heatProvider;
                var resultBinding = new Binding("[" + chartingProvider.Name + "]")
                {
                    StringFormat = "N2"
                };

                var backgroundBinding = new Binding("[" + chartingProvider.Name + "]")
                {
                    Converter = new HeatConverter(_heatProvider)
                };

                var textBlock = new FrameworkElementFactory(typeof(TextBlock));
                textBlock.SetValue(TextBlock.MarginProperty, new Thickness(0));
                textBlock.SetValue(TextBlock.PaddingProperty, new Thickness(3));

                textBlock.SetBinding(TextBlock.BackgroundProperty, backgroundBinding);
                textBlock.SetBinding(TextBlock.TextProperty, resultBinding);
                var col = new DataGridTemplateColumn
                {
                    CellTemplate = new DataTemplate()
                    {
                        VisualTree = textBlock
                    },
                    Header = chartingProvider.Name
                };
                _columns.Add(col);
            }

            // Create test cases. We transpose the matrix of cases so they are performed in the order
            //   Test1    (1)Version1    (2)Version2    (3)Version3
            //   Test3    (4)Version1    (5)Version2    (6)Version3
            // to avoid problem of CPU heating causing throttling and later versions looking slower

            var allSpeedTests = _chartProviders.SelectMany(this.CreateTestCases).OrderBy(tc => tc.TestNumber);

            foreach (var speedTest in allSpeedTests)
            {
                _testQueue.Enqueue(speedTest);
            }
        }
예제 #2
0
 public HeatConverter(HeatProvider heatProvider)
 {
     _heatProvider = heatProvider;
 }