/// <summary> /// Update the physical address of libCEC that is displayed in the UI /// </summary> public void UpdatePhysicalAddress() { if (SuppressUpdates || _activeProcess != null) { return; } _controller.SetControlsEnabled(false); _activeProcess = new GetCurrentPhysicalAddress(_controller.Lib); _activeProcess.EventHandler += ProcessEventHandler; (new Thread(_activeProcess.Run)).Start(); }
/// <summary> /// Event handler for processing updates for a background thread /// </summary> /// <param name="src">The source that sent the event</param> /// <param name="updateEvent">The type of event</param> private void ProcessEventHandler(object src, UpdateEvent updateEvent) { switch (updateEvent.Type) { case UpdateEventType.StatusReady: _controller.SetReady(); break; case UpdateEventType.StatusText: _controller.SetStatusText(updateEvent.StringValue); break; case UpdateEventType.ClearWarning: _controller.CecWarnings.Remove(updateEvent.AlertValue); _controller.UpdateAlertStatus(); break; case UpdateEventType.RegisterWarning: if (!_controller.CecWarnings.Contains(updateEvent.AlertValue)) { _controller.CecWarnings.AddLast(updateEvent.AlertValue); } _controller.UpdateAlertStatus(); break; case UpdateEventType.ProgressBar: _controller.SetProgressBar(updateEvent.IntValue, true); break; case UpdateEventType.PhysicalAddress: _controller.Settings.PhysicalAddress.Value = (ushort)updateEvent.IntValue; break; case UpdateEventType.TVVendorId: _controller.Settings.SetVendorName(CecLogicalAddress.Tv, (CecVendorId)updateEvent.IntValue, _controller.Lib.ToString((CecVendorId)updateEvent.IntValue)); break; case UpdateEventType.BaseDevice: _controller.Settings.ConnectedDevice.Value = (CecLogicalAddress)updateEvent.IntValue; break; case UpdateEventType.HDMIPort: _controller.Settings.HDMIPort.Value = (byte)updateEvent.IntValue; break; case UpdateEventType.HasAVRDevice: // XXX also allow the AVR to be selected if it's not detected at this time //CecLogicalAddresses allowedMask = new CecLogicalAddresses(); //allowedMask.Set(CecLogicalAddress.Tv); //if (updateEvent.BoolValue) // allowedMask.Set(CecLogicalAddress.AudioSystem); //_controller.Settings.ConnectedDevice.AllowedAddressMask = allowedMask; break; case UpdateEventType.AVRVendorId: _controller.Settings.SetVendorName(CecLogicalAddress.AudioSystem, (CecVendorId)updateEvent.IntValue, _controller.Lib.ToString((CecVendorId)updateEvent.IntValue)); break; case UpdateEventType.Configuration: SuppressUpdates = true; _controller.ConfigurationChanged(updateEvent.ConfigValue); SuppressUpdates = false; break; case UpdateEventType.PollDevices: _controller.CheckActiveDevices(); break; case UpdateEventType.ProcessCompleted: if (!(_activeProcess is GetCurrentPhysicalAddress) && !SuppressUpdates) { _activeProcess = new GetCurrentPhysicalAddress(_controller.Lib); _activeProcess.EventHandler += ProcessEventHandler; (new Thread(_activeProcess.Run)).Start(); } else { _activeProcess = null; } if (_updatingInfoPanel != null) { _updatingInfoPanel.SetControlEnabled(_updatingInfoPanel.bUpdate, true); _updatingInfoPanel = null; } _controller.SetControlsEnabled(true); _controller.SetProgressBar(100, false); if (_controller.Settings.StartHidden.Value) { _controller.SetShowInTaskbar(false); //SetToolStripMenuText(tsMenuShowHide, Resources.show); _controller.Hide(true); } break; case UpdateEventType.ExitApplication: SuppressUpdates = true; _activeProcess = null; Application.Exit(); break; case UpdateEventType.Connected: _controller.SetControlsEnabled(true); break; } }