public ConfigsContainerWidget(IConfigContainerFrontend viewModel)
            : base(Orientation.Vertical, SpacingPixels)
        {
            StyleContext.AddClass("border-round");

            var headingLabel = Label.New(viewModel.Heading);

            headingLabel.Xalign       = 0;
            headingLabel.MarginStart  = LabelStartMargin;
            headingLabel.MarginTop    = SpacingPixels;
            headingLabel.MarginBottom = SpacingPixels * 2;
            headingLabel.StyleContext.AddClass("heading-light");
            Add(headingLabel);

            Widget?lastEntryWidget = null;

            foreach (var entry in viewModel.Entries)
            {
                ConfigWidgetBase entryWidget = entry switch
                {
                    IConfigDirectoryFrontend dir => new ConfigDirectoryWidget(dir),
                    IConfigDropdownFrontend dd => new ConfigDropdownWidget(dd),
                    _ => throw new ArgumentOutOfRangeException(nameof(viewModel))
                };

                lastEntryWidget = entryWidget;
                Add(entryWidget);
            }

            if (lastEntryWidget != null)
            {
                lastEntryWidget.MarginBottom = SpacingPixels;
            }
        }
    }
Exemple #2
0
        public ConfigDropdownWidget(IConfigDropdownFrontend viewModel) : base(viewModel)
        {
            this.viewModel = viewModel;

            dropDown = new ComboBox(this.viewModel.Options.ToArray());
            dropDown.SetSizeRequest(ElementWidth, dropDown.AllocatedHeight);
            UpdateVisibleState();

            Add(dropDown);

            dropDown.Changed += delegate { UpdateViewModel(); };
            this.viewModel.PropertyChanged += delegate { UpdateVisibleState(); };
        }