Ejemplo n.º 1
0
 private static UInt32 GetBit(UDT_DLL.udtPatternType type)
 {
     return (UInt32)(1 << (int)type);
 }
Ejemplo n.º 2
0
 private static bool IsPatternActive(UInt32 patterns, UDT_DLL.udtPatternType type)
 {
     return (patterns & GetBit(type)) != 0;
 }
Ejemplo n.º 3
0
        public FilterGroupBox(string header, UDT_DLL.udtStringArray stringArrayId, int columnCount = 2)
        {
            var enableAllButton = new Button();
            enableAllButton.HorizontalAlignment = HorizontalAlignment.Left;
            enableAllButton.VerticalAlignment = VerticalAlignment.Top;
            enableAllButton.Content = "Check All";
            enableAllButton.Width = 75;
            enableAllButton.Height = 25;
            enableAllButton.Margin = new Thickness(5);
            enableAllButton.Click += (obj, args) => SetAllChecked(true);

            var disableAllButton = new Button();
            disableAllButton.HorizontalAlignment = HorizontalAlignment.Left;
            disableAllButton.VerticalAlignment = VerticalAlignment.Top;
            disableAllButton.Content = "Uncheck All";
            disableAllButton.Width = 75;
            disableAllButton.Height = 25;
            disableAllButton.Margin = new Thickness(5);
            disableAllButton.Click += (obj, args) => SetAllChecked(false);

            var rootPanel = new StackPanel();
            rootPanel.Margin = new Thickness(5);
            rootPanel.Orientation = Orientation.Vertical;
            rootPanel.HorizontalAlignment = HorizontalAlignment.Stretch;
            rootPanel.VerticalAlignment = VerticalAlignment.Stretch;

            var panel = new Grid();
            panel.Margin = new Thickness(5);
            panel.HorizontalAlignment = HorizontalAlignment.Stretch;
            panel.VerticalAlignment = VerticalAlignment.Stretch;

            const int rowOffset = 1; // One additional row for the EnableAll/DisableAll buttons.
            var itemNames = UDT_DLL.GetStringArray(stringArrayId);
            var rowCount = (itemNames.Count + columnCount - 1) / columnCount;
            var maxCheckBoxesPerColumn = rowCount;
            rowCount += rowOffset;

            for(var i = 0; i < rowCount; ++i)
            {
                panel.RowDefinitions.Add(new RowDefinition());
            }

            for(var i = 0; i < columnCount; ++i)
            {
                panel.ColumnDefinitions.Add(new ColumnDefinition());
            }

            panel.Children.Add(enableAllButton);
            panel.Children.Add(disableAllButton);
            Grid.SetRow(enableAllButton, 0);
            Grid.SetColumn(enableAllButton, 0);
            Grid.SetRow(disableAllButton, 0);
            Grid.SetColumn(disableAllButton, 1);

            for(var i = 0; i < itemNames.Count; ++i)
            {
                var name = itemNames[i];
                var rowIdx = i % maxCheckBoxesPerColumn;
                var columnIdx = i / maxCheckBoxesPerColumn;
                rowIdx += rowOffset;

                var checkBox = new CheckBox();
                checkBox.Margin = new Thickness(5, 0, 5, 5);
                checkBox.HorizontalAlignment = HorizontalAlignment.Left;
                checkBox.VerticalAlignment = VerticalAlignment.Center;
                checkBox.IsChecked = true;
                checkBox.Content = " " + name.Substring(0, 1).ToUpper() + name.Substring(1);
                Grid.SetRow(checkBox, rowIdx);
                Grid.SetColumn(checkBox, columnIdx);
                _checkBoxes.Add(checkBox);

                panel.Children.Add(checkBox);
            }

            rootPanel.Children.Add(panel);

            var groupBox = new GroupBox();
            groupBox.Header = header;
            groupBox.HorizontalAlignment = HorizontalAlignment.Stretch;
            groupBox.VerticalAlignment = VerticalAlignment.Stretch;
            groupBox.Margin = new Thickness(5);
            groupBox.Content = rootPanel;

            RootElement = groupBox;
        }