mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2025-12-12 17:48:31 +00:00
Fixed some basic stuff and added images to devices
This commit is contained in:
parent
2678d3f56d
commit
2d42bd85fc
@ -20,10 +20,20 @@ namespace RGB.NET.Core
|
||||
/// <inheritdoc />
|
||||
public Size Size => new Size(InternalSize?.Width ?? 0, InternalSize?.Height ?? 0);
|
||||
|
||||
private Size _internalSize;
|
||||
/// <summary>
|
||||
/// Gets the <see cref="Size"/> of the whole <see cref="IRGBDevice"/>.
|
||||
/// </summary>
|
||||
protected abstract Size InternalSize { get; set; }
|
||||
protected Size InternalSize
|
||||
{
|
||||
get { return _internalSize; }
|
||||
set
|
||||
{
|
||||
// ReSharper disable once ExplicitCallerInfoArgument
|
||||
if (SetProperty(ref _internalSize, value))
|
||||
OnPropertyChanged(nameof(Size));
|
||||
}
|
||||
}
|
||||
|
||||
private Point _location = new Point();
|
||||
/// <inheritdoc />
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
namespace RGB.NET.Core
|
||||
using System;
|
||||
|
||||
namespace RGB.NET.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a generic information for a <see cref="IRGBDevice"/>
|
||||
@ -22,9 +24,10 @@
|
||||
/// </summary>
|
||||
string Model { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
/// <summary>
|
||||
/// Gets the URI of an image of the <see cref="IRGBDevice"/> or null if there is no image.
|
||||
/// </summary>
|
||||
Uri Image { get; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace RGB.NET.Core
|
||||
{
|
||||
@ -15,7 +16,7 @@ namespace RGB.NET.Core
|
||||
/// <summary>
|
||||
/// Gets the <see cref="IRGBDevice"/> that caused the change. Returns null if the change isn't caused by a <see cref="IRGBDevice"/>.
|
||||
/// </summary>
|
||||
public IRGBDevice Device { get; }
|
||||
public IEnumerable<IRGBDevice> Devices { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating if the event is caused by the addition of a new <see cref="IRGBDevice"/> to the <see cref="RGBSurface"/>.
|
||||
@ -34,12 +35,12 @@ namespace RGB.NET.Core
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SurfaceLayoutChangedEventArgs"/> class.
|
||||
/// </summary>
|
||||
/// <param name="device">The <see cref="IRGBDevice"/> that caused the change</param>
|
||||
/// <param name="devices">The <see cref="IRGBDevice"/> that caused the change.</param>
|
||||
/// <param name="deviceAdded">A value indicating if the event is caused by the addition of a new <see cref="IRGBDevice"/> to the <see cref="RGBSurface"/>.</param>
|
||||
/// <param name="deviceLocationChanged">A value indicating if the event is caused by a changed location of one of the devices on the <see cref="RGBSurface"/>.</param>
|
||||
public SurfaceLayoutChangedEventArgs(IRGBDevice device, bool deviceAdded, bool deviceLocationChanged)
|
||||
public SurfaceLayoutChangedEventArgs(IEnumerable<IRGBDevice> devices, bool deviceAdded, bool deviceLocationChanged)
|
||||
{
|
||||
this.Device = device;
|
||||
this.Devices = devices;
|
||||
this.DeviceAdded = deviceAdded;
|
||||
this.DeviceLocationChanged = deviceLocationChanged;
|
||||
}
|
||||
|
||||
@ -116,6 +116,8 @@ namespace RGB.NET.Core
|
||||
internal void Update()
|
||||
{
|
||||
_color = RequestedColor;
|
||||
// ReSharper disable once ExplicitCallerInfoArgument
|
||||
OnPropertyChanged(nameof(Color));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -126,6 +128,9 @@ namespace RGB.NET.Core
|
||||
_color = Color.Transparent;
|
||||
RequestedColor = Color.Transparent;
|
||||
IsLocked = false;
|
||||
|
||||
// ReSharper disable once ExplicitCallerInfoArgument
|
||||
OnPropertyChanged(nameof(Color));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using System.ComponentModel;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
|
||||
namespace RGB.NET.Core
|
||||
@ -16,7 +17,7 @@ namespace RGB.NET.Core
|
||||
{
|
||||
if (_deviceProvider.Contains(deviceProvider) || _deviceProvider.Any(x => x.GetType() == deviceProvider.GetType())) return;
|
||||
|
||||
IRGBDevice addedDevice = null;
|
||||
List<IRGBDevice> addedDevices = new List<IRGBDevice>();
|
||||
if (deviceProvider.IsInitialized || deviceProvider.Initialize())
|
||||
{
|
||||
_deviceProvider.Add(deviceProvider);
|
||||
@ -25,7 +26,7 @@ namespace RGB.NET.Core
|
||||
{
|
||||
if (_devices.Contains(device)) continue;
|
||||
|
||||
addedDevice = device;
|
||||
addedDevices.Add(device);
|
||||
|
||||
device.PropertyChanged += DeviceOnPropertyChanged;
|
||||
device.Location.PropertyChanged += DeviceLocationOnPropertyChanged;
|
||||
@ -33,10 +34,10 @@ namespace RGB.NET.Core
|
||||
}
|
||||
}
|
||||
|
||||
if (addedDevice != null)
|
||||
if (addedDevices.Any())
|
||||
{
|
||||
UpdateSurfaceRectangle();
|
||||
SurfaceLayoutChanged?.Invoke(new SurfaceLayoutChangedEventArgs(addedDevice, true, false));
|
||||
SurfaceLayoutChanged?.Invoke(new SurfaceLayoutChangedEventArgs(addedDevices, true, false));
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,8 +45,8 @@ namespace RGB.NET.Core
|
||||
{
|
||||
if (string.Equals(propertyChangedEventArgs.PropertyName, nameof(IRGBDevice.Location)))
|
||||
{
|
||||
SurfaceLayoutChanged?.Invoke(new SurfaceLayoutChangedEventArgs(sender as IRGBDevice, false, true));
|
||||
UpdateSurfaceRectangle();
|
||||
SurfaceLayoutChanged?.Invoke(new SurfaceLayoutChangedEventArgs(new[] { sender as IRGBDevice }, false, true));
|
||||
|
||||
((IRGBDevice)sender).Location.PropertyChanged += DeviceLocationOnPropertyChanged;
|
||||
}
|
||||
@ -53,8 +54,8 @@ namespace RGB.NET.Core
|
||||
|
||||
private static void DeviceLocationOnPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs)
|
||||
{
|
||||
SurfaceLayoutChanged?.Invoke(new SurfaceLayoutChangedEventArgs(sender as IRGBDevice, false, true));
|
||||
UpdateSurfaceRectangle();
|
||||
SurfaceLayoutChanged?.Invoke(new SurfaceLayoutChangedEventArgs(new[] { sender as IRGBDevice }, false, true));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -19,9 +19,6 @@ namespace RGB.NET.Devices.Corsair
|
||||
/// </summary>
|
||||
public override IRGBDeviceInfo DeviceInfo { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override Size InternalSize { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
@ -45,7 +42,7 @@ namespace RGB.NET.Devices.Corsair
|
||||
internal void Initialize()
|
||||
{
|
||||
InitializeLeds();
|
||||
|
||||
|
||||
Rectangle ledRectangle = new Rectangle(this.Select(x => x.LedRectangle));
|
||||
InternalSize = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
|
||||
}
|
||||
|
||||
@ -31,6 +31,9 @@ namespace RGB.NET.Devices.Corsair
|
||||
/// <inheritdoc />
|
||||
public string Model { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public Uri Image { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a flag that describes device capabilities. (<see cref="CorsairDeviceCaps" />)
|
||||
/// </summary>
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using RGB.NET.Devices.Corsair.Native;
|
||||
using System;
|
||||
using RGB.NET.Devices.Corsair.Native;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair
|
||||
{
|
||||
@ -16,7 +17,9 @@ namespace RGB.NET.Devices.Corsair
|
||||
/// <param name="nativeInfo">The native <see cref="_CorsairDeviceInfo" />-struct</param>
|
||||
internal CorsairHeadsetRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
|
||||
: base(deviceIndex, Core.RGBDeviceType.Headset, nativeInfo)
|
||||
{ }
|
||||
{
|
||||
Image = new Uri($"pack://application:,,,/RGB.NET.Devices.Corsair;component/Images/Headsets/{Model.Replace(" ", string.Empty).ToUpper()}.png", UriKind.Absolute);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using System;
|
||||
using RGB.NET.Devices.Corsair.Native;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair
|
||||
@ -36,6 +37,8 @@ namespace RGB.NET.Devices.Corsair
|
||||
{
|
||||
this.PhysicalLayout = (CorsairPhysicalKeyboardLayout)nativeInfo.physicalLayout;
|
||||
this.LogicalLayout = (CorsairLogicalKeyboardLayout)nativeInfo.logicalLayout;
|
||||
|
||||
Image = new Uri($"pack://application:,,,/RGB.NET.Devices.Corsair;component/Images/Keyboards/{Model.Replace(" ", string.Empty).ToUpper()}/{LogicalLayout.ToString().ToUpper()}.png", UriKind.Absolute);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using RGB.NET.Devices.Corsair.Native;
|
||||
using System;
|
||||
using RGB.NET.Devices.Corsair.Native;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair
|
||||
{
|
||||
@ -27,6 +28,8 @@ namespace RGB.NET.Devices.Corsair
|
||||
: base(deviceIndex, Core.RGBDeviceType.Mouse, nativeInfo)
|
||||
{
|
||||
this.PhysicalLayout = (CorsairPhysicalMouseLayout)nativeInfo.physicalLayout;
|
||||
|
||||
Image = new Uri($"pack://application:,,,/RGB.NET.Devices.Corsair;component/Images/Mice/{Model.Replace(" ", string.Empty).ToUpper()}.png", UriKind.Absolute);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using RGB.NET.Devices.Corsair.Native;
|
||||
using System;
|
||||
using RGB.NET.Devices.Corsair.Native;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair
|
||||
{
|
||||
@ -16,7 +17,9 @@ namespace RGB.NET.Devices.Corsair
|
||||
/// <param name="nativeInfo">The native <see cref="_CorsairDeviceInfo" />-struct</param>
|
||||
internal CorsairMousematRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
|
||||
: base(deviceIndex, Core.RGBDeviceType.Mousemat, nativeInfo)
|
||||
{ }
|
||||
{
|
||||
Image = new Uri($"pack://application:,,,/RGB.NET.Devices.Corsair;component/Images/Mousemat/{Model.Replace(" ", string.Empty).ToUpper()}.png", UriKind.Absolute);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@ -84,6 +84,12 @@
|
||||
<None Include="libs\x64\CUESDK_2015.dll" />
|
||||
<None Include="libs\x86\CUESDK_2015.dll" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Images\Headsets\" />
|
||||
<Folder Include="Images\Keyboards\" />
|
||||
<Folder Include="Images\Mice\" />
|
||||
<Folder Include="Images\Mousemat\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user