Skip to content

Commit

Permalink
Switch to using display IDs rather than name + index
Browse files Browse the repository at this point in the history
  • Loading branch information
tombayley committed Sep 12, 2024
1 parent 29d2ebb commit 10b1612
Show file tree
Hide file tree
Showing 22 changed files with 910 additions and 557 deletions.
21 changes: 0 additions & 21 deletions NightGlow.MonitorConfig/Monitors.cs

This file was deleted.

9 changes: 0 additions & 9 deletions NightGlow.MonitorConfig/NightGlow.MonitorConfig.csproj

This file was deleted.

120 changes: 0 additions & 120 deletions NightGlow.MonitorConfig/PhysicalMonitor.cs

This file was deleted.

106 changes: 0 additions & 106 deletions NightGlow.MonitorConfig/VirtualMonitor.cs

This file was deleted.

17 changes: 0 additions & 17 deletions NightGlow.sln
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
VisualStudioVersion = 17.7.34009.444
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NightGlow", "NightGlow\NightGlow.csproj", "{8E4BBB59-4D6D-48CF-9E04-CB3D7CA97401}"
ProjectSection(ProjectDependencies) = postProject
{5D7C7E03-E446-49ED-977A-2EA6824FE29A} = {5D7C7E03-E446-49ED-977A-2EA6824FE29A}
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NightGlow.WindowsApi", "NightGlow.WindowsApi\NightGlow.WindowsApi.csproj", "{961F5C16-4446-40EC-9A72-1C352920335D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NightGlow.MonitorConfig", "NightGlow.MonitorConfig\NightGlow.MonitorConfig.csproj", "{5D7C7E03-E446-49ED-977A-2EA6824FE29A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -46,18 +41,6 @@ Global
{961F5C16-4446-40EC-9A72-1C352920335D}.Release|x64.Build.0 = Release|Any CPU
{961F5C16-4446-40EC-9A72-1C352920335D}.Release|x86.ActiveCfg = Release|Any CPU
{961F5C16-4446-40EC-9A72-1C352920335D}.Release|x86.Build.0 = Release|Any CPU
{5D7C7E03-E446-49ED-977A-2EA6824FE29A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5D7C7E03-E446-49ED-977A-2EA6824FE29A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5D7C7E03-E446-49ED-977A-2EA6824FE29A}.Debug|x64.ActiveCfg = Debug|Any CPU
{5D7C7E03-E446-49ED-977A-2EA6824FE29A}.Debug|x64.Build.0 = Debug|Any CPU
{5D7C7E03-E446-49ED-977A-2EA6824FE29A}.Debug|x86.ActiveCfg = Debug|Any CPU
{5D7C7E03-E446-49ED-977A-2EA6824FE29A}.Debug|x86.Build.0 = Debug|Any CPU
{5D7C7E03-E446-49ED-977A-2EA6824FE29A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5D7C7E03-E446-49ED-977A-2EA6824FE29A}.Release|Any CPU.Build.0 = Release|Any CPU
{5D7C7E03-E446-49ED-977A-2EA6824FE29A}.Release|x64.ActiveCfg = Release|Any CPU
{5D7C7E03-E446-49ED-977A-2EA6824FE29A}.Release|x64.Build.0 = Release|Any CPU
{5D7C7E03-E446-49ED-977A-2EA6824FE29A}.Release|x86.ActiveCfg = Release|Any CPU
{5D7C7E03-E446-49ED-977A-2EA6824FE29A}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
3 changes: 3 additions & 0 deletions NightGlow/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
<setting name="ShowBrightTempPopup" serializeAs="String">
<value>False</value>
</setting>
<setting name="DdcConfigJsonV2" serializeAs="String">
<value />
</setting>
</NightGlow.Properties.Settings>
</userSettings>
</configuration>
38 changes: 19 additions & 19 deletions NightGlow/Data/DdcConfig.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using NightGlow.MonitorConfig;
using NightGlow.Models;
using System;
using System.Collections.Generic;

Expand All @@ -8,56 +8,56 @@ namespace NightGlow.Data;
public class DdcConfig
{

public IList<DdcMonitorItem> DdcMonitorItems;
public IList<DdcConfigMonitor> DdcConfigMonitorItems;

public DdcConfig()
{
DdcMonitorItems = new List<DdcMonitorItem>();
DdcConfigMonitorItems = new List<DdcConfigMonitor>();
}

public DdcMonitorItem GetOrCreateDdcMonitorItem(VirtualMonitor vm)
public DdcConfigMonitor GetOrCreateDdcConfigMonitor(DdcMonitor monitor)
{
foreach (var item in DdcMonitorItems)
if (item.Name.Equals(vm.FriendlyName) && item.DeviceName.Equals(vm.DeviceName))
foreach (var item in DdcConfigMonitorItems)
if (item.DeviceInstanceId.Equals(monitor.DeviceInstanceId))
return item;

DdcMonitorItem newItem = new DdcMonitorItem
DdcConfigMonitor newItem = new DdcConfigMonitor
{
Name = vm.FriendlyName,
DeviceName = vm.DeviceName,
Description = monitor.Description,
DeviceInstanceId = monitor.DeviceInstanceId,
EnableDdc = false,
MinBrightnessPct = 0,
MaxBrightness = 100
};
DdcMonitorItems.Add(newItem);
DdcConfigMonitorItems.Add(newItem);
return newItem;
}

public void SetEnableDdc(VirtualMonitor vm, bool value)
public void SetEnableDdc(DdcMonitor monitor, bool value)
{
DdcMonitorItem item = GetOrCreateDdcMonitorItem(vm);
DdcConfigMonitor item = GetOrCreateDdcConfigMonitor(monitor);
item.EnableDdc = value;
}

public void SetMinBrightnessPct(VirtualMonitor vm, int value)
public void SetMinBrightnessPct(DdcMonitor monitor, int value)
{
DdcMonitorItem item = GetOrCreateDdcMonitorItem(vm);
DdcConfigMonitor item = GetOrCreateDdcConfigMonitor(monitor);
item.MinBrightnessPct = value;
}

public void SetMaxBrightness(VirtualMonitor vm, int value)
public void SetMaxBrightness(DdcMonitor monitor, int value)
{
DdcMonitorItem item = GetOrCreateDdcMonitorItem(vm);
DdcConfigMonitor item = GetOrCreateDdcConfigMonitor(monitor);
item.MaxBrightness = value;
}

}

[Serializable]
public class DdcMonitorItem
public class DdcConfigMonitor
{
public string Name;
public string DeviceName;
public string Description;

Check warning on line 59 in NightGlow/Data/DdcConfig.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable field 'Description' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.
public string DeviceInstanceId;

Check warning on line 60 in NightGlow/Data/DdcConfig.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable field 'DeviceInstanceId' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

public bool EnableDdc;

Expand Down
Loading

0 comments on commit 10b1612

Please sign in to comment.