/// <summary> /// Initializes a new instance of the <see cref="MidiOutModelBinding"/> class. /// </summary> /// <param name="model">The model.</param> /// <param name="midiOutAdapter">The midi out adapter.</param> public MidiOutModelBinding(AirCompModel model, IMidiOutAdapter midiOutAdapter) { _model = model; _midiOutAdapter = midiOutAdapter; _model.NoteOn += NoteOnHandler; _model.NoteOff += NoteOffHandler; _model.AllNotesOff += AllNotesOffHandler; _model.PropertyChanged += PropertyChangedHandler; }
/// <summary> /// Raises the <see cref="E:System.Windows.Application.Startup" /> event. /// </summary> /// <param name="e">A <see cref="T:System.Windows.StartupEventArgs" /> that contains the event data.</param> protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); var config = LoadConfig(); _midiOutAdapter = MidiOutAdapterFactory.GetInstance(); _model = SetupModel(config, _midiOutAdapter); _midiOutModelBinding = SetupMidiOutBinding(_model, _midiOutAdapter); _model.InitOutDevice(); ShowUi(_model); }
/// <summary> /// Shows the UI. /// </summary> /// <param name="model">The model.</param> private void ShowUi(AirCompModel model) { // Wire up MVVM var viewModel = new AirCompViewModel(); viewModel.Model = model; MainWindow = new MainWindow(); var view = (MainWindow)MainWindow; view.ViewModel = viewModel; // Show up! MainWindow.Show(); }
/// <summary> /// Setups the business model. /// </summary> /// <param name="config">The configuration.</param> /// <param name="adapter">The MIDI out adapter.</param> /// <returns> /// The created model. /// </returns> private static AirCompModel SetupModel(CompConfig config, IMidiOutAdapter adapter) { var model = new AirCompModel(config, adapter.GetMidiOutDevices(), adapter.GetMidiOutChannels()); try { // Without connected leap motion we recieve an exception here - move on model.InitializeControllerDevice(); } catch (Exception exception) { Debug.WriteLine(exception); } return(model); }
/// <summary> /// Setups the binding of the MIDI out adapter to the model. /// </summary> /// <param name="model">The model.</param> /// <param name="adapter">The adapter.</param> /// <returns> /// The created adapter. /// </returns> private static MidiOutModelBinding SetupMidiOutBinding(AirCompModel model, IMidiOutAdapter adapter) { return(new MidiOutModelBinding(model, adapter)); }