public void SetDefaults() { HdmiPort = 1; DeviceType = CecDeviceType.RecordingDevice; OsdName = "MediaPortal"; FastScrolling = false; FastScrollingRepeatDelay = 2; FastScrollingRepeatRate = 40; RequireDelayBetweenKeys = false; DelayBetweenKeys = 300; DisableScreensaver = false; ExtensiveLogging = false; WakeDevicesOnStart = true; ActivateSourceOnStart = true; OnStartWakeDevices = new CecLogicalAddresses(); OnStartWakeDevices.Set(CecLogicalAddress.Tv); OnStartWakeDevices.Set(CecLogicalAddress.AudioSystem); StandbyDevicesOnExit = false; InactivateSourceOnExit = false; OnExitStandbyDevices = new CecLogicalAddresses(); OnExitStandbyDevices.Set(CecLogicalAddress.Tv); OnExitStandbyDevices.Set(CecLogicalAddress.AudioSystem); WakeDevicesOnResume = true; ActivateSourceOnResume = true; RequireUserInputOnResume = true; OnResumeWakeDevices = new CecLogicalAddresses(); OnResumeWakeDevices.Set(CecLogicalAddress.Tv); OnResumeWakeDevices.Set(CecLogicalAddress.AudioSystem); StandbyDevicesOnSleep = true; InactivateSourceOnSleep = false; OnSleepStandbyDevices = new CecLogicalAddresses(); OnSleepStandbyDevices.Set(CecLogicalAddress.Tv); OnSleepStandbyDevices.Set(CecLogicalAddress.AudioSystem); ClientVersion = LibCECConfiguration.CurrentVersion; ConnectedTo = CecLogicalAddress.Tv; SendTvPowerOff = false; SendTvPowerOffOnlyIfActiveSource = true; RequireActiveSourceWhenSleep = true; ControlVolume = false; ForcePhysicalAddress = false; PhysicalAddress = "1000"; }
private static CecLogicalAddresses DeserialiseLogicalAddresses(int addresses) { CecLogicalAddresses retVal = new CecLogicalAddresses(); if (addresses == 0) return retVal; for (int addr = (int)CecLogicalAddress.Tv; addr <= (int)CecLogicalAddress.Broadcast; addr++) { int val = (int)Math.Pow(2, addr); if ((addresses & val) == val) retVal.Set((CecLogicalAddress)addr); } return retVal; }
private static CecLogicalAddresses DeserialiseLogicalAddresses(int addresses) { CecLogicalAddresses retVal = new CecLogicalAddresses(); if (addresses == 0) { return(retVal); } for (int addr = (int)CecLogicalAddress.Tv; addr <= (int)CecLogicalAddress.Broadcast; addr++) { int val = (int)Math.Pow(2, addr); if ((addresses & val) == val) { retVal.Set((CecLogicalAddress)addr); } } return(retVal); }
private CecLogicalAddresses ParseDevices(string devices) { CecLogicalAddresses list = new CecLogicalAddresses(); if (devices.Length == 0) { return(list); } string[] devicelist = devices.Split(','); foreach (string d in devicelist) { if (d != "Unknown" && d != "Unregistered") { list.Set((CecSharp.CecLogicalAddress)Enum.Parse(typeof(CecLogicalAddress), d)); } } return(list); }
private void ShowSelectDevices(CecLogicalAddresses list) { SelectDevices sel = new SelectDevices(); sel.StartPosition = FormStartPosition.CenterParent; foreach (PropertyInfo property in sel.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)) { if (property.CanWrite && property.PropertyType.Equals(typeof(System.Boolean))) { property.SetValue(sel, false, null); if (list.IsSet((CecLogicalAddress)Enum.Parse(typeof(CecLogicalAddress), property.Name, true))) { property.SetValue(sel, true, null); } } } if (sel.ShowDialog(this) == DialogResult.OK) { list.Clear(); foreach (PropertyInfo property in sel.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)) { if (property.CanRead && property.PropertyType.Equals(typeof(System.Boolean))) { if ((bool)property.GetValue(sel, null)) { list.Set((CecLogicalAddress)Enum.Parse(typeof(CecLogicalAddress), property.Name, true)); } } } sel = null; } }
/// <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) && !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; } }
private CecLogicalAddresses ParseDevices(string devices) { CecLogicalAddresses list = new CecLogicalAddresses(); if (devices.Length == 0) { return list; } string[] devicelist = devices.Split(','); foreach (string d in devicelist) { if (d != "Unknown" && d != "Unregistered") { list.Set((CecSharp.CecLogicalAddress)Enum.Parse(typeof(CecLogicalAddress), d)); } } return list; }
/// <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) && !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; } }