mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2025-12-13 01:58:30 +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 />
|
/// <inheritdoc />
|
||||||
public Size Size => new Size(InternalSize?.Width ?? 0, InternalSize?.Height ?? 0);
|
public Size Size => new Size(InternalSize?.Width ?? 0, InternalSize?.Height ?? 0);
|
||||||
|
|
||||||
|
private Size _internalSize;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the <see cref="Size"/> of the whole <see cref="IRGBDevice"/>.
|
/// Gets the <see cref="Size"/> of the whole <see cref="IRGBDevice"/>.
|
||||||
/// </summary>
|
/// </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();
|
private Point _location = new Point();
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
namespace RGB.NET.Core
|
using System;
|
||||||
|
|
||||||
|
namespace RGB.NET.Core
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a generic information for a <see cref="IRGBDevice"/>
|
/// Represents a generic information for a <see cref="IRGBDevice"/>
|
||||||
@ -22,9 +24,10 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
string Model { get; }
|
string Model { get; }
|
||||||
|
|
||||||
#endregion
|
/// <summary>
|
||||||
|
/// Gets the URI of an image of the <see cref="IRGBDevice"/> or null if there is no image.
|
||||||
#region Methods
|
/// </summary>
|
||||||
|
Uri Image { get; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace RGB.NET.Core
|
namespace RGB.NET.Core
|
||||||
{
|
{
|
||||||
@ -15,7 +16,7 @@ namespace RGB.NET.Core
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the <see cref="IRGBDevice"/> that caused the change. Returns null if the change isn't caused by a <see cref="IRGBDevice"/>.
|
/// Gets the <see cref="IRGBDevice"/> that caused the change. Returns null if the change isn't caused by a <see cref="IRGBDevice"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IRGBDevice Device { get; }
|
public IEnumerable<IRGBDevice> Devices { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating if the event is caused by the addition of a new <see cref="IRGBDevice"/> to the <see cref="RGBSurface"/>.
|
/// 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>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="SurfaceLayoutChangedEventArgs"/> class.
|
/// Initializes a new instance of the <see cref="SurfaceLayoutChangedEventArgs"/> class.
|
||||||
/// </summary>
|
/// </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="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>
|
/// <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.DeviceAdded = deviceAdded;
|
||||||
this.DeviceLocationChanged = deviceLocationChanged;
|
this.DeviceLocationChanged = deviceLocationChanged;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -116,6 +116,8 @@ namespace RGB.NET.Core
|
|||||||
internal void Update()
|
internal void Update()
|
||||||
{
|
{
|
||||||
_color = RequestedColor;
|
_color = RequestedColor;
|
||||||
|
// ReSharper disable once ExplicitCallerInfoArgument
|
||||||
|
OnPropertyChanged(nameof(Color));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -126,6 +128,9 @@ namespace RGB.NET.Core
|
|||||||
_color = Color.Transparent;
|
_color = Color.Transparent;
|
||||||
RequestedColor = Color.Transparent;
|
RequestedColor = Color.Transparent;
|
||||||
IsLocked = false;
|
IsLocked = false;
|
||||||
|
|
||||||
|
// ReSharper disable once ExplicitCallerInfoArgument
|
||||||
|
OnPropertyChanged(nameof(Color));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using System.ComponentModel;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace RGB.NET.Core
|
namespace RGB.NET.Core
|
||||||
@ -16,7 +17,7 @@ namespace RGB.NET.Core
|
|||||||
{
|
{
|
||||||
if (_deviceProvider.Contains(deviceProvider) || _deviceProvider.Any(x => x.GetType() == deviceProvider.GetType())) return;
|
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())
|
if (deviceProvider.IsInitialized || deviceProvider.Initialize())
|
||||||
{
|
{
|
||||||
_deviceProvider.Add(deviceProvider);
|
_deviceProvider.Add(deviceProvider);
|
||||||
@ -25,7 +26,7 @@ namespace RGB.NET.Core
|
|||||||
{
|
{
|
||||||
if (_devices.Contains(device)) continue;
|
if (_devices.Contains(device)) continue;
|
||||||
|
|
||||||
addedDevice = device;
|
addedDevices.Add(device);
|
||||||
|
|
||||||
device.PropertyChanged += DeviceOnPropertyChanged;
|
device.PropertyChanged += DeviceOnPropertyChanged;
|
||||||
device.Location.PropertyChanged += DeviceLocationOnPropertyChanged;
|
device.Location.PropertyChanged += DeviceLocationOnPropertyChanged;
|
||||||
@ -33,10 +34,10 @@ namespace RGB.NET.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addedDevice != null)
|
if (addedDevices.Any())
|
||||||
{
|
{
|
||||||
UpdateSurfaceRectangle();
|
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)))
|
if (string.Equals(propertyChangedEventArgs.PropertyName, nameof(IRGBDevice.Location)))
|
||||||
{
|
{
|
||||||
SurfaceLayoutChanged?.Invoke(new SurfaceLayoutChangedEventArgs(sender as IRGBDevice, false, true));
|
|
||||||
UpdateSurfaceRectangle();
|
UpdateSurfaceRectangle();
|
||||||
|
SurfaceLayoutChanged?.Invoke(new SurfaceLayoutChangedEventArgs(new[] { sender as IRGBDevice }, false, true));
|
||||||
|
|
||||||
((IRGBDevice)sender).Location.PropertyChanged += DeviceLocationOnPropertyChanged;
|
((IRGBDevice)sender).Location.PropertyChanged += DeviceLocationOnPropertyChanged;
|
||||||
}
|
}
|
||||||
@ -53,8 +54,8 @@ namespace RGB.NET.Core
|
|||||||
|
|
||||||
private static void DeviceLocationOnPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs)
|
private static void DeviceLocationOnPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs)
|
||||||
{
|
{
|
||||||
SurfaceLayoutChanged?.Invoke(new SurfaceLayoutChangedEventArgs(sender as IRGBDevice, false, true));
|
|
||||||
UpdateSurfaceRectangle();
|
UpdateSurfaceRectangle();
|
||||||
|
SurfaceLayoutChanged?.Invoke(new SurfaceLayoutChangedEventArgs(new[] { sender as IRGBDevice }, false, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -19,9 +19,6 @@ namespace RGB.NET.Devices.Corsair
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public override IRGBDeviceInfo DeviceInfo { get; }
|
public override IRGBDeviceInfo DeviceInfo { get; }
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override Size InternalSize { get; set; }
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
|
|||||||
@ -31,6 +31,9 @@ namespace RGB.NET.Devices.Corsair
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public string Model { get; }
|
public string Model { get; }
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public Uri Image { get; protected set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a flag that describes device capabilities. (<see cref="CorsairDeviceCaps" />)
|
/// Gets a flag that describes device capabilities. (<see cref="CorsairDeviceCaps" />)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using RGB.NET.Devices.Corsair.Native;
|
using System;
|
||||||
|
using RGB.NET.Devices.Corsair.Native;
|
||||||
|
|
||||||
namespace RGB.NET.Devices.Corsair
|
namespace RGB.NET.Devices.Corsair
|
||||||
{
|
{
|
||||||
@ -16,7 +17,9 @@ namespace RGB.NET.Devices.Corsair
|
|||||||
/// <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.RGBDeviceType.Headset, 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
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
// ReSharper disable MemberCanBePrivate.Global
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
// ReSharper disable UnusedMember.Global
|
// ReSharper disable UnusedMember.Global
|
||||||
|
|
||||||
|
using System;
|
||||||
using RGB.NET.Devices.Corsair.Native;
|
using RGB.NET.Devices.Corsair.Native;
|
||||||
|
|
||||||
namespace RGB.NET.Devices.Corsair
|
namespace RGB.NET.Devices.Corsair
|
||||||
@ -36,6 +37,8 @@ namespace RGB.NET.Devices.Corsair
|
|||||||
{
|
{
|
||||||
this.PhysicalLayout = (CorsairPhysicalKeyboardLayout)nativeInfo.physicalLayout;
|
this.PhysicalLayout = (CorsairPhysicalKeyboardLayout)nativeInfo.physicalLayout;
|
||||||
this.LogicalLayout = (CorsairLogicalKeyboardLayout)nativeInfo.logicalLayout;
|
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
|
#endregion
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using RGB.NET.Devices.Corsair.Native;
|
using System;
|
||||||
|
using RGB.NET.Devices.Corsair.Native;
|
||||||
|
|
||||||
namespace RGB.NET.Devices.Corsair
|
namespace RGB.NET.Devices.Corsair
|
||||||
{
|
{
|
||||||
@ -27,6 +28,8 @@ namespace RGB.NET.Devices.Corsair
|
|||||||
: base(deviceIndex, Core.RGBDeviceType.Mouse, nativeInfo)
|
: base(deviceIndex, Core.RGBDeviceType.Mouse, nativeInfo)
|
||||||
{
|
{
|
||||||
this.PhysicalLayout = (CorsairPhysicalMouseLayout)nativeInfo.physicalLayout;
|
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
|
#endregion
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using RGB.NET.Devices.Corsair.Native;
|
using System;
|
||||||
|
using RGB.NET.Devices.Corsair.Native;
|
||||||
|
|
||||||
namespace RGB.NET.Devices.Corsair
|
namespace RGB.NET.Devices.Corsair
|
||||||
{
|
{
|
||||||
@ -16,7 +17,9 @@ namespace RGB.NET.Devices.Corsair
|
|||||||
/// <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.RGBDeviceType.Mousemat, 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
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
@ -84,6 +84,12 @@
|
|||||||
<None Include="libs\x64\CUESDK_2015.dll" />
|
<None Include="libs\x64\CUESDK_2015.dll" />
|
||||||
<None Include="libs\x86\CUESDK_2015.dll" />
|
<None Include="libs\x86\CUESDK_2015.dll" />
|
||||||
</ItemGroup>
|
</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" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- 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.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user