fix bug when no Nvidia hardware is found

This commit is contained in:
Vincent Maas committed 2020-11-22 17:39:03 +01:00
1 parent d00595fb2e
commit aa371d739e
6 files changed
+40 -21

No files matched your search

+1 -1
View File
@@ -27,7 +27,7 @@
<ProductName>ColorControl</ProductName>
<PublisherName>Maassoft</PublisherName>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.3.1.0</ApplicationVersion>
<ApplicationVersion>1.3.2.0</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
+12 -16
View File
@@ -86,30 +86,26 @@ namespace ColorControl
File.WriteAllText(_configFilename, json);
}
public void RefreshDevices(Action callBack = null)
public async Task RefreshDevices(bool connect = true)
{
Utils.GetPnpDevices(LgDeviceSearchKey).ContinueWith((task) =>
var devices = await Utils.GetPnpDevices(LgDeviceSearchKey);
SetDevices(devices);
if (connect && SelectedDevice != null)
{
SetDevicesTask(task);
callBack?.Invoke();
if (callBack == null && SelectedDevice != null)
if (Config.PowerOnAfterStartup && _allowPowerOn)
{
if (Config.PowerOnAfterStartup && _allowPowerOn)
{
WakeAndConnectToSelectedDevice(0);
}
else
{
ConnectToSelectedDevice();
}
WakeAndConnectToSelectedDevice(0);
}
else
{
ConnectToSelectedDevice();
}
}
);
}
private void SetDevicesTask(Task<List<PnpDev>> task)
private void SetDevices(List<PnpDev> devices)
{
Devices = task.Result;
Devices = devices;
if (Devices?.Count > 0)
{
var preferredDevice = Devices.FirstOrDefault(x => x.MacAddress != null && x.MacAddress.Equals(Config.PreferredMacAddress)) ?? Devices[0];
+1 -1
View File
@@ -1419,7 +1419,7 @@ namespace ColorControl
var devices = _lgService.Devices;
if (devices == null || !devices.Any())
{
_lgService.RefreshDevices(() => BeginInvoke(new Action(FillLgDevices)));
_lgService.RefreshDevices(false).ContinueWith((task) => BeginInvoke(new Action(FillLgDevices)));
}
else
{
+6 -1
View File
@@ -38,6 +38,7 @@ namespace ColorControl
};
private Display _currentDisplay;
private bool _initialized = false;
public NvService()
{
@@ -193,11 +194,15 @@ namespace ColorControl
protected override void Initialize()
{
NVIDIA.Initialize();
_initialized = true;
}
protected override void Uninitialize()
{
NVIDIA.Unload();
if (_initialized)
{
NVIDIA.Unload();
}
}
}
}
+18
View File
@@ -12,6 +12,12 @@ namespace ColorControl
[STAThread]
static void Main(string[] args)
{
var currentDomain = AppDomain.CurrentDomain;
// Handler for unhandled exceptions.
currentDomain.UnhandledException += GlobalUnhandledExceptionHandler;
// Handler for exceptions in threads behind forms.
Application.ThreadException += GlobalThreadExceptionHandler;
var startUpParams = StartUpParams.Parse(args);
if (startUpParams.ActivateChromeFontFix || startUpParams.DeactivateChromeFontFix)
@@ -51,5 +57,17 @@ namespace ColorControl
}
}
}
private static void GlobalUnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs e)
{
var ex = (Exception)e.ExceptionObject;
MessageBox.Show("Unhandled exception: " + ex.ToLogString(Environment.StackTrace), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
private static void GlobalThreadExceptionHandler(object sender, System.Threading.ThreadExceptionEventArgs e)
{
var ex = e.Exception;
MessageBox.Show("Exception in thread: " + ex.ToLogString(Environment.StackTrace), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
+2 -2
View File
@@ -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.3.1.0")]
[assembly: AssemblyFileVersion("1.3.1.0")]
[assembly: AssemblyVersion("1.3.2.0")]
[assembly: AssemblyFileVersion("1.3.2.0")]