private void reloadJoysticks() { object prevJoy = comboJoysticks.SelectedItem; comboJoysticks.Items.Clear(); comboJoysticks.Items.AddRange(vJoyEnumerator.GetJoysticks()); comboJoysticks.SelectedItem = prevJoy; if (comboJoysticks.SelectedItem == null && comboJoysticks.Items.Count > 0) { comboJoysticks.SelectedIndex = 0; } }
private void initializePanel() { switch (Environment.OSVersion.Platform) { case PlatformID.Win32NT: vJoyEnumerator = (VJoyCollectionBase)Activator.CreateInstance(Type.GetType("vJoySerialFeeder.VJoyCollectionWindows")); break; case PlatformID.Unix: vJoyEnumerator = (VJoyCollectionBase)Activator.CreateInstance(Type.GetType("vJoySerialFeeder.VJoyCollectionLinux")); break; default: ErrorMessageBox("Unsupported platform", "Fatal"); Application.Exit(); break; } panel = new FlowLayoutPanel(); panel.SuspendLayout(); panel.Size = new Size(670, 30); var label = new Label(); label.Text = "Channel:"; label.Size = new Size(52, 20); label.TextAlign = ContentAlignment.MiddleLeft; panel.Controls.Add(label); channelSpinner = new NumericUpDown(); channelSpinner.Minimum = 0; channelSpinner.Maximum = 255; channelSpinner.Size = new Size(42, 20); channelSpinner.Value = Channel + 1; channelSpinner.ValueChanged += onChannelChange; panel.Controls.Add(channelSpinner); label = new Label(); label.Text = "Button:"; label.Size = new Size(42, 20); label.TextAlign = ContentAlignment.MiddleLeft; panel.Controls.Add(label); buttonSpinner = new NumericUpDown(); buttonSpinner.Minimum = 0; buttonSpinner.Maximum = 128; buttonSpinner.Size = new Size(42, 20); buttonSpinner.Value = Button + 1; buttonSpinner.ValueChanged += onButtonChange; panel.Controls.Add(buttonSpinner); label = new Label(); label.Text = "Input:"; label.Size = new Size(42, 20); label.TextAlign = ContentAlignment.MiddleLeft; panel.Controls.Add(label); inputLabel = new Label(); inputLabel.Text = "-"; inputLabel.Size = new Size(42, 20); inputLabel.TextAlign = ContentAlignment.MiddleLeft; panel.Controls.Add(inputLabel); label = new Label(); label.Text = "Output:"; label.Size = new Size(42, 20); label.TextAlign = ContentAlignment.MiddleLeft; panel.Controls.Add(label); buttonStateBox = new PictureBox(); buttonStateBox.Size = new Size(80, 20); buttonStateBox.Paint += onButtonStatePaint; panel.Controls.Add(buttonStateBox); var button = new Button(); button.Text = "Setup"; button.Click += onSetupClick; button.Size = new Size(50, 20); panel.Controls.Add(button); button = new Button(); button.Text = "Remove"; button.Click += onRemoveClick; button.Size = new Size(55, 20); panel.Controls.Add(button); joystickDropDown = new ComboBox(); joystickDropDown.DropDownStyle = ComboBoxStyle.DropDownList; joystickDropDown.Size = new Size(72, 20); joystickDropDown.Items.AddRange(vJoyEnumerator.GetJoysticks()); joystickDropDown.SelectedIndex = Joystick; joystickDropDown.SelectedIndexChanged += onJoystickChange; panel.Controls.Add(joystickDropDown); panel.ResumeLayout(); }