/// <summary> /// Activate the source at the given logical address. /// </summary> /// <param name="address">The logical address of the device to activate</param> public void ActivateSource(CecLogicalAddress address) { if (SuppressUpdates || _activeProcess != null) return; _controller.SetControlsEnabled(false); _activeProcess = new SendActivateSource(_controller.Lib, address); _activeProcess.EventHandler += ProcessEventHandler; (new Thread(_activeProcess.Run)).Start(); }
/// <summary> /// Connect to the adapter with the given configuration /// </summary> /// <param name="config">The client configuration</param> public void ConnectToDevice(LibCECConfiguration config) { if (_activeProcess != null) return; _activeProcess = new ConnectToDevice(_controller.Lib, config); _activeProcess.EventHandler += ProcessEventHandler; (new Thread(_activeProcess.Run)).Start(); }
/// <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.StatusText: _controller.SetStatusText(updateEvent.StringValue); 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: 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)) { _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: _activeProcess = null; Application.Exit(); break; } }
/// <summary> /// Updates the contents of a device information window /// </summary> /// <param name="panel">The panel to update</param> public void UpdateInfoPanel(DeviceInformation panel) { if (SuppressUpdates || _activeProcess != null) return; _controller.SetControlsEnabled(false); _updatingInfoPanel = panel; panel.SetControlEnabled(panel.bUpdate, false); _activeProcess = new UpdateDeviceInfo(_controller, _controller.Lib, panel); _activeProcess.EventHandler += ProcessEventHandler; (new Thread(_activeProcess.Run)).Start(); }
/// <summary> /// Send an updated configuration to libCEC /// </summary> /// <param name="config">The new configuration</param> public void UpdateConfigurationAsync(LibCECConfiguration config) { if (SuppressUpdates || _activeProcess != null) return; _controller.SetControlsEnabled(false); _activeProcess = new UpdateConfiguration(_controller.Lib, config); _activeProcess.EventHandler += ProcessEventHandler; (new Thread(_activeProcess.Run)).Start(); }
/// <summary> /// Changes the physical address setting of libCEC /// </summary> /// <param name="physicalAddress">The new physical address</param> public void SetPhysicalAddress(ushort physicalAddress) { if (SuppressUpdates || _activeProcess != null || !_controller.Settings.OverridePhysicalAddress.Value) return; _controller.SetControlsEnabled(false); _activeProcess = new UpdatePhysicalAddress(_controller.Lib, physicalAddress); _activeProcess.EventHandler += ProcessEventHandler; (new Thread(_activeProcess.Run)).Start(); }
/// <summary> /// Change the device to which the adapter is connected and/or the HDMI port number /// </summary> /// <param name="address">The new device to which the adapter is connected</param> /// <param name="portnumber">The new HDMI port number</param> public void SetConnectedDevice(CecLogicalAddress address, int portnumber) { if (SuppressUpdates || _activeProcess != null) return; _controller.SetControlsEnabled(false); _activeProcess = new UpdateConnectedDevice(_controller.Lib, address, portnumber); _activeProcess.EventHandler += ProcessEventHandler; (new Thread(_activeProcess.Run)).Start(); }
/// <summary> /// Poll devices to check which ones are active /// </summary> public void RescanDevices() { if (SuppressUpdates || _activeProcess != null) return; _controller.SetControlsEnabled(false); _activeProcess = new RescanDevices(_controller.Lib); _activeProcess.EventHandler += ProcessEventHandler; (new Thread(_activeProcess.Run)).Start(); }