mirror of
https://github.com/Maassoft/ColorControl.git
synced 2026-10-18 23:07:15 -05:00
add Nvidia scaling setting
This commit is contained in:
1 parent
9fd8e8f9bb
commit
db19a9ad68
11 files changed
+152
-13
No files matched your search
@@ -97,6 +97,7 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.2088.41" />
|
||||
<PackageReference Include="System.Configuration.ConfigurationManager" Version="7.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="NLog" Version="5.1.2" />
|
||||
|
||||
Generated
+23
-4
@@ -59,6 +59,7 @@
|
||||
chkStartMinimized = new System.Windows.Forms.CheckBox();
|
||||
chkStartAfterLogin = new System.Windows.Forms.CheckBox();
|
||||
tabInfo = new System.Windows.Forms.TabPage();
|
||||
webView21 = new Microsoft.Web.WebView2.WinForms.WebView2();
|
||||
groupBox3 = new System.Windows.Forms.GroupBox();
|
||||
lbPlugins = new System.Windows.Forms.ListBox();
|
||||
label7 = new System.Windows.Forms.Label();
|
||||
@@ -70,6 +71,7 @@
|
||||
grpMiscellaneousOptions.SuspendLayout();
|
||||
grpGeneralOptions.SuspendLayout();
|
||||
tabInfo.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)webView21).BeginInit();
|
||||
groupBox3.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
@@ -223,11 +225,11 @@
|
||||
grpGeneralOptions.Controls.Add(chkMinimizeOnClose);
|
||||
grpGeneralOptions.Controls.Add(chkStartMinimized);
|
||||
grpGeneralOptions.Controls.Add(chkStartAfterLogin);
|
||||
grpGeneralOptions.Location = new System.Drawing.Point(7, 7);
|
||||
grpGeneralOptions.Location = new System.Drawing.Point(7, 6);
|
||||
grpGeneralOptions.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
grpGeneralOptions.Name = "grpGeneralOptions";
|
||||
grpGeneralOptions.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
grpGeneralOptions.Size = new System.Drawing.Size(522, 210);
|
||||
grpGeneralOptions.Size = new System.Drawing.Size(522, 211);
|
||||
grpGeneralOptions.TabIndex = 2;
|
||||
grpGeneralOptions.TabStop = false;
|
||||
grpGeneralOptions.Text = "General";
|
||||
@@ -437,6 +439,7 @@
|
||||
//
|
||||
// tabInfo
|
||||
//
|
||||
tabInfo.Controls.Add(webView21);
|
||||
tabInfo.Controls.Add(groupBox3);
|
||||
tabInfo.Location = new System.Drawing.Point(4, 24);
|
||||
tabInfo.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
@@ -447,6 +450,19 @@
|
||||
tabInfo.Text = "Info";
|
||||
tabInfo.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// webView21
|
||||
//
|
||||
webView21.AllowExternalDrop = true;
|
||||
webView21.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
webView21.CreationProperties = null;
|
||||
webView21.DefaultBackgroundColor = System.Drawing.Color.White;
|
||||
webView21.Location = new System.Drawing.Point(436, 7);
|
||||
webView21.Name = "webView21";
|
||||
webView21.Size = new System.Drawing.Size(671, 526);
|
||||
webView21.Source = new System.Uri("https://github.com/Maassoft/ColorControl/releases", System.UriKind.Absolute);
|
||||
webView21.TabIndex = 6;
|
||||
webView21.ZoomFactor = 1D;
|
||||
//
|
||||
// groupBox3
|
||||
//
|
||||
groupBox3.Controls.Add(lbPlugins);
|
||||
@@ -456,20 +472,21 @@
|
||||
groupBox3.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
groupBox3.Name = "groupBox3";
|
||||
groupBox3.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
groupBox3.Size = new System.Drawing.Size(449, 254);
|
||||
groupBox3.Size = new System.Drawing.Size(422, 271);
|
||||
groupBox3.TabIndex = 5;
|
||||
groupBox3.TabStop = false;
|
||||
groupBox3.Text = "Info";
|
||||
//
|
||||
// lbPlugins
|
||||
//
|
||||
lbPlugins.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
lbPlugins.FormattingEnabled = true;
|
||||
lbPlugins.HorizontalScrollbar = true;
|
||||
lbPlugins.ItemHeight = 15;
|
||||
lbPlugins.Location = new System.Drawing.Point(10, 77);
|
||||
lbPlugins.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
lbPlugins.Name = "lbPlugins";
|
||||
lbPlugins.Size = new System.Drawing.Size(432, 169);
|
||||
lbPlugins.Size = new System.Drawing.Size(405, 184);
|
||||
lbPlugins.TabIndex = 3;
|
||||
//
|
||||
// label7
|
||||
@@ -539,6 +556,7 @@
|
||||
grpGeneralOptions.ResumeLayout(false);
|
||||
grpGeneralOptions.PerformLayout();
|
||||
tabInfo.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)webView21).EndInit();
|
||||
groupBox3.ResumeLayout(false);
|
||||
groupBox3.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
@@ -581,6 +599,7 @@
|
||||
private System.Windows.Forms.CheckBox chkOptionsUseDarkMode;
|
||||
private System.Windows.Forms.Button btnOptionsAdvanced;
|
||||
private System.Windows.Forms.Button btnOptionsLog;
|
||||
private Microsoft.Web.WebView2.WinForms.WebView2 webView21;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
|
||||
@@ -41,6 +41,12 @@ namespace ColorControl.Services.NVIDIA
|
||||
var node = TreeNodeBuilder.CreateTree(display, $"Display[{i}]");
|
||||
tvNVIDIAInfo.Nodes.Add(node);
|
||||
}
|
||||
|
||||
for (var i = 0; i < tvNVIDIAInfo.Nodes.Count; i++)
|
||||
{
|
||||
var node = tvNVIDIAInfo.Nodes[i];
|
||||
node.Expand();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -438,6 +438,9 @@ namespace ColorControl.Services.NVIDIA
|
||||
var subItem = FormUtils.BuildMenuItem(brightnessMenu.DropDownItems, subItemName, "", onClick: nvPresetBrightnessMenuItem_Click);
|
||||
subItem.Text = (preset.SDRBrightness.HasValue ? $"{preset.SDRBrightness.Value}%" : "Unset") + " (click to change)";
|
||||
|
||||
FormUtils.BuildDropDownMenu(mnuNvOtherSettings, "Scaling", typeof(Scaling), preset, "scaling", nvPresetScalingMenuItem_Click, unchanged: true, skipValues: new object[] { Scaling.Customized })
|
||||
.DropDownItems[0].Visible = !isCurrentDisplay;
|
||||
|
||||
FormUtils.BuildDropDownMenu(mnuNvHdmiSettings, "Content type", typeof(InfoFrameVideoContentType), preset.HdmiInfoFrameSettings, "ContentType", nvPresetHdmiContentTypeMenuItem_Click, unchanged: true)
|
||||
.DropDownItems[0].Visible = !isCurrentDisplay;
|
||||
FormUtils.BuildDropDownMenu(mnuNvHdmiSettings, "Colorimetry", typeof(InfoFrameVideoColorimetry), preset.HdmiInfoFrameSettings, "Colorimetry", nvPresetHdmiColorimetryMenuItem_Click, unchanged: true)
|
||||
@@ -822,6 +825,28 @@ namespace ColorControl.Services.NVIDIA
|
||||
AddOrUpdateItem();
|
||||
}
|
||||
|
||||
private void nvPresetScalingMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var menuItem = (ToolStripMenuItem)sender;
|
||||
var propName = ((PropertyInfo)menuItem.OwnerItem.Tag).Name;
|
||||
var value = (Scaling?)menuItem.Tag;
|
||||
|
||||
var preset = GetSelectedNvPreset(true);
|
||||
|
||||
var propInfo = preset.GetType().GetDeclaredProperty(propName);
|
||||
propInfo.SetValue(preset, value);
|
||||
|
||||
if (preset.IsDisplayPreset)
|
||||
{
|
||||
_nvService.SetScaling(preset.Display, value ?? Scaling.Default);
|
||||
|
||||
UpdateDisplayInfoItems();
|
||||
return;
|
||||
}
|
||||
|
||||
AddOrUpdateItem();
|
||||
}
|
||||
|
||||
private void refreshRateMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var refreshRate = (uint)((ToolStripItem)sender).Tag;
|
||||
@@ -953,6 +978,7 @@ namespace ColorControl.Services.NVIDIA
|
||||
|
||||
if (!ask)
|
||||
{
|
||||
preset.applyColorData = false;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1812,7 +1838,7 @@ namespace ColorControl.Services.NVIDIA
|
||||
{
|
||||
var panel = new NvInfoPanel(_nvService);
|
||||
|
||||
MessageForms.ShowControl(panel, "NVIDIA Info");
|
||||
MessageForms.ShowControl(panel, "NVIDIA Info", height: 800);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,7 @@ namespace ColorControl.Services.NVIDIA
|
||||
public uint ditheringMode { get; set; }
|
||||
public bool applyOther { get; set; }
|
||||
public int? SDRBrightness { get; set; }
|
||||
public Scaling? scaling { get; set; }
|
||||
public bool applyDriverSettings { get; set; }
|
||||
public Dictionary<uint, uint> driverSettings { get; set; }
|
||||
public bool applyOverclocking { get; set; }
|
||||
@@ -104,6 +105,7 @@ namespace ColorControl.Services.NVIDIA
|
||||
driverSettings = new Dictionary<uint, uint>(preset.driverSettings);
|
||||
|
||||
SDRBrightness = preset.SDRBrightness;
|
||||
scaling = preset.scaling;
|
||||
applyOther = preset.applyOther;
|
||||
|
||||
HdmiInfoFrameSettings = new NvHdmiInfoFrameSettings(preset.HdmiInfoFrameSettings);
|
||||
@@ -273,6 +275,10 @@ namespace ColorControl.Services.NVIDIA
|
||||
{
|
||||
values.Add($"SDR brightness: {SDRBrightness.Value}%");
|
||||
}
|
||||
if (scaling.HasValue)
|
||||
{
|
||||
values.Add($"Scaling: {scaling.Value.GetDescription()}");
|
||||
}
|
||||
|
||||
if (!values.Any())
|
||||
{
|
||||
|
||||
@@ -17,6 +17,7 @@ using NvAPIWrapper.Native.Display;
|
||||
using NvAPIWrapper.Native.Display.Structures;
|
||||
using NvAPIWrapper.Native.General.Structures;
|
||||
using NvAPIWrapper.Native.GPU.Structures;
|
||||
using NvAPIWrapper.Native.Interfaces.Display;
|
||||
using NWin32;
|
||||
using NWin32.NativeTypes;
|
||||
using System;
|
||||
@@ -297,6 +298,11 @@ namespace ColorControl.Services.NVIDIA
|
||||
return Task.FromResult(false);
|
||||
}
|
||||
|
||||
if (preset.applyOther && preset.scaling.HasValue)
|
||||
{
|
||||
SetScaling(display, preset.scaling.Value);
|
||||
}
|
||||
|
||||
var hdrEnabled = IsHDREnabled();
|
||||
|
||||
var newHdrEnabled = preset.applyHDR && (preset.HDREnabled || (preset.toggleHDR && !hdrEnabled));
|
||||
@@ -838,6 +844,65 @@ namespace ColorControl.Services.NVIDIA
|
||||
};
|
||||
}
|
||||
|
||||
public Scaling GetScaling(Display display)
|
||||
{
|
||||
var pathTargetInfo = GetTargetInfoForDisplay(display);
|
||||
|
||||
if (pathTargetInfo?.Details == null)
|
||||
{
|
||||
return Scaling.Default;
|
||||
}
|
||||
|
||||
var details = pathTargetInfo.Details.Value;
|
||||
|
||||
return details.Scaling;
|
||||
}
|
||||
|
||||
public void SetScaling(Display display, Scaling scaling)
|
||||
{
|
||||
var pathInfo = GetPathInfoForDisplay(display);
|
||||
|
||||
var pathTargetInfo = pathInfo.TargetsInfo.FirstOrDefault(ti => ti.DisplayId == display.DisplayDevice.DisplayId);
|
||||
|
||||
if (pathTargetInfo?.Details == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var details = pathTargetInfo.Details.Value;
|
||||
|
||||
var newDetails = new PathAdvancedTargetInfo(details.Rotation, scaling);
|
||||
|
||||
var newPathTargetInfo = new PathTargetInfoV2(pathTargetInfo.DisplayId, newDetails);
|
||||
|
||||
var newPathInfo = new PathInfoV2(new[] { newPathTargetInfo }, pathInfo.SourceModeInfo);
|
||||
|
||||
DisplayApi.SetDisplayConfig(new IPathInfo[] { newPathInfo }, DisplayConfigFlags.SaveToPersistence);
|
||||
}
|
||||
|
||||
private IPathTargetInfo? GetTargetInfoForDisplay(Display display)
|
||||
{
|
||||
var pathInfos = DisplayApi.GetDisplayConfig();
|
||||
|
||||
var pathInfo = pathInfos.FirstOrDefault(c => c.TargetsInfo.Any(ti => ti.DisplayId == display.DisplayDevice.DisplayId));
|
||||
|
||||
if (pathInfo == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var pathTargetInfo = pathInfo.TargetsInfo.FirstOrDefault(ti => ti.DisplayId == display.DisplayDevice.DisplayId);
|
||||
|
||||
return pathTargetInfo;
|
||||
}
|
||||
|
||||
private IPathInfo? GetPathInfoForDisplay(Display display)
|
||||
{
|
||||
var pathInfos = DisplayApi.GetDisplayConfig();
|
||||
|
||||
return pathInfos.FirstOrDefault(c => c.TargetsInfo.Any(ti => ti.DisplayId == display.DisplayDevice.DisplayId));
|
||||
}
|
||||
|
||||
public void TestResolution()
|
||||
{
|
||||
//var display = GetCurrentDisplay();
|
||||
@@ -1012,6 +1077,7 @@ namespace ColorControl.Services.NVIDIA
|
||||
preset.colorData = GetCurrentColorData(display);
|
||||
preset.HdmiInfoFrameSettings = GetHdmiSettings(display);
|
||||
preset.SDRBrightness = GetSDRBrightness(display);
|
||||
preset.scaling = GetScaling(display);
|
||||
|
||||
var mode = GetCurrentMode(display.Name);
|
||||
|
||||
|
||||
@@ -308,7 +308,7 @@ namespace nspector.Common
|
||||
|
||||
if (drsEvent.Handled)
|
||||
{
|
||||
removeFromModified = drsEvent.Result;
|
||||
removeFromModified = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace NvAPIWrapper.Native.Display
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace NvAPIWrapper.Native.Display
|
||||
{
|
||||
/// <summary>
|
||||
/// Possible scaling modes
|
||||
@@ -13,31 +15,37 @@
|
||||
/// <summary>
|
||||
/// Balanced - Full Screen
|
||||
/// </summary>
|
||||
[Description("Display - Full-screen")]
|
||||
ToClosest = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Force GPU - Full Screen
|
||||
/// </summary>
|
||||
[Description("GPU - Full-screen")]
|
||||
ToNative = 2,
|
||||
|
||||
/// <summary>
|
||||
/// Force GPU - Centered\No Scaling
|
||||
/// </summary>
|
||||
[Description("GPU - No Scaling")]
|
||||
GPUScanOutToNative = 3,
|
||||
|
||||
/// <summary>
|
||||
/// Force GPU - Aspect Ratio
|
||||
/// </summary>
|
||||
[Description("GPU - Aspect Ratio")]
|
||||
ToAspectScanOutToNative = 5,
|
||||
|
||||
/// <summary>
|
||||
/// Balanced - Aspect Ratio
|
||||
/// </summary>
|
||||
[Description("Display - Aspect Ratio")]
|
||||
ToAspectScanOutToClosest = 6,
|
||||
|
||||
/// <summary>
|
||||
/// Balanced - Centered\No Scaling
|
||||
/// </summary>
|
||||
[Description("Display - No Scaling")]
|
||||
GPUScanOutToClosest = 7,
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace ColorControl.Shared.Forms
|
||||
return subMenuItem;
|
||||
}
|
||||
|
||||
public static ToolStripMenuItem BuildDropDownMenu(ToolStripDropDownItem mnuParent, string name, Type enumType, object colorData, string propertyName, EventHandler clickEvent, Font font = null, bool unchanged = false)
|
||||
public static ToolStripMenuItem BuildDropDownMenu(ToolStripDropDownItem mnuParent, string name, Type enumType, object colorData, string propertyName, EventHandler clickEvent, Font font = null, bool unchanged = false, object[] skipValues = null)
|
||||
{
|
||||
PropertyInfo property = null;
|
||||
var subMenuItems = mnuParent.DropDownItems.Find("miColorSettings_" + name, false);
|
||||
@@ -172,7 +172,14 @@ namespace ColorControl.Shared.Forms
|
||||
|
||||
foreach (var enumValue in Enum.GetValues(enumType))
|
||||
{
|
||||
var item = subMenuItem.DropDownItems.AddCustom(enumValue.ToString());
|
||||
if (skipValues?.Contains(enumValue) == true)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var text = (enumValue as IConvertible)?.GetDescription() ?? enumValue.ToString();
|
||||
|
||||
var item = subMenuItem.DropDownItems.AddCustom(text);
|
||||
item.Tag = enumValue;
|
||||
item.Click += clickEvent;
|
||||
|
||||
|
||||
@@ -532,14 +532,14 @@ namespace ColorControl.Shared.Forms
|
||||
return prompt;
|
||||
}
|
||||
|
||||
public static Form ShowControl(Control control, string title)
|
||||
public static Form ShowControl(Control control, string title, int width = 800, int height = 400)
|
||||
{
|
||||
var prompt = new Form()
|
||||
{
|
||||
Icon = MainForm.Icon,
|
||||
Text = title,
|
||||
Width = 800,
|
||||
Height = 400,
|
||||
Width = width,
|
||||
Height = height,
|
||||
StartPosition = FormStartPosition.CenterScreen,
|
||||
BackColor = FormUtils.CurrentBackColor,
|
||||
ForeColor = FormUtils.CurrentForeColor,
|
||||
|
||||
Reference in new issue
Block a user