private string CheckButtonAssignments() { if (!instance.Enabled) { return(string.Empty); } byte[] buttons = new byte[EnumExtension.GetLength <UserCommand>()]; foreach (Control control in panelRDButtons.Controls) { if (control is Panel) { foreach (Control child in control.Controls) { if (child is RDButtonInputControl) { buttons[(int)child.Tag] = (child as RDButtonInputControl).UserButton; } } break; } } return(RailDriverSettings.CheckForErrors(buttons)); }
private Task <Panel> InitializeRailDriverInputControls() { TaskCompletionSource <Panel> tcs = new TaskCompletionSource <Panel>(); Panel panel = new Panel() { AutoScroll = true, Width = panelRDSettings.Width / 2 }; panel.SuspendLayout(); var columnWidth = (panel.ClientSize.Width - 20) / 3; Label tempLabel = new Label(); RDButtonInputControl tempControl = new RDButtonInputControl(Settings.RailDriver.UserCommands[(int)UserCommand.GameQuit], RailDriverSettings.GetDefaultValue(UserCommand.GameQuit), instance); int rowTop = Math.Max(tempLabel.Margin.Top, tempControl.Margin.Top); int rowHeight = tempControl.Height; int rowSpacing = rowHeight + tempControl.Margin.Vertical; Size categorySize = new Size(columnWidth * 2 - tempLabel.Margin.Horizontal, rowHeight); Size inputControlSize = new Size(columnWidth - tempControl.Margin.Horizontal, rowHeight); Size labelSize = new Size(columnWidth * 2 - tempLabel.Margin.Horizontal, rowHeight); string previousCategory = ""; var i = 0; foreach (UserCommand command in EnumExtension.GetValues <UserCommand>()) { string name = catalog.GetString(command.GetDescription()); string category, description; int index = name.IndexOf(' '); if (index == -1) { category = string.Empty; description = name; } else { category = name.Substring(0, index); description = name.Substring(index + 1); } if (category != previousCategory) { Label categorylabel = new Label { Location = new Point(tempLabel.Margin.Left, rowTop + rowSpacing * i), Size = categorySize, Text = category, TextAlign = ContentAlignment.MiddleLeft }; categorylabel.Font = new Font(categorylabel.Font, FontStyle.Bold); panel.Controls.Add(categorylabel); previousCategory = category; ++i; } var label = new Label { Location = new Point(tempLabel.Margin.Left, rowTop + rowSpacing * i), Size = labelSize, Text = description, TextAlign = ContentAlignment.MiddleRight }; panel.Controls.Add(label); RDButtonInputControl rdButtonControl = new RDButtonInputControl(Settings.RailDriver.UserCommands[(int)command], RailDriverSettings.GetDefaultValue(command), instance) { Location = new Point(columnWidth * 2 + tempControl.Margin.Left, rowTop + rowSpacing * i), Size = inputControlSize, Tag = command }; panel.Controls.Add(rdButtonControl); ++i; } panel.ResumeLayout(true); tcs.SetResult(panel); return(tcs.Task); }
private Panel InitializeRailDriverInputControls() { Panel panel = new Panel() { AutoScroll = true, Width = panelRDSettings.Width / 2 }; panel.SuspendLayout(); int columnWidth = (panel.ClientSize.Width - 20) / 3; Label tempLabel = new Label(); RDButtonInputControl tempControl = new RDButtonInputControl(settings.RailDriver.UserCommands[UserCommand.GameQuit], RailDriverSettings.GetDefaultValue(UserCommand.GameQuit), instance); int rowTop = Math.Max(tempLabel.Margin.Top, tempControl.Margin.Top); int rowHeight = tempControl.Height; int rowSpacing = rowHeight + tempControl.Margin.Vertical; Size categorySize = new Size(columnWidth * 2 - tempLabel.Margin.Horizontal, rowHeight); Size inputControlSize = new Size(columnWidth - tempControl.Margin.Horizontal, rowHeight); Size labelSize = new Size(columnWidth * 2 - tempLabel.Margin.Horizontal, rowHeight); string previousCategory = ""; int i = 0; foreach (UserCommand command in EnumExtension.GetValues <UserCommand>()) { string name = command.GetLocalizedDescription(); string category, description; int index = name.IndexOf(' ', StringComparison.OrdinalIgnoreCase); if (index == -1) { category = string.Empty; description = name; } else { category = name[..index];