コード例 #1
0
        public MappingsListViewModel(
            IFactoryService factoryService,
            ISettingsService settingsService,
            IMidiService midiService,
            IOrchestratorService orchestratorService,
            IDialogService dialogService)
        {
            if (factoryService == null)
            {
                throw new ArgumentNullException(nameof(factoryService));
            }
            if (settingsService == null)
            {
                throw new ArgumentNullException(nameof(settingsService));
            }
            if (midiService == null)
            {
                throw new ArgumentNullException(nameof(midiService));
            }
            if (dialogService == null)
            {
                throw new ArgumentNullException(nameof(dialogService));
            }
            if (orchestratorService == null)
            {
                throw new ArgumentNullException(nameof(orchestratorService));
            }

            _factoryService      = factoryService;
            _settingsService     = settingsService;
            _dialogService       = dialogService;
            _orchestratorService = orchestratorService;

            RouteCommand(MappingsCommand.Add, AddMapping);
            RouteCommand(MappingsCommand.Edit, EditMapping);
            RouteCommand(MappingsCommand.Delete, DeleteMapping);
            RouteCommand(MappingsCommand.MoveUp, () => MoveMapping(-1));
            RouteCommand(MappingsCommand.MoveDown, () => MoveMapping(1));
            RouteCommand(ToolBarCommand.Reset, ResetStates);

            LoadMappings();
            midiService.NoteEventReceived += MapMidiEvent;
        }
コード例 #2
0
        public MappingEditorViewModel(IMidiService midiService, ISettingsService settingsService)
        {
            if (midiService == null)
            {
                throw new ArgumentNullException(nameof(midiService));
            }

            _midiService = midiService;
            _midiService.NoteEventReceived += FillFromPressedNote;

            for (var i = 0; i < 12; i++)
            {
                Channels.Add(new SelectableViewModel <int>(i)
                {
                    IsSelected = i == 2
                });
            }

            for (var i = 0; i < 9; i++)
            {
                Octaves.Add(new SelectableViewModel <int>(i));
            }

            Outputs.AddRange(settingsService.OutputViewModels.Select(o => new SelectableViewModel <OutputViewModel>(o)));

            Notes.Add(new SelectableViewModel <string>("C"));
            Notes.Add(new SelectableViewModel <string>("C#"));
            Notes.Add(new SelectableViewModel <string>("D"));
            Notes.Add(new SelectableViewModel <string>("D#"));
            Notes.Add(new SelectableViewModel <string>("E"));
            Notes.Add(new SelectableViewModel <string>("F"));
            Notes.Add(new SelectableViewModel <string>("F#"));
            Notes.Add(new SelectableViewModel <string>("G"));
            Notes.Add(new SelectableViewModel <string>("G#"));
            Notes.Add(new SelectableViewModel <string>("A"));
            Notes.Add(new SelectableViewModel <string>("A#"));
            Notes.Add(new SelectableViewModel <string>("B"));

            RouteCommand(MappingsCommand.Import, ImportOutputsFromCurrentState);
            RouteCommand(MappingsCommand.Reset, ResetOutputs);

            ImportOutputsFromCurrentState();
        }
コード例 #3
0
ファイル: SettingsViewModel.cs プロジェクト: chkr1011/LightPi
        public SettingsViewModel(ISettingsService settingsService, IMidiService midiService, ILogService logService)
        {
            if (settingsService == null)
            {
                throw new ArgumentNullException(nameof(settingsService));
            }
            if (midiService == null)
            {
                throw new ArgumentNullException(nameof(midiService));
            }
            if (logService == null)
            {
                throw new ArgumentNullException(nameof(logService));
            }

            _settingsService = settingsService;
            _midiService     = midiService;
            _logService      = logService;
        }
コード例 #4
0
 public HomeController(IMidiService midiService)
 {
     _midiService = midiService;
 }
コード例 #5
0
        public MainWindowViewModel(
            IFactoryService factoryService,
            IDialogService dialogService,
            ISettingsService settingsService,
            IMidiService midiService,
            IOrchestratorService orchestratorService,
            ILogService logService,
            EmulatorViewModel emulatorViewModel,
            MappingsListViewModel mappingsViewModel,
            LogViewModel logViewModel)
        {
            if (factoryService == null)
            {
                throw new ArgumentNullException(nameof(factoryService));
            }
            if (settingsService == null)
            {
                throw new ArgumentNullException(nameof(settingsService));
            }
            if (midiService == null)
            {
                throw new ArgumentNullException(nameof(midiService));
            }
            if (orchestratorService == null)
            {
                throw new ArgumentNullException(nameof(orchestratorService));
            }
            if (logService == null)
            {
                throw new ArgumentNullException(nameof(logService));
            }
            if (mappingsViewModel == null)
            {
                throw new ArgumentNullException(nameof(mappingsViewModel));
            }
            if (logViewModel == null)
            {
                throw new ArgumentNullException(nameof(logViewModel));
            }

            _factoryService      = factoryService;
            _dialogService       = dialogService;
            _settingsService     = settingsService;
            _midiService         = midiService;
            _orchestratorService = orchestratorService;
            _logService          = logService;

            Mappings = mappingsViewModel;
            Emulator = emulatorViewModel;
            Log      = logViewModel;

            RouteCommand(ToolBarCommand.Settings, ChangeSettings);
            RouteCommand(ToolBarCommand.Outputs, ChangeOutputs);

            Initialize();

            _dialogService.DialogShown  += (s, e) => HasDialog = true;
            _dialogService.DialogClosed += (s, e) => HasDialog = false;

            var version = Assembly.GetEntryAssembly().GetName().Version;

            Title = $"MIDI 2 Orchestrator Bridge v{version} - LightPi (c) Christian Kratky 2016";
        }