/// <summary> /// Sets up the button on the form with the necessary parameters /// </summary> /// <param name="name">id/name of the button to find</param> /// <param name="led">led to attach to the button</param> public void SetupButton(string name, IAPCLEDButton led) { Button btn = GetButton(name); btn.Tag = led; btn.Click += ButtonClickEventHandler; btn.MouseDown += ButtonMouseDownEventHandler; led.SelectedOptionChanged += SelectedOptionChangedEventHandler; led.SetParentButton(btn); usedButtons.Add(btn.Name, btn); }
/// <summary> /// Sends a note on to the selected device /// </summary> private void TurnOnLED(IAPCLEDButton button, IAPCLEDButtonOption option) { OutputDevice selectedDevice = (OutputDevice)lbDevices.SelectedItem; selectedDevice.Open(); try { selectedDevice.SendNoteOn(button.Channel, button.NoteNumber, option.Velocity); } catch (Exception ex) { MessageBox.Show("An error occurred while sending the SysEx message to " + selectedDevice.Name + ".", "Error"); } finally { selectedDevice.Close(); } }