diff --git a/ColorControl.sln b/ColorControl.sln index 09a46d9..9133d2a 100644 --- a/ColorControl.sln +++ b/ColorControl.sln @@ -13,6 +13,8 @@ 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}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -61,6 +63,14 @@ Global {D5E4D314-CFCD-4859-98FC-68F660AC7FB4}.Release|Any CPU.Build.0 = Release|Any CPU {D5E4D314-CFCD-4859-98FC-68F660AC7FB4}.Release|x64.ActiveCfg = Release|Any CPU {D5E4D314-CFCD-4859-98FC-68F660AC7FB4}.Release|x64.Build.0 = Release|Any CPU + {8F38D6B0-82DA-4DD1-89EB-918D8A18AEB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8F38D6B0-82DA-4DD1-89EB-918D8A18AEB1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8F38D6B0-82DA-4DD1-89EB-918D8A18AEB1}.Debug|x64.ActiveCfg = Debug|Any CPU + {8F38D6B0-82DA-4DD1-89EB-918D8A18AEB1}.Debug|x64.Build.0 = Debug|Any CPU + {8F38D6B0-82DA-4DD1-89EB-918D8A18AEB1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8F38D6B0-82DA-4DD1-89EB-918D8A18AEB1}.Release|Any CPU.Build.0 = Release|Any CPU + {8F38D6B0-82DA-4DD1-89EB-918D8A18AEB1}.Release|x64.ActiveCfg = Release|Any CPU + {8F38D6B0-82DA-4DD1-89EB-918D8A18AEB1}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/ColorControl/ColorControl.csproj b/ColorControl/ColorControl.csproj index cbe23ba..36bc9ed 100644 --- a/ColorControl/ColorControl.csproj +++ b/ColorControl/ColorControl.csproj @@ -48,7 +48,6 @@ MinimumRecommendedRules.ruleset - @@ -70,9 +69,6 @@ PreserveNewest - - Never - @@ -113,6 +109,7 @@ + diff --git a/ColorControl/MainForm.cs b/ColorControl/MainForm.cs index 29cd681..c57f611 100644 --- a/ColorControl/MainForm.cs +++ b/ColorControl/MainForm.cs @@ -1044,13 +1044,20 @@ NOTE: installing the service may cause a User Account Control popup."); bool CompareVersions() { var result = true; + var aNumberIsLarger = false; for (var i = 0; i < nvParts.Length; i++) { - var part = nvParts[i]; - var cvPart = cvParts[i]; + var part = Utils.ParseInt(nvParts[i]); + var cvPart = Utils.ParseInt(cvParts[i]); - if (Utils.ParseInt(part) >= Utils.ParseInt(cvPart)) + if (part > cvPart) + { + aNumberIsLarger = true; + break; + } + + if (part == cvPart) { continue; } @@ -1059,7 +1066,7 @@ NOTE: installing the service may cause a User Account Control popup."); break; } - return result; + return result && aNumberIsLarger; } if (nvParts.Length != cvParts.Length || CompareVersions()) diff --git a/ColorControl/Services/NVIDIA/NvPanel.Designer.cs b/ColorControl/Services/NVIDIA/NvPanel.Designer.cs index 5123a92..964b46f 100644 --- a/ColorControl/Services/NVIDIA/NvPanel.Designer.cs +++ b/ColorControl/Services/NVIDIA/NvPanel.Designer.cs @@ -87,9 +87,11 @@ namespace ColorControl.Services.NVIDIA lvNvPresets = new System.Windows.Forms.ListView(); mnuNvSettings = new System.Windows.Forms.ContextMenuStrip(components); miNvProfileInspector = new System.Windows.Forms.ToolStripMenuItem(); + miNvNovideo = new System.Windows.Forms.ToolStripMenuItem(); miNvSettings = new System.Windows.Forms.ToolStripMenuItem(); lvNvPresetsToolTip = new System.Windows.Forms.ToolTip(components); - miNvNovideo = new System.Windows.Forms.ToolStripMenuItem(); + mnuNvOtherSettings = new System.Windows.Forms.ToolStripMenuItem(); + miNvOtherIncluded = new System.Windows.Forms.ToolStripMenuItem(); mnuNvPresets.SuspendLayout(); mnuNvSettings.SuspendLayout(); SuspendLayout(); @@ -320,9 +322,9 @@ namespace ColorControl.Services.NVIDIA // mnuNvPresets // mnuNvPresets.ImageScalingSize = new System.Drawing.Size(20, 20); - mnuNvPresets.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { miNvApply, miNvPresetApplyOnStartup, tssNvPresetMenu, mnuNvDisplay, mnuNvPresetsColorSettings, mnuRefreshRate, mnuNvResolution, miNvPresetDithering, miNvHDR, mnuNvDriverSettings, mnuNvOverclocking, miNvCopyId }); + mnuNvPresets.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { miNvApply, miNvPresetApplyOnStartup, tssNvPresetMenu, mnuNvDisplay, mnuNvPresetsColorSettings, mnuRefreshRate, mnuNvResolution, miNvPresetDithering, miNvHDR, mnuNvDriverSettings, mnuNvOtherSettings, mnuNvOverclocking, miNvCopyId }); mnuNvPresets.Name = "mnuNvPresets"; - mnuNvPresets.Size = new System.Drawing.Size(185, 252); + mnuNvPresets.Size = new System.Drawing.Size(185, 296); mnuNvPresets.Opening += mnuNvPresets_Opening; // // miNvApply @@ -539,7 +541,7 @@ namespace ColorControl.Services.NVIDIA // miNvDriverSettingsIncluded // miNvDriverSettingsIncluded.Name = "miNvDriverSettingsIncluded"; - miNvDriverSettingsIncluded.Size = new System.Drawing.Size(120, 22); + miNvDriverSettingsIncluded.Size = new System.Drawing.Size(180, 22); miNvDriverSettingsIncluded.Text = "Included"; miNvDriverSettingsIncluded.Click += miNvDriverSettingsIncluded_Click; // @@ -553,7 +555,7 @@ namespace ColorControl.Services.NVIDIA // miNvOverclockingIncluded // miNvOverclockingIncluded.Name = "miNvOverclockingIncluded"; - miNvOverclockingIncluded.Size = new System.Drawing.Size(120, 22); + miNvOverclockingIncluded.Size = new System.Drawing.Size(180, 22); miNvOverclockingIncluded.Text = "Included"; miNvOverclockingIncluded.Click += miNvOverclockingIncluded_Click; // @@ -604,7 +606,7 @@ namespace ColorControl.Services.NVIDIA mnuNvSettings.ImageScalingSize = new System.Drawing.Size(20, 20); mnuNvSettings.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { miNvProfileInspector, miNvNovideo, miNvSettings }); mnuNvSettings.Name = "mnuLgButtons"; - mnuNvSettings.Size = new System.Drawing.Size(202, 92); + mnuNvSettings.Size = new System.Drawing.Size(202, 70); // // miNvProfileInspector // @@ -613,6 +615,13 @@ namespace ColorControl.Services.NVIDIA miNvProfileInspector.Text = "NVIDIA Profile Inspector"; miNvProfileInspector.Click += miNvProfileInspector_Click; // + // miNvNovideo + // + miNvNovideo.Name = "miNvNovideo"; + miNvNovideo.Size = new System.Drawing.Size(201, 22); + miNvNovideo.Text = "Novideo sRGB"; + miNvNovideo.Click += miNvNovideo_Click; + // // miNvSettings // miNvSettings.Name = "miNvSettings"; @@ -620,12 +629,19 @@ namespace ColorControl.Services.NVIDIA miNvSettings.Text = "Settings"; miNvSettings.Click += miNvSettings_Click; // - // miNvNovideo + // mnuNvOtherSettings // - miNvNovideo.Name = "miNvNovideo"; - miNvNovideo.Size = new System.Drawing.Size(201, 22); - miNvNovideo.Text = "Novideo sRGB"; - miNvNovideo.Click += miNvNovideo_Click; + mnuNvOtherSettings.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { miNvOtherIncluded }); + mnuNvOtherSettings.Name = "mnuNvOtherSettings"; + mnuNvOtherSettings.Size = new System.Drawing.Size(184, 22); + mnuNvOtherSettings.Text = "Other"; + // + // miNvOtherIncluded + // + miNvOtherIncluded.Name = "miNvOtherIncluded"; + miNvOtherIncluded.Size = new System.Drawing.Size(180, 22); + miNvOtherIncluded.Text = "Included"; + miNvOtherIncluded.Click += miNvOtherIncluded_Click; // // NvPanel // @@ -724,5 +740,7 @@ namespace ColorControl.Services.NVIDIA private System.Windows.Forms.ToolStripMenuItem mnuNvOverclocking; private System.Windows.Forms.ToolStripMenuItem miNvOverclockingIncluded; private System.Windows.Forms.ToolStripMenuItem miNvNovideo; + private System.Windows.Forms.ToolStripMenuItem mnuNvOtherSettings; + private System.Windows.Forms.ToolStripMenuItem miNvOtherIncluded; } } diff --git a/ColorControl/Services/NVIDIA/NvPanel.cs b/ColorControl/Services/NVIDIA/NvPanel.cs index f7d93ef..cf2548e 100644 --- a/ColorControl/Services/NVIDIA/NvPanel.cs +++ b/ColorControl/Services/NVIDIA/NvPanel.cs @@ -326,6 +326,8 @@ namespace ColorControl.Services.NVIDIA miNvDriverSettingsIncluded.Visible = presetItemsVisible; mnuNvDriverSettings.Enabled = preset != null; mnuNvOverclocking.Visible = preset != null && _nvService.Config.ShowOverclocking; + mnuNvOtherSettings.Enabled = preset != null; + miNvOtherIncluded.Visible = presetItemsVisible; if (preset == null) { @@ -406,6 +408,8 @@ namespace ColorControl.Services.NVIDIA miNvHDR.Font = _menuItemFonts[preset.applyHDR]; mnuNvOverclocking.Font = _menuItemFonts[preset.applyOverclocking]; + FormUtils.BuildDropDownMenu(mnuNvOtherSettings, "Content type", typeof(InfoFrameVideoContentType), preset, "contentType", nvPresetContentTypeMenuItem_Click); + BuildNvOverclockingMenu(preset); UpdateNvPresetMenuFont(); @@ -710,6 +714,27 @@ namespace ColorControl.Services.NVIDIA AddOrUpdateItem(); } + private void nvPresetContentTypeMenuItem_Click(object sender, EventArgs e) + { + var menuItem = (ToolStripMenuItem)sender; + + var value = (InfoFrameVideoContentType)menuItem.Tag; + + var preset = GetSelectedNvPreset(true); + + if (preset.IsDisplayPreset) + { + _nvService.SetHDMIContentType(preset.Display, value); + + UpdateDisplayInfoItems(); + return; + } + + preset.contentType = value; + + AddOrUpdateItem(); + } + private void refreshRateMenuItem_Click(object sender, EventArgs e) { var refreshRate = (uint)((ToolStripItem)sender).Tag; @@ -1522,5 +1547,14 @@ namespace ColorControl.Services.NVIDIA { MainWindow.CreateAndShow(); } + + private void miNvOtherIncluded_Click(object sender, EventArgs e) + { + var preset = GetSelectedNvPreset(); + + preset.applyOther = !preset.applyOther; + + AddOrUpdateItem(); + } } } diff --git a/ColorControl/Services/NVIDIA/NvPanel.resx b/ColorControl/Services/NVIDIA/NvPanel.resx index e5d9137..86701cd 100644 --- a/ColorControl/Services/NVIDIA/NvPanel.resx +++ b/ColorControl/Services/NVIDIA/NvPanel.resx @@ -1,4 +1,64 @@ - + + + diff --git a/ColorControl/Services/NVIDIA/NvPreset.cs b/ColorControl/Services/NVIDIA/NvPreset.cs index 0f05ad4..0ae6c95 100644 --- a/ColorControl/Services/NVIDIA/NvPreset.cs +++ b/ColorControl/Services/NVIDIA/NvPreset.cs @@ -30,6 +30,8 @@ namespace ColorControl.Services.NVIDIA public string displayName { get; set; } public uint ditheringBits { get; set; } public uint ditheringMode { get; set; } + public bool applyOther { get; set; } + public InfoFrameVideoContentType contentType { get; set; } public bool applyDriverSettings { get; set; } public Dictionary driverSettings { get; set; } public bool applyOverclocking { get; set; } @@ -55,6 +57,7 @@ namespace ColorControl.Services.NVIDIA primaryDisplay = true; ditheringBits = 1; ditheringMode = 4; + contentType = InfoFrameVideoContentType.Auto; applyDriverSettings = false; driverSettings = new Dictionary(); ocSettings = new List(); @@ -89,6 +92,9 @@ namespace ColorControl.Services.NVIDIA resolutionHeight = preset.resolutionHeight; applyDriverSettings = preset.applyDriverSettings; driverSettings = new Dictionary(preset.driverSettings); + + contentType = preset.contentType; + applyOther = preset.applyOther; } public NvPreset Clone() @@ -100,7 +106,7 @@ namespace ColorControl.Services.NVIDIA public static string[] GetColumnNames() { - return new[] { "Name", "Display|140", "Color settings (BPC, format, dyn. range, color space)|260", "Refresh rate|100", "Resolution|120", "Dithering", "HDR", "Driver settings|300", "Overclocking|300", "Shortcut", "Apply on startup" }; + return new[] { "Name", "Display|140", "Color settings (BPC, format, dyn. range, color space)|260", "Refresh rate|100", "Resolution|120", "Dithering", "HDR", "Driver settings|300", "Other|200", "Overclocking|300", "Shortcut", "Apply on startup" }; } public override List GetDisplayValues(Config config = null) @@ -133,6 +139,8 @@ 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}", applyOverclocking ? "Included" : "Excluded", GetOverclockingSettingsDescription())); values.Add(shortcut); diff --git a/ColorControl/Services/NVIDIA/NvService.cs b/ColorControl/Services/NVIDIA/NvService.cs index 157ad56..6db6a64 100644 --- a/ColorControl/Services/NVIDIA/NvService.cs +++ b/ColorControl/Services/NVIDIA/NvService.cs @@ -322,6 +322,11 @@ namespace ColorControl.Services.NVIDIA } } + if (preset.applyOther) + { + SetHDMIContentType(display, preset.contentType); + } + if (preset.applyDithering) { if (!SetDithering(preset.ditheringEnabled ? NvDitherState.Enabled : NvDitherState.Disabled, preset: preset)) @@ -648,7 +653,7 @@ namespace ColorControl.Services.NVIDIA return GetAvailableRefreshRatesInternal(display.Name, portrait, desktopRect.Width, desktopRect.Height); } - private bool IsDisplayInPortraitMode(NvAPIWrapper.Display.Display display) + private bool IsDisplayInPortraitMode(Display display) { try { @@ -692,6 +697,30 @@ namespace ColorControl.Services.NVIDIA return hdr?.HDRMode == ColorDataHDRMode.UHDA; } + public void SetHDMIContentType(Display display, InfoFrameVideoContentType contentType) + { + var displayDevice = display.DisplayDevice; + + var info = displayDevice.HDMIVideoFrameCurrentInformation; + + if (info.HasValue) + { + var infoValue = info.Value; + + infoValue.SetContentType(contentType); + + displayDevice.SetHDMIVideoFrameInformation(infoValue); + } + } + public InfoFrameVideoContentType GetHDMIContentType(Display display) + { + var displayDevice = display.DisplayDevice; + + var info = displayDevice.HDMIVideoFrameCurrentInformation; + + return info.HasValue ? info.Value.ContentType : InfoFrameVideoContentType.Auto; + } + public Display[] GetDisplays() { return Display.GetDisplays(); @@ -799,6 +828,8 @@ namespace ColorControl.Services.NVIDIA values.Add(string.Join(", ", drsValues)); + values.Add($"Content type: {GetHDMIContentType(display)}"); + var infoLine = string.Format("{0}: {1}, {2}Hz, HDR: {3}", name, colorSettings, refreshRate, hdrEnabled ? "Yes" : "No"); var displayInfo = new NvDisplayInfo(display, values, infoLine, name); @@ -831,6 +862,7 @@ namespace ColorControl.Services.NVIDIA preset.displayName = FormUtils.ExtendedDisplayName(display.Name); preset.colorData = GetCurrentColorData(display); + preset.contentType = GetHDMIContentType(display); var mode = GetCurrentMode(display.Name); diff --git a/ColorControl/XForms/LogWindow.xaml b/ColorControl/XForms/LogWindow.xaml index 6e193d7..effbd19 100644 --- a/ColorControl/XForms/LogWindow.xaml +++ b/ColorControl/XForms/LogWindow.xaml @@ -1,4 +1,4 @@ - @@ -46,4 +47,4 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/ColorControl/XForms/LogWindow.xaml.cs b/ColorControl/XForms/LogWindow.xaml.cs index 765e3b6..15fb353 100644 --- a/ColorControl/XForms/LogWindow.xaml.cs +++ b/ColorControl/XForms/LogWindow.xaml.cs @@ -1,6 +1,7 @@ using ColorControl.Common; using ColorControl.Forms; using ColorControl.Native; +using ColorControl.Shared.XForms; using ColorControl.Svc; using DJ; using NLog; @@ -15,7 +16,7 @@ using System.Windows.Navigation; namespace ColorControl.XForms { - public partial class LogWindow : Window + public partial class LogWindow : BaseWindow { private static LogWindow _window; @@ -77,7 +78,7 @@ namespace ColorControl.XForms { if (DarkModeUtils.UseDarkMode) { - var dict = new ResourceDictionary { Source = new Uri($"Themes/DarkTheme.xaml", UriKind.Relative) }; + var dict = new ResourceDictionary { Source = new Uri($"pack://application:,,,/Shared;component/Themes/DarkTheme.xaml", UriKind.Absolute) }; if (Application.Current.Resources.MergedDictionaries.Any()) { diff --git a/NvAPIWrapper/Native/Display/Structures/InfoFrameVideo.cs b/NvAPIWrapper/Native/Display/Structures/InfoFrameVideo.cs index a366bda..fc0fac1 100644 --- a/NvAPIWrapper/Native/Display/Structures/InfoFrameVideo.cs +++ b/NvAPIWrapper/Native/Display/Structures/InfoFrameVideo.cs @@ -1,5 +1,5 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Helpers; +using NvAPIWrapper.Native.Helpers; +using System.Runtime.InteropServices; namespace NvAPIWrapper.Native.Display.Structures { @@ -10,7 +10,7 @@ namespace NvAPIWrapper.Native.Display.Structures public struct InfoFrameVideo { [FieldOffset(0)] private readonly uint _WordAt0; - [FieldOffset(4)] private readonly uint _WordAt4; + [FieldOffset(4)] private uint _WordAt4; [FieldOffset(8)] private readonly uint _WordAt8; [FieldOffset(12)] private readonly uint _WordAt12; [FieldOffset(16)] private readonly uint _WordAt16; @@ -62,22 +62,22 @@ namespace NvAPIWrapper.Native.Display.Structures { _WordAt0 = 0u .SetBits(0, 8, videoIdentificationCode) - .SetBits(8, 5, (uint) pixelRepetition) - .SetBits(13, 3, (uint) colorFormat) - .SetBits(16, 3, (uint) colorimetry) - .SetBits(19, 4, (uint) extendedColorimetry) - .SetBits(23, 3, (uint) rgbQuantization) - .SetBits(26, 3, (uint) yccQuantization) - .SetBits(29, 2, (uint) contentMode); + .SetBits(8, 5, (uint)pixelRepetition) + .SetBits(13, 3, (uint)colorFormat) + .SetBits(16, 3, (uint)colorimetry) + .SetBits(19, 4, (uint)extendedColorimetry) + .SetBits(23, 3, (uint)rgbQuantization) + .SetBits(26, 3, (uint)yccQuantization) + .SetBits(29, 2, (uint)contentMode); _WordAt4 = 0u - .SetBits(0, 3, (uint) contentType) - .SetBits(3, 3, (uint) scanInfo) - .SetBits(6, 2, (uint) isActiveFormatInfoPresent) - .SetBits(8, 5, (uint) activeFormatAspectRatio) - .SetBits(13, 3, (uint) pictureAspectRatio) - .SetBits(16, 3, (uint) nonUniformPictureScaling) - .SetBits(19, 3, (uint) barInfo); + .SetBits(0, 3, (uint)contentType) + .SetBits(3, 3, (uint)scanInfo) + .SetBits(6, 2, (uint)isActiveFormatInfoPresent) + .SetBits(8, 5, (uint)activeFormatAspectRatio) + .SetBits(13, 3, (uint)pictureAspectRatio) + .SetBits(16, 3, (uint)nonUniformPictureScaling) + .SetBits(19, 3, (uint)barInfo); _WordAt8 = topBar == null ? 0x1FFFF : 0u.SetBits(0, 17, topBar.Value); _WordAt12 = bottomBar == null ? 0x1FFFF : 0u.SetBits(0, 17, bottomBar.Value); @@ -85,6 +85,20 @@ namespace NvAPIWrapper.Native.Display.Structures _WordAt20 = rightBar == null ? 0x1FFFF : 0u.SetBits(0, 17, rightBar.Value); } + public void SetContentType(InfoFrameVideoContentType contentType) + { + var newWord = 0u + .SetBits(0, 3, (uint)contentType) + .SetBits(3, 3, (uint)ScanInfo) + .SetBits(6, 2, (uint)IsActiveFormatInfoPresent) + .SetBits(8, 5, (uint)ActiveFormatAspectRatio) + .SetBits(13, 3, (uint)PictureAspectRatio) + .SetBits(16, 3, (uint)NonUniformPictureScaling) + .SetBits(19, 3, (uint)BarInfo); + + _WordAt4 = newWord; + } + /// /// Gets the video identification code (VIC) /// @@ -93,7 +107,7 @@ namespace NvAPIWrapper.Native.Display.Structures { get { - var value = (byte) _WordAt0.GetBits(0, 8); + var value = (byte)_WordAt0.GetBits(0, 8); if (value == 0xFF) { @@ -109,7 +123,7 @@ namespace NvAPIWrapper.Native.Display.Structures /// public InfoFrameVideoPixelRepetition PixelRepetition { - get => (InfoFrameVideoPixelRepetition) _WordAt0.GetBits(8, 5); + get => (InfoFrameVideoPixelRepetition)_WordAt0.GetBits(8, 5); } /// @@ -117,7 +131,7 @@ namespace NvAPIWrapper.Native.Display.Structures /// public InfoFrameVideoColorFormat ColorFormat { - get => (InfoFrameVideoColorFormat) _WordAt0.GetBits(13, 3); + get => (InfoFrameVideoColorFormat)_WordAt0.GetBits(13, 3); } /// @@ -125,7 +139,7 @@ namespace NvAPIWrapper.Native.Display.Structures /// public InfoFrameVideoColorimetry Colorimetry { - get => (InfoFrameVideoColorimetry) _WordAt0.GetBits(16, 3); + get => (InfoFrameVideoColorimetry)_WordAt0.GetBits(16, 3); } /// @@ -141,7 +155,7 @@ namespace NvAPIWrapper.Native.Display.Structures return null; } - return (InfoFrameVideoExtendedColorimetry) _WordAt0.GetBits(19, 4); + return (InfoFrameVideoExtendedColorimetry)_WordAt0.GetBits(19, 4); } } @@ -150,7 +164,7 @@ namespace NvAPIWrapper.Native.Display.Structures /// public InfoFrameVideoRGBQuantization RGBQuantization { - get => (InfoFrameVideoRGBQuantization) _WordAt0.GetBits(23, 3); + get => (InfoFrameVideoRGBQuantization)_WordAt0.GetBits(23, 3); } /// @@ -158,7 +172,7 @@ namespace NvAPIWrapper.Native.Display.Structures /// public InfoFrameVideoYCCQuantization YCCQuantization { - get => (InfoFrameVideoYCCQuantization) _WordAt0.GetBits(26, 3); + get => (InfoFrameVideoYCCQuantization)_WordAt0.GetBits(26, 3); } /// @@ -166,7 +180,7 @@ namespace NvAPIWrapper.Native.Display.Structures /// public InfoFrameVideoITC ContentMode { - get => (InfoFrameVideoITC) _WordAt0.GetBits(29, 2); + get => (InfoFrameVideoITC)_WordAt0.GetBits(29, 2); } /// @@ -174,7 +188,7 @@ namespace NvAPIWrapper.Native.Display.Structures /// public InfoFrameVideoContentType ContentType { - get => (InfoFrameVideoContentType) _WordAt4.GetBits(0, 3); + get => (InfoFrameVideoContentType)_WordAt4.GetBits(0, 3); } /// @@ -182,7 +196,7 @@ namespace NvAPIWrapper.Native.Display.Structures /// public InfoFrameVideoScanInfo ScanInfo { - get => (InfoFrameVideoScanInfo) _WordAt4.GetBits(3, 3); + get => (InfoFrameVideoScanInfo)_WordAt4.GetBits(3, 3); } /// @@ -190,7 +204,7 @@ namespace NvAPIWrapper.Native.Display.Structures /// public InfoFrameBoolean IsActiveFormatInfoPresent { - get => (InfoFrameBoolean) _WordAt4.GetBits(6, 2); + get => (InfoFrameBoolean)_WordAt4.GetBits(6, 2); } /// @@ -198,7 +212,7 @@ namespace NvAPIWrapper.Native.Display.Structures /// public InfoFrameVideoAspectRatioActivePortion ActiveFormatAspectRatio { - get => (InfoFrameVideoAspectRatioActivePortion) _WordAt4.GetBits(8, 5); + get => (InfoFrameVideoAspectRatioActivePortion)_WordAt4.GetBits(8, 5); } /// @@ -206,7 +220,7 @@ namespace NvAPIWrapper.Native.Display.Structures /// public InfoFrameVideoAspectRatioCodedFrame PictureAspectRatio { - get => (InfoFrameVideoAspectRatioCodedFrame) _WordAt4.GetBits(13, 3); + get => (InfoFrameVideoAspectRatioCodedFrame)_WordAt4.GetBits(13, 3); } /// @@ -214,7 +228,7 @@ namespace NvAPIWrapper.Native.Display.Structures /// public InfoFrameVideoNonUniformPictureScaling NonUniformPictureScaling { - get => (InfoFrameVideoNonUniformPictureScaling) _WordAt4.GetBits(16, 3); + get => (InfoFrameVideoNonUniformPictureScaling)_WordAt4.GetBits(16, 3); } /// @@ -222,7 +236,7 @@ namespace NvAPIWrapper.Native.Display.Structures /// public InfoFrameVideoBarData BarInfo { - get => (InfoFrameVideoBarData) _WordAt4.GetBits(19, 3); + get => (InfoFrameVideoBarData)_WordAt4.GetBits(19, 3); } /// @@ -244,7 +258,7 @@ namespace NvAPIWrapper.Native.Display.Structures return null; } - return (uint) val; + return (uint)val; } } @@ -267,7 +281,7 @@ namespace NvAPIWrapper.Native.Display.Structures return null; } - return (uint) val; + return (uint)val; } } @@ -290,7 +304,7 @@ namespace NvAPIWrapper.Native.Display.Structures return null; } - return (uint) val; + return (uint)val; } } @@ -313,7 +327,7 @@ namespace NvAPIWrapper.Native.Display.Structures return null; } - return (uint) val; + return (uint)val; } } } diff --git a/Shared/Shared.csproj b/Shared/Shared.csproj new file mode 100644 index 0000000..55212c1 --- /dev/null +++ b/Shared/Shared.csproj @@ -0,0 +1,20 @@ + + + + net7.0-windows10.0.20348.0 + enable + enable + true + + + + + + + + + Never + + + + diff --git a/ColorControl/Themes/DarkTheme.xaml b/Shared/Themes/DarkTheme.xaml similarity index 100% rename from ColorControl/Themes/DarkTheme.xaml rename to Shared/Themes/DarkTheme.xaml diff --git a/Shared/XForms/BaseWindow.xaml.cs b/Shared/XForms/BaseWindow.xaml.cs new file mode 100644 index 0000000..23a1af1 --- /dev/null +++ b/Shared/XForms/BaseWindow.xaml.cs @@ -0,0 +1,45 @@ +using System.Windows; + +namespace ColorControl.Shared.XForms +{ + public partial class BaseWindow : Window + { + public BaseWindow() : base() + { + } + + //protected void InitThemeAfterShow() + //{ + // var useDarkTheme = DarkModeUtils.UseDarkMode; + + // var handle = new WindowInteropHelper(this).Handle; + + // var value = useDarkTheme ? 1 : 0; + + // // Takes care of title bar + // WinApi.DwmSetWindowAttribute(handle, DarkModeUtils.DWMWA_USE_IMMERSIVE_DARK_MODE, ref value, 4); + //} + + //protected void InitTheme() + //{ + // if (DarkModeUtils.UseDarkMode) + // { + // var dict = new ResourceDictionary { Source = new Uri($"pack://application:,,,/Shared;component/Themes/DarkTheme.xaml", UriKind.Absolute) }; + + // if (Application.Current.Resources.MergedDictionaries.Any()) + // { + // Application.Current.Resources.MergedDictionaries[0] = dict; + // } + // else + // { + // Application.Current.Resources.MergedDictionaries.Add(dict); + // } + // } + // else + // { + // Application.Current.Resources.MergedDictionaries.Clear(); + // } + //} + + } +} \ No newline at end of file diff --git a/novideo_srgb/AboutWindow.xaml b/novideo_srgb/AboutWindow.xaml index b91f4c3..226c157 100644 --- a/novideo_srgb/AboutWindow.xaml +++ b/novideo_srgb/AboutWindow.xaml @@ -1,4 +1,4 @@ - @@ -19,4 +20,4 @@ https://github.com/ledoge/novideo_srgb - \ No newline at end of file + \ No newline at end of file diff --git a/novideo_srgb/AboutWindow.xaml.cs b/novideo_srgb/AboutWindow.xaml.cs index f3143e5..5f48ab9 100644 --- a/novideo_srgb/AboutWindow.xaml.cs +++ b/novideo_srgb/AboutWindow.xaml.cs @@ -1,9 +1,9 @@ -using System.Windows; +using ColorControl.Shared.XForms; using System.Windows.Navigation; namespace novideo_srgb { - public partial class AboutWindow : Window + public partial class AboutWindow : BaseWindow { public AboutWindow() { diff --git a/novideo_srgb/AdvancedWindow.xaml b/novideo_srgb/AdvancedWindow.xaml index b9ddd1d..73719a1 100644 --- a/novideo_srgb/AdvancedWindow.xaml +++ b/novideo_srgb/AdvancedWindow.xaml @@ -1,4 +1,4 @@ - @@ -163,4 +164,4 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/novideo_srgb/AdvancedWindow.xaml.cs b/novideo_srgb/AdvancedWindow.xaml.cs index cbad16e..ecfd34d 100644 --- a/novideo_srgb/AdvancedWindow.xaml.cs +++ b/novideo_srgb/AdvancedWindow.xaml.cs @@ -1,8 +1,9 @@ -using System.Windows; +using ColorControl.Shared.XForms; +using System.Windows; namespace novideo_srgb { - public partial class AdvancedWindow + public partial class AdvancedWindow : BaseWindow { private AdvancedViewModel _viewModel; diff --git a/novideo_srgb/MainWindow.xaml b/novideo_srgb/MainWindow.xaml index d200f80..16bd232 100644 --- a/novideo_srgb/MainWindow.xaml +++ b/novideo_srgb/MainWindow.xaml @@ -1,4 +1,4 @@ - @@ -70,4 +72,4 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/novideo_srgb/MainWindow.xaml.cs b/novideo_srgb/MainWindow.xaml.cs index 412788c..3a771c1 100644 --- a/novideo_srgb/MainWindow.xaml.cs +++ b/novideo_srgb/MainWindow.xaml.cs @@ -1,10 +1,11 @@ -using Microsoft.Win32; +using ColorControl.Shared.XForms; +using Microsoft.Win32; using System.ComponentModel; using System.Windows; namespace novideo_srgb { - public partial class MainWindow + public partial class MainWindow : BaseWindow { private readonly MainViewModel _viewModel; diff --git a/novideo_srgb/novideo_srgb.csproj b/novideo_srgb/novideo_srgb.csproj index cf283ca..ecde4dd 100644 --- a/novideo_srgb/novideo_srgb.csproj +++ b/novideo_srgb/novideo_srgb.csproj @@ -25,6 +25,7 @@ +