/// <summary> /// Sets the state of this user control, according to the zone state passed into. /// It keeps the current selected Zone Id. /// </summary> /// <param name="zoneState">Zone state, which shall be set.</param> public void updateZoneState(ZoneState zoneState) { if (_zoneState != zoneState) { _log.Trace(m => m("Update Zone state in control {0}, for zone {1} ({2}). New State='{3}'", this.Name, GetSelectedZone().ToString(), _selectedZone.ToString(), zoneState)); _zoneState = zoneState; if ((cmbSourceSelect != null) && (cmbSourceSelect.Items.Count > 0)) { // triggers the method cmbSourceSelect_SelectedIndexChanged() cmbSourceSelect.SelectedIndex = zoneState.Source.ObjectId - 1; } if ((cmbPowerStatusSelect != null) && (cmbPowerStatusSelect.Items.Count > 0)) { // triggers the method cmbPowerStatusSelect_SelectedIndexChanged() cmbPowerStatusSelect.SelectedItem = (zoneState.PowerStatus ? EZonePowerStatus.ZoneStatusON.ToString() : EZonePowerStatus.ZoneStatusOFF.ToString()); } if (trackVolume != null) { trackVolume.Value = zoneState.Volume; VolumeLevel_Changed(); } } }
/// <summary> /// Private method to notify the subscribers about changes in the zone state. /// </summary> /// <param name="zoneId">Zone Id, of the changed zone. One-Based enumeration.</param> /// <param name="oldZoneState">Old Zone State.</param> /// <param name="newZoneState">New Zone State.</param> private void notifyZoneStateSubscribers(ENuvoEssentiaZones zoneId, ZoneState oldZoneState, ZoneState newZoneState) { _log.Trace(m => m("Zone State with zoneId='{0}' has changed, notify the subscribers. oldState='{1}' newState='{2}'.", zoneId.ToString(), oldZoneState.ToString(), newZoneState.ToString())); if (onZoneUpdated != null) { if (oldZoneState != newZoneState) { onZoneUpdated(this, new ZoneStateEventArgs(zoneId, oldZoneState, newZoneState)); } } }