mirror of
https://github.com/Maassoft/ColorControl.git
synced 2026-10-22 08:32:18 -05:00
fix bug when no Nvidia hardware is found
This commit is contained in:
1 parent
d00595fb2e
commit
aa371d739e
6 files changed
+40
-21
No files matched your search
@@ -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
@@ -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];
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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")]
|
||||
Reference in new issue
Block a user