1
0
mirror of https://github.com/DarthAffe/CUE.NET.git synced 2025-12-12 16:58:29 +00:00

Added events in the update-process

This commit is contained in:
Darth Affe 2016-03-26 19:48:14 +01:00
parent a0a0132ca0
commit 6f2e77b797
6 changed files with 62 additions and 12 deletions

View File

@ -0,0 +1,24 @@
// ReSharper disable MemberCanBePrivate.Global
using System.Collections.Generic;
namespace CUE.NET.Devices.Generic.EventArgs
{
public class LedsUpdatedEventArgs : System.EventArgs
{
#region Properties & Fields
public IEnumerable<KeyValuePair<int, CorsairLed>> UpdatedLeds { get; private set; }
#endregion
#region Constructors
public LedsUpdatedEventArgs(IEnumerable<KeyValuePair<int, CorsairLed>> updatedLeds)
{
this.UpdatedLeds = new List<KeyValuePair<int, CorsairLed>>(updatedLeds); // Copy this - we don't want anyone to change the original led list.
}
#endregion
}
}

View File

@ -0,0 +1,24 @@
// ReSharper disable MemberCanBePrivate.Global
using System.Collections.Generic;
namespace CUE.NET.Devices.Generic.EventArgs
{
public class LedsUpdatingEventArgs : System.EventArgs
{
#region Properties & Fields
public ICollection<KeyValuePair<int, CorsairLed>> UpdatingLeds { get; private set; }
#endregion
#region Constructors
public LedsUpdatingEventArgs(ICollection<KeyValuePair<int, CorsairLed>> updatingLeds)
{
this.UpdatingLeds = updatingLeds; // No copy here - before the update changing this is ok.
}
#endregion
}
}

View File

@ -0,0 +1,5 @@
namespace CUE.NET.Devices.Generic.EventArgs
{
public class UpdatedEventArgs : System.EventArgs
{ }
}

View File

@ -0,0 +1,5 @@
namespace CUE.NET.Devices.Generic.EventArgs
{
public class UpdatingEventArgs : System.EventArgs
{ }
}

View File

@ -146,18 +146,9 @@ namespace CUE.NET.Devices.Keyboard
#region Update
/// <summary>
/// Updates all groups and effects and perform an update for all dirty keys, or all keys if flushLeds is set to true.
/// Updates all brushes on the keyboard and on groups.
/// </summary>
/// <param name="flushLeds">Specifies whether all keys (including clean ones) should be updated.</param>
public override void Update(bool flushLeds = false)
{
UpdateBrushes();
// Perform 'real' update
base.Update(flushLeds);
}
private void UpdateBrushes()
protected override void DeviceUpdate()
{
if (Brush != null)
ApplyBrush(this.ToList(), Brush);
@ -203,7 +194,7 @@ namespace CUE.NET.Devices.Keyboard
}
}
// ReSharper disable once CatchAllClause
catch (Exception ex) { ManageException(ex); }
catch (Exception ex) { OnException(ex); }
}
public IEnumerable<CorsairLed> GetLeds()

View File

@ -38,6 +38,7 @@
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />