Exemplo n.º 1
0
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            ApplicationSettings.CallbackDeviceID = ((KeyValuePair <int, string>)cbAudioDevices.SelectedItem).Value;


            if (((KeyValuePair <int, string>)cbMidiInDevice.SelectedItem).Key == -1)
            {
                ApplicationSettings.MidiInputDeviceID = null;
            }
            else
            {
                ApplicationSettings.MidiInputDeviceID = ((KeyValuePair <int, string>)cbMidiInDevice.SelectedItem).Value;
            }


            if (((KeyValuePair <int, string>)cbMidiOutDevice.SelectedItem).Key == -1)
            {
                ApplicationSettings.MidiOutputDeviceID = null;
            }
            else
            {
                ApplicationSettings.MidiOutputDeviceID = ((KeyValuePair <int, string>)cbMidiOutDevice.SelectedItem).Value;
            }


            if (((KeyValuePair <int, string>)cbMidiOutRepeaterDevice.SelectedItem).Key == -1)
            {
                ApplicationSettings.MidiOutputRepeatedDeviceID = null;
            }
            else
            {
                ApplicationSettings.MidiOutputRepeatedDeviceID = ((KeyValuePair <int, string>)cbMidiOutRepeaterDevice.SelectedItem).Value;
            }


            ApplicationSettings.SaveConfig();

            //Reload Midi Devices
            GlobalStaticContext.DetachAllMidiDevices();
            if (((KeyValuePair <int, string>)cbMidiInDevice.SelectedItem).Key != -1)
            {
                GlobalStaticContext.AttachMidiInDevice(((KeyValuePair <int, string>)cbMidiInDevice.SelectedItem).Key);
            }

            if (((KeyValuePair <int, string>)cbMidiOutDevice.SelectedItem).Key != -1)
            {
                GlobalStaticContext.AttachMidiOutDevice(((KeyValuePair <int, string>)cbMidiOutDevice.SelectedItem).Key);
            }

            if (((KeyValuePair <int, string>)cbMidiOutRepeaterDevice.SelectedItem).Key != -1)
            {
                GlobalStaticContext.AttachMidiRepeatDevice(((KeyValuePair <int, string>)cbMidiOutRepeaterDevice.SelectedItem).Key);
            }

            this.Close();
        }
Exemplo n.º 2
0
        public MainWindow()
        {
            InitializeComponent();
            this.Visibility = Visibility.Hidden;

            MainNotifyIcon.Icon = new System.Drawing.Icon("boardy_logo.ico");

            foreach (var pcs in ApplicationSettings.PadControls)
            {
                PadControl pc = new PadControl(pcs.AudioDeviceID, pcs.Volume, pcs.AudioFilePath, pcs.MidiNoteMap, pcs.VolumeSliderControllerMap);
                GlobalStaticContext.AddPad(pc);
                MainWrapPanel.Children.Add(pc);
            }

            int selectedMidiINPUTDevId = -1;

            for (int i = 0; i < MidiIn.NumberOfDevices; i++)
            {
                if (ApplicationSettings.MidiInputDeviceID == MidiIn.DeviceInfo(i).ProductName)
                {
                    selectedMidiINPUTDevId = i;
                }
            }

            int selectedMidiOUTPUTDevId   = -1;
            int selectedMidiREPEATEDDevId = -1;

            for (int i = 0; i < MidiOut.NumberOfDevices; i++)
            {
                if (ApplicationSettings.MidiOutputDeviceID == MidiOut.DeviceInfo(i).ProductName)
                {
                    selectedMidiOUTPUTDevId = i;
                }
                if (ApplicationSettings.MidiOutputRepeatedDeviceID == MidiOut.DeviceInfo(i).ProductName)
                {
                    selectedMidiREPEATEDDevId = i;
                }
            }


            if (ApplicationSettings.MidiInputDeviceID != null && ApplicationSettings.MidiInputDeviceID != "")
            {
                GlobalStaticContext.AttachMidiInDevice(selectedMidiINPUTDevId);
            }

            if (ApplicationSettings.MidiOutputDeviceID != null && ApplicationSettings.MidiOutputDeviceID != "")
            {
                GlobalStaticContext.AttachMidiOutDevice(selectedMidiOUTPUTDevId);
            }

            if (ApplicationSettings.MidiOutputRepeatedDeviceID != null && ApplicationSettings.MidiOutputRepeatedDeviceID != "")
            {
                GlobalStaticContext.AttachMidiRepeatDevice(selectedMidiREPEATEDDevId);
            }
        }