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;
|
||||
}
|
||||
|
||||
if (instanceType.Namespace == nameof(DesktopMagic))
|
||||
{
|
||||
MessageBox.Show("NO!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
Exit();
|
||||
return;
|
||||
}
|
||||
|
||||
LoadOptions(instance);
|
||||
|
||||
valueTimer = new System.Timers.Timer();
|
||||
@@ -254,18 +247,32 @@ namespace DesktopMagic
|
||||
System.Drawing.Color color = newBrush.Color;
|
||||
string font = MainWindow.GlobalFont;
|
||||
|
||||
try
|
||||
{
|
||||
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)
|
||||
{
|
||||
MainWindow.Logger.Log(ex.ToString(), "Plugin");
|
||||
MessageBox.Show("File execution error:\n" + ex, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
Exit();
|
||||
return;
|
||||
}
|
||||
|
||||
if (stop)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user