示例#1
0
        private void UpdateOutputState(object sender, EventArgs e)
        {
            var output = (OutputViewModel)sender;

            _orchestratorService.SetOutputState(output.Output.Id, output.IsActive);
            _orchestratorService.CommitChanges();
        }
示例#2
0
        private void MapMidiEvent(object sender, NoteEventReceivedEventArgs e)
        {
            Dispatcher.CurrentDispatcher.Invoke(() =>
            {
                if (e.Command == MidiCommandCode.NoteOn)
                {
                    LatestNote = e;
                }

                if (SelectedProfile == null)
                {
                    return;
                }

                var isActive           = NoteIsActive(e);
                var hasChangedMappings = false;
                foreach (var mapping in SelectedProfile.Mappings)
                {
                    var isMatch = mapping.Channel == e.Channel && mapping.Octave == e.Octave && mapping.Note == e.Note;
                    if (!isMatch)
                    {
                        continue;
                    }

                    var hasChanged = mapping.IsActive != isActive;
                    if (!hasChanged)
                    {
                        continue;
                    }

                    mapping.IsActive   = isActive;
                    hasChangedMappings = true;

                    foreach (var output in mapping.Outputs)
                    {
                        _orchestratorService.SetOutputState(output.Output.Id, mapping.IsActive);
                    }
                }

                if (hasChangedMappings)
                {
                    _orchestratorService.CommitChanges();
                }
            }, DispatcherPriority.Render);
        }