1
0
mirror of https://github.com/DarthAffe/RGB.NET.git synced 2025-12-13 10:08:31 +00:00

Fixed wrong exception-handling

This commit is contained in:
Darth Affe 2017-03-26 20:22:42 +02:00
parent 993feabd47
commit 9617771368

View File

@ -70,23 +70,33 @@ namespace RGB.NET.Core
/// <param name="flushLeds">Specifies whether all <see cref="Led"/>, (including clean ones) should be updated.</param> /// <param name="flushLeds">Specifies whether all <see cref="Led"/>, (including clean ones) should be updated.</param>
public void Update(bool flushLeds = false) public void Update(bool flushLeds = false)
{ {
OnUpdating(); try
lock (_ledGroups)
{ {
// Update effects OnUpdating();
foreach (ILedGroup ledGroup in _ledGroups)
ledGroup.UpdateEffects();
// Render brushes lock (_ledGroups)
foreach (ILedGroup ledGroup in _ledGroups.OrderBy(x => x.ZIndex)) {
Render(ledGroup); // Update effects
foreach (ILedGroup ledGroup in _ledGroups)
try { ledGroup.UpdateEffects(); }
catch (Exception ex) { OnException(ex); }
// Render brushes
foreach (ILedGroup ledGroup in _ledGroups.OrderBy(x => x.ZIndex))
try { Render(ledGroup); }
catch (Exception ex) { OnException(ex); }
}
foreach (IRGBDevice device in Devices)
try { device.Update(flushLeds); }
catch (Exception ex) { OnException(ex); }
OnUpdated();
}
catch (Exception ex)
{
OnException(ex);
} }
foreach (IRGBDevice device in Devices)
device.Update(flushLeds);
OnUpdated();
} }
/// <summary> /// <summary>
@ -100,36 +110,28 @@ namespace RGB.NET.Core
if ((brush == null) || !brush.IsEnabled) return; if ((brush == null) || !brush.IsEnabled) return;
try switch (brush.BrushCalculationMode)
{ {
switch (brush.BrushCalculationMode) case BrushCalculationMode.Relative:
{ Rectangle brushRectangle = new Rectangle(leds.Select(x => GetDeviceLedLocation(x)));
case BrushCalculationMode.Relative: Point offset = new Point(-brushRectangle.Location.X, -brushRectangle.Location.Y);
Rectangle brushRectangle = new Rectangle(leds.Select(x => GetDeviceLedLocation(x))); brushRectangle.Location.X = 0;
Point offset = new Point(-brushRectangle.Location.X, -brushRectangle.Location.Y); brushRectangle.Location.Y = 0;
brushRectangle.Location.X = 0; brush.PerformRender(brushRectangle,
brushRectangle.Location.Y = 0; leds.Select(x => new BrushRenderTarget(x, GetDeviceLedLocation(x, offset))));
brush.PerformRender(brushRectangle, break;
leds.Select(x => new BrushRenderTarget(x, GetDeviceLedLocation(x, offset)))); case BrushCalculationMode.Absolute:
break; brush.PerformRender(SurfaceRectangle, leds.Select(x => new BrushRenderTarget(x, GetDeviceLedLocation(x))));
case BrushCalculationMode.Absolute: break;
brush.PerformRender(SurfaceRectangle, leds.Select(x => new BrushRenderTarget(x, GetDeviceLedLocation(x)))); default:
break; throw new ArgumentException();
default:
throw new ArgumentException();
}
brush.UpdateEffects();
brush.PerformFinalize();
foreach (KeyValuePair<BrushRenderTarget, Color> renders in brush.RenderedTargets)
renders.Key.Led.Color = renders.Value;
}
// ReSharper disable once CatchAllClause
catch (Exception ex)
{
OnException(ex);
} }
brush.UpdateEffects();
brush.PerformFinalize();
foreach (KeyValuePair<BrushRenderTarget, Color> renders in brush.RenderedTargets)
renders.Key.Led.Color = renders.Value;
} }
private Rectangle GetDeviceLedLocation(Led led, Point extraOffset = null) private Rectangle GetDeviceLedLocation(Led led, Point extraOffset = null)