mirror of
https://github.com/Stone-Red-Code/DesktopMagic.git
synced 2026-09-04 08:56:15 +02:00
Proper handling and logging of errors during the execution of a plugin
This commit is contained in:
@@ -191,13 +191,6 @@ namespace DesktopMagic
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (instanceType.Namespace == nameof(DesktopMagic))
|
|
||||||
{
|
|
||||||
MessageBox.Show("NO!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
|
||||||
Exit();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
LoadOptions(instance);
|
LoadOptions(instance);
|
||||||
|
|
||||||
valueTimer = new System.Timers.Timer();
|
valueTimer = new System.Timers.Timer();
|
||||||
@@ -254,18 +247,32 @@ namespace DesktopMagic
|
|||||||
System.Drawing.Color color = newBrush.Color;
|
System.Drawing.Color color = newBrush.Color;
|
||||||
string font = MainWindow.GlobalFont;
|
string font = MainWindow.GlobalFont;
|
||||||
|
|
||||||
Bitmap result = pluginClassInstance.Main();
|
try
|
||||||
|
|
||||||
if (pluginClassInstance.UpdateInterval > 0)
|
|
||||||
{
|
{
|
||||||
valueTimer.Interval = pluginClassInstance.UpdateInterval;
|
Bitmap result = pluginClassInstance.Main();
|
||||||
|
|
||||||
|
if (pluginClassInstance.UpdateInterval > 0)
|
||||||
|
{
|
||||||
|
valueTimer.Interval = pluginClassInstance.UpdateInterval;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
valueTimer.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Update Image
|
||||||
|
Dispatcher.Invoke(() =>
|
||||||
|
{
|
||||||
|
image.Source = BitmapToImageSource(result);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
//Update Image
|
|
||||||
Dispatcher.Invoke(() =>
|
|
||||||
{
|
{
|
||||||
image.Source = BitmapToImageSource(result);
|
MainWindow.Logger.Log(ex.ToString(), "Plugin");
|
||||||
});
|
MessageBox.Show("File execution error:\n" + ex, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
Exit();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (stop)
|
if (stop)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user