using System;
namespace RGB.NET.Core
{
public partial class RGBSurface
{
#region EventHandler
///
/// Represents the event-handler of the -event.
///
/// The arguments provided by the event.
public delegate void ExceptionEventHandler(ExceptionEventArgs args);
///
/// Represents the event-handler of the -event.
///
/// The arguments provided by the event.
public delegate void UpdatingEventHandler(UpdatingEventArgs args);
///
/// Represents the event-handler of the -event.
///
/// The arguments provided by the event.
public delegate void UpdatedEventHandler(UpdatedEventArgs args);
///
/// Represents the event-handler of the -event.
///
///
public delegate void SurfaceLayoutChangedEventHandler(SurfaceLayoutChangedEventArgs args);
#endregion
#region Events
// ReSharper disable EventNeverSubscribedTo.Global
///
/// Occurs when a catched exception is thrown inside the .
///
public event ExceptionEventHandler Exception;
///
/// Occurs when the starts updating.
///
public event UpdatingEventHandler Updating;
///
/// Occurs when the update is done.
///
public event UpdatedEventHandler Updated;
///
/// Occurs when the layout of this changed.
///
public event SurfaceLayoutChangedEventHandler SurfaceLayoutChanged;
// ReSharper restore EventNeverSubscribedTo.Global
#endregion
#region Methods
///
/// Handles the needed event-calls for an exception.
///
/// The exception previously thrown.
private void OnException(Exception ex)
{
try
{
Exception?.Invoke(new ExceptionEventArgs(ex));
}
catch { /* Well ... that's not my fault */ }
}
///
/// Handles the needed event-calls before updating.
///
private void OnUpdating(IUpdateTrigger trigger, CustomUpdateData customData)
{
try
{
double deltaTime = _deltaTimeCounter.Elapsed.TotalSeconds;
_deltaTimeCounter.Restart();
Updating?.Invoke(new UpdatingEventArgs(deltaTime, trigger, customData));
}
catch { /* Well ... that's not my fault */ }
}
///
/// Handles the needed event-calls after an update.
///
private void OnUpdated()
{
try
{
Updated?.Invoke(new UpdatedEventArgs());
}
catch { /* Well ... that's not my fault */ }
}
#endregion
}
}