public void CreateTextBoxTest()
        {
            string name  = "TestName";
            string text  = "TestText";
            string style = string.Empty;

            TextBox expected = new TextBox
            {
                Name   = name,
                Text   = text,
                Margin = new Thickness(0, 0, 0, 0),
                Style  = new Style()
            };

            TextBox actual;

            actual = InterfaceHelpers.CreateTextBox(name, text, style);
            Assert.IsTrue(actual.Name == expected.Name && actual.Text == expected.Text && actual.Margin == expected.Margin);
        }
Exemple #2
0
        //Constructor
        public EventDimensionSelector(int axis)
        {
            _axis = axis;

            // Create basic DimensionSelectorGrid with four columns
            DimensionSelectorGrid = new Grid {
                Name = "dimensionSelectorGrid" + axis
            };
            var col1 = new ColumnDefinition {
                Width = new GridLength(Column1Width)
            };
            var col2 = new ColumnDefinition {
                Width = new GridLength(Column2Width)
            };
            var col3 = new ColumnDefinition {
                Width = new GridLength(Column3Width)
            };
            var col4 = new ColumnDefinition {
                Width = new GridLength(Column4Width)
            };

            DimensionSelectorGrid.ColumnDefinitions.Add(col1);
            DimensionSelectorGrid.ColumnDefinitions.Add(col2);
            DimensionSelectorGrid.ColumnDefinitions.Add(col3);
            DimensionSelectorGrid.ColumnDefinitions.Add(col4);

            // Number on the left
            DimensionSelectorGrid.Children.Add(InterfaceHelpers.CreateTextBlock(axis + "", "Title", gridColumn: 0));

            // Create Dimension, Level and Aggregation combo boxes on the middle
            var panelMiddle = new StackPanel();

            panelMiddle.SetValue(Grid.ColumnProperty, 1);
            panelMiddle.HorizontalAlignment = HorizontalAlignment.Left;
            panelMiddle.VerticalAlignment   = VerticalAlignment.Top;
            panelMiddle.Children.Add(InterfaceHelpers.CreateLabel("Dimension"));
            _dimensionComboBox = InterfaceHelpers.CreateComboBox("axis" + axis + "_selector", width: ComboBoxWidth);
            panelMiddle.Children.Add(_dimensionComboBox);

            panelMiddle.Children.Add(InterfaceHelpers.CreateLabel("Level", top: LabelTopMargin));
            _dimensionLevelComboBox = InterfaceHelpers.CreateComboBox("level" + axis + "_selector", width: ComboBoxWidth);
            panelMiddle.Children.Add(_dimensionLevelComboBox);

            panelMiddle.Children.Add(InterfaceHelpers.CreateLabel("Aggregation", top: LabelTopMargin));
            _dimensionAggregationComboBox = InterfaceHelpers.CreateComboBox("aggregation" + axis + "_selector", width: ComboBoxWidth);
            panelMiddle.Children.Add(_dimensionAggregationComboBox);

            DimensionSelectorGrid.Children.Add(panelMiddle);

            // Filters on the right
            var panelRight = new StackPanel();

            panelRight.SetValue(Grid.ColumnProperty, 3);
            panelRight.HorizontalAlignment = HorizontalAlignment.Left;
            panelRight.VerticalAlignment   = VerticalAlignment.Top;
            panelRight.Children.Add(InterfaceHelpers.CreateLabel("Filter"));
            _dimensionContentSearch       = InterfaceHelpers.CreateTextBox("txtSearchAxis" + axis);
            _dimensionContentSearch.Width = SearchBoxWidth;
            panelRight.Children.Add(_dimensionContentSearch);
            // Filterlist
            _dimensionContentFilter = new ListBox
            {
                Name = "filter" + axis + "_selector",
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Top,
                Width              = FilterListWidth,
                Height             = FilterListHeight,
                Style              = Application.Current.TryFindResource("ListBox") as Style,
                ItemContainerStyle = Application.Current.TryFindResource("ListBoxItemWithCheckbox") as Style,
                SelectionMode      = SelectionMode.Extended
            };
            panelRight.Children.Add(_dimensionContentFilter);

            // Select all / none
            var selectAllNone = new StackPanel {
                Orientation = Orientation.Horizontal
            };

            _selectAllButton = InterfaceHelpers.CreateButton("selectAll" + axis, "Select all", "PlainTextButton");
            selectAllNone.Children.Add(_selectAllButton);
            selectAllNone.Children.Add(InterfaceHelpers.CreateLabel("/"));
            _selectNoneButton = InterfaceHelpers.CreateButton("selectNone" + axis, "none", "PlainTextButton");
            selectAllNone.Children.Add(_selectNoneButton);
            panelRight.Children.Add(selectAllNone);

            DimensionSelectorGrid.Children.Add(panelRight);
        }
Exemple #3
0
        /// <summary>
        /// Creates for each dimension a column with textboxes(dimension, level) where the metadata can be modified
        /// </summary>
        /// <author>Jannik Arndt, Bernhard Bruns</author>
        private void LoadDimensionMetaData()
        {
            DimensionGrid.Children.Clear();
            DimensionGrid.ColumnDefinitions.Clear();

            foreach (string registeredName in _registeredNames)
            {
                DimensionGrid.UnregisterName(registeredName);
            }

            _registeredNames.Clear();

            // Load the columnnames of the event table into the combobox to let the user decide which one to use as a classifier
            ClassifierComboBox.ItemsSource = DBWorker.MetaData.ListOfEventsTableColumnNames;

            if (DBWorker.MetaData.ListOfEventsTableColumnNames.Contains(DBWorker.MetaData.EventClassifier))
            {
                ClassifierComboBox.SelectedItem = DBWorker.MetaData.EventClassifier;
            }
            else if (DBWorker.MetaData.ListOfEventsTableColumnNames.Count > 0)
            {
                ClassifierComboBox.SelectedIndex = 0;
            }


            int dimensionNumber = 0;

            foreach (Dimension dimension in DBWorker.MetaData.ListOfFactDimensions)
            {
                DimensionGrid.ColumnDefinitions.Add(new ColumnDefinition());

                if (!dimension.IsEmptyDimension && dimension.Name != "--no selection--")
                {
                    StackPanel dimensionPanel = new StackPanel();
                    dimensionPanel.SetValue(Grid.ColumnProperty, dimensionNumber);
                    dimensionPanel.Width = 150;

                    dimensionPanel.Children.Add(InterfaceHelpers.CreateTextBlock("DIMENSION " + (dimensionNumber + 1), "Emphasis", bottom: 8));
                    dimensionPanel.Children.Add(InterfaceHelpers.CreateTextBlock("Original Name: \n" + dimension.Name, bottom: 8));
                    dimensionPanel.Children.Add(InterfaceHelpers.CreateTextBlock("New Name:", bottom: 8));

                    TextBox dimensionNumberTextBox = InterfaceHelpers.CreateTextBox("Dimension" + (dimensionNumber + 1) + "newName", dimension.Dimensionname, bottom: 8);
                    dimensionNumberTextBox.GotKeyboardFocus += SelectTextInTextbox;

                    DimensionGrid.RegisterName(dimensionNumberTextBox.Name, dimensionNumberTextBox);
                    _registeredNames.Add(dimensionNumberTextBox.Name);
                    dimensionPanel.Children.Add(dimensionNumberTextBox);

                    dimensionPanel.Children.Add(InterfaceHelpers.CreateTextBlock("LEVELS", "Emphasis", top: 20, bottom: 8));

                    int j = 0;
                    foreach (Dimension cDim in dimension.GetLevel())
                    {
                        if (j >= 0)
                        {
                            dimensionPanel.Children.Add(InterfaceHelpers.CreateTextBlock(cDim.ToTable, bottom: 8));

                            TextBox txtLevel = InterfaceHelpers.CreateTextBox("level" + (dimensionNumber + 1) + "_" + j + "newName", cDim.Level, bottom: 15);
                            txtLevel.GotKeyboardFocus += SelectTextInTextbox;

                            DimensionGrid.RegisterName(txtLevel.Name, txtLevel);
                            _registeredNames.Add(txtLevel.Name);
                            dimensionPanel.Children.Add(txtLevel);
                        }
                        j++;
                    }

                    DimensionGrid.Children.Add(dimensionPanel);
                    dimensionNumber++;
                }
            }

            if (DBConnectionHelpers.DefaultEventClassifierIsSelected)
            {
                ModernDialog.ShowMessage("Auto selected " + ClassifierComboBox.SelectedItem + " as classifier.", "Metadata", MessageBoxButton.OK);
                DBConnectionHelpers.DefaultEventClassifierIsSelected = false;
            }
        }
        /// <summary>
        /// Creates a grid with dimension-, level- and filter-selection to be displayed right of the matrix.
        /// </summary>
        /// <param name="number">Number of the dimension (starting from 1)</param>
        /// <returns>A Grid that should be added to the interface.</returns>
        /// <author>Jannik Arndt</author>
        private Grid CreateSelectorGrid(int number)
        {
            const double column1Width     = 30;
            const double column2Width     = 130;
            const double column3Width     = 10;
            const double column4Width     = 130;
            const double comboBoxWidth    = column2Width - 10;
            const double searchBoxWidth   = column4Width - 10;
            const double filterListWidth  = column4Width - 10;
            const double filterListHeight = 80;
            const double labelTopMargin   = 8;

            // Create basic SelectorGrid with four columns
            var selectorGrid = new Grid {
                Name = "selectorGrid" + number
            };
            var col1 = new ColumnDefinition {
                Width = new GridLength(column1Width)
            };
            var col2 = new ColumnDefinition {
                Width = new GridLength(column2Width)
            };
            var col3 = new ColumnDefinition {
                Width = new GridLength(column3Width)
            };
            var col4 = new ColumnDefinition {
                Width = new GridLength(column4Width)
            };

            selectorGrid.ColumnDefinitions.Add(col1);
            selectorGrid.ColumnDefinitions.Add(col2);
            selectorGrid.ColumnDefinitions.Add(col3);
            selectorGrid.ColumnDefinitions.Add(col4);

            // Number on the left
            selectorGrid.Children.Add(InterfaceHelpers.CreateTextBlock(number + "", "Title", gridColumn: 0));

            // Dimension and Level-Selectors in the middle
            var panelMiddle = new StackPanel();

            panelMiddle.SetValue(Grid.ColumnProperty, 1);
            panelMiddle.HorizontalAlignment = HorizontalAlignment.Left;
            panelMiddle.VerticalAlignment   = VerticalAlignment.Top;
            panelMiddle.Children.Add(InterfaceHelpers.CreateLabel("Dimension"));
            var axisComboBox = InterfaceHelpers.CreateComboBox("axis" + number + "_selector", width: comboBoxWidth);

            axisComboBox.SelectionChanged += OnDimensionComboBoxSelectionChanged;
            panelMiddle.Children.Add(axisComboBox);

            panelMiddle.Children.Add(InterfaceHelpers.CreateLabel("Level", top: labelTopMargin));
            var levelComboBox = InterfaceHelpers.CreateComboBox("level" + number + "_selector", width: comboBoxWidth);

            levelComboBox.SelectionChanged += OnLevelComboBoxSelectionChanged;
            panelMiddle.Children.Add(levelComboBox);

            selectorGrid.Children.Add(panelMiddle);

            // Filters on the right
            var panelRight = new StackPanel();

            panelRight.SetValue(Grid.ColumnProperty, 3);
            panelRight.HorizontalAlignment = HorizontalAlignment.Left;
            panelRight.VerticalAlignment   = VerticalAlignment.Top;
            panelRight.Children.Add(InterfaceHelpers.CreateLabel("Filter"));
            var quickSearchTextBox = InterfaceHelpers.CreateTextBox("txtSearchAxis" + number);

            quickSearchTextBox.TextChanged += QuickSearch;

            quickSearchTextBox.Width = searchBoxWidth;
            panelRight.Children.Add(quickSearchTextBox);
            //  Filterlist
            var filterListBox = new ListBox
            {
                Name = "filter" + number + "_selector",
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Top,
                Width              = filterListWidth,
                Height             = filterListHeight,
                Style              = Application.Current.TryFindResource("ListBox") as Style,
                ItemContainerStyle = Application.Current.TryFindResource("ListBoxItemWithCheckbox") as Style,
                SelectionMode      = SelectionMode.Extended
            };

            filterListBox.SelectionChanged += OnFilterListBoxSelectionChanged;
            panelRight.Children.Add(filterListBox);

            // Select all / none
            var selectAllNone = new StackPanel {
                Orientation = Orientation.Horizontal
            };
            var selectAllButton = InterfaceHelpers.CreateButton("selectAll" + number, "Select all", "PlainTextButton");

            selectAllButton.Click += FilterListBoxSelectAll;
            selectAllNone.Children.Add(selectAllButton);
            selectAllNone.Children.Add(InterfaceHelpers.CreateLabel("/"));
            var selectNoneButton = InterfaceHelpers.CreateButton("selectNone" + number, "none", "PlainTextButton");

            selectNoneButton.Click += FilterListBoxSelectNone;
            selectAllNone.Children.Add(selectNoneButton);
            panelRight.Children.Add(selectAllNone);

            selectorGrid.Children.Add(panelRight);

            _listOfAxisComboBoxes.Add(axisComboBox);
            _listOfLevelComboBoxes.Add(levelComboBox);
            _listOfFilterComboBoxes.Add(filterListBox);
            _listOfSelectAllButtons.Add(selectAllButton);
            _listOfSelectNoneButtons.Add(selectNoneButton);
            _listOfQuicksearchTextfields.Add(quickSearchTextBox);
            _listOfQuicksearchFirstSearch.Add(true);

            return(selectorGrid);
        }