public IdCardConsoleWindow(IdCardConsoleBoundUserInterface owner, ILocalizationManager loc) { _loc = loc; _owner = owner; var vBox = new VBoxContainer(); vBox.AddChild(new GridContainer { Columns = 3, Children = { new Label { Text = loc.GetString("Privileged ID:") }, (_privilegedIdButton = new Button()), (_privilegedIdLabel = new Label()), new Label { Text = loc.GetString("Target ID:") }, (_targetIdButton = new Button()), (_targetIdLabel = new Label()) } }); _privilegedIdButton.OnPressed += _ => _owner.ButtonPressed(UiButton.PrivilegedId); _targetIdButton.OnPressed += _ => _owner.ButtonPressed(UiButton.TargetId); // Separator vBox.AddChild(new Control { CustomMinimumSize = (0, 8) });
public IdCardConsoleWindow(IdCardConsoleBoundUserInterface owner, ILocalizationManager localizationManager) { _localizationManager = localizationManager; _owner = owner; var vBox = new VBoxContainer(); { var hBox = new HBoxContainer(); vBox.AddChild(hBox); _privilegedIdButton = new Button(); _privilegedIdButton.OnPressed += _ => _owner.ButtonPressed(UiButton.PrivilegedId); hBox.AddChild(_privilegedIdButton); _targetIdButton = new Button(); _targetIdButton.OnPressed += _ => _owner.ButtonPressed(UiButton.TargetId); hBox.AddChild(_targetIdButton); } { var hBox = new HBoxContainer(); vBox.AddChild(hBox); hBox.AddChild(_fullNameLabel = new Label() { Text = localizationManager.GetString("Full name:") }); _fullNameLineEdit = new LineEdit() { SizeFlagsHorizontal = SizeFlags.FillExpand, }; hBox.AddChild(_fullNameLineEdit); } { var hBox = new HBoxContainer(); vBox.AddChild(hBox); hBox.AddChild(_jobTitleLabel = new Label() { Text = localizationManager.GetString("Job title:") }); _jobTitleLineEdit = new LineEdit() { SizeFlagsHorizontal = SizeFlags.FillExpand }; hBox.AddChild(_jobTitleLineEdit); } { var hBox = new HBoxContainer(); vBox.AddChild(hBox); foreach (var accessName in SharedAccess.AllAccess) { var newButton = new Button() { Text = accessName, ToggleMode = true, }; hBox.AddChild(newButton); _accessButtons.Add(accessName, newButton); } } { var hBox = new HBoxContainer(); vBox.AddChild(hBox); _submitButton = new Button() { Text = localizationManager.GetString("Submit") }; _submitButton.OnPressed += _ => owner.SubmitData( _fullNameLineEdit.Text, _jobTitleLineEdit.Text, // Iterate over the buttons dictionary, filter by `Pressed`, only get key from the key/value pair _accessButtons.Where(x => x.Value.Pressed).Select(x => x.Key).ToList()); hBox.AddChild(_submitButton); } Contents.AddChild(vBox); }