Exemplo n.º 1
0
        protected override void StartCore(dynamic parameters = null)
        {
            MidiInput = MIDIManager.GetDevice(parameters?.DeviceID);
            MidiInput.AddChannelMessageAction(HandleMidi);
            MidiInput.StartRecording();

            ColorsToSend = new Dictionary <int, Color>();
            Zone.SortedLights.Keys.ToList().ForEach(lightIndex => ColorsToSend.Add(lightIndex, Color.Black));
        }
Exemplo n.º 2
0
        protected override void StartCore(dynamic parameters = null)
        {
            if (parameters != null)
            {
                int?deviceID      = parameters?.DeviceID;
                var freeDevices   = MIDIManager.FreeDevices;
                var freeDeviceIDs = freeDevices?.Select(x => x.DeviceID).ToList();
                var isDeviceNull  = parameters?.DeviceID == null;

                if (!isDeviceNull && freeDeviceIDs?.Contains(deviceID))
                {
                    MidiInput = MIDIManager.GetDevice(parameters.DeviceID);
                    MidiInput.AddChannelMessageAction(HandleMidi);
                    MidiInput.StartRecording();
                }
                else
                {
                    throw new WarningException("Supplied MIDI Device ID is either in use or invalid.");
                }
            }

            base.StartCore(null);
        }