fix error with dark mode, add clone functionality of current settings, add SDR brightness setting

This commit is contained in:
Vincent Maas committed 2023-07-01 17:37:49 +02:00
1 parent c6f9bedcd2
commit 3c5c2b3e4e
23 files changed
+564 -325

No files matched your search

+5 -5
View File
@@ -13,7 +13,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "novideo_srgb", "novideo_srg
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NLogViewer", "NLogViewer\NLogViewer.csproj", "{D5E4D314-CFCD-4859-98FC-68F660AC7FB4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared", "Shared\Shared.csproj", "{8F38D6B0-82DA-4DD1-89EB-918D8A18AEB1}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Shared", "Shared\Shared.csproj", "{8F38D6B0-82DA-4DD1-89EB-918D8A18AEB1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -29,8 +29,8 @@ Global
{A6005D08-70F0-44CB-A384-9219EBA84F21}.Debug|x64.Build.0 = Debug|Any CPU
{A6005D08-70F0-44CB-A384-9219EBA84F21}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A6005D08-70F0-44CB-A384-9219EBA84F21}.Release|Any CPU.Build.0 = Release|Any CPU
{A6005D08-70F0-44CB-A384-9219EBA84F21}.Release|x64.ActiveCfg = Release|x64
{A6005D08-70F0-44CB-A384-9219EBA84F21}.Release|x64.Build.0 = Release|x64
{A6005D08-70F0-44CB-A384-9219EBA84F21}.Release|x64.ActiveCfg = Release|Any CPU
{A6005D08-70F0-44CB-A384-9219EBA84F21}.Release|x64.Build.0 = Release|Any CPU
{76797290-48F5-4A82-86C3-FAD25DAE4500}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{76797290-48F5-4A82-86C3-FAD25DAE4500}.Debug|Any CPU.Build.0 = Debug|Any CPU
{76797290-48F5-4A82-86C3-FAD25DAE4500}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -53,8 +53,8 @@ Global
{A6A97834-7BE1-474A-B92F-A512DB1D5186}.Debug|x64.Build.0 = Debug|Any CPU
{A6A97834-7BE1-474A-B92F-A512DB1D5186}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A6A97834-7BE1-474A-B92F-A512DB1D5186}.Release|Any CPU.Build.0 = Release|Any CPU
{A6A97834-7BE1-474A-B92F-A512DB1D5186}.Release|x64.ActiveCfg = Release|x64
{A6A97834-7BE1-474A-B92F-A512DB1D5186}.Release|x64.Build.0 = Release|x64
{A6A97834-7BE1-474A-B92F-A512DB1D5186}.Release|x64.ActiveCfg = Release|Any CPU
{A6A97834-7BE1-474A-B92F-A512DB1D5186}.Release|x64.Build.0 = Release|Any CPU
{D5E4D314-CFCD-4859-98FC-68F660AC7FB4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D5E4D314-CFCD-4859-98FC-68F660AC7FB4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D5E4D314-CFCD-4859-98FC-68F660AC7FB4}.Debug|x64.ActiveCfg = Debug|Any CPU
+121 -120
View File
@@ -1,122 +1,123 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0-windows10.0.20348.0</TargetFramework>
<OutputType>WinExe</OutputType>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>false</MapFileExtensions>
<UpdateUrl>https://www.maassoft.com/downloads/ColorControl/</UpdateUrl>
<ProductName>ColorControl</ProductName>
<PublisherName>Maassoft</PublisherName>
<Company>Maassoft</Company>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>9.6.1.1</ApplicationVersion>
<Version>9.6.1.1</Version>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>false</BootstrapperEnabled>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<UseWindowsForms>true</UseWindowsForms>
<UseWPF>false</UseWPF>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<ApplicationIcon>pngbarn.ico</ApplicationIcon>
<SupportedOSPlatformVersion>10.0.20348.0</SupportedOSPlatformVersion>
<Copyright>2020-2023 Maassoft</Copyright>
<Authors>Maassoft</Authors>
<ManifestCertificateThumbprint>CF0BC153EA664CD97AC6F234B91F45D34630958F</ManifestCertificateThumbprint>
<ManifestKeyFile>ColorControl_1_TemporaryKey.pfx</ManifestKeyFile>
<GenerateManifests>true</GenerateManifests>
<TargetZone>LocalIntranet</TargetZone>
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
<SignManifests>true</SignManifests>
<AssemblyOriginatorKeyFile>ColorControl_TemporaryKey.pfx</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<OutputPath>bin\x64\Debug\</OutputPath>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<None Remove="XForms\LogWindow.xaml" />
</ItemGroup>
<ItemGroup>
<Compile Update="Forms\ElevatedForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="Services\Common\QuickAccessForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="services\lg\RemoteControlPanel.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Update="Services\NVIDIA\NvPanel.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Update="Services\Samsung\SamsungPanel.cs">
<SubType>UserControl</SubType>
</Compile>
<EmbeddedResource Include="Resources\LG_register.json" />
<EmbeddedResource Include="Resources\RC_coords.txt" />
<EmbeddedResource Include="Resources\LG_remote.jpg" />
<Content Include="LgPresets.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="pngbarn.ico" />
</ItemGroup>
<ItemGroup>
<Folder Include="bin\x64\Debug\" />
</ItemGroup>
<ItemGroup>
<COMReference Include="IWshRuntimeLibrary">
<Guid>{F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}</Guid>
<VersionMajor>1</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>tlbimp</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="7.0.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="7.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NLog" Version="5.1.2" />
<PackageReference Include="NStandard" Version="0.24.0" />
<PackageReference Include="NWin32" Version="1.2.6" />
<PackageReference Include="System.Management" Version="7.0.0" />
<PackageReference Include="TaskScheduler" Version="2.10.1" />
<PackageReference Include="Vanara.PInvoke.IpHlpApi" Version="3.4.13" />
</ItemGroup>
<ItemGroup>
<Page Include="XForms\LogWindow.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NLogViewer\NLogViewer.csproj" />
<ProjectReference Include="..\novideo_srgb\novideo_srgb.csproj" />
<ProjectReference Include="..\Nspector\Nspector.csproj" />
<ProjectReference Include="..\NvAPIWrapper\NvAPIWrapper.csproj" />
<ProjectReference Include="..\Shared\Shared.csproj" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Services\Samsung\SamsungPanel.resx">
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<PropertyGroup>
<TargetFramework>net7.0-windows10.0.20348.0</TargetFramework>
<OutputType>WinExe</OutputType>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>false</MapFileExtensions>
<UpdateUrl>https://www.maassoft.com/downloads/ColorControl/</UpdateUrl>
<ProductName>ColorControl</ProductName>
<PublisherName>Maassoft</PublisherName>
<Company>Maassoft</Company>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>9.6.2.0</ApplicationVersion>
<Version>9.6.2.0</Version>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>false</BootstrapperEnabled>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<UseWindowsForms>true</UseWindowsForms>
<UseWPF>false</UseWPF>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<ApplicationIcon>pngbarn.ico</ApplicationIcon>
<SupportedOSPlatformVersion>10.0.20348.0</SupportedOSPlatformVersion>
<Copyright>2020-2023 Maassoft</Copyright>
<Authors>Maassoft</Authors>
<ManifestCertificateThumbprint>CF0BC153EA664CD97AC6F234B91F45D34630958F</ManifestCertificateThumbprint>
<ManifestKeyFile>ColorControl_1_TemporaryKey.pfx</ManifestKeyFile>
<GenerateManifests>true</GenerateManifests>
<TargetZone>LocalIntranet</TargetZone>
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
<SignManifests>true</SignManifests>
<AssemblyOriginatorKeyFile>ColorControl_TemporaryKey.pfx</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<OutputPath>bin\x64\Debug\</OutputPath>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup>
<PathMap Condition="'$(Configuration)' == 'Release'">$(MSBuildThisFileDirectory)=.\</PathMap>
</PropertyGroup>
<ItemGroup>
<None Remove="XForms\LogWindow.xaml" />
</ItemGroup>
<ItemGroup>
<Compile Update="Forms\ElevatedForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="Services\Common\QuickAccessForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="services\lg\RemoteControlPanel.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Update="Services\NVIDIA\NvPanel.cs" />
<Compile Update="Services\Samsung\SamsungPanel.cs">
<SubType>UserControl</SubType>
</Compile>
<EmbeddedResource Include="Resources\LG_register.json" />
<EmbeddedResource Include="Resources\RC_coords.txt" />
<EmbeddedResource Include="Resources\LG_remote.jpg" />
<Content Include="LgPresets.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="pngbarn.ico" />
</ItemGroup>
<ItemGroup>
<Folder Include="bin\x64\Debug\" />
</ItemGroup>
<ItemGroup>
<COMReference Include="IWshRuntimeLibrary">
<Guid>{F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}</Guid>
<VersionMajor>1</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>tlbimp</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="7.0.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="7.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NLog" Version="5.1.2" />
<PackageReference Include="NStandard" Version="0.24.0" />
<PackageReference Include="NWin32" Version="1.2.6" />
<PackageReference Include="System.Management" Version="7.0.0" />
<PackageReference Include="TaskScheduler" Version="2.10.1" />
<PackageReference Include="Vanara.PInvoke.IpHlpApi" Version="3.4.13" />
</ItemGroup>
<ItemGroup>
<Page Include="XForms\LogWindow.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NLogViewer\NLogViewer.csproj" />
<ProjectReference Include="..\novideo_srgb\novideo_srgb.csproj" />
<ProjectReference Include="..\Nspector\Nspector.csproj" />
<ProjectReference Include="..\NvAPIWrapper\NvAPIWrapper.csproj" />
<ProjectReference Include="..\Shared\Shared.csproj" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Services\Samsung\SamsungPanel.resx">
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
</Project>
+4 -6
View File
@@ -33,7 +33,6 @@ namespace ColorControl
{
private static bool SystemShutdown = false;
private static bool EndSession = false;
private static bool UserExit = false;
private static int SHORTCUTID_SCREENSAVER = -100;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
@@ -429,7 +428,7 @@ namespace ColorControl
void Exit(object sender, EventArgs e)
{
UserExit = true;
Program.UserExit = true;
Close();
}
@@ -454,11 +453,11 @@ namespace ColorControl
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (!(SystemShutdown || EndSession || UserExit) && _config.MinimizeOnClose)
if (!(SystemShutdown || EndSession || Program.UserExit) && _config.MinimizeOnClose)
{
e.Cancel = true;
WindowState = FormWindowState.Minimized;
UserExit = false;
Program.UserExit = false;
return;
}
@@ -480,6 +479,7 @@ namespace ColorControl
_amdPanel?.Save();
_lgPanel?.Save();
_gamePanel?.Save();
_samsungPanel?.Save();
SaveConfig();
}
@@ -1334,8 +1334,6 @@ Currently ColorControl is {(Utils.IsAdministrator() ? "" : "not ")}running as ad
//Environment.Exit(0);
//InstallUpdate("");
//await Test();
//Utils.SetBrightness(Handle);
}
private async Task Test()
+6
View File
@@ -34,6 +34,7 @@ namespace ColorControl
public static Shared.Common.AppContext AppContext { get; private set; }
public static bool IsRestarting { get; private set; }
public static bool UserExit = false;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private static Mutex _mutex;
@@ -292,6 +293,11 @@ namespace ColorControl
private static void GlobalHandleException(Exception exception, string type)
{
if (UserExit)
{
return;
}
var trace = exception.ToLogString(Environment.StackTrace);
var message = $"{type}: {trace}";
+2 -1
View File
@@ -1,4 +1,5 @@
using ColorControl.Shared.Common;
using ColorControl.Shared.Forms;
using NWin32;
using System;
using System.Collections.Generic;
@@ -146,7 +147,7 @@ namespace ColorControl.Services.LG
return;
}
BeginInvoke(new Action(UpdateValues));
FormUtils.BeginInvokeCheck(this, UpdateValues);
}
private void UpdateValues()
+4 -4
View File
@@ -72,13 +72,13 @@ namespace ColorControl.Services.LG
public void Init()
{
_lgService.RefreshDevices(afterStartUp: true).ContinueWith((_) => BeginInvoke(() => AfterLgServiceRefreshDevices()));
_lgService.RefreshDevices(afterStartUp: true).ContinueWith((_) => FormUtils.BeginInvokeCheck(this, () => AfterLgServiceRefreshDevices()));
_lgService.InstallEventHandlers();
}
private void _lgService_SelectedDeviceChangedEvent(object sender, EventArgs e)
{
BeginInvoke(() => SetLgDevicesSelectedIndex(sender));
FormUtils.BeginInvokeCheck(this, () => SetLgDevicesSelectedIndex(sender));
}
private void SetLgDevicesSelectedIndex(object sender)
@@ -695,7 +695,7 @@ You can also activate this option by using the Expert-button and selecting Wake-
if (e.Index == 10)
{
_lgService.RefreshDevices().ContinueWith((_) => BeginInvoke(() => FillLgDevices()));
_lgService.RefreshDevices().ContinueWith((_) => FormUtils.BeginInvokeCheck(this, () => FillLgDevices()));
}
});
}
@@ -715,7 +715,7 @@ You can also activate this option by using the Expert-button and selecting Wake-
private void RefreshLgDevices()
{
_lgService.RefreshDevices(false).ContinueWith((task) => BeginInvoke(() => FillLgDevices()));
_lgService.RefreshDevices(false).ContinueWith((task) => FormUtils.BeginInvokeCheck(this, () => FillLgDevices()));
}
private void edtShortcutLg_TextChanged(object sender, EventArgs e)
+1 -1
View File
@@ -58,7 +58,7 @@ namespace ColorControl.Services.LG
public static List<string> GetColumnNames()
{
return new List<string>() { "Name", "Device|120", "App|200", "Steps|400", "Shortcut", "Trigger" };
return new List<string>() { "Name", "Device|140", "App|200", "Steps|400", "Shortcut", "Trigger" };
}
public override List<string> GetDisplayValues(Config config = null)
@@ -137,7 +137,7 @@ namespace ColorControl.Services.LG
if (_mouseService == null)
{
await _lgService.GetMouseAsync().ContinueWith((task) => BeginInvoke(new Action<Task<LgWebOsMouseService>>(SetMouseService), new[] { task }));
await _lgService.GetMouseAsync().ContinueWith((task) => BeginInvoke(SetMouseService, new[] { task }));
}
}
else
+91 -6
View File
@@ -211,6 +211,8 @@ namespace ColorControl.Services.NVIDIA
FormUtils.EnableControls(this, enabled, new List<Control> { lvNvPresets, btnAddModesNv, btnChange, edtNvGpuInfo, btnNvSetClocks, btnNvSettings, edtNvOverclock, btnNvSetClocks });
btnClone.Enabled = preset != null || GetSelectedNvPreset(true) != null;
if (enabled)
{
edtNvPresetName.Text = preset.name;
@@ -247,7 +249,12 @@ namespace ColorControl.Services.NVIDIA
private void btnClone_Click(object sender, EventArgs e)
{
var preset = GetSelectedNvPreset();
var preset = GetSelectedNvPreset(true, true);
if (preset == null)
{
return;
}
var newPreset = preset.Clone();
AddOrUpdateItem(newPreset);
@@ -412,7 +419,15 @@ namespace ColorControl.Services.NVIDIA
mnuNvOverclocking.Font = _menuItemFonts[preset.applyOverclocking];
mnuNvOtherSettings.Font = _menuItemFonts[preset.applyOther];
FormUtils.BuildDropDownMenu(mnuNvOtherSettings, "Content type", typeof(InfoFrameVideoContentType), preset, "contentType", nvPresetContentTypeMenuItem_Click);
var contentTypeItem = FormUtils.BuildDropDownMenu(mnuNvOtherSettings, "Content type", typeof(InfoFrameVideoContentType), preset, "contentType", nvPresetContentTypeMenuItem_Click, unchanged: true);
contentTypeItem.DropDownItems[0].Visible = !isCurrentDisplay;
var itemName = $"{mnuNvOtherSettings.Name}_SDRBrightness";
var brightnessMenu = FormUtils.BuildMenuItem(mnuNvOtherSettings.DropDownItems, itemName, "SDR brightness");
var subItemName = $"{itemName}_SubItem";
var subItem = FormUtils.BuildMenuItem(brightnessMenu.DropDownItems, subItemName, "", onClick: nvPresetBrightnessMenuItem_Click);
subItem.Text = (preset.SDRBrightness.HasValue ? $"{preset.SDRBrightness.Value}%" : "Unset") + " (click to change)";
BuildNvOverclockingMenu(preset);
@@ -722,13 +737,18 @@ namespace ColorControl.Services.NVIDIA
{
var menuItem = (ToolStripMenuItem)sender;
var value = (InfoFrameVideoContentType)menuItem.Tag;
var value = (InfoFrameVideoContentType?)menuItem.Tag;
var preset = GetSelectedNvPreset(true);
if (preset.IsDisplayPreset)
{
_nvService.SetHDMIContentType(preset.Display, value);
if (!value.HasValue)
{
return;
}
_nvService.SetHDMIContentType(preset.Display, value.Value);
UpdateDisplayInfoItems();
return;
@@ -739,6 +759,41 @@ namespace ColorControl.Services.NVIDIA
AddOrUpdateItem();
}
private void nvPresetBrightnessMenuItem_Click(object sender, EventArgs e)
{
var preset = GetSelectedNvPreset(true);
var label = "SDR brightness in %";
if (!preset.IsDisplayPreset)
{
label += " (clear to set to unchanged)";
}
var value = SelectValue(0, 100, preset.SDRBrightness, label);
if (value == -1)
{
return;
}
if (preset.IsDisplayPreset)
{
if (!value.HasValue)
{
return;
}
_nvService.SetSDRBrightness(preset.Display, value.Value);
UpdateDisplayInfoItems();
return;
}
preset.SDRBrightness = value;
AddOrUpdateItem();
}
private void refreshRateMenuItem_Click(object sender, EventArgs e)
{
var refreshRate = (uint)((ToolStripItem)sender).Tag;
@@ -905,7 +960,7 @@ namespace ColorControl.Services.NVIDIA
}
}
private NvPreset GetSelectedNvPreset(bool currentDisplay = false)
private NvPreset GetSelectedNvPreset(bool currentDisplay = false, bool driverSettings = false)
{
if (lvNvPresets.SelectedItems.Count > 0)
{
@@ -914,7 +969,7 @@ namespace ColorControl.Services.NVIDIA
if (result == null && currentDisplay)
{
result = _nvService.GetPresetForDisplay(item.SubItems[1].Text);
result = _nvService.GetPresetForDisplay(item.SubItems[1].Text, driverSettings);
}
return result;
@@ -1100,6 +1155,36 @@ namespace ColorControl.Services.NVIDIA
return settingValue;
}
private int? SelectValue(int min, int max, int? currentValue, string label)
{
var field = new MessageForms.FieldDefinition
{
MinValue = min,
MaxValue = max,
Label = label,
FieldType = MessageForms.FieldType.Numeric,
Value = currentValue
};
var resultFields = MessageForms.ShowDialog(field.Label, new[] { field });
if (!resultFields.Any())
{
return -1;
}
var strValue = (string)resultFields.First().Value;
if (string.IsNullOrWhiteSpace(strValue))
{
return null;
}
var settingValue = Utils.ParseInt(strValue);
return settingValue;
}
private void miNvProfileInspector_Click(object sender, EventArgs e)
{
StartNvProfileInspector();
+26 -2
View File
@@ -8,6 +8,7 @@ using NvAPIWrapper.Display;
using NvAPIWrapper.Native.Display;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ColorControl.Services.NVIDIA
@@ -33,7 +34,8 @@ namespace ColorControl.Services.NVIDIA
public uint ditheringBits { get; set; }
public uint ditheringMode { get; set; }
public bool applyOther { get; set; }
public InfoFrameVideoContentType contentType { get; set; }
public InfoFrameVideoContentType? contentType { get; set; }
public int? SDRBrightness { get; set; }
public bool applyDriverSettings { get; set; }
public Dictionary<uint, uint> driverSettings { get; set; }
public bool applyOverclocking { get; set; }
@@ -96,6 +98,7 @@ namespace ColorControl.Services.NVIDIA
driverSettings = new Dictionary<uint, uint>(preset.driverSettings);
contentType = preset.contentType;
SDRBrightness = preset.SDRBrightness;
applyOther = preset.applyOther;
}
@@ -141,7 +144,7 @@ namespace ColorControl.Services.NVIDIA
values.Add(string.Format("{0}: {1}", applyDriverSettings ? "Included" : "Excluded", GetDriverSettingsDescription()));
values.Add(string.Format("{0}: {1}", applyOther ? "Included" : "Excluded", $"Content type: {contentType}"));
values.Add(string.Format("{0}: {1}", applyOther ? "Included" : "Excluded", GetOtherDescription()));
values.Add(string.Format("{0}: {1}", applyOverclocking ? "Included" : "Excluded", GetOverclockingSettingsDescription()));
@@ -209,6 +212,27 @@ namespace ColorControl.Services.NVIDIA
return dithering;
}
public string GetOtherDescription()
{
var values = new List<string>();
if (contentType.HasValue)
{
values.Add($"Content type: {contentType.Value}");
}
if (SDRBrightness.HasValue)
{
values.Add($"SDR brightness: {SDRBrightness.Value}%");
}
if (!values.Any())
{
values.Add("None");
}
return string.Join(", ", values);
}
public static List<NvPreset> GetDefaultPresets()
{
var presets = new List<NvPreset>();
+89 -8
View File
@@ -14,6 +14,7 @@ using NvAPIWrapper.GPU;
using NvAPIWrapper.Native;
using NvAPIWrapper.Native.Display;
using NvAPIWrapper.Native.GPU.Structures;
using NWin32;
using NWin32.NativeTypes;
using System;
using System.Collections.Generic;
@@ -104,6 +105,9 @@ namespace ColorControl.Services.NVIDIA
private DrsSettingsMetaService _meta;
private List<SettingItem> _settings = new List<SettingItem>();
private int _lastSetSDRBrightness = -1;
private int _lastReadSDRBrightness = -1;
private Semaphore _semaphore = new Semaphore(1, 1);
public const uint DRS_GSYNC_APPLICATION_MODE = 294973784;
@@ -312,11 +316,6 @@ namespace ColorControl.Services.NVIDIA
SetHDRState(display, newHdrEnabled);
}
if (hdrEnabled)
{
//CCD.SetSDRWhiteLevel(1000, display.Name);
}
if (preset.applyRefreshRate || preset.applyResolution)
{
if (!SetMode(preset.applyResolution ? preset.resolutionWidth : 0, preset.applyResolution ? preset.resolutionHeight : 0, preset.applyRefreshRate ? preset.refreshRate : 0, true))
@@ -327,7 +326,15 @@ namespace ColorControl.Services.NVIDIA
if (preset.applyOther)
{
SetHDMIContentType(display, preset.contentType);
if (preset.contentType.HasValue)
{
SetHDMIContentType(display, preset.contentType.Value);
}
if (preset.SDRBrightness.HasValue)
{
SetSDRBrightness(display, preset.SDRBrightness.Value);
}
}
if (preset.applyDithering)
@@ -528,6 +535,43 @@ namespace ColorControl.Services.NVIDIA
CCD.SetHDRState(enabled, display.Name);
}
public void SetSDRBrightness(Display display, int brightnessPercent)
{
var hmon = FormUtils.GetMonitorForDisplayName(display.Name);
if (hmon == IntPtr.Zero)
{
hmon = NativeMethods.MonitorFromWindow(0, 1);
}
var brightness = 1 + (double)brightnessPercent / 20;
WinApi.DwmpSDRToHDRBoostPtr(hmon, brightness);
_lastSetSDRBrightness = brightnessPercent;
}
public int GetSDRBrightness(Display display)
{
var whiteLevel = CCD.GetSDRWhiteLevel(display.Name);
if (whiteLevel >= 1000)
{
var newBrightnessPercent = (int)(whiteLevel - 1000) / 50;
if (_lastSetSDRBrightness >= 0 && newBrightnessPercent == _lastReadSDRBrightness)
{
return _lastSetSDRBrightness;
}
_lastReadSDRBrightness = newBrightnessPercent;
return newBrightnessPercent;
}
return 0;
}
public bool SetDithering(NvDitherState state, uint bits = 1, uint mode = 4, NvPreset preset = null, Display currentDisplay = null)
{
var result = true;
@@ -832,7 +876,19 @@ namespace ColorControl.Services.NVIDIA
values.Add(string.Join(", ", drsValues));
values.Add($"Content type: {GetHDMIContentType(display)}");
var otherValues = new List<string>
{
$"Content type: {GetHDMIContentType(display)}"
};
if (hdrEnabled)
{
var sdrBrightness = GetSDRBrightness(display);
otherValues.Add($"SDR brightness: {sdrBrightness}%");
}
values.Add(string.Join(", ", otherValues));
var infoLine = string.Format("{0}: {1}, {2}Hz, HDR: {3}", name, colorSettings, refreshRate, hdrEnabled ? "Yes" : "No");
@@ -850,7 +906,7 @@ namespace ColorControl.Services.NVIDIA
}
}
public NvPreset GetPresetForDisplay(string displayName)
public NvPreset GetPresetForDisplay(string displayName, bool driverSettings = false)
{
var displays = GetDisplays();
@@ -867,6 +923,7 @@ namespace ColorControl.Services.NVIDIA
preset.displayName = FormUtils.ExtendedDisplayName(display.Name);
preset.colorData = GetCurrentColorData(display);
preset.contentType = GetHDMIContentType(display);
preset.SDRBrightness = GetSDRBrightness(display);
var mode = GetCurrentMode(display.Name);
@@ -905,6 +962,30 @@ namespace ColorControl.Services.NVIDIA
}
}
if (driverSettings)
{
var settings = GetVisibleSettings();
foreach (var setting in settings)
{
var settingMeta = GetSettingMeta(setting.SettingId);
if (settingMeta == null)
{
continue;
}
var (presetSetting, isDefault) = settingMeta.ToIntValue(setting.ValueText);
if (isDefault)
{
continue;
}
preset.driverSettings.Add(setting.SettingId, presetSetting);
}
}
return preset;
}
@@ -70,13 +70,13 @@ namespace ColorControl.Services.Samsung
public void Init()
{
var _ = Handle;
_samsungService.RefreshDevices(afterStartUp: true).ContinueWith((_) => BeginInvoke(() => AfterSamsungServiceRefreshDevices()));
_samsungService.RefreshDevices(afterStartUp: true).ContinueWith((_) => FormUtils.BeginInvokeCheck(this, AfterSamsungServiceRefreshDevices));
_samsungService.InstallEventHandlers();
}
private void _samsungService_SelectedDeviceChangedEvent(object sender, EventArgs e)
{
BeginInvoke(() => SetSamsungDevicesSelectedIndex(sender));
FormUtils.BeginInvokeCheck(this, () => SetSamsungDevicesSelectedIndex(sender));
}
private void SetSamsungDevicesSelectedIndex(object sender)
@@ -369,7 +369,7 @@ namespace ColorControl.Services.Samsung
//if (cbxSamsungApps.Items.Count == 0 && device != null)
//{
// _samsungService.RefreshAppsAsync().ContinueWith((task) => BeginInvoke(() => FillApps(false)));
// _samsungService.RefreshAppsAsync().ContinueWith((task) => FormUtils.BeginInvokeCheck(this, () => FillApps(false)));
//}
btnSamsungDeviceConvertToCustom.Enabled = devices.Any();
@@ -480,7 +480,7 @@ namespace ColorControl.Services.Samsung
private void btnSamsungRefreshApps_Click(object sender, EventArgs e)
{
//_samsungService.RefreshApps(true).ContinueWith((task) => BeginInvoke(() => FillLgApps(true)));
//_samsungService.RefreshApps(true).ContinueWith((task) => FormUtils.BeginInvokeCheck(this, () => FillLgApps(true)));
}
private void cbxSamsungDevices_SelectedIndexChanged(object sender, EventArgs e)
@@ -676,7 +676,7 @@ Use 'Settings > Test power off/on' to test this functionality."
);
}
BeginInvoke(() =>
FormUtils.BeginInvokeCheck(this, () =>
{
device.Options.PowerOnAfterStartup = clbLgPower.GetItemChecked(0);
device.Options.PowerOnAfterResume = clbLgPower.GetItemChecked(1);
@@ -692,7 +692,7 @@ Use 'Settings > Test power off/on' to test this functionality."
if (e.Index == 10)
{
_samsungService.RefreshDevices().ContinueWith((_) => BeginInvoke(() => FillSamsungDevices()));
_samsungService.RefreshDevices().ContinueWith((_) => FormUtils.BeginInvokeCheck(this, () => FillSamsungDevices()));
}
});
}
@@ -712,7 +712,7 @@ Use 'Settings > Test power off/on' to test this functionality."
private void RefreshSamsungDevices()
{
_samsungService.RefreshDevices(false).ContinueWith((task) => BeginInvoke(() => FillSamsungDevices()));
_samsungService.RefreshDevices(false).ContinueWith((task) => FormUtils.BeginInvokeCheck(this, () => FillSamsungDevices()));
}
private void edtShortcutLg_TextChanged(object sender, EventArgs e)
@@ -48,7 +48,7 @@ namespace ColorControl.Services.Samsung
public static string[] GetColumnNames()
{
return new[] { "Name", "Device|120", "App|200", "Steps|400", "Shortcut", "Trigger" };
return new[] { "Name", "Device|140", "App|200", "Steps|400", "Shortcut", "Trigger" };
}
public override List<string> GetDisplayValues(Config config = null)
+53 -49
View File
@@ -1,56 +1,60 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0-windows10.0.20348.0</TargetFramework>
<UseWPF>true</UseWPF>
<RootNamespace>DJ</RootNamespace>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>Sentinel.NLogViewer</PackageId>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net7.0-windows10.0.20348.0</TargetFramework>
<UseWPF>true</UseWPF>
<RootNamespace>DJ</RootNamespace>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>Sentinel.NLogViewer</PackageId>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<ItemGroup>
<None Remove="NLogViewer.xaml" />
</ItemGroup>
<PropertyGroup>
<PathMap Condition="'$(Configuration)' == 'Release'">$(MSBuildThisFileDirectory)=.\</PathMap>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NLog" Version="5.1.2" />
<PackageReference Include="System.Reactive" Version="6.0.0" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\Glyphs\SortDownArrow.png" />
<Resource Include="Images\Glyphs\SortUpArrow.png" />
<Resource Include="Images\Small\Add.png" />
<Resource Include="Images\Small\Clear.png" />
<Resource Include="Images\Small\Clock.png" />
<Resource Include="Images\Small\Context.png" />
<Resource Include="Images\Small\Debug.png" />
<Resource Include="Images\Small\DebugSource.png" />
<Resource Include="Images\Small\Error.png" />
<Resource Include="Images\Small\Exception.png" />
<Resource Include="Images\Small\Exit.png" />
<Resource Include="Images\Small\Export.png" />
<Resource Include="Images\Small\Fatal.png" />
<Resource Include="Images\Small\Info.png" />
<Resource Include="Images\Small\Layout.png" />
<Resource Include="Images\Small\MonoLightning.png" />
<Resource Include="Images\Small\Network.png" />
<Resource Include="Images\Small\Open.png" />
<Resource Include="Images\Small\Pause.png" />
<Resource Include="Images\Small\Save.png" />
<Resource Include="Images\Small\ScrollDown.png" />
<Resource Include="Images\Small\Settings.png" />
<Resource Include="Images\Small\Thread.png" />
<Resource Include="Images\Small\Trace.png" />
<Resource Include="Images\Small\Unknown.png" />
<Resource Include="Images\Small\Warning.png" />
</ItemGroup>
<ItemGroup>
<None Remove="NLogViewer.xaml" />
</ItemGroup>
<ItemGroup>
<None Update="NLogView.xaml">
<Generator>MSBuild:Compile</Generator>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="NLog" Version="5.1.2" />
<PackageReference Include="System.Reactive" Version="6.0.0" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\Glyphs\SortDownArrow.png" />
<Resource Include="Images\Glyphs\SortUpArrow.png" />
<Resource Include="Images\Small\Add.png" />
<Resource Include="Images\Small\Clear.png" />
<Resource Include="Images\Small\Clock.png" />
<Resource Include="Images\Small\Context.png" />
<Resource Include="Images\Small\Debug.png" />
<Resource Include="Images\Small\DebugSource.png" />
<Resource Include="Images\Small\Error.png" />
<Resource Include="Images\Small\Exception.png" />
<Resource Include="Images\Small\Exit.png" />
<Resource Include="Images\Small\Export.png" />
<Resource Include="Images\Small\Fatal.png" />
<Resource Include="Images\Small\Info.png" />
<Resource Include="Images\Small\Layout.png" />
<Resource Include="Images\Small\MonoLightning.png" />
<Resource Include="Images\Small\Network.png" />
<Resource Include="Images\Small\Open.png" />
<Resource Include="Images\Small\Pause.png" />
<Resource Include="Images\Small\Save.png" />
<Resource Include="Images\Small\ScrollDown.png" />
<Resource Include="Images\Small\Settings.png" />
<Resource Include="Images\Small\Thread.png" />
<Resource Include="Images\Small\Trace.png" />
<Resource Include="Images\Small\Unknown.png" />
<Resource Include="Images\Small\Warning.png" />
</ItemGroup>
<ItemGroup>
<None Update="NLogView.xaml">
<Generator>MSBuild:Compile</Generator>
</None>
</ItemGroup>
</Project>
+4
View File
@@ -9,6 +9,10 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup>
<PathMap Condition="'$(Configuration)' == 'Release'">$(MSBuildThisFileDirectory)=.\</PathMap>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Resources.Extensions" Version="7.0.0" />
</ItemGroup>
+47 -44
View File
@@ -1,47 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0-windows10.0.20348.0</TargetFramework>
<Version>0.8.1.106</Version>
<Company>falahati.net</Company>
<Description>NvAPIWrapper is a .Net wrapper for NVIDIA public API</Description>
<Authors>Soroush Falahati</Authors>
<Copyright>Copyright © Soroush Falahati 2018 (falahati.net)</Copyright>
<Platforms>AnyCPU</Platforms>
<Product>NvAPIWrapper.Net</Product>
<PackageProjectUrl>https://github.com/falahati/NvAPIWrapper</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/falahati/NvAPIWrapper/blob/master/LICENSE</PackageLicenseUrl>
<PackageIconUrl>https://github.com/falahati/NvAPIWrapper/blob/master/NvAPIWrapper/Icon.png?raw=true</PackageIconUrl>
<IncludeSymbols>true</IncludeSymbols>
<IncludeSource>true</IncludeSource>
<PlatformTarget>AnyCPU</PlatformTarget>
<Title>NvAPIWrapper (for NVAPI 410)</Title>
<PackageId>NvAPIWrapper.Net</PackageId>
<AssemblyOriginatorKeyFile>OpenSourceStrongNameSignKey.pfx</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<OutputPath>..\Debug</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<BumpRevision>False</BumpRevision>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<OutputPath>..\Release</OutputPath>
<DocumentationFile>..\Release\NvAPIWrapper.xml</DocumentationFile>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
<Content Include="readme.txt">
<Pack>true</Pack>
<PackagePath>\</PackagePath>
</Content>
<Content Include="Icon.png">
<Pack>true</Pack>
<PackagePath>\</PackagePath>
</Content>
</ItemGroup>
<ItemGroup>
<None Include="..\.editorconfig" Link=".editorconfig" />
</ItemGroup>
<PropertyGroup>
<TargetFramework>net7.0-windows10.0.20348.0</TargetFramework>
<Version>0.8.1.106</Version>
<Company>falahati.net</Company>
<Description>NvAPIWrapper is a .Net wrapper for NVIDIA public API</Description>
<Authors>Soroush Falahati</Authors>
<Copyright>Copyright © Soroush Falahati 2018 (falahati.net)</Copyright>
<Platforms>AnyCPU</Platforms>
<Product>NvAPIWrapper.Net</Product>
<PackageProjectUrl>https://github.com/falahati/NvAPIWrapper</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/falahati/NvAPIWrapper/blob/master/LICENSE</PackageLicenseUrl>
<PackageIconUrl>https://github.com/falahati/NvAPIWrapper/blob/master/NvAPIWrapper/Icon.png?raw=true</PackageIconUrl>
<IncludeSymbols>true</IncludeSymbols>
<IncludeSource>true</IncludeSource>
<PlatformTarget>AnyCPU</PlatformTarget>
<Title>NvAPIWrapper (for NVAPI 410)</Title>
<PackageId>NvAPIWrapper.Net</PackageId>
<AssemblyOriginatorKeyFile>OpenSourceStrongNameSignKey.pfx</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<OutputPath>..\Debug</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<BumpRevision>False</BumpRevision>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<OutputPath>..\Release</OutputPath>
<DocumentationFile>..\Release\NvAPIWrapper.xml</DocumentationFile>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<PathMap Condition="'$(Configuration)' == 'Release'">$(MSBuildThisFileDirectory)=.\</PathMap>
</PropertyGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
<Content Include="readme.txt">
<Pack>true</Pack>
<PackagePath>\</PackagePath>
</Content>
<Content Include="Icon.png">
<Pack>true</Pack>
<PackagePath>\</PackagePath>
</Content>
</ItemGroup>
<ItemGroup>
<None Include="..\.editorconfig" Link=".editorconfig" />
</ItemGroup>
</Project>
-16
View File
@@ -381,22 +381,6 @@ The best and suggested method to provide this is via a Windows Service. Only whe
return values;
}
public static void SetBrightness(nint handle)
{
var displays = Windows.Graphics.Display.DisplayServices.FindAll();
var folderPicker = new Windows.Storage.Pickers.FolderPicker();
// Initialize the folder picker with the window handle (HWND).
WinRT.Interop.InitializeWithWindow.Initialize(folderPicker, handle);
folderPicker.FileTypeFilter.Add("*");
var folder = folderPicker.PickSingleFolderAsync().GetAwaiter();
//var info = Windows.Graphics.Display.DisplayInformation.GetForCurrentView();
//var colorInfo = info.GetAdvancedColorInfo();
}
public static async Task<List<PnpDev>> GetPnpDevices(string deviceName, string category = null)
{
var devices = new List<PnpDev>();
+5
View File
@@ -55,6 +55,11 @@ namespace ColorControl.Shared.Forms
public static void InitWpfTheme()
{
if (System.Windows.Application.Current == null)
{
new System.Windows.Application();
}
var resources = System.Windows.Application.Current.Resources;
if (DarkModeUtils.UseDarkMode)
+47 -2
View File
@@ -139,7 +139,7 @@ namespace ColorControl.Shared.Forms
return subMenuItem;
}
public static void BuildDropDownMenu(ToolStripDropDownItem mnuParent, string name, Type enumType, object colorData, string propertyName, EventHandler clickEvent, Font font = null)
public static ToolStripMenuItem BuildDropDownMenu(ToolStripDropDownItem mnuParent, string name, Type enumType, object colorData, string propertyName, EventHandler clickEvent, Font font = null, bool unchanged = false)
{
PropertyInfo property = null;
var subMenuItems = mnuParent.DropDownItems.Find("miColorSettings_" + name, false);
@@ -159,6 +159,17 @@ namespace ColorControl.Shared.Forms
subMenuItem.Tag = property;
}
if (unchanged)
{
var item = subMenuItem.DropDownItems.AddCustom("Unchanged");
item.Click += clickEvent;
if (font != null)
{
item.Font = font;
}
}
foreach (var enumValue in Enum.GetValues(enumType))
{
var item = subMenuItem.DropDownItems.AddCustom(enumValue.ToString());
@@ -180,7 +191,7 @@ namespace ColorControl.Shared.Forms
if (colorData == null)
{
return;
return subMenuItem;
}
var value = property.GetValue(colorData);
@@ -193,8 +204,13 @@ namespace ColorControl.Shared.Forms
{
menuItem.Checked = menuItem.Tag.Equals(value);
}
else
{
menuItem.Checked = value == null;
}
}
}
return subMenuItem;
}
public static ToolStripMenuItem BuildMenuItem(ToolStripItemCollection itemCollection, string name, string text, object tag = null, EventHandler onClick = null)
@@ -489,6 +505,18 @@ namespace ColorControl.Shared.Forms
return name;
}
public static IntPtr GetMonitorForDisplayName(string displayName)
{
var name = displayName;
var screen = Screen.AllScreens.FirstOrDefault(x => x.DeviceName.Equals(name));
if (screen != null)
{
return screen.GetHashCode();
}
return IntPtr.Zero;
}
public static string EditShortcut(string shortcut, string label = "Shortcut", string title = null)
{
var field = new MessageForms.FieldDefinition
@@ -569,6 +597,23 @@ namespace ColorControl.Shared.Forms
sortState.SortOrder = sorter.Order;
sortState.SortIndex = sorter.SortColumn;
}
public static IAsyncResult BeginInvokeCheck(Control control, Delegate action)
{
return BeginInvokeCheck(control, action, null);
}
public static IAsyncResult BeginInvokeCheck(Control control, Delegate action, params object[] args)
{
if (control?.IsHandleCreated != true)
{
Logger.Debug($"Skipping BeginInvoke due to missing handle of control {control.Name}");
return null;
}
return control.BeginInvoke(action, args);
}
}
public class EnumComboBoxItem
+8 -20
View File
@@ -107,11 +107,6 @@ namespace ColorControl.Shared.Native
NativeMethods.DisplayConfigSetDeviceInfo(ref setpacket);
IsHDRActive = enabled;
//if (enabled && SDRWhiteLevelInNits.HasValue)
//{
// SetSDRWhiteLevel(modesArray[i], SDRWhiteLevelInNits.Value);
//}
}
}
}
@@ -125,8 +120,7 @@ namespace ColorControl.Shared.Native
}
}
// Does not work...
public static void SetSDRWhiteLevel(float SDRWhiteLevelInNits, string displayName = null)
public static uint GetSDRWhiteLevel(string displayName = null)
{
uint pathCount, modeCount;
@@ -164,7 +158,7 @@ namespace ColorControl.Shared.Native
if (err == NativeConstants.ERROR_SUCCESS && requestpacket.advancedColorSupported)
{
SetSDRWhiteLevel(modesArray[i], SDRWhiteLevelInNits);
return GetSDRWhiteLevelForDisplayConfig(modesArray[i]);
}
}
}
@@ -176,6 +170,8 @@ namespace ColorControl.Shared.Native
{
throw new Win32Exception(err);
}
return 0;
}
public static bool IsHDREnabled(string displayName = null)
@@ -258,13 +254,8 @@ namespace ColorControl.Shared.Native
return true;
}
private static void SetSDRWhiteLevel(DisplayConfigModeInfo displayConfigModeInfo, float value)
private static uint GetSDRWhiteLevelForDisplayConfig(DisplayConfigModeInfo displayConfigModeInfo)
{
var setpacket = new DISPLAYCONFIG_SDR_WHITE_LEVEL();
setpacket.header = new DISPLAYCONFIG_DEVICE_INFO_HEADER();
setpacket.header.type = DISPLAYCONFIG_DEVICE_INFO_TYPE.DISPLAYCONFIG_DEVICE_INFO_SET_SDR_WHITE_LEVEL;
setpacket.header.size = Marshal.SizeOf<DISPLAYCONFIG_SDR_WHITE_LEVEL>();
var requestpacket = new DISPLAYCONFIG_SDR_WHITE_LEVEL();
requestpacket.header = new DISPLAYCONFIG_DEVICE_INFO_HEADER();
requestpacket.header.type = DISPLAYCONFIG_DEVICE_INFO_TYPE.DISPLAYCONFIG_DEVICE_INFO_GET_SDR_WHITE_LEVEL;
@@ -276,13 +267,10 @@ namespace ColorControl.Shared.Native
if (error == NativeConstants.ERROR_SUCCESS)
{
setpacket.header.adapterId = displayConfigModeInfo.adapterId;
setpacket.header.id = displayConfigModeInfo.id;
setpacket.SDRWhiteLevel = 2000;
error = NativeMethods.DisplayConfigSetDeviceInfo(ref setpacket);
return requestpacket.SDRWhiteLevel;
}
return 0;
}
private static bool EqualDisplayNames(string displayName1, string displayName2)
+3
View File
@@ -163,5 +163,8 @@ namespace ColorControl.Shared.Native
[DllImport("ntdll.dll")]
public static extern int NtQueryInformationProcess(IntPtr processHandle, int processInformationClass, ref ParentProcessUtilities processInformation, int processInformationLength, out int returnLength);
[DllImport("dwmapi.dll", EntryPoint = "#171")]
public static extern void DwmpSDRToHDRBoostPtr(IntPtr monitor, double brightness);
}
}
+3
View File
@@ -7,6 +7,9 @@
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
<PropertyGroup>
<PathMap Condition="'$(Configuration)' == 'Release'">$(MSBuildThisFileDirectory)=.\</PathMap>
</PropertyGroup>
<ItemGroup>
<COMReference Include="IWshRuntimeLibrary">
+36 -32
View File
@@ -1,27 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0-windows10.0.20348.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AppDesignerFolder>Properties</AppDesignerFolder>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<PropertyGroup>
<TargetFramework>net7.0-windows10.0.20348.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AppDesignerFolder>Properties</AppDesignerFolder>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<UseWindowsForms>true</UseWindowsForms>
<UseWPF>true</UseWPF>
<SupportedOSPlatformVersion>10.0.20348.0</SupportedOSPlatformVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NLog" Version="5.1.2" />
<PackageReference Include="System.Resources.Extensions" Version="7.0.0" />
</ItemGroup>
<PropertyGroup>
<PathMap Condition="'$(Configuration)' == 'Release'">$(MSBuildThisFileDirectory)=.\</PathMap>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="6.2.14" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="EDIDParser" Version="1.2.5.4" />
<PackageReference Include="WindowsDisplayAPI" Version="1.3.0.13" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="NLog" Version="5.1.2" />
<PackageReference Include="System.Resources.Extensions" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="6.2.14" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="EDIDParser" Version="1.2.5.4" />
<PackageReference Include="WindowsDisplayAPI" Version="1.3.0.13" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NvAPIWrapper\NvAPIWrapper.csproj" />
@@ -29,22 +33,22 @@
</ItemGroup>
<ItemGroup>
<Content Include="icon.ico" />
</ItemGroup>
<Content Include="icon.ico" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Settings.Designer.cs">
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Settings.Designer.cs">
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Update="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<None Update="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
</Project>