Ejemplo n.º 1
0
        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;
            }
        }
    }
Ejemplo n.º 2
0
        public ConfigDirectoryWidget(IConfigDirectoryFrontend viewModel) : base(viewModel)
        {
            this.viewModel = viewModel;

            var valueBox = new Box(Orientation.Horizontal, 0);

            valueBox.Add(chooser = CreateFileChooser());
            valueBox.Add(CreateShowInFilesButton());
            valueBox.SetSizeRequest(ElementWidth, chooser.AllocatedHeight);
            Add(valueBox);

            UpdateVisibleState();
            chooser.FileSet           += delegate { UpdateViewModel(); };
            viewModel.PropertyChanged += delegate { UpdateVisibleState(); };
        }