mirror of
https://github.com/Maassoft/ColorControl.git
synced 2026-10-22 00:22:18 -05:00
improve checking on attached displays
This commit is contained in:
1 parent
d2aacbb8e0
commit
48b13b1c64
4 files changed
+46
-8
No files matched your search
@@ -27,7 +27,7 @@
|
||||
<ProductName>ColorControl</ProductName>
|
||||
<PublisherName>Maassoft</PublisherName>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.5.1.0</ApplicationVersion>
|
||||
<ApplicationVersion>1.5.2.0</ApplicationVersion>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<PublishWizardCompleted>true</PublishWizardCompleted>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
|
||||
@@ -1466,7 +1466,7 @@ namespace ColorControl
|
||||
{
|
||||
if (tcMain.SelectedTab == tabLG)
|
||||
{
|
||||
if (cbxLgDevices.Items.Count == 0)
|
||||
if (cbxLgDevices.Items.Count == 0 && _lgService != null)
|
||||
{
|
||||
var devices = _lgService.Devices;
|
||||
if (devices == null || !devices.Any())
|
||||
@@ -1694,11 +1694,11 @@ namespace ColorControl
|
||||
_config.DisplaySettingsDelay = (int)edtDelayDisplaySettings.Value;
|
||||
}
|
||||
|
||||
private void ApplyNvPreset(NvPreset preset)
|
||||
private bool ApplyNvPreset(NvPreset preset)
|
||||
{
|
||||
if (preset == null || _nvService == null)
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
try
|
||||
{
|
||||
@@ -1709,10 +1709,12 @@ namespace ColorControl
|
||||
}
|
||||
|
||||
UpdateDisplayInfoItems();
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageForms.ErrorOk($"Error applying NVIDIA-preset ({e.TargetSite.Name}): {e.Message}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2030,6 +2032,10 @@ Do you want to continue?";
|
||||
|
||||
private void AfterInitialized()
|
||||
{
|
||||
ApplyNvPresetOnStartup();
|
||||
}
|
||||
|
||||
private void ApplyNvPresetOnStartup(int attempts = 5) {
|
||||
if (_config.NvPresetId_ApplyOnStartup != 0)
|
||||
{
|
||||
var preset = _presets.FirstOrDefault(p => p.id == _config.NvPresetId_ApplyOnStartup);
|
||||
@@ -2037,9 +2043,24 @@ Do you want to continue?";
|
||||
{
|
||||
_config.NvPresetId_ApplyOnStartup = 0;
|
||||
}
|
||||
else
|
||||
else if (_nvService != null)
|
||||
{
|
||||
ApplyNvPreset(preset);
|
||||
if (_nvService.HasDisplaysAttached())
|
||||
{
|
||||
ApplyNvPreset(preset);
|
||||
}
|
||||
else
|
||||
{
|
||||
attempts--;
|
||||
if (attempts > 0)
|
||||
{
|
||||
System.Threading.Tasks.Task.Run(async () =>
|
||||
{
|
||||
await System.Threading.Tasks.Task.Delay(2000);
|
||||
BeginInvoke(new Action(() => ApplyNvPresetOnStartup(attempts)));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,6 +81,18 @@ namespace ColorControl
|
||||
return _currentDisplay;
|
||||
}
|
||||
|
||||
public bool HasDisplaysAttached()
|
||||
{
|
||||
try
|
||||
{
|
||||
return DisplayDevice.GetGDIPrimaryDisplayDevice() != null;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetCurrentDisplay(NvPreset preset)
|
||||
{
|
||||
if (preset.primaryDisplay)
|
||||
@@ -99,6 +111,11 @@ namespace ColorControl
|
||||
{
|
||||
var result = true;
|
||||
|
||||
if (!HasDisplaysAttached())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
SetCurrentDisplay(preset);
|
||||
|
||||
var hdrEnabled = IsHDREnabled();
|
||||
|
||||
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.5.1.0")]
|
||||
[assembly: AssemblyFileVersion("1.5.1.0")]
|
||||
[assembly: AssemblyVersion("1.5.2.0")]
|
||||
[assembly: AssemblyFileVersion("1.5.2.0")]
|
||||
Reference in new issue
Block a user