Skip to content

Commit 0227c25

Browse files
committed
Nvapi, UI Changes
Implemented Nvapi UI overhaul
1 parent 6997353 commit 0227c25

30 files changed

+1277
-774
lines changed

Source/AutoHDR.Displays/AutoHDR.Displays.csproj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@
5454
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
5555
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
5656
</Reference>
57+
<Reference Include="NvAPIWrapper, Version=0.8.1.100, Culture=neutral, PublicKeyToken=310fd07b25df79b3, processorArchitecture=MSIL">
58+
<HintPath>..\packages\NvAPIWrapper.Net.0.8.1.101\lib\net45\NvAPIWrapper.dll</HintPath>
59+
</Reference>
5760
<Reference Include="System" />
5861
<Reference Include="System.AppContext, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
5962
<HintPath>..\packages\System.AppContext.4.3.0\lib\net463\System.AppContext.dll</HintPath>
@@ -181,11 +184,17 @@
181184
<Reference Include="WindowsBase" />
182185
</ItemGroup>
183186
<ItemGroup>
187+
<Compile Include="ColorDepth.cs" />
184188
<Compile Include="Display.cs" />
185189
<Compile Include="DisplayInformation.cs" />
186190
<Compile Include="DisplayInterop.cs" />
191+
<Compile Include="DisplayManagerBase.cs" />
187192
<Compile Include="DisplayManager.cs" />
193+
<Compile Include="DisplayManagerNvidia.cs" />
194+
<Compile Include="DisplayManagerGeneric.cs" />
195+
<Compile Include="GraphicsCardType.cs" />
188196
<Compile Include="HDRController.cs" />
197+
<Compile Include="IDisplayManagerBase.cs" />
189198
<Compile Include="Locale.Designer.cs">
190199
<AutoGen>True</AutoGen>
191200
<DesignTime>True</DesignTime>
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace AutoHDR.Displays
8+
{
9+
public enum ColorDepth
10+
{
11+
BPC16 = 16,
12+
BPC12 = 12,
13+
BPC10 = 10,
14+
BPC8 = 8,
15+
BPC6 = 6,
16+
BPCUnkown = 0
17+
}
18+
19+
public static class ColorDepthExcetion
20+
{
21+
public static NvAPIWrapper.Native.Display.ColorDataDepth ConvertNvidiaColorDepth(this ColorDepth colorDepth)
22+
{
23+
NvAPIWrapper.Native.Display.ColorDataDepth nvColorDepth;
24+
25+
switch (colorDepth)
26+
{
27+
case ColorDepth.BPC16:
28+
nvColorDepth = NvAPIWrapper.Native.Display.ColorDataDepth.BPC16;
29+
break;
30+
case ColorDepth.BPC12:
31+
nvColorDepth = NvAPIWrapper.Native.Display.ColorDataDepth.BPC12;
32+
break;
33+
case ColorDepth.BPC10:
34+
nvColorDepth = NvAPIWrapper.Native.Display.ColorDataDepth.BPC10;
35+
break;
36+
case ColorDepth.BPC8:
37+
nvColorDepth = NvAPIWrapper.Native.Display.ColorDataDepth.BPC8;
38+
break;
39+
case ColorDepth.BPC6:
40+
nvColorDepth = NvAPIWrapper.Native.Display.ColorDataDepth.BPC6;
41+
break;
42+
default:
43+
nvColorDepth = NvAPIWrapper.Native.Display.ColorDataDepth.Default;
44+
break;
45+
}
46+
return nvColorDepth;
47+
}
48+
49+
public static ColorDepth ConvertToColorDepth(this NvAPIWrapper.Native.Display.ColorDataDepth? nvidiaColorDepth)
50+
{
51+
ColorDepth colorDepth;
52+
53+
switch (nvidiaColorDepth)
54+
{
55+
case NvAPIWrapper.Native.Display.ColorDataDepth.BPC16:
56+
colorDepth = ColorDepth.BPC16;
57+
break;
58+
case NvAPIWrapper.Native.Display.ColorDataDepth.BPC12:
59+
colorDepth = ColorDepth.BPC12;
60+
break;
61+
case NvAPIWrapper.Native.Display.ColorDataDepth.BPC10:
62+
colorDepth = ColorDepth.BPC10;
63+
break;
64+
case NvAPIWrapper.Native.Display.ColorDataDepth.BPC8:
65+
colorDepth = ColorDepth.BPC8;
66+
break;
67+
case NvAPIWrapper.Native.Display.ColorDataDepth.BPC6:
68+
colorDepth = ColorDepth.BPC6;
69+
break;
70+
default:
71+
colorDepth = ColorDepth.BPCUnkown;
72+
break;
73+
}
74+
return colorDepth;
75+
}
76+
}
77+
}

Source/AutoHDR.Displays/Display.cs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ public class Display : BaseViewModel
3535

3636
public string GraphicsCard { get => _graphicsCard; set { _graphicsCard = value; OnPropertyChanged(); } }
3737

38-
private string _deviceKey;
39-
40-
public string DeviceKey { get => _deviceKey; set { _deviceKey = value; OnPropertyChanged(); } }
4138

4239
private UInt32 _uid;
4340

@@ -63,9 +60,11 @@ public class Display : BaseViewModel
6360

6461
public int RefreshRate { get => _refreshRate; set { _refreshRate = value; OnPropertyChanged(); } }
6562

66-
private int _colorDepth;
63+
private ColorDepth _colorDepth;
64+
65+
public ColorDepth ColorDepth { get => _colorDepth; set { _colorDepth = value; OnPropertyChanged(); } }
6766

68-
public int ColorDepth { get => _colorDepth; set { _colorDepth = value; OnPropertyChanged(); } }
67+
public object Tag;
6968

7069
private Display()
7170
{
@@ -79,7 +78,6 @@ public Display(DisplayInformation monitorInformation, uint uid)
7978
UID = uid;
8079
ID = monitorInformation.Id;
8180
IsPrimary = monitorInformation.IsPrimary;
82-
DeviceKey = monitorInformation.DisplayDevice.DeviceKey;
8381
Resolution = new Size(monitorInformation.Devmode.dmPelsWidth, monitorInformation.Devmode.dmPelsHeight);
8482
RefreshRate = monitorInformation.Devmode.dmDisplayFrequency;
8583
GraphicsCard = monitorInformation.DisplayDevice.DeviceString;
@@ -91,24 +89,33 @@ public Display(string name, uint uid)
9189
UID = uid;
9290
}
9391

92+
public Display(uint iD, uint uID, bool isPrimary, string name, string graphicsCard)
93+
{
94+
IsPrimary = isPrimary;
95+
Name = name;
96+
GraphicsCard = graphicsCard;
97+
UID = uID;
98+
ID = iD;
99+
}
100+
94101
public void UpdateHDRState()
95102
{
96103
HDRState= HDRController.GetHDRState(UID);
97104
}
98105

99106
public void SetResolution(Size resolution)
100107
{
101-
DisplayManager.Instance.SetResolution(ID, resolution);
108+
DisplayManagerHandler.Instance.SetResolution(this, resolution);
102109
}
103110

104111
public void SetRefreshRate(int refreshRate)
105112
{
106-
DisplayManager.Instance.SetRefreshRate(ID, refreshRate);
113+
DisplayManagerHandler.Instance.SetRefreshRate(this, refreshRate);
107114
}
108115

109-
public void SetColorDepth(int colorDepth)
116+
public void SetColorDepth(ColorDepth colorDepth)
110117
{
111-
DisplayManager.Instance.SetColorDepth(ID, colorDepth);
118+
DisplayManagerHandler.Instance.SetColorDepth(this, colorDepth);
112119
}
113120

114121
public bool IsAllDisplay()

0 commit comments

Comments
 (0)