using System; using System.Windows; using System.Windows.Controls; using Commons.Music.Midi; namespace MidiTest { /// /// Interaction logic for MainWindow.xaml /// public partial class MainWindow : Window { public MainWindow() { this.InitializeComponent(); this.DetectMidi(); } private void DetectMidi() { IMidiAccess access = MidiAccessManager.Default; foreach (IMidiPortDetails item in access.Outputs) { _ = this.MidiSelector.Items.Add(new Tuple(item.Manufacturer + " - " + item.Name, item.Id)); } } private void test(Object sender, System.Windows.Input.MouseButtonEventArgs e) { IMidiOutput outp = MidiAccessManager.Default.OpenOutputAsync(((Tuple)this.MidiSelector.SelectedItem).Item2).Result; outp.Send(new Byte[] { 144, 81, 45 }, 0, 3, 0); outp.Send(new Byte[] { 176, 106, 53 }, 0, 3, 0); outp.Send(new Byte[] { 145, 11, 5 }, 0, 3, 0); outp.Send(new Byte[] { 144, 12, 21 }, 0, 3, 0); outp.Send(new Byte[] { 145, 12, 5 }, 0, 3, 0); outp.Send(new Byte[] { 146, 88, 81 }, 0, 3, 0); } private void ShowPopup(Object sender, System.Windows.Input.MouseButtonEventArgs e) { } private void ModusChanged(Object sender, EventArgs e) { if (sender is ComboBox) { if (((ComboBox)sender).SelectedItem is ComboBoxItem) { switch (((ComboBoxItem)((ComboBox)sender).SelectedItem).Content.ToString()) { case "Aus": this.Color1.Visibility = Visibility.Hidden; this.Color2.Visibility = Visibility.Hidden; break; case "Einfarbig": this.Color1.Visibility = Visibility.Visible; this.Color2.Visibility = Visibility.Hidden; break; case "Blinken": this.Color1.Visibility = Visibility.Visible; this.Color2.Visibility = Visibility.Visible; break; case "Pulsieren": this.Color1.Visibility = Visibility.Visible; this.Color2.Visibility = Visibility.Hidden; break; } } } } private void Color1Changed(Object sender, EventArgs e) { if (sender is ComboBox) { if (((ComboBox)sender).SelectedItem is ComboBoxItem) { this.Color1Prev.Fill = ((ComboBoxItem)((ComboBox)sender).SelectedItem).Background; } } } private void Color2Changed(Object sender, EventArgs e) { if (sender is ComboBox) { if (((ComboBox)sender).SelectedItem is ComboBoxItem) { this.Color2Prev.Fill = ((ComboBoxItem)((ComboBox)sender).SelectedItem).Background; } } } } }