示例#1
0
        private void MakeRuler()
        {
            ruler = new UniformGrid {
                Rows = 1, VerticalAlignment = VerticalAlignment.Top, HorizontalAlignment = HorizontalAlignment.Left
            };
            ruler.SetValue(Panel.ZIndexProperty, 999);

            var wholeSeconds = Math.Floor(vm.DurationMilliseconds / 1000);

            for (var x = 0; x < wholeSeconds; x++)
            {
                for (var x2 = 0; x2 < 9; x2++)
                {
                    ruler.Children.Add(new Line {
                        Margin = new Thickness(-1, 0, -1, 0), VerticalAlignment = VerticalAlignment.Top, StrokeEndLineCap = PenLineCap.Triangle, HorizontalAlignment = HorizontalAlignment.Right, Stroke = new SolidColorBrush(Colors.Gray), Y2 = 3, StrokeThickness = 2
                    });
                }

                var theSecondMarker = new StackPanel {
                    Margin = new Thickness(-1, 0, -1, 0)
                };
                theSecondMarker.Children.Add(new Line {
                    VerticalAlignment = VerticalAlignment.Top, StrokeEndLineCap = PenLineCap.Triangle, HorizontalAlignment = HorizontalAlignment.Right, Stroke = new SolidColorBrush(Colors.Black), Y2 = 8, StrokeThickness = 4
                });
                theSecondMarker.Children.Add(new TextBlock {
                    VerticalAlignment = VerticalAlignment.Top, HorizontalAlignment = HorizontalAlignment.Right, FontSize = 9, Text = $"{x + 1}"
                });
                ruler.Children.Add(theSecondMarker);
            }

            var    rem  = vm.DurationMilliseconds % 1000;
            double todo = Math.Ceiling(rem / 100);

            for (int x = 0; x < todo; x++)
            {
                ruler.Children.Add(new Line {
                    Margin = new Thickness(-1, 0, -1, 0), VerticalAlignment = VerticalAlignment.Top, StrokeEndLineCap = PenLineCap.Triangle, HorizontalAlignment = HorizontalAlignment.Right, Stroke = new SolidColorBrush(Colors.Gray), Y2 = 3, StrokeThickness = 2
                });
            }

            mainGrid.Children.Add(ruler);
        }
示例#2
0
 public static void SetItemWidth(UniformGrid grid, double value)
 {
     grid.SetValue(ItemWidthProperty, value);
 }
        public void MakeTable(int count)
        {
            Brush color1 = (Brush)(new BrushConverter()).ConvertFromString("#FFD2D9F1");
            Brush color2 = (Brush)(new BrushConverter()).ConvertFromString("#FF96AFF4");
            Brush color3 = (Brush)(new BrushConverter()).ConvertFromString("#FFF2EFFF");


            Label[]   cellNames = new Label[count];
            TextBox[] cells     = new TextBox[count * count];

            UniformGrid CellNamesCol = new UniformGrid()
            {
                Name = "CellNamesCol", Rows = count, Columns = 1
            };

            CellNamesCol.SetValue(Grid.ColumnProperty, 0);
            CellNamesCol.SetValue(Grid.RowProperty, 1);

            UniformGrid CellNamesRow = new UniformGrid()
            {
                Name = "CellNamesRow", Rows = 1, Columns = count
            };

            CellNamesRow.SetValue(Grid.ColumnProperty, 1);
            CellNamesRow.SetValue(Grid.RowProperty, 0);

            UniformGrid Cells = new UniformGrid()
            {
                Name = "Cells", Rows = count, Columns = count
            };

            Cells.SetValue(Grid.ColumnProperty, 1);
            Cells.SetValue(Grid.RowProperty, 1);

            for (int i = 0; i < count; i++)
            {
                cellNames[i] = new Label()
                {
                    VerticalContentAlignment   = VerticalAlignment.Center,
                    HorizontalContentAlignment = HorizontalAlignment.Center,
                    BorderThickness            = new Thickness(3),
                    Foreground  = Brushes.White,
                    FontWeight  = FontWeights.Bold,
                    BorderBrush = color1,
                    Background  = color2
                };
                cellNames[i].Content = i + 1;
                CellNamesCol.Children.Add(cellNames[i]);
            }

            for (int i = 0; i < count; i++)
            {
                cellNames[i] = new Label()
                {
                    VerticalContentAlignment   = VerticalAlignment.Center,
                    HorizontalContentAlignment = HorizontalAlignment.Center,
                    BorderThickness            = new Thickness(3),
                    Foreground  = Brushes.White,
                    FontWeight  = FontWeights.Bold,
                    BorderBrush = color1,
                    Background  = color2
                };
                cellNames[i].Content = i + 1;
                CellNamesRow.Children.Add(cellNames[i]);
            }

            for (int i = 0; i < count * count; i++)
            {
                cells[i] = new TextBox()
                {
                    VerticalContentAlignment   = VerticalAlignment.Center,
                    HorizontalContentAlignment = HorizontalAlignment.Center,
                    BorderThickness            = new Thickness(3),
                    FontWeight    = FontWeights.Bold,
                    FontSize      = 14,
                    Padding       = new Thickness(0, 13, 0, 0),
                    TextAlignment = TextAlignment.Center,
                    BorderBrush   = color1,
                    Background    = color3
                };
                Cells.Children.Add(cells[i]);
            }



            MainGrid.Children.Add(CellNamesCol);
            MainGrid.Children.Add(CellNamesRow);
            MainGrid.Children.Add(Cells);
        }
示例#4
0
        public void StartDrawData(SimulationResultsDictionary dictionary)
        {
            DataContainer.Children.Clear();
            DataContainer.ColumnDefinitions.Clear();

            if (currentDictionary != null)
            {
                currentDictionary.newValueReceived -= new simulationResultsDictionaryNewValueReceived(dictionary_NewValueReceived);
            }
            dictionary.newValueReceived += new simulationResultsDictionaryNewValueReceived(dictionary_NewValueReceived);
            currentDictionary            = dictionary;

            int column = 0;
            int j;
            FrameworkElement caption;

            traceGrids.Clear();
            foreach (KeyValuePair <BenchmarkInfo, int> benchmarkAndIndex in dictionary.BenchmarksWithIndices)
            {
                UniformGrid traceGrid = new UniformGrid();
                traceGrid.HorizontalAlignment = HorizontalAlignment.Stretch;
                traceGrid.Columns             = dictionary.Predictors.Count + 2;
                traceGrid.Rows   = 1;
                traceGrid.Margin = new Thickness(2);
                traceGrid.Children.Add(new Border());

                foreach (KeyValuePair <PredictorInfo, int> predictorAndIndex in dictionary.PredictorsWithIndices)
                {
                    traceGrid.Children.Add(getNewIndividualColumn(0, predictorAndIndex.Value, predictorAndIndex.Key.description));
                }
                traceGrid.SetValue(Grid.ColumnProperty, column);

                DataContainer.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = SimpleStarLength
                });
                DataContainer.Children.Add(traceGrid);
                traceGrids.Add(traceGrid);

                caption = getNewCaption(benchmarkAndIndex.Key.benchmarkName);
                caption.SetValue(Grid.ColumnProperty, column);
                caption.SetValue(Grid.RowProperty, 3);
                DataContainer.Children.Add(caption);

                column++;
            }

            amGrid = new UniformGrid();
            amGrid.HorizontalAlignment = HorizontalAlignment.Stretch;
            amGrid.Columns             = dictionary.Predictors.Count + 2;
            amGrid.Rows   = 1;
            amGrid.Margin = new Thickness(2);
            amGrid.Children.Add(new Border());

            j = 0;
            foreach (PredictorInfo predictor in dictionary.Predictors)
            {
                amGrid.Children.Add(getNewIndividualColumn(dictionary.getResultCollectionForPredictor(predictor).ArithmeticMean.Accuracy, j, predictor.description));
                j++;
            }

            amGrid.SetValue(Grid.ColumnProperty, column);
            DataContainer.ColumnDefinitions.Add(AMColumnDefinition);
            DataContainer.Children.Add(amGrid);

            caption = getNewCaption("Arithm. Mean");
            caption.SetValue(Grid.ColumnProperty, column);
            caption.SetValue(Grid.RowProperty, 3);
            DataContainer.Children.Add(caption);

            column++;

            gmGrid = new UniformGrid();
            gmGrid.HorizontalAlignment = HorizontalAlignment.Stretch;
            gmGrid.Columns             = dictionary.Predictors.Count + 2;
            gmGrid.Rows   = 1;
            gmGrid.Margin = new Thickness(2);
            gmGrid.Children.Add(new Border());

            j = 0;
            foreach (PredictorInfo predictor in dictionary.Predictors)
            {
                gmGrid.Children.Add(getNewIndividualColumn(dictionary.getResultCollectionForPredictor(predictor).GeometricMean.Accuracy, j, predictor.description));
                j++;
            }

            gmGrid.SetValue(Grid.ColumnProperty, column);
            DataContainer.ColumnDefinitions.Add(GMColumnDefinition);
            DataContainer.Children.Add(gmGrid);

            caption = getNewCaption("Geom. Mean");
            caption.SetValue(Grid.ColumnProperty, column);
            caption.SetValue(Grid.RowProperty, 3);
            DataContainer.Children.Add(caption);

            column++;

            hmGrid = new UniformGrid();
            hmGrid.HorizontalAlignment = HorizontalAlignment.Stretch;
            hmGrid.Columns             = dictionary.Predictors.Count + 2;
            hmGrid.Rows   = 1;
            hmGrid.Margin = new Thickness(2);
            hmGrid.Children.Add(new Border());

            j = 0;
            foreach (var pred in dictionary.Predictors)
            {
                hmGrid.Children.Add(getNewIndividualColumn(dictionary.getResultCollectionForPredictor(pred).HarmonicMean.Accuracy, j, pred.description));
                j++;
            }

            hmGrid.SetValue(Grid.ColumnProperty, column);
            DataContainer.ColumnDefinitions.Add(HMColumnDefinition);
            DataContainer.Children.Add(hmGrid);

            caption = getNewCaption("Harm. Mean");
            caption.SetValue(Grid.ColumnProperty, column);
            caption.SetValue(Grid.RowProperty, 3);
            DataContainer.Children.Add(caption);
        }