mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2025-12-12 17:48:31 +00:00
Somehow finished the really basic stuff
This commit is contained in:
parent
5cbcbd9d9c
commit
c8dac3905d
@ -1,4 +1,7 @@
|
|||||||
using System.Collections;
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
// ReSharper disable UnusedMember.Global
|
||||||
|
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
@ -7,7 +10,7 @@ namespace RGB.NET.Core
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a generic RGB-device
|
/// Represents a generic RGB-device
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class AbstractRGBDevice : IRGBDevice
|
public abstract class AbstractRGBDevice : AbstractBindable, IRGBDevice
|
||||||
{
|
{
|
||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|
||||||
@ -15,7 +18,20 @@ namespace RGB.NET.Core
|
|||||||
public abstract IRGBDeviceInfo DeviceInfo { get; }
|
public abstract IRGBDeviceInfo DeviceInfo { get; }
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public abstract Rectangle DeviceRectangle { get; }
|
public Size Size => new Size(InternalSize?.Width ?? 0, InternalSize?.Height ?? 0);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the <see cref="Size"/> of the whole <see cref="IRGBDevice"/>.
|
||||||
|
/// </summary>
|
||||||
|
protected abstract Size InternalSize { get; set; }
|
||||||
|
|
||||||
|
private Point _location = new Point();
|
||||||
|
/// <inheritdoc />
|
||||||
|
public Point Location
|
||||||
|
{
|
||||||
|
get { return _location; }
|
||||||
|
set { SetProperty(ref _location, value ?? new Point()); }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a dictionary containing all <see cref="Led"/> of the <see cref="IRGBDevice"/>.
|
/// Gets a dictionary containing all <see cref="Led"/> of the <see cref="IRGBDevice"/>.
|
||||||
@ -39,8 +55,7 @@ namespace RGB.NET.Core
|
|||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
IEnumerable<Led> IRGBDevice.this[Rectangle referenceRect, double minOverlayPercentage]
|
IEnumerable<Led> IRGBDevice.this[Rectangle referenceRect, double minOverlayPercentage]
|
||||||
=> LedMapping.Values.Where(x => referenceRect.CalculateIntersectPercentage(x.LedRectangle) >= minOverlayPercentage)
|
=> LedMapping.Values.Where(x => referenceRect.CalculateIntersectPercentage(x.LedRectangle) >= minOverlayPercentage);
|
||||||
;
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@ namespace RGB.NET.Core
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a generic RGB-device
|
/// Represents a generic RGB-device
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IRGBDevice : IEnumerable<Led>
|
public interface IRGBDevice : IEnumerable<Led>, IBindable
|
||||||
{
|
{
|
||||||
#region Properties
|
#region Properties
|
||||||
|
|
||||||
@ -15,9 +15,14 @@ namespace RGB.NET.Core
|
|||||||
IRGBDeviceInfo DeviceInfo { get; }
|
IRGBDeviceInfo DeviceInfo { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the <see cref="Rectangle"/> representing the whole <see cref="IRGBDevice"/>.
|
/// Gets or sets the location of the <see cref="IRGBDevice"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Rectangle DeviceRectangle { get; }
|
Point Location { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a copy of the <see cref="Size"/> of the whole <see cref="IRGBDevice"/>.
|
||||||
|
/// </summary>
|
||||||
|
Size Size { get; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -48,7 +53,7 @@ namespace RGB.NET.Core
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Perform an update for all dirty <see cref="Led"/>, or all <see cref="Led"/> if flushLeds is set to true.
|
/// Perform an update for all dirty <see cref="Led"/>, or all <see cref="Led"/> if flushLeds is set to true.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -8,9 +8,9 @@
|
|||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the <see cref="Core.DeviceType"/> of the <see cref="IRGBDevice"/>.
|
/// Gets the <see cref="RGBDeviceType"/> of the <see cref="IRGBDevice"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
DeviceType DeviceType { get; }
|
RGBDeviceType DeviceType { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the manufacturer-name of the <see cref="IRGBDevice"/>.
|
/// Gets the manufacturer-name of the <see cref="IRGBDevice"/>.
|
||||||
|
|||||||
@ -5,7 +5,7 @@ namespace RGB.NET.Core
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a generic device provider.
|
/// Represents a generic device provider.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IDeviceProvider
|
public interface IRGBDeviceProvider
|
||||||
{
|
{
|
||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ namespace RGB.NET.Core
|
|||||||
bool IsInitialized { get; }
|
bool IsInitialized { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a list of <see cref="IRGBDevice"/> loaded by this <see cref="IDeviceProvider"/>.
|
/// Gets a list of <see cref="IRGBDevice"/> loaded by this <see cref="IRGBDeviceProvider"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
IEnumerable<IRGBDevice> Devices { get; }
|
IEnumerable<IRGBDevice> Devices { get; }
|
||||||
|
|
||||||
@ -27,9 +27,9 @@ namespace RGB.NET.Core
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes the <see cref="IDeviceProvider"/> if not already happened or reloads it if it is already initialized.
|
/// Initializes the <see cref="IRGBDeviceProvider"/> if not already happened or reloads it if it is already initialized.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="exclusiveAccessIfPossible">Specifies whether the application should request exclusive access of possible or not.</param>
|
/// <param name="exclusiveAccessIfPossible">Specifies whether the application should request exclusive access of possible or not.</param>
|
||||||
/// <param name="throwExceptions">Specifies whether exception during the initialization sequence should be thrown or not.</param>
|
/// <param name="throwExceptions">Specifies whether exception during the initialization sequence should be thrown or not.</param>
|
||||||
@ -3,7 +3,7 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Contains list of different types of device.
|
/// Contains list of different types of device.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public enum DeviceType
|
public enum RGBDeviceType
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a device where the type is not known or not present in the list.
|
/// Represents a device where the type is not known or not present in the list.
|
||||||
@ -6,7 +6,7 @@ using System;
|
|||||||
namespace RGB.NET.Core
|
namespace RGB.NET.Core
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents the information supplied with an <see cref="IRGBSurface.Exception"/>-event.
|
/// Represents the information supplied with an <see cref="RGBSurface.Exception"/>-event.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ExceptionEventArgs : EventArgs
|
public class ExceptionEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
namespace RGB.NET.Core
|
namespace RGB.NET.Core
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents the information supplied with an <see cref="IRGBSurface.Updated"/>-event.
|
/// Represents the information supplied with an <see cref="RGBSurface.Updated"/>-event.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class UpdatedEventArgs : EventArgs
|
public class UpdatedEventArgs : EventArgs
|
||||||
{ }
|
{ }
|
||||||
|
|||||||
@ -6,7 +6,7 @@ using System;
|
|||||||
namespace RGB.NET.Core
|
namespace RGB.NET.Core
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents the information supplied with an <see cref="IRGBSurface.Updating"/>-event.
|
/// Represents the information supplied with an <see cref="RGBSurface.Updating"/>-event.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class UpdatingEventArgs : EventArgs
|
public class UpdatingEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
|
|||||||
@ -6,7 +6,7 @@ namespace RGB.NET.Core
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a basic bindable class which notifies when a property value changes.
|
/// Represents a basic bindable class which notifies when a property value changes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class AbstractBindable : INotifyPropertyChanged
|
public abstract class AbstractBindable : IBindable
|
||||||
{
|
{
|
||||||
#region Events
|
#region Events
|
||||||
|
|
||||||
|
|||||||
11
RGB.NET.Core/MVVM/IBindable.cs
Normal file
11
RGB.NET.Core/MVVM/IBindable.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace RGB.NET.Core
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a basic bindable class which notifies when a property value changes.
|
||||||
|
/// </summary>
|
||||||
|
public interface IBindable : INotifyPropertyChanged
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -105,20 +105,26 @@ namespace RGB.NET.Core
|
|||||||
/// <param name="rectangles">The list of <see cref="Rectangle"/> used to calculate the <see cref="Location"/> and <see cref="Size"/></param>
|
/// <param name="rectangles">The list of <see cref="Rectangle"/> used to calculate the <see cref="Location"/> and <see cref="Size"/></param>
|
||||||
public Rectangle(IEnumerable<Rectangle> rectangles)
|
public Rectangle(IEnumerable<Rectangle> rectangles)
|
||||||
{
|
{
|
||||||
|
bool hasPoint = false;
|
||||||
double posX = double.MaxValue;
|
double posX = double.MaxValue;
|
||||||
double posY = double.MaxValue;
|
double posY = double.MaxValue;
|
||||||
double posX2 = double.MinValue;
|
double posX2 = double.MinValue;
|
||||||
double posY2 = double.MinValue;
|
double posY2 = double.MinValue;
|
||||||
|
|
||||||
foreach (Rectangle rectangle in rectangles)
|
if (rectangles != null)
|
||||||
{
|
foreach (Rectangle rectangle in rectangles)
|
||||||
posX = Math.Min(posX, rectangle.Location.X);
|
{
|
||||||
posY = Math.Min(posY, rectangle.Location.Y);
|
hasPoint = true;
|
||||||
posX2 = Math.Max(posX2, rectangle.Location.X + rectangle.Size.Width);
|
posX = Math.Min(posX, rectangle.Location.X);
|
||||||
posY2 = Math.Max(posY2, rectangle.Location.Y + rectangle.Size.Height);
|
posY = Math.Min(posY, rectangle.Location.Y);
|
||||||
}
|
posX2 = Math.Max(posX2, rectangle.Location.X + rectangle.Size.Width);
|
||||||
|
posY2 = Math.Max(posY2, rectangle.Location.Y + rectangle.Size.Height);
|
||||||
|
}
|
||||||
|
|
||||||
InitializeFromPoints(new Point(posX, posY), new Point(posX2, posY2));
|
if (hasPoint)
|
||||||
|
InitializeFromPoints(new Point(posX, posY), new Point(posX2, posY2));
|
||||||
|
else
|
||||||
|
InitializeFromPoints(new Point(0, 0), new Point(0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -138,20 +144,26 @@ namespace RGB.NET.Core
|
|||||||
public Rectangle(IEnumerable<Point> points)
|
public Rectangle(IEnumerable<Point> points)
|
||||||
: this()
|
: this()
|
||||||
{
|
{
|
||||||
|
bool hasPoint = false;
|
||||||
double posX = double.MaxValue;
|
double posX = double.MaxValue;
|
||||||
double posY = double.MaxValue;
|
double posY = double.MaxValue;
|
||||||
double posX2 = double.MinValue;
|
double posX2 = double.MinValue;
|
||||||
double posY2 = double.MinValue;
|
double posY2 = double.MinValue;
|
||||||
|
|
||||||
foreach (Point point in points)
|
if (points != null)
|
||||||
|
foreach (Point point in points)
|
||||||
{
|
{
|
||||||
|
hasPoint = true;
|
||||||
posX = Math.Min(posX, point.X);
|
posX = Math.Min(posX, point.X);
|
||||||
posY = Math.Min(posY, point.Y);
|
posY = Math.Min(posY, point.Y);
|
||||||
posX2 = Math.Max(posX2, point.X);
|
posX2 = Math.Max(posX2, point.X);
|
||||||
posY2 = Math.Max(posY2, point.Y);
|
posY2 = Math.Max(posY2, point.Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
InitializeFromPoints(new Point(posX, posY), new Point(posX2, posY2));
|
if (hasPoint)
|
||||||
|
InitializeFromPoints(new Point(posX, posY), new Point(posX2, posY2));
|
||||||
|
else
|
||||||
|
InitializeFromPoints(new Point(0, 0), new Point(0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -47,8 +47,8 @@
|
|||||||
<Compile Include="Brushes\IBrush.cs" />
|
<Compile Include="Brushes\IBrush.cs" />
|
||||||
<Compile Include="ColorCorrection\IColorCorrection.cs" />
|
<Compile Include="ColorCorrection\IColorCorrection.cs" />
|
||||||
<Compile Include="Devices\AbstractRGBDevice.cs" />
|
<Compile Include="Devices\AbstractRGBDevice.cs" />
|
||||||
<Compile Include="Devices\DeviceType.cs" />
|
<Compile Include="Devices\RGBDeviceType.cs" />
|
||||||
<Compile Include="Devices\IDeviceProvider.cs" />
|
<Compile Include="Devices\IRGBDeviceProvider.cs" />
|
||||||
<Compile Include="Devices\IRGBDeviceInfo.cs" />
|
<Compile Include="Devices\IRGBDeviceInfo.cs" />
|
||||||
<Compile Include="Effects\AbstractEffectTarget.cs" />
|
<Compile Include="Effects\AbstractEffectTarget.cs" />
|
||||||
<Compile Include="Effects\EffectTimeContainer.cs" />
|
<Compile Include="Effects\EffectTimeContainer.cs" />
|
||||||
@ -62,17 +62,19 @@
|
|||||||
<Compile Include="Groups\AbstractLedGroup.cs" />
|
<Compile Include="Groups\AbstractLedGroup.cs" />
|
||||||
<Compile Include="Groups\ILedGroup.cs" />
|
<Compile Include="Groups\ILedGroup.cs" />
|
||||||
<Compile Include="Leds\ILedId.cs" />
|
<Compile Include="Leds\ILedId.cs" />
|
||||||
<Compile Include="Surfaces\IRGBSurface.cs" />
|
|
||||||
<Compile Include="MVVM\AbstractBindable.cs" />
|
<Compile Include="MVVM\AbstractBindable.cs" />
|
||||||
<Compile Include="Leds\Color.cs" />
|
<Compile Include="Leds\Color.cs" />
|
||||||
<Compile Include="Extensions\DoubleExtensions.cs" />
|
<Compile Include="Extensions\DoubleExtensions.cs" />
|
||||||
<Compile Include="Devices\IRGBDevice.cs" />
|
<Compile Include="Devices\IRGBDevice.cs" />
|
||||||
<Compile Include="Leds\Led.cs" />
|
<Compile Include="Leds\Led.cs" />
|
||||||
|
<Compile Include="MVVM\IBindable.cs" />
|
||||||
<Compile Include="Positioning\Point.cs" />
|
<Compile Include="Positioning\Point.cs" />
|
||||||
<Compile Include="Positioning\Size.cs" />
|
<Compile Include="Positioning\Size.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Positioning\Rectangle.cs" />
|
<Compile Include="Positioning\Rectangle.cs" />
|
||||||
<Compile Include="Surfaces\RGBSurface.cs" />
|
<Compile Include="RGBSurface.cs" />
|
||||||
|
<Compile Include="RGBSurfaceDeviceEvents.cs" />
|
||||||
|
<Compile Include="RGBSurfaceDeviceLoader.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup />
|
<ItemGroup />
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
|||||||
@ -1,42 +1,42 @@
|
|||||||
using System;
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
// ReSharper disable UnusedMember.Global
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace RGB.NET.Core
|
namespace RGB.NET.Core
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a generic RGB-surface.
|
/// Represents a RGB-surface containing multiple devices.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class RGBSurface : AbstractLedGroup, IRGBSurface
|
public static partial class RGBSurface
|
||||||
{
|
{
|
||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|
||||||
private DateTime _lastUpdate;
|
private static DateTime _lastUpdate;
|
||||||
|
|
||||||
/// <inheritdoc />
|
private static IList<IRGBDeviceProvider> _deviceProvider = new List<IRGBDeviceProvider>();
|
||||||
public Dictionary<IRGBDevice, Point> Devices { get; } = new Dictionary<IRGBDevice, Point>();
|
private static IList<IRGBDevice> _devices = new List<IRGBDevice>();
|
||||||
|
|
||||||
|
// ReSharper disable InconsistentNaming
|
||||||
|
|
||||||
private readonly LinkedList<ILedGroup> _ledGroups = new LinkedList<ILedGroup>();
|
private static readonly LinkedList<ILedGroup> _ledGroups = new LinkedList<ILedGroup>();
|
||||||
|
|
||||||
/// <inheritdoc />
|
private static readonly Rectangle _surfaceRectangle = new Rectangle();
|
||||||
public Rectangle SurfaceRectangle => new Rectangle(Devices.Select(x => x.Key.DeviceRectangle));
|
|
||||||
|
|
||||||
#endregion
|
// ReSharper restore InconsistentNaming
|
||||||
|
|
||||||
#region Events
|
/// <summary>
|
||||||
|
/// Gets a readonly list containing all loaded <see cref="IRGBDevice"/>.
|
||||||
|
/// </summary>
|
||||||
|
public static IEnumerable<IRGBDevice> Devices => new ReadOnlyCollection<IRGBDevice>(_devices);
|
||||||
|
|
||||||
// ReSharper disable EventNeverSubscribedTo.Global
|
/// <summary>
|
||||||
|
/// Gets a copy of the <see cref="Rectangle"/> representing this <see cref="RGBSurface"/>.
|
||||||
/// <inheritdoc />
|
/// </summary>
|
||||||
public event ExceptionEventHandler Exception;
|
public static Rectangle SurfaceRectangle => new Rectangle(_surfaceRectangle);
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public event UpdatingEventHandler Updating;
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public event UpdatedEventHandler Updated;
|
|
||||||
|
|
||||||
// ReSharper restore EventNeverSubscribedTo.Global
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ namespace RGB.NET.Core
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="RGBSurface"/> class.
|
/// Initializes a new instance of the <see cref="RGBSurface"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public RGBSurface()
|
static RGBSurface()
|
||||||
{
|
{
|
||||||
_lastUpdate = DateTime.Now;
|
_lastUpdate = DateTime.Now;
|
||||||
}
|
}
|
||||||
@ -54,8 +54,11 @@ namespace RGB.NET.Core
|
|||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <summary>
|
||||||
public void Update(bool flushLeds = false)
|
/// Perform an update for all dirty <see cref="Led"/>, or all <see cref="Led"/>, if flushLeds is set to true.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="flushLeds">Specifies whether all <see cref="Led"/>, (including clean ones) should be updated.</param>
|
||||||
|
public static void Update(bool flushLeds = false)
|
||||||
{
|
{
|
||||||
OnUpdating();
|
OnUpdating();
|
||||||
|
|
||||||
@ -66,12 +69,11 @@ namespace RGB.NET.Core
|
|||||||
ledGroup.UpdateEffects();
|
ledGroup.UpdateEffects();
|
||||||
|
|
||||||
// Render brushes
|
// Render brushes
|
||||||
Render(this);
|
|
||||||
foreach (ILedGroup ledGroup in _ledGroups.OrderBy(x => x.ZIndex))
|
foreach (ILedGroup ledGroup in _ledGroups.OrderBy(x => x.ZIndex))
|
||||||
Render(ledGroup);
|
Render(ledGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (IRGBDevice device in Devices.Keys)
|
foreach (IRGBDevice device in Devices)
|
||||||
device.Update(flushLeds);
|
device.Update(flushLeds);
|
||||||
|
|
||||||
OnUpdated();
|
OnUpdated();
|
||||||
@ -81,7 +83,7 @@ namespace RGB.NET.Core
|
|||||||
/// Renders a ledgroup.
|
/// Renders a ledgroup.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ledGroup">The led group to render.</param>
|
/// <param name="ledGroup">The led group to render.</param>
|
||||||
private void Render(ILedGroup ledGroup)
|
private static void Render(ILedGroup ledGroup)
|
||||||
{
|
{
|
||||||
IList<Led> leds = ledGroup.GetLeds().ToList();
|
IList<Led> leds = ledGroup.GetLeds().ToList();
|
||||||
IBrush brush = ledGroup.Brush;
|
IBrush brush = ledGroup.Brush;
|
||||||
@ -118,24 +120,11 @@ namespace RGB.NET.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Rectangle GetDeviceLedLocation(Led led, Point extraOffset = null)
|
private static Rectangle GetDeviceLedLocation(Led led, Point extraOffset = null)
|
||||||
{
|
{
|
||||||
Point deviceLocation;
|
|
||||||
if (!Devices.TryGetValue(led.Device, out deviceLocation))
|
|
||||||
deviceLocation = new Point();
|
|
||||||
|
|
||||||
return extraOffset != null
|
return extraOffset != null
|
||||||
? new Rectangle(led.LedRectangle.Location + deviceLocation + extraOffset, led.LedRectangle.Size)
|
? new Rectangle(led.LedRectangle.Location + led.Device.Location + extraOffset, led.LedRectangle.Size)
|
||||||
: new Rectangle(led.LedRectangle.Location + deviceLocation, led.LedRectangle.Size);
|
: new Rectangle(led.LedRectangle.Location + led.Device.Location, led.LedRectangle.Size);
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public void PositionDevice(IRGBDevice device, Point location)
|
|
||||||
{
|
|
||||||
if (device == null) return;
|
|
||||||
|
|
||||||
lock (Devices)
|
|
||||||
Devices[device] = location ?? new Point();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -143,9 +132,8 @@ namespace RGB.NET.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ledGroup">The <see cref="ILedGroup"/> to attach.</param>
|
/// <param name="ledGroup">The <see cref="ILedGroup"/> to attach.</param>
|
||||||
/// <returns><c>true</c> if the <see cref="ILedGroup"/> could be attached; otherwise, <c>false</c>.</returns>
|
/// <returns><c>true</c> if the <see cref="ILedGroup"/> could be attached; otherwise, <c>false</c>.</returns>
|
||||||
public bool AttachLedGroup(ILedGroup ledGroup)
|
public static bool AttachLedGroup(ILedGroup ledGroup)
|
||||||
{
|
{
|
||||||
if (ledGroup is IRGBSurface) return false;
|
|
||||||
if (ledGroup == null) return false;
|
if (ledGroup == null) return false;
|
||||||
|
|
||||||
lock (_ledGroups)
|
lock (_ledGroups)
|
||||||
@ -162,9 +150,8 @@ namespace RGB.NET.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ledGroup">The <see cref="ILedGroup"/> to detached.</param>
|
/// <param name="ledGroup">The <see cref="ILedGroup"/> to detached.</param>
|
||||||
/// <returns><c>true</c> if the <see cref="ILedGroup"/> could be detached; otherwise, <c>false</c>.</returns>
|
/// <returns><c>true</c> if the <see cref="ILedGroup"/> could be detached; otherwise, <c>false</c>.</returns>
|
||||||
public bool DetachLedGroup(ILedGroup ledGroup)
|
public static bool DetachLedGroup(ILedGroup ledGroup)
|
||||||
{
|
{
|
||||||
if (ledGroup is IRGBSurface) return false;
|
|
||||||
if (ledGroup == null) return false;
|
if (ledGroup == null) return false;
|
||||||
|
|
||||||
lock (_ledGroups)
|
lock (_ledGroups)
|
||||||
@ -177,64 +164,14 @@ namespace RGB.NET.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
private static void UpdateSurfaceRectangle()
|
||||||
public override IEnumerable<Led> GetLeds()
|
|
||||||
{
|
{
|
||||||
return Devices.SelectMany(d => d.Key);
|
Rectangle devicesRectangle = new Rectangle(_devices.Select(d => new Rectangle(d.Location, d.Size)));
|
||||||
|
|
||||||
|
_surfaceRectangle.Size.Width = devicesRectangle.Location.X + devicesRectangle.Size.Width;
|
||||||
|
_surfaceRectangle.Size.Height = devicesRectangle.Location.Y + devicesRectangle.Size.Height;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region EventCaller
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Handles the needed event-calls for an exception.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="ex">The exception previously thrown.</param>
|
|
||||||
protected virtual void OnException(Exception ex)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Exception?.Invoke(this, new ExceptionEventArgs(ex));
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
// Well ... that's not my fault
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Handles the needed event-calls before updating.
|
|
||||||
/// </summary>
|
|
||||||
protected virtual void OnUpdating()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
long lastUpdateTicks = _lastUpdate.Ticks;
|
|
||||||
_lastUpdate = DateTime.Now;
|
|
||||||
Updating?.Invoke(this, new UpdatingEventArgs((DateTime.Now.Ticks - lastUpdateTicks) / 10000000.0));
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
// Well ... that's not my fault
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Handles the needed event-calls after an update.
|
|
||||||
/// </summary>
|
|
||||||
protected virtual void OnUpdated()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Updated?.Invoke(this, new UpdatedEventArgs());
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
// Well ... that's not my fault
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
95
RGB.NET.Core/RGBSurfaceDeviceEvents.cs
Normal file
95
RGB.NET.Core/RGBSurfaceDeviceEvents.cs
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace RGB.NET.Core
|
||||||
|
{
|
||||||
|
public static partial class RGBSurface
|
||||||
|
{
|
||||||
|
#region EventHandler
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents the event-handler of the <see cref="RGBSurface.Exception"/>-event.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="args">The arguments provided by the event.</param>
|
||||||
|
public delegate void ExceptionEventHandler(ExceptionEventArgs args);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents the event-handler of the <see cref="RGBSurface.Updating"/>-event.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="args">The arguments provided by the event.</param>
|
||||||
|
public delegate void UpdatingEventHandler(UpdatingEventArgs args);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents the event-handler of the <see cref="RGBSurface.Updated"/>-event.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="args">The arguments provided by the event.</param>
|
||||||
|
public delegate void UpdatedEventHandler(UpdatedEventArgs args);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Events
|
||||||
|
|
||||||
|
// ReSharper disable EventNeverSubscribedTo.Global
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Occurs when a catched exception is thrown inside the <see cref="RGBSurface"/>.
|
||||||
|
/// </summary>
|
||||||
|
public static event ExceptionEventHandler Exception;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Occurs when the <see cref="RGBSurface"/> starts updating.
|
||||||
|
/// </summary>
|
||||||
|
public static event UpdatingEventHandler Updating;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Occurs when the <see cref="RGBSurface"/> update is done.
|
||||||
|
/// </summary>
|
||||||
|
public static event UpdatedEventHandler Updated;
|
||||||
|
|
||||||
|
// ReSharper restore EventNeverSubscribedTo.Global
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handles the needed event-calls for an exception.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ex">The exception previously thrown.</param>
|
||||||
|
private static void OnException(Exception ex)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Exception?.Invoke(new ExceptionEventArgs(ex));
|
||||||
|
}
|
||||||
|
catch { /* Well ... that's not my fault */ }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handles the needed event-calls before updating.
|
||||||
|
/// </summary>
|
||||||
|
private static void OnUpdating()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
long lastUpdateTicks = _lastUpdate.Ticks;
|
||||||
|
_lastUpdate = DateTime.Now;
|
||||||
|
Updating?.Invoke(new UpdatingEventArgs((DateTime.Now.Ticks - lastUpdateTicks) / 10000000.0));
|
||||||
|
}
|
||||||
|
catch { /* Well ... that's not my fault */ }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handles the needed event-calls after an update.
|
||||||
|
/// </summary>
|
||||||
|
private static void OnUpdated()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Updated?.Invoke(new UpdatedEventArgs());
|
||||||
|
}
|
||||||
|
catch { /* Well ... that's not my fault */ }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
43
RGB.NET.Core/RGBSurfaceDeviceLoader.cs
Normal file
43
RGB.NET.Core/RGBSurfaceDeviceLoader.cs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace RGB.NET.Core
|
||||||
|
{
|
||||||
|
public static partial class RGBSurface
|
||||||
|
{
|
||||||
|
#region Methods
|
||||||
|
|
||||||
|
// ReSharper disable once UnusedMember.Global
|
||||||
|
/// <summary>
|
||||||
|
/// Loads all devices the given <see cref="IRGBDeviceProvider"/> is able to provide.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="deviceProvider"></param>
|
||||||
|
public static void LoadDevices(IRGBDeviceProvider deviceProvider)
|
||||||
|
{
|
||||||
|
if (_deviceProvider.Contains(deviceProvider) || _deviceProvider.Any(x => x.GetType() == deviceProvider.GetType())) return;
|
||||||
|
|
||||||
|
if (deviceProvider.IsInitialized || deviceProvider.Initialize())
|
||||||
|
{
|
||||||
|
_deviceProvider.Add(deviceProvider);
|
||||||
|
|
||||||
|
foreach (IRGBDevice device in deviceProvider.Devices)
|
||||||
|
{
|
||||||
|
if (_devices.Contains(device)) continue;
|
||||||
|
|
||||||
|
device.PropertyChanged += DeviceOnPropertyChanged;
|
||||||
|
_devices.Add(device);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateSurfaceRectangle();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void DeviceOnPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs)
|
||||||
|
{
|
||||||
|
if (string.Equals(propertyChangedEventArgs.PropertyName, nameof(IRGBDevice.Location)))
|
||||||
|
UpdateSurfaceRectangle();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,104 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace RGB.NET.Core
|
|
||||||
{
|
|
||||||
|
|
||||||
#region EventHandler
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represents the event-handler of the <see cref="IRGBSurface.Exception"/>-event.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender">The sender of the event.</param>
|
|
||||||
/// <param name="args">The arguments provided by the event.</param>
|
|
||||||
public delegate void ExceptionEventHandler(object sender, ExceptionEventArgs args);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represents the event-handler of the <see cref="IRGBSurface.Updating"/>-event.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender">The sender of the event.</param>
|
|
||||||
/// <param name="args">The arguments provided by the event.</param>
|
|
||||||
public delegate void UpdatingEventHandler(object sender, UpdatingEventArgs args);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represents the event-handler of the <see cref="IRGBSurface.Updated"/>-event.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender">The sender of the event.</param>
|
|
||||||
/// <param name="args">The arguments provided by the event.</param>
|
|
||||||
public delegate void UpdatedEventHandler(object sender, UpdatedEventArgs args);
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a generic RGB-surface.
|
|
||||||
/// </summary>
|
|
||||||
public interface IRGBSurface : ILedGroup
|
|
||||||
{
|
|
||||||
#region Properties & Fields
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets a dictionary containing the locations of all <see cref="IRGBDevice"/> positioned on this <see cref="IRGBSurface"/>.
|
|
||||||
/// </summary>
|
|
||||||
Dictionary<IRGBDevice, Point> Devices { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets a copy of the <see cref="Rectangle"/> representing this <see cref="IRGBSurface"/>.
|
|
||||||
/// </summary>
|
|
||||||
Rectangle SurfaceRectangle { get; }
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Methods
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Perform an update for all dirty <see cref="Led"/>, or all <see cref="Led"/>, if flushLeds is set to true.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="flushLeds">Specifies whether all <see cref="Led"/>, (including clean ones) should be updated.</param>
|
|
||||||
void Update(bool flushLeds = false);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sets the location of the given <see cref="IRGBDevice"/> to the given <see cref="Point"/>.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="device">The <see cref="IRGBDevice"/> to move.</param>
|
|
||||||
/// <param name="location">The target <see cref="PositionDevice"/>.</param>
|
|
||||||
void PositionDevice(IRGBDevice device, Point location);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Attaches the given <see cref="ILedGroup"/>.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="ledGroup">The <see cref="ILedGroup"/> to attach.</param>
|
|
||||||
/// <returns><c>true</c> if the <see cref="ILedGroup"/> could be attached; otherwise, <c>false</c>.</returns>
|
|
||||||
bool AttachLedGroup(ILedGroup ledGroup);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Detaches the given <see cref="ILedGroup"/>.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="ledGroup">The <see cref="ILedGroup"/> to detached.</param>
|
|
||||||
/// <returns><c>true</c> if the <see cref="ILedGroup"/> could be detached; otherwise, <c>false</c>.</returns>
|
|
||||||
bool DetachLedGroup(ILedGroup ledGroup);
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Events
|
|
||||||
|
|
||||||
// ReSharper disable EventNeverSubscribedTo.Global
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Occurs when a catched exception is thrown inside the <see cref="IRGBSurface"/>.
|
|
||||||
/// </summary>
|
|
||||||
event ExceptionEventHandler Exception;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Occurs when the <see cref="IRGBSurface"/> starts updating.
|
|
||||||
/// </summary>
|
|
||||||
event UpdatingEventHandler Updating;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Occurs when the <see cref="IRGBSurface"/> update is done.
|
|
||||||
/// </summary>
|
|
||||||
event UpdatedEventHandler Updated;
|
|
||||||
|
|
||||||
// ReSharper restore EventNeverSubscribedTo.Global
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,4 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
// ReSharper disable UnusedMember.Global
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using RGB.NET.Core;
|
using RGB.NET.Core;
|
||||||
@ -10,10 +13,15 @@ namespace RGB.NET.Devices.Corsair
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a device provider responsible for corsair (CUE) devices.
|
/// Represents a device provider responsible for corsair (CUE) devices.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class CorsairDeviceProvider : IDeviceProvider
|
public class CorsairDeviceProvider : IRGBDeviceProvider
|
||||||
{
|
{
|
||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the singleton <see cref="CorsairDeviceProvider"/> instance.
|
||||||
|
/// </summary>
|
||||||
|
public static CorsairDeviceProvider Instance { get; } = new CorsairDeviceProvider();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicates if the SDK is initialized and ready to use.
|
/// Indicates if the SDK is initialized and ready to use.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -44,6 +52,13 @@ namespace RGB.NET.Devices.Corsair
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Constructors
|
||||||
|
|
||||||
|
private CorsairDeviceProvider()
|
||||||
|
{ }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -109,7 +124,7 @@ namespace RGB.NET.Devices.Corsair
|
|||||||
{
|
{
|
||||||
_CorsairDeviceInfo nativeDeviceInfo =
|
_CorsairDeviceInfo nativeDeviceInfo =
|
||||||
(_CorsairDeviceInfo)Marshal.PtrToStructure(_CUESDK.CorsairGetDeviceInfo(i), typeof(_CorsairDeviceInfo));
|
(_CorsairDeviceInfo)Marshal.PtrToStructure(_CUESDK.CorsairGetDeviceInfo(i), typeof(_CorsairDeviceInfo));
|
||||||
CorsairRGBDeviceInfo info = new CorsairRGBDeviceInfo(i, DeviceType.Unknown, nativeDeviceInfo);
|
CorsairRGBDeviceInfo info = new CorsairRGBDeviceInfo(i, RGBDeviceType.Unknown, nativeDeviceInfo);
|
||||||
if (!info.CapsMask.HasFlag(CorsairDeviceCaps.Lighting))
|
if (!info.CapsMask.HasFlag(CorsairDeviceCaps.Lighting))
|
||||||
continue; // Everything that doesn't support lighting control is useless
|
continue; // Everything that doesn't support lighting control is useless
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@ namespace RGB.NET.Devices.Corsair
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a Id of a <see cref="Led"/> on a <see cref="CorsairRGBDevice"/>.
|
/// Represents a Id of a <see cref="Led"/> on a <see cref="CorsairRGBDevice"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DebuggerDisplay("{_ledId}")]
|
[DebuggerDisplay("{" + nameof(_ledId) + "}")]
|
||||||
public class CorsairLedId : ILedId
|
public class CorsairLedId : ILedId
|
||||||
{
|
{
|
||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|||||||
@ -15,9 +15,8 @@ namespace RGB.NET.Devices.Corsair
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public override IRGBDeviceInfo DeviceInfo { get; }
|
public override IRGBDeviceInfo DeviceInfo { get; }
|
||||||
|
|
||||||
private Rectangle _deviceRectangle;
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override Rectangle DeviceRectangle => _deviceRectangle;
|
protected override Size InternalSize { get; set; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -43,7 +42,8 @@ namespace RGB.NET.Devices.Corsair
|
|||||||
{
|
{
|
||||||
InitializeLeds();
|
InitializeLeds();
|
||||||
|
|
||||||
_deviceRectangle = new Rectangle(this.Select(x => x.LedRectangle));
|
Rectangle ledRectangle = new Rectangle(this.Select(x => x.LedRectangle));
|
||||||
|
InternalSize = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -23,7 +23,7 @@ namespace RGB.NET.Devices.Corsair
|
|||||||
public int CorsairDeviceIndex { get; }
|
public int CorsairDeviceIndex { get; }
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public DeviceType DeviceType { get; }
|
public RGBDeviceType DeviceType { get; }
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public string Manufacturer => "Corsair";
|
public string Manufacturer => "Corsair";
|
||||||
@ -46,7 +46,7 @@ namespace RGB.NET.Devices.Corsair
|
|||||||
/// <param name="deviceIndex">The index of the <see cref="CorsairRGBDevice"/>.</param>
|
/// <param name="deviceIndex">The index of the <see cref="CorsairRGBDevice"/>.</param>
|
||||||
/// <param name="deviceType">The type of the <see cref="IRGBDevice"/>.</param>
|
/// <param name="deviceType">The type of the <see cref="IRGBDevice"/>.</param>
|
||||||
/// <param name="nativeInfo">The native <see cref="_CorsairDeviceInfo" />-struct</param>
|
/// <param name="nativeInfo">The native <see cref="_CorsairDeviceInfo" />-struct</param>
|
||||||
internal CorsairRGBDeviceInfo(int deviceIndex, DeviceType deviceType, _CorsairDeviceInfo nativeInfo)
|
internal CorsairRGBDeviceInfo(int deviceIndex, RGBDeviceType deviceType, _CorsairDeviceInfo nativeInfo)
|
||||||
{
|
{
|
||||||
this.CorsairDeviceIndex = deviceIndex;
|
this.CorsairDeviceIndex = deviceIndex;
|
||||||
this.DeviceType = deviceType;
|
this.DeviceType = deviceType;
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
using RGB.NET.Core;
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
// ReSharper disable UnusedMember.Global
|
||||||
|
|
||||||
|
using RGB.NET.Core;
|
||||||
|
|
||||||
namespace RGB.NET.Devices.Corsair
|
namespace RGB.NET.Devices.Corsair
|
||||||
{
|
{
|
||||||
|
|||||||
@ -15,7 +15,7 @@ namespace RGB.NET.Devices.Corsair
|
|||||||
/// <param name="deviceIndex">The index of the <see cref="CorsairHeadsetRGBDevice"/>.</param>
|
/// <param name="deviceIndex">The index of the <see cref="CorsairHeadsetRGBDevice"/>.</param>
|
||||||
/// <param name="nativeInfo">The native <see cref="_CorsairDeviceInfo" />-struct</param>
|
/// <param name="nativeInfo">The native <see cref="_CorsairDeviceInfo" />-struct</param>
|
||||||
internal CorsairHeadsetRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
|
internal CorsairHeadsetRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
|
||||||
: base(deviceIndex, Core.DeviceType.Headset, nativeInfo)
|
: base(deviceIndex, Core.RGBDeviceType.Headset, nativeInfo)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
using System;
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
// ReSharper disable UnusedMember.Global
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using RGB.NET.Core;
|
using RGB.NET.Core;
|
||||||
using RGB.NET.Devices.Corsair.Native;
|
using RGB.NET.Devices.Corsair.Native;
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
using RGB.NET.Devices.Corsair.Native;
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
// ReSharper disable UnusedMember.Global
|
||||||
|
|
||||||
|
using RGB.NET.Devices.Corsair.Native;
|
||||||
|
|
||||||
namespace RGB.NET.Devices.Corsair
|
namespace RGB.NET.Devices.Corsair
|
||||||
{
|
{
|
||||||
@ -29,7 +32,7 @@ namespace RGB.NET.Devices.Corsair
|
|||||||
/// <param name="deviceIndex">The index of the <see cref="CorsairKeyboardRGBDevice"/>.</param>
|
/// <param name="deviceIndex">The index of the <see cref="CorsairKeyboardRGBDevice"/>.</param>
|
||||||
/// <param name="nativeInfo">The native <see cref="_CorsairDeviceInfo" />-struct</param>
|
/// <param name="nativeInfo">The native <see cref="_CorsairDeviceInfo" />-struct</param>
|
||||||
internal CorsairKeyboardRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
|
internal CorsairKeyboardRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
|
||||||
: base(deviceIndex, Core.DeviceType.Keyboard, nativeInfo)
|
: base(deviceIndex, Core.RGBDeviceType.Keyboard, nativeInfo)
|
||||||
{
|
{
|
||||||
this.PhysicalLayout = (CorsairPhysicalKeyboardLayout)nativeInfo.physicalLayout;
|
this.PhysicalLayout = (CorsairPhysicalKeyboardLayout)nativeInfo.physicalLayout;
|
||||||
this.LogicalLayout = (CorsairLogicalKeyboardLayout)nativeInfo.logicalLayout;
|
this.LogicalLayout = (CorsairLogicalKeyboardLayout)nativeInfo.logicalLayout;
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
using RGB.NET.Core;
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
// ReSharper disable UnusedMember.Global
|
||||||
|
|
||||||
|
using RGB.NET.Core;
|
||||||
using RGB.NET.Core.Exceptions;
|
using RGB.NET.Core.Exceptions;
|
||||||
|
|
||||||
namespace RGB.NET.Devices.Corsair
|
namespace RGB.NET.Devices.Corsair
|
||||||
|
|||||||
@ -24,7 +24,7 @@ namespace RGB.NET.Devices.Corsair
|
|||||||
/// <param name="deviceIndex">The index of the <see cref="CorsairMouseRGBDevice"/>.</param>
|
/// <param name="deviceIndex">The index of the <see cref="CorsairMouseRGBDevice"/>.</param>
|
||||||
/// <param name="nativeInfo">The native <see cref="_CorsairDeviceInfo" />-struct</param>
|
/// <param name="nativeInfo">The native <see cref="_CorsairDeviceInfo" />-struct</param>
|
||||||
internal CorsairMouseRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
|
internal CorsairMouseRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
|
||||||
: base(deviceIndex, Core.DeviceType.Mouse, nativeInfo)
|
: base(deviceIndex, Core.RGBDeviceType.Mouse, nativeInfo)
|
||||||
{
|
{
|
||||||
this.PhysicalLayout = (CorsairPhysicalMouseLayout)nativeInfo.physicalLayout;
|
this.PhysicalLayout = (CorsairPhysicalMouseLayout)nativeInfo.physicalLayout;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
using System;
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
// ReSharper disable UnusedMember.Global
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|||||||
@ -15,7 +15,7 @@ namespace RGB.NET.Devices.Corsair
|
|||||||
/// <param name="deviceIndex">The index if the <see cref="CorsairMousematRGBDevice"/>.</param>
|
/// <param name="deviceIndex">The index if the <see cref="CorsairMousematRGBDevice"/>.</param>
|
||||||
/// <param name="nativeInfo">The native <see cref="_CorsairDeviceInfo" />-struct</param>
|
/// <param name="nativeInfo">The native <see cref="_CorsairDeviceInfo" />-struct</param>
|
||||||
internal CorsairMousematRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
|
internal CorsairMousematRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
|
||||||
: base(deviceIndex, Core.DeviceType.Mousemat, nativeInfo)
|
: base(deviceIndex, Core.RGBDeviceType.Mousemat, nativeInfo)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user