Skip to content

Commit

Permalink
add device filter
Browse files Browse the repository at this point in the history
  • Loading branch information
Maassoft committed Dec 4, 2020
1 parent 067b6d7 commit bc87260
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 41 deletions.
2 changes: 1 addition & 1 deletion ColorControl/ColorControl.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<ProductName>ColorControl</ProductName>
<PublisherName>Maassoft</PublisherName>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.3.5.0</ApplicationVersion>
<ApplicationVersion>1.3.6.0</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
Expand Down
2 changes: 1 addition & 1 deletion ColorControl/ColorDataConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public override object Deserialize(IDictionary<string, object> dictionary, Type
{
selectionPolicy = (ColorDataSelectionPolicy)Enum.ToObject(typeof(ColorDataSelectionPolicy), value);
}
return new ColorData(format, dynamicRange: dynamicRange, colorimetry: colorimetry, colorDepth: colorDepth, colorSelectionPolicy: selectionPolicy);
return new ColorData(format, dynamicRange: dynamicRange, colorimetry: colorimetry, colorDepth: colorDepth, colorSelectionPolicy: selectionPolicy, desktopColorDepth: ColorDataDesktopDepth.Default);
}
}
}
4 changes: 1 addition & 3 deletions ColorControl/LgService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ class LgService
{
public static string LgListAppsJson = "listApps.json";

public static string LgDeviceSearchKey = "[LG]";

private static readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger();

public string FriendlyScreenName { get; private set; }
Expand Down Expand Up @@ -88,7 +86,7 @@ public void SaveConfig()

public async Task RefreshDevices(bool connect = true)
{
var devices = await Utils.GetPnpDevices(LgDeviceSearchKey);
var devices = await Utils.GetPnpDevices(Config.DeviceSearchKey);
SetDevices(devices);
if (connect && SelectedDevice != null)
{
Expand Down
3 changes: 3 additions & 0 deletions ColorControl/LgServiceConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ class LgServiceConfig

public string PreferredMacAddress { get; set; }

public string DeviceSearchKey { get; set; }

public LgServiceConfig()
{
PowerOnDelayAfterResume = 5000;
DeviceSearchKey = "[LG]";
}
}
}
69 changes: 41 additions & 28 deletions ColorControl/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 21 additions & 2 deletions ColorControl/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ public MainForm(StartUpParams startUpParams)
clbLgPower.SetItemChecked(2, _lgService.Config.PowerOffOnShutdown);
clbLgPower.SetItemChecked(3, _lgService.Config.PowerOffOnStandby);
edtLgPowerOnAfterResumeDelay.Value = _lgService.Config.PowerOnDelayAfterResume;
edtLgDeviceFilter.Text = _lgService.Config.DeviceSearchKey;
}
catch (Exception e)
{
Expand Down Expand Up @@ -1420,7 +1421,7 @@ private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
var devices = _lgService.Devices;
if (devices == null || !devices.Any())
{
_lgService.RefreshDevices(false).ContinueWith((task) => BeginInvoke(new Action(FillLgDevices)));
RefreshLgDevices();
}
else
{
Expand All @@ -1440,6 +1441,7 @@ private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)

private void FillLgDevices()
{
cbxLgDevices.Items.Clear();
var devices = _lgService.Devices;
foreach (var device in devices)
{
Expand All @@ -1458,7 +1460,6 @@ private void FillLgDevices()
if (cbxLgApps.Items.Count == 0 && _lgService.SelectedDevice != null)
{
_lgService.RefreshApps().ContinueWith((task) => BeginInvoke(new Action<Task<List<LgApp>>>(FillLgApps), new[] { task }));
edtLgTvName.Text = _lgService.FriendlyScreenName;
}
}

Expand Down Expand Up @@ -1890,5 +1891,23 @@ private void btnClearLog_Click(object sender, EventArgs e)
edtLog.Clear();
}
}

private void edtLgDeviceFilter_TextChanged(object sender, EventArgs e)
{
if (_lgService != null)
{
_lgService.Config.DeviceSearchKey = edtLgDeviceFilter.Text;
}
}

private void btnLgDeviceFilterRefresh_Click(object sender, EventArgs e)
{
RefreshLgDevices();
}

private void RefreshLgDevices()
{
_lgService.RefreshDevices(false).ContinueWith((task) => BeginInvoke(new Action(FillLgDevices)));
}
}
}
10 changes: 8 additions & 2 deletions ColorControl/NvService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,14 @@ public bool ApplyPreset(NvPreset preset, Config config)
if (preset.applyColorData)
{
var display = GetCurrentDisplay();
//var data = new ColorData(ColorDataFormat.YUV444, ColorDataColorimetry.YCC709, ColorDataDynamicRange.Auto, ColorDataDepth.BPC8, preset.colorData.SelectionPolicy, ColorDataDesktopDepth.Default);
display.DisplayDevice.SetColorData(preset.colorData);
//var data = new ColorData(ColorDataFormat.YUV444, ColorDataColorimetry.Auto, ColorDataDynamicRange.Auto, ColorDataDepth.BPC10, preset.colorData.SelectionPolicy, ColorDataDesktopDepth.Default);
try
{
display.DisplayDevice.SetColorData(preset.colorData);
}
catch (Exception ex)
{
}

//var master = display.DisplayDevice.HDRColorData.MasteringDisplayData;
//var newMaster = new MasteringDisplayColorData(master.FirstColorCoordinate, master.SecondColorCoordinate, master.ThirdColorCoordinate, new ColorDataColorCoordinate(0.25f, 0.25f), 50, 0, 50, 50);
Expand Down
4 changes: 2 additions & 2 deletions ColorControl/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.3.5.0")]
[assembly: AssemblyFileVersion("1.3.5.0")]
[assembly: AssemblyVersion("1.3.6.0")]
[assembly: AssemblyFileVersion("1.3.6.0")]
4 changes: 2 additions & 2 deletions ColorControl/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public static string GetDeviceProperty(PnpObject device, string propertyName)
}
else
{
value = objValue.ToString();
value = objValue?.ToString();
}
}

Expand Down Expand Up @@ -272,7 +272,7 @@ public static async Task<List<PnpDev>> GetPnpDevices(string deviceName)
var ipAddress = GetDeviceProperty(dev2, "System.Devices.IpAddress");
var macAddress = GetDeviceProperty(dev2, PKEY_PNPX_PhysicalAddress);

if (!devices.Any(x => x.Name.Equals(name) && x.IpAddress.Equals(ipAddress)))
if (!devices.Any(x => x.Name.Equals(name) && x.IpAddress != null && x.IpAddress.Equals(ipAddress)))
{
var device = new PnpDev(dev, dev2, name, ipAddress, macAddress);
devices.Add(device);
Expand Down

0 comments on commit bc87260

Please sign in to comment.