private void AddOperationField(FormContext formContext, BaseField fieldInfo, FilterExpField filterField = null) { var widgetContext = WidgetContext.BuildContext(formContext, "OP"); widgetContext.WidgetType = FormControlType.Dropdown; DropdownWidget widget = (DropdownWidget)ViewModel.FormWidget.WidgetFactory.Create(widgetContext); widget.Options = GetOptions(fieldInfo.BaseType, fieldInfo.Type); widget.OnCompile(); if (filterField != null) { widget.SetValue((int)filterField.Op); } formContext.AddControl(widget); }
public SessionSettingsView(ISessionSettingsViewListener handler, Session session) : base(WindowType.Toplevel) { _listener = handler; _session = session; SetSizeRequest(400, 650); SetPosition(WindowPosition.Center); //Build(); Title = "Session Settings"; /* * ------------------------------------------- Machine Page */ VBox machinePage = new VBox(false, 20); // Log file path _chosenFilePath = PreferenceManager.Manager.Preferences.System.LogFilePath ?? _chosenFilePath; HBox filepathContainer = new HBox(false, 0); _lblFilepath = new Label(); SetFilePathLabel(_chosenFilePath); _btnChooseFilePath = new Button { Label = "Choose" }; _btnChooseFilePath.Pressed += ChooseFilePathPressed; filepathContainer.PackStart(_btnChooseFilePath, false, false, 10); filepathContainer.PackStart(_lblFilepath, false, false, 0); // Select serial port HBox portBox = new HBox(false, 10); _portDropdown = new DropdownWidget(null); PortRefreshPressed(null, null); if (PreferenceManager.Manager.Preferences.System.Serial.PortName != null) { _portDropdown.Set(PreferenceManager.Manager.Preferences.System.Serial.PortName); } _btnPortRefresh = new Button { Label = "Refresh" }; _btnPortRefresh.Pressed += PortRefreshPressed; portBox.PackStart(_portDropdown, false, false, 10); portBox.PackStart(_btnPortRefresh, false, false, 0); _baudRateDropdown = new DropdownWidget("Baud rate", bauds.Select(x => x.ToString()).ToArray()); _baudRateDropdown.Set(PreferenceManager.Manager.Preferences.System.Serial.BaudRate.ToString()); _chkSettingsOnStartup = new LabelledCheckboxWidget { LabelText = "Show settings on startup", Checked = PreferenceManager.Manager.Preferences.Visual.ShowSettingsOnStartup }; machinePage.PackStart(new Label("Serial port:"), false, false, 10); machinePage.PackStart(portBox, false, false, 0); machinePage.PackStart(_baudRateDropdown, false, false, 10); machinePage.PackStart(new Label("Save path:"), false, false, 0); machinePage.PackStart(filepathContainer, false, false, 0); machinePage.PackStart(_chkSettingsOnStartup, false, false, 20); /* * ------------------------------------------- Visual Page */ VBox visualPage = new VBox(false, 10); // Component limits _session.Mapping.Components().ForEach((Component obj) => { if (obj is IWarningLimits sc) { _componentWidgets.Add(new ComponentSettingWidget(obj)); } }); VBox componentSections = new VBox(false, 20); componentSections.PackStart(LayoutLimitsSection(_componentWidgets.FindAll((ComponentSettingWidget obj) => obj.Component is PressureComponent)), false, false, 0); componentSections.PackStart(LayoutLimitsSection(_componentWidgets.FindAll((ComponentSettingWidget obj) => obj.Component is TemperatureComponent)), false, false, 0); componentSections.PackStart(LayoutLimitsSection(_componentWidgets.FindAll((ComponentSettingWidget obj) => obj.Component is LoadComponent)), false, false, 0); componentSections.PackStart(LayoutLimitsSection(_componentWidgets.FindAll((ComponentSettingWidget obj) => obj.Component is VoltageComponent)), false, false, 0); componentSections.PackStart(LayoutLimitsSection(_componentWidgets.FindAll((ComponentSettingWidget obj) => obj.Component is FlowComponent)), false, false, 0); ScrolledWindow scrolledWindow = new ScrolledWindow { HeightRequest = 550 }; //scrolledWindow.SetPolicy(PolicyType.Never, PolicyType.Automatic); scrolledWindow.AddWithViewport(componentSections); visualPage.PackStart(scrolledWindow, false, false, 0); /* * ------------------------------------------- Fluid Page */ VBox fluidPage = new VBox(false, 20); oxidValveCoefficient = new LabelledEntryWidget() { LabelText = "Oxidizer valve flow coefficient (CV)", EntryText = FloatValue(PreferenceManager.Manager.Preferences.Fluid.Oxid.CV) }; oxidDensity = new LabelledEntryWidget() { LabelText = "Oxidizer density [kg/m^3]", EntryText = FloatValue(PreferenceManager.Manager.Preferences.Fluid.Oxid.Density) }; fuelValveCoefficient = new LabelledEntryWidget() { LabelText = "Fuel valve flow coefficient (CV)", EntryText = FloatValue(PreferenceManager.Manager.Preferences.Fluid.Fuel.CV) }; fuelDensity = new LabelledEntryWidget() { LabelText = "Fuel density [kg/m^3]", EntryText = FloatValue(PreferenceManager.Manager.Preferences.Fluid.Fuel.Density) }; todaysPressure = new LabelledEntryWidget() { LabelText = "Today's pressure [bar]", EntryText = FloatValue(PreferenceManager.Manager.Preferences.Fluid.TodaysPressure) }; showAbsolutePressure = new LabelledRadioWidget { LabelText = "Pressure measure: ", ShowAbsolutePressure = PreferenceManager.Manager.Preferences.Visual.ShowAbsolutePressure }; fluidPage.PackStart(new Label("Fluid system values"), false, false, 0); fluidPage.PackStart(oxidValveCoefficient, false, false, 0); fluidPage.PackStart(oxidDensity, false, false, 0); fluidPage.PackStart(fuelValveCoefficient, false, false, 0); fluidPage.PackStart(fuelDensity, false, false, 0); fluidPage.PackStart(new Label("Pressure properties"), false, false, 0); fluidPage.PackStart(todaysPressure, false, false, 0); fluidPage.PackStart(showAbsolutePressure, false, false, 0); /* * ------------------------------------------- Overall */ VBox container = new VBox(false, 10); Notebook notebook = new Notebook { machinePage, visualPage, fluidPage }; notebook.SetTabLabelText(machinePage, "Machine"); notebook.SetTabLabelText(visualPage, "Visuals"); notebook.SetTabLabelText(fluidPage, "Fluid system"); // Bottom save container HBox cancelSaveContainer = new HBox(false, 0); _btnSave = new Button { Label = "Save", WidthRequest = 60, HeightRequest = 40 }; _btnSave.Pressed += SavePressed; cancelSaveContainer.PackEnd(_btnSave, false, false, 10); container.PackStart(notebook, false, false, 0); container.PackStart(cancelSaveContainer, false, false, 0); Add(container); Resizable = false; ShowAll(); }