/// <summary> /// Initializes the sender component with the Midi Out Port. /// </summary> /// <param name="port">The Midi Out Port.</param> public void Initialize(IMidiPort port) { Check.IfArgumentNull(port, "port"); Check.IfArgumentNotOfType <MidiOutPort>(port, "port"); port.StatusChanged += new EventHandler(MidiPort_StatusChanged); }
/// <summary> /// Removes any references the receiver component has to/from the Midi Port. /// </summary> /// <param name="port">A Midi In Port. Must not be null.</param> public void Uninitialize(IMidiPort port) { Check.IfArgumentNull(port, "port"); Check.IfArgumentNotOfType <MidiInPort>(port, "port"); port.StatusChanged -= new EventHandler(MidiPort_StatusChanged); PortStatus = MidiPortStatus.None; }
/// <summary> /// Event handler for the port status changed event. /// </summary> /// <param name="sender">The originating midi port.</param> /// <param name="e">Not used.</param> private void MidiPort_StatusChanged(object sender, EventArgs e) { IMidiPort port = (IMidiPort)sender; if (port.HasStatus(MidiPortStatus.Closed | MidiPortStatus.Reset)) { RunningStatus = 0; } }
/// <summary> /// Contract. /// </summary> /// <param name="port">Must not be null.</param> void IInitializeByMidiPort.Uninitialize(IMidiPort port) { Contract.Requires(port != null); throw new System.NotImplementedException(); }
/// <summary> /// Event handler when the port status changes. /// </summary> /// <param name="sender">The midi port.</param> /// <param name="e">Not used.</param> private void MidiPort_StatusChanged(object sender, EventArgs e) { IMidiPort port = (IMidiPort)sender; OnNewPortStatus(port.Status); }