예제 #1
0
        public DropdownList(string[] options, int selectedIndex, float width = 100) : base(width)
        {
            _options = options;

            var grid  = new HorizontalGrid();
            var left  = new HorizontalLayout();
            var right = new HorizontalLayout(true);

            _activeLabel = new Label(options[selectedIndex]);
            left.Attach(_activeLabel);
            float height = Utils.CalcSize("Adsd", Style).y;

            _triangle = new TriangleComponent(height, height, Col.white);
            right.Attach(_triangle);
            grid.Attach(left, right);
            AddChild(grid);

            _opened = new VerticalLayout(InnerWidth);
            foreach (var option in options)
            {
                _opened.Attach(new ClickableLable(option, x =>
                {
                    _activeLabel.Title = x;
                    Toggle();
                }));
            }
        }
예제 #2
0
        public ToggleMatrix(string text, int x = 2, int y = 2)
        {
            var z = x;

            x          = y;
            y          = z;
            toggleGrid = new BoolInstance[y][];
            var index = 0;

            Toggles = new ToggleBase[x * y];
            for (int i = 0; i < y; i++)
            {
                toggleGrid[i] = new BoolInstance[x];
                var grid = new HorizontalLayout();
                for (int j = 0; j < x; j++)
                {
                    var instance = new BoolInstance();
                    toggleGrid[i][j] = instance;
                    var toggle = new Toggle("", () => instance.Value, a => instance.Value = a)
                                 .SetLabelHidden();
                    Toggles[index] = toggle;
                    if (index++ == 0)
                    {
                        _toggleStyle = toggle.Style;
                    }
                    toggle.SetStyle(_toggleStyle);
                    grid.Attach(toggle);
                }
                Attach(grid);
            }
        }
예제 #3
0
        public HeaderWidget(string title) : base(title)
        {
            var layout = new HorizontalGrid();
            var hL0    = new HorizontalLayout();

            hL0.Attach(new Label(title));
            layout.Attach(hL0);
            AddChild(layout);
        }
예제 #4
0
        public RadioToggle(string title, System.Func <bool> getValueCallback = null, System.Action <bool> setValueCallback = null)
        {
            var horizontal = new HorizontalLayout();

            _value  = new ValueComponent <bool>(getValueCallback, setValueCallback);
            _filled = new EmptySpace();
            _filled.Style.Set(Styles.Margin, Dim.right * 5);
            horizontal.Attach(_filled, new Label(title));
            AddChild(horizontal);
        }
예제 #5
0
        public HeaderWidget2(string title) : base(title)
        {
            var layout = new HorizontalGrid();
            var hL0    = new HorizontalLayout();
            var hL1    = new HorizontalLayout(true);

            hL0.Attach(new Label(title));
            _button = new ToggleButton(true);
            // add toggle button to hl1
            hL1.Attach(_button);

            layout.Attach(hL0, hL1);
            AddChild(layout);
        }