Пример #1
0
 private void OnSettingChanged(CECSetting setting, object oldValue, object newValue)
 {
     if (SettingChanged != null)
     {
         SettingChanged(setting, oldValue, newValue);
     }
 }
Пример #2
0
 /// <summary>
 /// Load a setting value from the registry
 /// </summary>
 /// <param name="setting">The setting to load</param>
 public void Load(CECSetting setting)
 {
     using (var subRegKey = Registry.CurrentUser.OpenSubKey(RegistryKeyName, true))
     {
         if (subRegKey == null)
         {
             return;
         }
         setting.Load(subRegKey);
         subRegKey.Close();
     }
     setting.SettingChanged += OnSettingChanged;
 }
Пример #3
0
 /// <summary>
 /// Called when a setting changed
 /// </summary>
 /// <param name="setting">The setting that changed</param>
 /// <param name="oldValue">The old value</param>
 /// <param name="newValue">The new value</param>
 private void OnSettingChanged(CECSetting setting, object oldValue, object newValue)
 {
     if (setting.KeyName == CECSettings.KeyHDMIPort)
       {
     CECSettingByte byteSetting = setting as CECSettingByte;
     if (byteSetting != null)
     {
       if (!Settings.OverridePhysicalAddress.Value)
     Config.HDMIPort = byteSetting.Value;
       CECActions.SetConnectedDevice(Settings.ConnectedDevice.Value, byteSetting.Value);
     }
       }
       else if (setting.KeyName == CECSettings.KeyConnectedToHDMIDevice)
       {
     CECSettingLogicalAddress laSetting = setting as CECSettingLogicalAddress;
     if (laSetting != null)
     {
       if (!Settings.OverridePhysicalAddress.Value)
     Config.BaseDevice = laSetting.Value;
       CECActions.SetConnectedDevice(laSetting.Value, Settings.HDMIPort.Value);
     }
       }
       else if (setting.KeyName == CECSettings.KeyPhysicalAddress)
       {
     CECSettingUShort ushortSetting = setting as CECSettingUShort;
     if (ushortSetting != null && Settings.OverridePhysicalAddress.Value && Config.PhysicalAddress != ushortSetting.Value)
     {
       Config.PhysicalAddress = ushortSetting.Value;
       CECActions.SetPhysicalAddress(ushortSetting.Value);
     }
       }
       else if (setting.KeyName == CECSettings.KeyOverridePhysicalAddress)
       {
     CECSettingBool boolSetting = setting as CECSettingBool;
     if (boolSetting != null)
     {
       Settings.PhysicalAddress.Enabled = boolSetting.Value;
       Settings.HDMIPort.Enabled = !boolSetting.Value;
       Settings.ConnectedDevice.Enabled = !boolSetting.Value;
       if (boolSetting.Value)
       {
     Config.BaseDevice = Settings.ConnectedDevice.Value;
     Config.HDMIPort = 0;
     Config.PhysicalAddress = Settings.PhysicalAddress.Value;
       }
       else
       {
     Config.BaseDevice = Settings.ConnectedDevice.Value;
     Config.HDMIPort = Settings.HDMIPort.Value;
     Config.PhysicalAddress = 0xFFFF;
       }
     }
       }
       else if (setting.KeyName == CECSettings.KeyDeviceType)
       {
     CECSettingDeviceType dtSetting = setting as CECSettingDeviceType;
     if (dtSetting != null)
     {
       if (dtSetting.Value != Config.DeviceTypes.Types[0] && Settings.OverrideTVVendor.Value)
       {
     Config.DeviceTypes.Types[0] = dtSetting.Value;
     if (!_deviceChangeWarningDisplayed)
     {
       _deviceChangeWarningDisplayed = true;
       MessageBox.Show(Resources.device_type_changed, Resources.app_name, MessageBoxButtons.OK,
                       MessageBoxIcon.Warning);
     }
       }
     }
       }
       else if (setting.KeyName == CECSettings.KeyOverrideTVVendor)
       {
     CECSettingBool boolSetting = setting as CECSettingBool;
     if (boolSetting != null)
     {
       Settings.TVVendor.Enabled = boolSetting.Value;
       Settings.TVVendor.Value = boolSetting.Value ? Lib.GetDeviceVendorId(CecLogicalAddress.Tv) : CecVendorId.Unknown;
       Config.TvVendor = boolSetting.Value ? Settings.TVVendor.Value : CecVendorId.Unknown;
     }
       }
       else if (setting.KeyName == CECSettings.KeyActivateSource)
       {
     CECSettingBool boolSetting = setting as CECSettingBool;
     if (boolSetting != null)
       Config.ActivateSource = boolSetting.Value;
       }
       else if (setting.KeyName == CECSettings.KeyTVVendor)
       {
     CECSettingVendorId vendorSetting = setting as CECSettingVendorId;
     if (vendorSetting != null && Settings.OverrideTVVendor.Value)
       Config.TvVendor = vendorSetting.Value;
       }
       else if (setting.KeyName == CECSettings.KeyWakeDevices)
       {
     CECSettingLogicalAddresses laSetting = setting as CECSettingLogicalAddresses;
     if (laSetting != null)
       Config.WakeDevices = laSetting.Value;
       }
       else if (setting.KeyName == CECSettings.KeyPowerOffDevices)
       {
     CECSettingLogicalAddresses laSetting = setting as CECSettingLogicalAddresses;
     if (laSetting != null)
       Config.PowerOffDevices = laSetting.Value;
       }
 }
Пример #4
0
 private void OnSettingChanged(CECSetting setting, object oldValue, object newValue)
 {
     SettingChanged?.Invoke(setting, oldValue, newValue);
 }
Пример #5
0
 private bool EnableSettingTVVendor(CECSetting setting, bool value)
 {
     return(value && OverrideTVVendor.Value);
 }
Пример #6
0
 private bool EnableDetectAddressSetting(CECSetting setting, bool value)
 {
     return(value && !OverridePhysicalAddress.Value);
 }
Пример #7
0
 /// <summary>
 /// Load a setting value from the registry
 /// </summary>
 /// <param name="setting">The setting to load</param>
 public void Load(CECSetting setting)
 {
   using (var subRegKey = Registry.CurrentUser.OpenSubKey(RegistryKeyName, true))
   {
     if (subRegKey == null) return;
     setting.Load(subRegKey);
     subRegKey.Close();
   }
   setting.SettingChanged += OnSettingChanged;
 }
Пример #8
0
 public CECSettings(CECSetting.SettingChangedHandler changedHandler)
 {
   _changedHandler = changedHandler;
   Load();
 }
Пример #9
0
 private void OnSettingChanged(CECSetting setting, object oldValue, object newValue)
 {
   if (SettingChanged != null)
     SettingChanged(setting, oldValue, newValue);
 }
Пример #10
0
 private bool EnableSettingTVVendor(CECSetting setting, bool value)
 {
   return value && OverrideTVVendor.Value;
 }
Пример #11
0
 private bool EnablePhysicalAddressSetting(CECSetting setting, bool value)
 {
   return value && OverridePhysicalAddress.Value;
 }