コード例 #1
0
        public static UniformGrid createTestDataAndFieldsReturnUniformGridContainingResultElements(bool isSynchronousMode, ref List <TestDataAndFields> listOfTestDataAndFields)
        {
            UniformGrid uniformGrid = new UniformGrid();

            uniformGrid.Rows = 2;

            for (int i = 0; i < 8; i++)
            {
                TestDataAndFields currentTestDataAndFields = new TestDataAndFields();
                currentTestDataAndFields.iterationHistory  = new List <SingleIterationResult>();
                currentTestDataAndFields.foundPattern      = new List <SingleIterationResult>();
                currentTestDataAndFields.resultValueLabels = new List <Label>();
                currentTestDataAndFields.index             = i;
                currentTestDataAndFields.synchronousMode   = isSynchronousMode;

                GroupBox groupBox = new GroupBox();
                {
                    groupBox.Header = "Badanie " + (i + 1);
                    Grid grid = new Grid();
                    {
                        LayoutGenerationHelpers.addNMStarWideColumnsToGrid(3, 1, ref grid);
                        LayoutGenerationHelpers.addNMStarHighRowsToGrid(1, 3, ref grid);
                        LayoutGenerationHelpers.addNMStarHighRowsToGrid(2, 1, ref grid);

                        Grid gridInputs = new Grid();
                        {
                            LayoutGenerationHelpers.addNMStarHighRowsToGrid(3, 1, ref gridInputs);
                            Grid.SetColumn(gridInputs, 0);
                            LayoutGenerationHelpers.addNLabelsToGridWithBitsOfIAsContent(3, ref gridInputs, i);

                            currentTestDataAndFields.startingValue = new DMU.Math.Matrix(
                                new double[] {
                                ((i >> (2 - 0)) & 0x1) == 0 ? -1 : 1,
                                ((i >> (2 - 1)) & 0x1) == 0 ? -1 : 1,
                                ((i >> (2 - 2)) & 0x1) == 0 ? -1 : 1
                            },
                                true
                                );

                            currentTestDataAndFields.currentValue = currentTestDataAndFields.startingValue.Clone();
                        }

                        grid.Children.Add(gridInputs);

                        Label label = new Label();
                        {
                            Grid.SetColumn(label, 1);
                            Grid.SetRow(label, 0);
                            label.VerticalAlignment   = VerticalAlignment.Center;
                            label.HorizontalAlignment = HorizontalAlignment.Center;
                            label.Content             = "=>";
                        }
                        grid.Children.Add(label);

                        Grid gridOutputs = new Grid();
                        {
                            LayoutGenerationHelpers.addNMStarHighRowsToGrid(3, 1, ref gridOutputs);
                            Grid.SetColumn(gridOutputs, 2);
                            addNLabelsToGridWithStringValueAndAddToList(3, ref gridOutputs, "-", ref currentTestDataAndFields.resultValueLabels);
                        }
                        grid.Children.Add(gridOutputs);

                        label = new Label();
                        {
                            Grid.SetColumn(label, 0);
                            Grid.SetRow(label, 1);
                            Grid.SetColumnSpan(label, 3);
                            label.HorizontalAlignment            = HorizontalAlignment.Center;
                            currentTestDataAndFields.resultLabel = label;
                        }
                        grid.Children.Add(label);

                        Button button = new Button();
                        {
                            Grid.SetColumn(button, 0);
                            Grid.SetRow(button, 2);
                            Grid.SetColumnSpan(button, 3);
                            button.Content = "Więcej";
                            button.Tag     = currentTestDataAndFields;
                            button.Click  += MainWindow.displayMoreInformation;
                            currentTestDataAndFields.moreButton = button;
                        }
                        grid.Children.Add(button);
                    }
                    groupBox.Content = grid;
                }
                uniformGrid.Children.Add(groupBox);
                listOfTestDataAndFields.Add(currentTestDataAndFields);
            }

            return(uniformGrid);
        }
コード例 #2
0
        public void displayInformation(TestDataAndFields testDataAndFields)
        {
            DMU.Math.Matrix currentValue = testDataAndFields.startingValue;
            string          text         = "Badanie " + (testDataAndFields.index + 1) + " Wektor: " + currentValue.ToString("F0");

            this.Title        = text;
            SourceInfo.Header = text;
            List <Rectangle> rectangles = new List <Rectangle>();

            Label label = new Label();

            {
                label.VerticalAlignment   = VerticalAlignment.Center;
                label.HorizontalAlignment = HorizontalAlignment.Center;
                label.Content             = DataConverters.resultTypeToString(testDataAndFields.resultType);
            }
            results.Children.Add(label);

            UniformGrid uniformGrid = new UniformGrid();

            {
                uniformGrid.Rows = 1;
                for (int rectIndex = 0; rectIndex < testDataAndFields.iterationHistory.Count + 1; rectIndex++)
                {
                    Rectangle rect = new Rectangle();
                    {
                        rect.Width  = 20;
                        rect.Height = 20;
                        rectangles.Add(rect);
                    }
                    uniformGrid.Children.Add(rect);
                }
            }
            results.Children.Add(uniformGrid);
            rectangles[0].Fill = brushes[biPolarToNumber(testDataAndFields.startingValue.ToArray())];

            int i = 1;

            foreach (SingleIterationResult resultOfStep in testDataAndFields.iterationHistory)
            {
                GroupBox groupBox = new GroupBox();
                {
                    groupBox.Header    = "Krok " + i;
                    rectangles[i].Fill = brushes[biPolarToNumber(resultOfStep.matrixResultBiPolar.ToArray())];
                    Grid grid = new Grid();
                    {
                        LayoutGenerationHelpers.addNMStarWideColumnsToGrid(4, 1, ref grid);
                        LayoutGenerationHelpers.addNMStarHighRowsToGrid(3, 1, ref grid);
                        LayoutGenerationHelpers.addNMStarHighRowsToGrid(1, 1, ref grid);

                        label = new Label();
                        {
                            Grid.SetColumn(label, 0);
                            Grid.SetRow(label, 0);
                            label.VerticalAlignment   = VerticalAlignment.Center;
                            label.HorizontalAlignment = HorizontalAlignment.Center;
                            label.Content             = "Potencjał wejściowy (U):";
                        }
                        grid.Children.Add(label);

                        Grid gridOutputs = new Grid();
                        {
                            LayoutGenerationHelpers.addNMStarHighRowsToGrid(3, 1, ref gridOutputs);
                            Grid.SetColumn(gridOutputs, 1);
                            LayoutGenerationHelpers.addNLabelsToGridWithArrayAsContent(3, ref gridOutputs, resultOfStep.matrixResult.ToArray());
                        }
                        grid.Children.Add(gridOutputs);

                        label = new Label();
                        {
                            Grid.SetColumn(label, 2);
                            Grid.SetRow(label, 0);
                            label.VerticalAlignment   = VerticalAlignment.Center;
                            label.HorizontalAlignment = HorizontalAlignment.Center;
                            label.Content             = "Potencjał wyjściowy (V):";
                        }
                        grid.Children.Add(label);

                        Grid gridOutputsBiPolar = new Grid();
                        {
                            LayoutGenerationHelpers.addNMStarHighRowsToGrid(3, 1, ref gridOutputsBiPolar);
                            Grid.SetColumn(gridOutputsBiPolar, 3);
                            LayoutGenerationHelpers.addNLabelsToGridWithArrayAsContent(3, ref gridOutputsBiPolar, resultOfStep.matrixResultBiPolar.ToArray());
                        }
                        grid.Children.Add(gridOutputsBiPolar);

                        label = new Label();
                        {
                            Grid.SetColumn(label, 0);
                            Grid.SetRow(label, 1);
                            Grid.SetColumnSpan(label, 4);
                            label.VerticalAlignment   = VerticalAlignment.Center;
                            label.HorizontalAlignment = HorizontalAlignment.Center;
                            label.Content             = "Energia: " + resultOfStep.energy;
                        }
                        grid.Children.Add(label);
                    }
                    groupBox.Content = grid;
                }
                results.Children.Add(groupBox);

                i++;
            }
        }