mirror of
https://github.com/DarthAffe/CUE.NET.git
synced 2025-12-13 09:08:34 +00:00
Compare commits
No commits in common. "master" and "1.1.0" have entirely different histories.
@ -5,7 +5,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using CUE.NET.ColorCorrection;
|
|
||||||
using CUE.NET.Devices.Generic;
|
using CUE.NET.Devices.Generic;
|
||||||
using CUE.NET.Devices.Keyboard.Enums;
|
using CUE.NET.Devices.Keyboard.Enums;
|
||||||
using CUE.NET.Effects;
|
using CUE.NET.Effects;
|
||||||
@ -35,11 +34,6 @@ namespace CUE.NET.Brushes
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public float Opacity { get; set; }
|
public float Opacity { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets a list of <see cref="IColorCorrection"/> used to correct the colors of the brush.
|
|
||||||
/// </summary>
|
|
||||||
public IList<IColorCorrection> ColorCorrections { get; } = new List<IColorCorrection>();
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the Rectangle used in the last render pass.
|
/// Gets the Rectangle used in the last render pass.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -85,7 +79,7 @@ namespace CUE.NET.Brushes
|
|||||||
RenderedTargets.Clear();
|
RenderedTargets.Clear();
|
||||||
|
|
||||||
foreach (BrushRenderTarget point in renderTargets)
|
foreach (BrushRenderTarget point in renderTargets)
|
||||||
RenderedTargets[point] = new CorsairColor(GetColorAtPoint(rectangle, point)); // Clone the color, we don't want to have reference issues here and brushes might return the same color multiple times!
|
RenderedTargets[point] = GetColorAtPoint(rectangle, point);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -95,7 +89,7 @@ namespace CUE.NET.Brushes
|
|||||||
{
|
{
|
||||||
List<BrushRenderTarget> renderTargets = RenderedTargets.Keys.ToList();
|
List<BrushRenderTarget> renderTargets = RenderedTargets.Keys.ToList();
|
||||||
foreach (BrushRenderTarget renderTarget in renderTargets)
|
foreach (BrushRenderTarget renderTarget in renderTargets)
|
||||||
RenderedTargets[renderTarget] = FinalizeColor(RenderedTargets[renderTarget]); // Cloning here again shouldn't be needed since we did this above.
|
RenderedTargets[renderTarget] = FinalizeColor(RenderedTargets[renderTarget]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -109,21 +103,16 @@ namespace CUE.NET.Brushes
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Finalizes the color by appliing the overall brightness and opacity.<br/>
|
/// Finalizes the color by appliing the overall brightness and opacity.<br/>
|
||||||
/// This method should always be the last call of a <see cref="GetColorAtPoint" /> implementation.
|
/// This method should always be the last call of a <see cref="GetColorAtPoint" /> implementation.
|
||||||
/// If you overwrite this method please make sure that you never return the same color-object twice to prevent reference-issues!
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="color">The color to finalize.</param>
|
/// <param name="color">The color to finalize.</param>
|
||||||
/// <returns>The finalized color.</returns>
|
/// <returns>The finalized color.</returns>
|
||||||
protected virtual CorsairColor FinalizeColor(CorsairColor color)
|
protected virtual CorsairColor FinalizeColor(CorsairColor color)
|
||||||
{
|
{
|
||||||
foreach (IColorCorrection colorCorrection in ColorCorrections)
|
|
||||||
colorCorrection.ApplyTo(color);
|
|
||||||
|
|
||||||
// Since we use HSV to calculate there is no way to make a color 'brighter' than 100%
|
// Since we use HSV to calculate there is no way to make a color 'brighter' than 100%
|
||||||
// Be carefull with the naming: Since we use HSV the correct term is 'value' but outside we call it 'brightness'
|
// Be carefull with the naming: Since we use HSV the correct term is 'value' but outside we call it 'brightness'
|
||||||
// THIS IS NOT A HSB CALCULATION!!!
|
// THIS IS NOT A HSB CALCULATION!!!
|
||||||
float finalBrightness = color.GetHSVValue() * (Brightness < 0 ? 0 : (Brightness > 1f ? 1f : Brightness));
|
float finalBrightness = color.GetHSVValue() * (Brightness < 0 ? 0 : (Brightness > 1f ? 1f : Brightness));
|
||||||
byte finalAlpha = (byte)(color.A * (Opacity < 0 ? 0 : (Opacity > 1f ? 1f : Opacity)));
|
byte finalAlpha = (byte)(color.A * (Opacity < 0 ? 0 : (Opacity > 1f ? 1f : Opacity)));
|
||||||
|
|
||||||
return ColorHelper.ColorFromHSV(color.GetHSVHue(), color.GetHSVSaturation(), finalBrightness, finalAlpha);
|
return ColorHelper.ColorFromHSV(color.GetHSVHue(), color.GetHSVSaturation(), finalBrightness, finalAlpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using CUE.NET.Devices.Generic.Enums;
|
using CUE.NET.Devices.Generic.Enums;
|
||||||
using CUE.NET.Helper;
|
|
||||||
|
|
||||||
namespace CUE.NET.Brushes
|
namespace CUE.NET.Brushes
|
||||||
{
|
{
|
||||||
@ -19,11 +18,6 @@ namespace CUE.NET.Brushes
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public CorsairLedId LedId { get; }
|
public CorsairLedId LedId { get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the rectangle representing the area to render the target-LED.
|
|
||||||
/// </summary>
|
|
||||||
public RectangleF Rectangle { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the point representing the position to render the target-LED.
|
/// Gets the point representing the position to render the target-LED.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -37,13 +31,11 @@ namespace CUE.NET.Brushes
|
|||||||
/// Initializes a new instance of the <see cref="BrushRenderTarget"/> class.
|
/// Initializes a new instance of the <see cref="BrushRenderTarget"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ledId">The ID of the target-LED.</param>
|
/// <param name="ledId">The ID of the target-LED.</param>
|
||||||
/// <param name="rectangle">The rectangle representing the area to render the target-LED.</param>
|
/// <param name="point">The point representing the position to render the target-LED.</param>
|
||||||
public BrushRenderTarget(CorsairLedId ledId, RectangleF rectangle)
|
public BrushRenderTarget(CorsairLedId ledId, PointF point)
|
||||||
{
|
{
|
||||||
this.Rectangle = rectangle;
|
this.Point = point;
|
||||||
this.LedId = ledId;
|
this.LedId = ledId;
|
||||||
|
|
||||||
Point = rectangle.GetCenter();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -1,103 +0,0 @@
|
|||||||
// ReSharper disable MemberCanBePrivate.Global
|
|
||||||
// ReSharper disable MemberCanBeProtected.Global
|
|
||||||
// ReSharper disable ReturnTypeCanBeEnumerable.Global
|
|
||||||
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global
|
|
||||||
// ReSharper disable UnusedMember.Global
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Drawing;
|
|
||||||
using CUE.NET.Devices.Generic;
|
|
||||||
using CUE.NET.Gradients;
|
|
||||||
|
|
||||||
namespace CUE.NET.Brushes
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a brush drawing a conical gradient.
|
|
||||||
/// </summary>
|
|
||||||
public class ConicalGradientBrush : AbstractBrush, IGradientBrush
|
|
||||||
{
|
|
||||||
#region Properties & Fields
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the origin (radian-angle) the brush is drawn to. (default: -π/2)
|
|
||||||
/// </summary>
|
|
||||||
public float Origin { get; set; } = (float)Math.Atan2(-1, 0);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the center point (as percentage in the range [0..1]) of the gradient drawn by the brush. (default: 0.5f, 0.5f)
|
|
||||||
/// </summary>
|
|
||||||
public PointF Center { get; set; } = new PointF(0.5f, 0.5f);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the gradient drawn by the brush. If null it will default to full transparent.
|
|
||||||
/// </summary>
|
|
||||||
public IGradient Gradient { get; set; }
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Constructors
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="ConicalGradientBrush"/> class.
|
|
||||||
/// </summary>
|
|
||||||
public ConicalGradientBrush()
|
|
||||||
{ }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="ConicalGradientBrush"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="gradient">The gradient drawn by the brush.</param>
|
|
||||||
public ConicalGradientBrush(IGradient gradient)
|
|
||||||
{
|
|
||||||
this.Gradient = gradient;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="ConicalGradientBrush"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="center">The center point (as percentage in the range [0..1]).</param>
|
|
||||||
/// <param name="gradient">The gradient drawn by the brush.</param>
|
|
||||||
public ConicalGradientBrush(PointF center, IGradient gradient)
|
|
||||||
{
|
|
||||||
this.Center = center;
|
|
||||||
this.Gradient = gradient;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="ConicalGradientBrush"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="center">The center point (as percentage in the range [0..1]).</param>
|
|
||||||
/// <param name="origin">The origin (radian-angle) the brush is drawn to.</param>
|
|
||||||
/// <param name="gradient">The gradient drawn by the brush.</param>
|
|
||||||
public ConicalGradientBrush(PointF center, float origin, IGradient gradient)
|
|
||||||
{
|
|
||||||
this.Center = center;
|
|
||||||
this.Origin = origin;
|
|
||||||
this.Gradient = gradient;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Methods
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the color at an specific point assuming the brush is drawn into the given rectangle.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="rectangle">The rectangle in which the brush should be drawn.</param>
|
|
||||||
/// <param name="renderTarget">The target (key/point) from which the color should be taken.</param>
|
|
||||||
/// <returns>The color at the specified point.</returns>
|
|
||||||
protected override CorsairColor GetColorAtPoint(RectangleF rectangle, BrushRenderTarget renderTarget)
|
|
||||||
{
|
|
||||||
float centerX = rectangle.Width * Center.X;
|
|
||||||
float centerY = rectangle.Height * Center.Y;
|
|
||||||
|
|
||||||
double angle = Math.Atan2(renderTarget.Point.Y - centerY, renderTarget.Point.X - centerX) - Origin;
|
|
||||||
if (angle < 0) angle += Math.PI * 2;
|
|
||||||
float offset = (float)(angle / (Math.PI * 2));
|
|
||||||
|
|
||||||
return Gradient.GetColor(offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,10 +1,8 @@
|
|||||||
// ReSharper disable UnusedMemberInSuper.Global
|
// ReSharper disable UnusedMemberInSuper.Global
|
||||||
// ReSharper disable UnusedMember.Global
|
// ReSharper disable UnusedMember.Global
|
||||||
// ReSharper disable ReturnTypeCanBeEnumerable.Global
|
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using CUE.NET.ColorCorrection;
|
|
||||||
using CUE.NET.Devices.Generic;
|
using CUE.NET.Devices.Generic;
|
||||||
using CUE.NET.Devices.Keyboard.Enums;
|
using CUE.NET.Devices.Keyboard.Enums;
|
||||||
using CUE.NET.Effects;
|
using CUE.NET.Effects;
|
||||||
@ -31,11 +29,6 @@ namespace CUE.NET.Brushes
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
float Opacity { get; set; }
|
float Opacity { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets a list of color-corrections used to correct the colors of the brush.
|
|
||||||
/// </summary>
|
|
||||||
IList<IColorCorrection> ColorCorrections { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the Rectangle used in the last render pass.
|
/// Gets the Rectangle used in the last render pass.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -2,14 +2,8 @@
|
|||||||
|
|
||||||
namespace CUE.NET.Brushes
|
namespace CUE.NET.Brushes
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Represents a basic gradient-brush.
|
|
||||||
/// </summary>
|
|
||||||
public interface IGradientBrush : IBrush
|
public interface IGradientBrush : IBrush
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Gets the gradient used by this <see cref="IGradientBrush"/>.
|
|
||||||
/// </summary>
|
|
||||||
IGradient Gradient { get; }
|
IGradient Gradient { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -50,37 +50,21 @@ namespace CUE.NET.Brushes
|
|||||||
|
|
||||||
#region Operators
|
#region Operators
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Converts a <see cref="Color" /> to a <see cref="SolidColorBrush" />.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="color">The <see cref="Color"/> to convert.</param>
|
|
||||||
public static explicit operator SolidColorBrush(Color color)
|
public static explicit operator SolidColorBrush(Color color)
|
||||||
{
|
{
|
||||||
return new SolidColorBrush(color);
|
return new SolidColorBrush(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Converts a <see cref="SolidColorBrush" /> to a <see cref="Color" />.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="brush">The <see cref="Color"/> to convert.</param>
|
|
||||||
public static implicit operator Color(SolidColorBrush brush)
|
public static implicit operator Color(SolidColorBrush brush)
|
||||||
{
|
{
|
||||||
return brush.Color;
|
return brush.Color;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Converts a <see cref="CorsairColor" /> to a <see cref="SolidColorBrush" />.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="color">The <see cref="Color"/> to convert.</param>
|
|
||||||
public static explicit operator SolidColorBrush(CorsairColor color)
|
public static explicit operator SolidColorBrush(CorsairColor color)
|
||||||
{
|
{
|
||||||
return new SolidColorBrush(color);
|
return new SolidColorBrush(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Converts a <see cref="SolidColorBrush" /> to a <see cref="CorsairColor" />.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="brush">The <see cref="Color"/> to convert.</param>
|
|
||||||
public static implicit operator CorsairColor(SolidColorBrush brush)
|
public static implicit operator CorsairColor(SolidColorBrush brush)
|
||||||
{
|
{
|
||||||
return brush.Color;
|
return brush.Color;
|
||||||
|
|||||||
@ -22,7 +22,6 @@
|
|||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
<Prefer32Bit>false</Prefer32Bit>
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
<DocumentationFile>bin\CUE.NET.XML</DocumentationFile>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
|
||||||
<OutputPath>bin\</OutputPath>
|
<OutputPath>bin\</OutputPath>
|
||||||
@ -33,7 +32,6 @@
|
|||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
<Prefer32Bit>false</Prefer32Bit>
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
<DocumentationFile>bin\CUE.NET.XML</DocumentationFile>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
@ -47,19 +45,15 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Brushes\ConicalGradientBrush.cs" />
|
|
||||||
<Compile Include="Brushes\IGradientBrush.cs" />
|
<Compile Include="Brushes\IGradientBrush.cs" />
|
||||||
<Compile Include="Brushes\ImageBrush.cs" />
|
<Compile Include="Brushes\ImageBrush.cs" />
|
||||||
<Compile Include="Brushes\ProfileBrush.cs" />
|
<Compile Include="Brushes\ProfileBrush.cs" />
|
||||||
<Compile Include="Brushes\BrushRenderTarget.cs" />
|
<Compile Include="Brushes\BrushRenderTarget.cs" />
|
||||||
<Compile Include="ColorCorrection\GammaCorrection.cs" />
|
|
||||||
<Compile Include="ColorCorrection\IColorCorrection.cs" />
|
|
||||||
<Compile Include="CueSDKAutoUpdate.cs" />
|
<Compile Include="CueSDKAutoUpdate.cs" />
|
||||||
<Compile Include="Devices\Generic\CorsairColor.cs" />
|
<Compile Include="Devices\Generic\CorsairColor.cs" />
|
||||||
<Compile Include="Devices\Generic\Enums\CorsairAccessMode.cs" />
|
<Compile Include="Devices\Generic\Enums\CorsairAccessMode.cs" />
|
||||||
<Compile Include="Devices\Generic\Enums\CorsairDeviceCaps.cs" />
|
<Compile Include="Devices\Generic\Enums\CorsairDeviceCaps.cs" />
|
||||||
<Compile Include="Devices\Generic\Enums\CorsairDeviceType.cs" />
|
<Compile Include="Devices\Generic\Enums\CorsairDeviceType.cs" />
|
||||||
<Compile Include="Devices\Generic\Enums\CorsairKeyId.cs" />
|
|
||||||
<Compile Include="Devices\Generic\Enums\CorsairLedId.cs" />
|
<Compile Include="Devices\Generic\Enums\CorsairLedId.cs" />
|
||||||
<Compile Include="Devices\Generic\EventArgs\ExceptionEventArgs.cs" />
|
<Compile Include="Devices\Generic\EventArgs\ExceptionEventArgs.cs" />
|
||||||
<Compile Include="Brushes\AbstractBrush.cs" />
|
<Compile Include="Brushes\AbstractBrush.cs" />
|
||||||
@ -68,12 +62,7 @@
|
|||||||
<Compile Include="Devices\Generic\EventArgs\UpdatedEventArgs.cs" />
|
<Compile Include="Devices\Generic\EventArgs\UpdatedEventArgs.cs" />
|
||||||
<Compile Include="Devices\Generic\EventArgs\UpdatingEventArgs.cs" />
|
<Compile Include="Devices\Generic\EventArgs\UpdatingEventArgs.cs" />
|
||||||
<Compile Include="Devices\Generic\LedUpateRequest.cs" />
|
<Compile Include="Devices\Generic\LedUpateRequest.cs" />
|
||||||
<Compile Include="Devices\HeadsetStand\CorsairHeadsetStand.cs" />
|
|
||||||
<Compile Include="Devices\HeadsetStand\CorsairHeadsetStandDeviceInfo.cs" />
|
|
||||||
<Compile Include="Devices\HeadsetStand\Enums\CorsairHeadsetStandLedId.cs" />
|
|
||||||
<Compile Include="Devices\Keyboard\Enums\BrushCalculationMode.cs" />
|
<Compile Include="Devices\Keyboard\Enums\BrushCalculationMode.cs" />
|
||||||
<Compile Include="Devices\Keyboard\Enums\CorsairKeyboardKeyId.cs" />
|
|
||||||
<Compile Include="Devices\Mouse\Enums\CorsairMouseKeyId.cs" />
|
|
||||||
<Compile Include="Effects\AbstractLedGroupEffect.cs" />
|
<Compile Include="Effects\AbstractLedGroupEffect.cs" />
|
||||||
<Compile Include="Effects\AbstractBrushEffect.cs" />
|
<Compile Include="Effects\AbstractBrushEffect.cs" />
|
||||||
<Compile Include="Effects\AbstractEffectTarget.cs" />
|
<Compile Include="Effects\AbstractEffectTarget.cs" />
|
||||||
@ -81,8 +70,6 @@
|
|||||||
<Compile Include="Devices\Mousemat\CorsairMousemat.cs" />
|
<Compile Include="Devices\Mousemat\CorsairMousemat.cs" />
|
||||||
<Compile Include="Devices\Mousemat\CorsairMousematDeviceInfo.cs" />
|
<Compile Include="Devices\Mousemat\CorsairMousematDeviceInfo.cs" />
|
||||||
<Compile Include="Devices\Mousemat\Enums\CorsairMousematLedId.cs" />
|
<Compile Include="Devices\Mousemat\Enums\CorsairMousematLedId.cs" />
|
||||||
<Compile Include="Effects\MoveGradientEffect.cs" />
|
|
||||||
<Compile Include="EventArgs\KeyPressedEventArgs.cs" />
|
|
||||||
<Compile Include="Gradients\AbstractGradient.cs" />
|
<Compile Include="Gradients\AbstractGradient.cs" />
|
||||||
<Compile Include="Gradients\GradientStop.cs" />
|
<Compile Include="Gradients\GradientStop.cs" />
|
||||||
<Compile Include="Gradients\IGradient.cs" />
|
<Compile Include="Gradients\IGradient.cs" />
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
<metadata>
|
<metadata>
|
||||||
<id>CUE.NET</id>
|
<id>CUE.NET</id>
|
||||||
<title>CUE.NET</title>
|
<title>CUE.NET</title>
|
||||||
<version>1.2.0.1</version>
|
<version>1.1.0.0</version>
|
||||||
<authors>Darth Affe</authors>
|
<authors>Darth Affe</authors>
|
||||||
<owners>Darth Affe</owners>
|
<owners>Darth Affe</owners>
|
||||||
<projectUrl>https://github.com/DarthAffe/CUE.NET</projectUrl>
|
<projectUrl>https://github.com/DarthAffe/CUE.NET</projectUrl>
|
||||||
@ -11,14 +11,20 @@
|
|||||||
<requireLicenseAcceptance>true</requireLicenseAcceptance>
|
<requireLicenseAcceptance>true</requireLicenseAcceptance>
|
||||||
<description>Corsair HID SDK Wrapper</description>
|
<description>Corsair HID SDK Wrapper</description>
|
||||||
<releaseNotes>
|
<releaseNotes>
|
||||||
- Updated SDK to 2.18.127
|
######### #########
|
||||||
- Added methods to use the new GetColor method
|
### This release contains a lot of breaking changes and will most likely not work without changes to existing code! ###
|
||||||
- Added an event to get the key-change of special keys (G and M)
|
######### #########
|
||||||
- Fixed missing LoadedArchitecture assignment
|
|
||||||
- Fixed an issue that prevents further reinitializing if an exception was thrown earlier
|
Updated SDK to 2.4.67,
|
||||||
|
Adde Corsair RGB Mous Mat support,
|
||||||
|
Rewrote brushes to perform two-pass-rendering,
|
||||||
|
Added own Color-Type to allow easier extension and modification (this type can be implicit converted to .NET-Colors)
|
||||||
|
Refactored everything to work based on LEDs - This will adapt the devices and reduces the importance of the "special case keyboard",
|
||||||
|
Added usable effect-system which allows to modify groups and brushes,
|
||||||
|
Refactored automatic updates to be SDK-wide (moved from device to CueSDK)
|
||||||
</releaseNotes>
|
</releaseNotes>
|
||||||
<summary>C# (.NET) Wrapper library around the Corsair CUE-SDK</summary>
|
<summary>C# (.NET) Wrapper library around the Corsair CUE-SDK</summary>
|
||||||
<copyright>Copyright © Wyrez 2017</copyright>
|
<copyright>Copyright © Wyrez 2016</copyright>
|
||||||
<language>en-US</language>
|
<language>en-US</language>
|
||||||
</metadata>
|
</metadata>
|
||||||
<files>
|
<files>
|
||||||
|
|||||||
12
CUE.NET.sln
12
CUE.NET.sln
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio 14
|
# Visual Studio 14
|
||||||
VisualStudioVersion = 14.0.25420.1
|
VisualStudioVersion = 14.0.25123.0
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CUE.NET", "CUE.NET.csproj", "{70A266B5-E9D4-4EAA-A91A-947C0039FFB6}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CUE.NET", "CUE.NET.csproj", "{70A266B5-E9D4-4EAA-A91A-947C0039FFB6}"
|
||||||
EndProject
|
EndProject
|
||||||
@ -32,10 +32,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AudioAnalyzer", "AudioAnaly
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example_AudioAnalyzer_full", "Examples\AudioAnalyzer\Example_AudioAnalyzer_full\Example_AudioAnalyzer_full.csproj", "{E06B4E1D-9735-4CB4-BC11-9ECDF27A0972}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example_AudioAnalyzer_full", "Examples\AudioAnalyzer\Example_AudioAnalyzer_full\Example_AudioAnalyzer_full.csproj", "{E06B4E1D-9735-4CB4-BC11-9ECDF27A0972}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Ambilight", "Ambilight", "{1ABADCA4-AC96-4E9F-91C5-232EB824D6DE}"
|
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example_Ambilight_full", "Examples\Ambilight\Example_Ambilight_full\Example_Ambilight_full.csproj", "{6D7BAF89-A705-4FFA-A3A2-AF93EC3A909C}"
|
|
||||||
EndProject
|
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -54,10 +50,6 @@ Global
|
|||||||
{E06B4E1D-9735-4CB4-BC11-9ECDF27A0972}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{E06B4E1D-9735-4CB4-BC11-9ECDF27A0972}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{E06B4E1D-9735-4CB4-BC11-9ECDF27A0972}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{E06B4E1D-9735-4CB4-BC11-9ECDF27A0972}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{E06B4E1D-9735-4CB4-BC11-9ECDF27A0972}.Release|Any CPU.Build.0 = Release|Any CPU
|
{E06B4E1D-9735-4CB4-BC11-9ECDF27A0972}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{6D7BAF89-A705-4FFA-A3A2-AF93EC3A909C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{6D7BAF89-A705-4FFA-A3A2-AF93EC3A909C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{6D7BAF89-A705-4FFA-A3A2-AF93EC3A909C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{6D7BAF89-A705-4FFA-A3A2-AF93EC3A909C}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@ -69,7 +61,5 @@ Global
|
|||||||
{2F99124B-FAED-432D-B797-45566D373411} = {D69EF6D8-68FF-4C56-B5CB-253971B1DF91}
|
{2F99124B-FAED-432D-B797-45566D373411} = {D69EF6D8-68FF-4C56-B5CB-253971B1DF91}
|
||||||
{BE16A0BF-6794-4718-AF27-F2A50078D880} = {1F52DDC9-E9D0-4A7B-8E78-930528203EE6}
|
{BE16A0BF-6794-4718-AF27-F2A50078D880} = {1F52DDC9-E9D0-4A7B-8E78-930528203EE6}
|
||||||
{E06B4E1D-9735-4CB4-BC11-9ECDF27A0972} = {BE16A0BF-6794-4718-AF27-F2A50078D880}
|
{E06B4E1D-9735-4CB4-BC11-9ECDF27A0972} = {BE16A0BF-6794-4718-AF27-F2A50078D880}
|
||||||
{1ABADCA4-AC96-4E9F-91C5-232EB824D6DE} = {1F52DDC9-E9D0-4A7B-8E78-930528203EE6}
|
|
||||||
{6D7BAF89-A705-4FFA-A3A2-AF93EC3A909C} = {1ABADCA4-AC96-4E9F-91C5-232EB824D6DE}
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
@ -1,108 +0,0 @@
|
|||||||
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global
|
|
||||||
// ReSharper disable MemberCanBePrivate.Global
|
|
||||||
// ReSharper disable UnusedMember.Global
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using CUE.NET.Devices.Generic;
|
|
||||||
using CUE.NET.Helper;
|
|
||||||
|
|
||||||
namespace CUE.NET.ColorCorrection
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a gamma-color-correction.
|
|
||||||
/// </summary>
|
|
||||||
public class GammaCorrection : IColorCorrection
|
|
||||||
{
|
|
||||||
#region Properties & Fields
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the gamma-value of the color 'red' used for color-correction.
|
|
||||||
/// Values greater than one will make colors brighter, values less than one will make colors darker.
|
|
||||||
/// </summary>
|
|
||||||
public float R { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the gamma-value of the color 'green' used for color-correction.
|
|
||||||
/// Values greater than one will make colors brighter, values less than one will make colors darker.
|
|
||||||
/// </summary>
|
|
||||||
public float G { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the gamma-value of the color 'blue' used for color-correction.
|
|
||||||
/// Values greater than one will make colors brighter, values less than one will make colors darker.
|
|
||||||
/// </summary>
|
|
||||||
public float B { get; set; }
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Constructors
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="GammaCorrection"/> class using the default-value 1f (no correction) for all colors.
|
|
||||||
/// </summary>
|
|
||||||
public GammaCorrection() : this(1f) { }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="GammaCorrection"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="gamma">The gamma-value for all colors used for color-correction.
|
|
||||||
/// Values greater than one will make colors brighter, values less than one will make colors darker.</param>
|
|
||||||
public GammaCorrection(float gamma)
|
|
||||||
{
|
|
||||||
this.R = gamma;
|
|
||||||
this.G = gamma;
|
|
||||||
this.B = gamma;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="GammaCorrection"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="r">The gamma-value for the color 'red' used for color-correction.
|
|
||||||
/// Values greater than one will make colors brighter, values less than one will make colors darker.</param>
|
|
||||||
/// <param name="g">The gamma-value for the color 'green' used for color-correction. Values
|
|
||||||
/// greater than one will make colors brighter, values less than one will make colors darker.</param>
|
|
||||||
/// <param name="b">The gamma-value for the color 'blue' used for color-correction. Values
|
|
||||||
/// greater than one will make colors brighter, values less than one will make colors darker.</param>
|
|
||||||
public GammaCorrection(float r, float g, float b)
|
|
||||||
{
|
|
||||||
this.R = r;
|
|
||||||
this.G = g;
|
|
||||||
this.B = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Methods
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Applies the gamma-correction to the given color.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="color">The color to correct.</param>
|
|
||||||
public void ApplyTo(CorsairColor color)
|
|
||||||
{
|
|
||||||
if (Math.Abs(R - 1f) > float.Epsilon)
|
|
||||||
color.R = ColorHelper.GetIntColorFromFloat((float)Math.Pow(color.GetFloatR(), 1.0 / R));
|
|
||||||
|
|
||||||
if (Math.Abs(G - 1f) > float.Epsilon)
|
|
||||||
color.G = ColorHelper.GetIntColorFromFloat((float)Math.Pow(color.GetFloatG(), 1.0 / G));
|
|
||||||
|
|
||||||
if (Math.Abs(B - 1f) > float.Epsilon)
|
|
||||||
color.B = ColorHelper.GetIntColorFromFloat((float)Math.Pow(color.GetFloatB(), 1.0 / B));
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Operators
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Converts a <see cref="float" /> to a <see cref="GammaCorrection" /> using the same value for all colors.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="gamma">The float-value to convert.</param>
|
|
||||||
public static implicit operator GammaCorrection(float gamma)
|
|
||||||
{
|
|
||||||
return new GammaCorrection(gamma);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,16 +0,0 @@
|
|||||||
using CUE.NET.Devices.Generic;
|
|
||||||
|
|
||||||
namespace CUE.NET.ColorCorrection
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Represents generic color-correction.
|
|
||||||
/// </summary>
|
|
||||||
public interface IColorCorrection
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Applies the color-correction to the given color.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="color">The color to correct.</param>
|
|
||||||
void ApplyTo(CorsairColor color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
117
CueSDK.cs
117
CueSDK.cs
@ -1,7 +1,6 @@
|
|||||||
// ReSharper disable MemberCanBePrivate.Global
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
// ReSharper disable UnusedMember.Global
|
// ReSharper disable UnusedMember.Global
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
@ -9,37 +8,20 @@ using CUE.NET.Devices;
|
|||||||
using CUE.NET.Devices.Generic;
|
using CUE.NET.Devices.Generic;
|
||||||
using CUE.NET.Devices.Generic.Enums;
|
using CUE.NET.Devices.Generic.Enums;
|
||||||
using CUE.NET.Devices.Headset;
|
using CUE.NET.Devices.Headset;
|
||||||
using CUE.NET.Devices.HeadsetStand;
|
|
||||||
using CUE.NET.Devices.Keyboard;
|
using CUE.NET.Devices.Keyboard;
|
||||||
using CUE.NET.Devices.Mouse;
|
using CUE.NET.Devices.Mouse;
|
||||||
using CUE.NET.Devices.Mousemat;
|
using CUE.NET.Devices.Mousemat;
|
||||||
using CUE.NET.EventArgs;
|
|
||||||
using CUE.NET.Exceptions;
|
using CUE.NET.Exceptions;
|
||||||
using CUE.NET.Native;
|
using CUE.NET.Native;
|
||||||
|
|
||||||
namespace CUE.NET
|
namespace CUE.NET
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Static entry point to work with the Corsair-SDK.
|
|
||||||
/// </summary>
|
|
||||||
public static partial class CueSDK
|
public static partial class CueSDK
|
||||||
{
|
{
|
||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|
||||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications.
|
|
||||||
/// The first match will be used.
|
|
||||||
/// </summary>
|
|
||||||
public static List<string> PossibleX86NativePaths { get; } = new List<string> { "x86/CUESDK_2015.dll", "x86/CUESDK.dll" };
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets a modifiable list of paths used to find the native SDK-dlls for x64 applications.
|
|
||||||
/// The first match will be used.
|
|
||||||
/// </summary>
|
|
||||||
public static List<string> PossibleX64NativePaths { get; } = new List<string> { "x64/CUESDK_2015.dll", "x64/CUESDK.dll" };
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicates if the SDK is initialized and ready to use.
|
/// Indicates if the SDK is initialized and ready to use.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -89,35 +71,13 @@ namespace CUE.NET
|
|||||||
public static CorsairHeadset HeadsetSDK { get; private set; }
|
public static CorsairHeadset HeadsetSDK { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the managed representation of a mousemat managed by the CUE-SDK.
|
/// Gets the managed representation of a moustmat managed by the CUE-SDK.
|
||||||
/// Note that currently only one connected mousemat is supported.
|
/// Note that currently only one connected mousemat is supported.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static CorsairMousemat MousematSDK { get; private set; }
|
public static CorsairMousemat MousematSDK { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the managed representation of a headset stand managed by the CUE-SDK.
|
|
||||||
/// Note that currently only one connected headset stand is supported.
|
|
||||||
/// </summary>
|
|
||||||
public static CorsairHeadsetStand HeadsetStandSDK { get; private set; }
|
|
||||||
|
|
||||||
// ReSharper restore UnusedAutoPropertyAccessor.Global
|
// ReSharper restore UnusedAutoPropertyAccessor.Global
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
||||||
private delegate void OnKeyPressedDelegate(IntPtr context, CorsairKeyId keyId, [MarshalAs(UnmanagedType.I1)] bool pressed);
|
|
||||||
private static OnKeyPressedDelegate _onKeyPressedDelegate;
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Events
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Occurs when the SDK reports that a key is pressed.
|
|
||||||
/// Notice that right now only G- (keyboard) and M- (mouse) keys are supported.
|
|
||||||
///
|
|
||||||
/// To enable this event <see cref="EnableKeypressCallback"/> needs to be called.
|
|
||||||
/// </summary>
|
|
||||||
public static event EventHandler<KeyPressedEventArgs> KeyPressed;
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
@ -125,13 +85,12 @@ namespace CUE.NET
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks if the SDK for the provided <see cref="CorsairDeviceType"/> is available or checks if CUE is installed and SDK supported enabled if null is provided.
|
/// Checks if the SDK for the provided <see cref="CorsairDeviceType"/> is available or checks if CUE is installed and SDK supported enabled if null is provided.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sdkType">The <see cref="CorsairDeviceType"/> to check or null to check for general SDK availability.</param>
|
/// <param name="sdkType">The <see cref="CorsairDeviceType"/> to check or null to check for generall SDK availability.</param>
|
||||||
/// <returns>The availability of the provided <see cref="CorsairDeviceType"/>.</returns>
|
/// <returns>The availability of the provided <see cref="CorsairDeviceType"/>.</returns>
|
||||||
public static bool IsSDKAvailable(CorsairDeviceType? sdkType = null)
|
public static bool IsSDKAvailable(CorsairDeviceType? sdkType = null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// ReSharper disable once RedundantIfElseBlock
|
|
||||||
if (IsInitialized)
|
if (IsInitialized)
|
||||||
{
|
{
|
||||||
// ReSharper disable once SwitchStatementMissingSomeCases - everything else is true
|
// ReSharper disable once SwitchStatementMissingSomeCases - everything else is true
|
||||||
@ -145,15 +104,12 @@ namespace CUE.NET
|
|||||||
return HeadsetSDK != null;
|
return HeadsetSDK != null;
|
||||||
case CorsairDeviceType.Mousemat:
|
case CorsairDeviceType.Mousemat:
|
||||||
return MousematSDK != null;
|
return MousematSDK != null;
|
||||||
case CorsairDeviceType.HeadsetStand:
|
|
||||||
return HeadsetStandSDK != null;
|
|
||||||
default:
|
default:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_CUESDK.Reload();
|
|
||||||
_CUESDK.CorsairPerformProtocolHandshake();
|
_CUESDK.CorsairPerformProtocolHandshake();
|
||||||
|
|
||||||
if (sdkType == null || sdkType == CorsairDeviceType.Unknown)
|
if (sdkType == null || sdkType == CorsairDeviceType.Unknown)
|
||||||
@ -187,13 +143,11 @@ namespace CUE.NET
|
|||||||
if (IsInitialized)
|
if (IsInitialized)
|
||||||
throw new WrapperException("CueSDK is already initialized.");
|
throw new WrapperException("CueSDK is already initialized.");
|
||||||
|
|
||||||
_CUESDK.Reload();
|
|
||||||
|
|
||||||
ProtocolDetails = new CorsairProtocolDetails(_CUESDK.CorsairPerformProtocolHandshake());
|
ProtocolDetails = new CorsairProtocolDetails(_CUESDK.CorsairPerformProtocolHandshake());
|
||||||
|
|
||||||
CorsairError error = LastError;
|
CorsairError error = LastError;
|
||||||
if (error != CorsairError.Success)
|
if (error != CorsairError.Success)
|
||||||
Throw(error, true);
|
Throw(error);
|
||||||
|
|
||||||
if (ProtocolDetails.BreakingChanges)
|
if (ProtocolDetails.BreakingChanges)
|
||||||
throw new WrapperException("The SDK currently used isn't compatible with the installed version of CUE.\r\n"
|
throw new WrapperException("The SDK currently used isn't compatible with the installed version of CUE.\r\n"
|
||||||
@ -203,7 +157,7 @@ namespace CUE.NET
|
|||||||
if (exclusiveAccess)
|
if (exclusiveAccess)
|
||||||
{
|
{
|
||||||
if (!_CUESDK.CorsairRequestControl(CorsairAccessMode.ExclusiveLightingControl))
|
if (!_CUESDK.CorsairRequestControl(CorsairAccessMode.ExclusiveLightingControl))
|
||||||
Throw(LastError, true);
|
Throw(LastError);
|
||||||
|
|
||||||
HasExclusiveAccess = true;
|
HasExclusiveAccess = true;
|
||||||
}
|
}
|
||||||
@ -232,9 +186,6 @@ namespace CUE.NET
|
|||||||
case CorsairDeviceType.Mousemat:
|
case CorsairDeviceType.Mousemat:
|
||||||
device = MousematSDK = new CorsairMousemat(new CorsairMousematDeviceInfo(nativeDeviceInfo));
|
device = MousematSDK = new CorsairMousemat(new CorsairMousematDeviceInfo(nativeDeviceInfo));
|
||||||
break;
|
break;
|
||||||
case CorsairDeviceType.HeadsetStand:
|
|
||||||
device = HeadsetStandSDK = new CorsairHeadsetStand(new CorsairHeadsetStandDeviceInfo(nativeDeviceInfo));
|
|
||||||
break;
|
|
||||||
// ReSharper disable once RedundantCaseLabel
|
// ReSharper disable once RedundantCaseLabel
|
||||||
case CorsairDeviceType.Unknown:
|
case CorsairDeviceType.Unknown:
|
||||||
default:
|
default:
|
||||||
@ -246,45 +197,14 @@ namespace CUE.NET
|
|||||||
|
|
||||||
error = LastError;
|
error = LastError;
|
||||||
if (error != CorsairError.Success)
|
if (error != CorsairError.Success)
|
||||||
Throw(error, true);
|
Throw(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
error = LastError;
|
|
||||||
if (error != CorsairError.Success)
|
|
||||||
Throw(error, false);
|
|
||||||
|
|
||||||
InitializedDevices = new ReadOnlyCollection<ICueDevice>(devices);
|
InitializedDevices = new ReadOnlyCollection<ICueDevice>(devices);
|
||||||
|
|
||||||
IsInitialized = true;
|
IsInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Enables the keypress-callback.
|
|
||||||
/// This method needs to be called to enable the <see cref="KeyPressed"/>-event.
|
|
||||||
///
|
|
||||||
/// WARNING: AFTER THIS METHOD IS CALLED IT'S NO LONGER POSSIBLE TO REINITIALIZE THE SDK!
|
|
||||||
/// </summary>
|
|
||||||
public static void EnableKeypressCallback()
|
|
||||||
{
|
|
||||||
if (!IsInitialized)
|
|
||||||
throw new WrapperException("CueSDK isn't initialized.");
|
|
||||||
|
|
||||||
if (_onKeyPressedDelegate != null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_onKeyPressedDelegate = OnKeyPressed;
|
|
||||||
_CUESDK.CorsairRegisterKeypressCallback(Marshal.GetFunctionPointerForDelegate(_onKeyPressedDelegate), IntPtr.Zero);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Resets the colors of all devices back to the last saved color-data. (If there wasn't a manual save, that's the data from the time the SDK was initialized.)
|
|
||||||
/// </summary>
|
|
||||||
public static void Reset()
|
|
||||||
{
|
|
||||||
foreach (ICueDevice device in InitializedDevices)
|
|
||||||
device.RestoreColors();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reinitialize the CUE-SDK and temporarily hand back full control to CUE.
|
/// Reinitialize the CUE-SDK and temporarily hand back full control to CUE.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -302,14 +222,10 @@ namespace CUE.NET
|
|||||||
if (!IsInitialized)
|
if (!IsInitialized)
|
||||||
throw new WrapperException("CueSDK isn't initialized.");
|
throw new WrapperException("CueSDK isn't initialized.");
|
||||||
|
|
||||||
if (_onKeyPressedDelegate != null)
|
|
||||||
throw new WrapperException("Keypress-Callback is enabled.");
|
|
||||||
|
|
||||||
KeyboardSDK?.ResetLeds();
|
KeyboardSDK?.ResetLeds();
|
||||||
MouseSDK?.ResetLeds();
|
MouseSDK?.ResetLeds();
|
||||||
HeadsetSDK?.ResetLeds();
|
HeadsetSDK?.ResetLeds();
|
||||||
MousematSDK?.ResetLeds();
|
MousematSDK?.ResetLeds();
|
||||||
HeadsetStandSDK?.ResetLeds();
|
|
||||||
|
|
||||||
_CUESDK.Reload();
|
_CUESDK.Reload();
|
||||||
|
|
||||||
@ -317,7 +233,7 @@ namespace CUE.NET
|
|||||||
|
|
||||||
CorsairError error = LastError;
|
CorsairError error = LastError;
|
||||||
if (error != CorsairError.Success)
|
if (error != CorsairError.Success)
|
||||||
Throw(error, false);
|
Throw(error);
|
||||||
|
|
||||||
if (ProtocolDetails.BreakingChanges)
|
if (ProtocolDetails.BreakingChanges)
|
||||||
throw new WrapperException("The SDK currently used isn't compatible with the installed version of CUE.\r\n"
|
throw new WrapperException("The SDK currently used isn't compatible with the installed version of CUE.\r\n"
|
||||||
@ -326,7 +242,7 @@ namespace CUE.NET
|
|||||||
|
|
||||||
if (exclusiveAccess)
|
if (exclusiveAccess)
|
||||||
if (!_CUESDK.CorsairRequestControl(CorsairAccessMode.ExclusiveLightingControl))
|
if (!_CUESDK.CorsairRequestControl(CorsairAccessMode.ExclusiveLightingControl))
|
||||||
Throw(LastError, false);
|
Throw(LastError);
|
||||||
HasExclusiveAccess = exclusiveAccess;
|
HasExclusiveAccess = exclusiveAccess;
|
||||||
|
|
||||||
int deviceCount = _CUESDK.CorsairGetDeviceCount();
|
int deviceCount = _CUESDK.CorsairGetDeviceCount();
|
||||||
@ -341,7 +257,7 @@ namespace CUE.NET
|
|||||||
|
|
||||||
error = LastError;
|
error = LastError;
|
||||||
if (error != CorsairError.Success)
|
if (error != CorsairError.Success)
|
||||||
Throw(error, false);
|
Throw(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (KeyboardSDK != null)
|
if (KeyboardSDK != null)
|
||||||
@ -360,21 +276,11 @@ namespace CUE.NET
|
|||||||
if (!reloadedDevices.ContainsKey(CorsairDeviceType.Mousemat)
|
if (!reloadedDevices.ContainsKey(CorsairDeviceType.Mousemat)
|
||||||
|| MousematSDK.MousematDeviceInfo.Model != reloadedDevices[CorsairDeviceType.Mousemat].Model)
|
|| MousematSDK.MousematDeviceInfo.Model != reloadedDevices[CorsairDeviceType.Mousemat].Model)
|
||||||
throw new WrapperException("The previously loaded Mousemat got disconnected.");
|
throw new WrapperException("The previously loaded Mousemat got disconnected.");
|
||||||
if (HeadsetStandSDK != null)
|
|
||||||
if (!reloadedDevices.ContainsKey(CorsairDeviceType.HeadsetStand)
|
|
||||||
|| HeadsetStandSDK.HeadsetStandDeviceInfo.Model != reloadedDevices[CorsairDeviceType.HeadsetStand].Model)
|
|
||||||
throw new WrapperException("The previously loaded Headset Stand got disconnected.");
|
|
||||||
|
|
||||||
error = LastError;
|
|
||||||
if (error != CorsairError.Success)
|
|
||||||
Throw(error, false);
|
|
||||||
|
|
||||||
IsInitialized = true;
|
IsInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void Throw(CorsairError error, bool reset)
|
private static void Throw(CorsairError error)
|
||||||
{
|
|
||||||
if (reset)
|
|
||||||
{
|
{
|
||||||
ProtocolDetails = null;
|
ProtocolDetails = null;
|
||||||
HasExclusiveAccess = false;
|
HasExclusiveAccess = false;
|
||||||
@ -382,16 +288,11 @@ namespace CUE.NET
|
|||||||
MouseSDK = null;
|
MouseSDK = null;
|
||||||
HeadsetSDK = null;
|
HeadsetSDK = null;
|
||||||
MousematSDK = null;
|
MousematSDK = null;
|
||||||
HeadsetStandSDK = null;
|
|
||||||
IsInitialized = false;
|
IsInitialized = false;
|
||||||
}
|
|
||||||
|
|
||||||
throw new CUEException(error);
|
throw new CUEException(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void OnKeyPressed(IntPtr context, CorsairKeyId keyId, bool pressed)
|
|
||||||
=> KeyPressed?.Invoke(null, new KeyPressedEventArgs(keyId, pressed));
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,9 +9,6 @@ using CUE.NET.Devices.Generic.Enums;
|
|||||||
|
|
||||||
namespace CUE.NET
|
namespace CUE.NET
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Static entry point to work with the Corsair-SDK.
|
|
||||||
/// </summary>
|
|
||||||
public static partial class CueSDK
|
public static partial class CueSDK
|
||||||
{
|
{
|
||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|||||||
@ -29,8 +29,6 @@ namespace CUE.NET.Devices.Generic
|
|||||||
|
|
||||||
private static DateTime _lastUpdate = DateTime.Now;
|
private static DateTime _lastUpdate = DateTime.Now;
|
||||||
|
|
||||||
private Dictionary<CorsairLedId, CorsairColor> _colorDataSave;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets generic information provided by CUE for the device.
|
/// Gets generic information provided by CUE for the device.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -39,7 +37,7 @@ namespace CUE.NET.Devices.Generic
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the rectangle containing all LEDs of the device.
|
/// Gets the rectangle containing all LEDs of the device.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public RectangleF DeviceRectangle { get; protected set; }
|
public RectangleF DeviceRectangle { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a dictionary containing all LEDs of the device.
|
/// Gets a dictionary containing all LEDs of the device.
|
||||||
@ -58,7 +56,6 @@ namespace CUE.NET.Devices.Generic
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the background brush of the keyboard.
|
/// Gets or sets the background brush of the keyboard.
|
||||||
/// If this is null the last saved color-data is used as background.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IBrush Brush { get; set; }
|
public IBrush Brush { get; set; }
|
||||||
|
|
||||||
@ -142,6 +139,8 @@ namespace CUE.NET.Devices.Generic
|
|||||||
protected AbstractCueDevice(IDeviceInfo info)
|
protected AbstractCueDevice(IDeviceInfo info)
|
||||||
{
|
{
|
||||||
this.DeviceInfo = info;
|
this.DeviceInfo = info;
|
||||||
|
|
||||||
|
DeviceRectangle = RectangleHelper.CreateRectangleFromRectangles((this).Select(x => x.LedRectangle));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -153,11 +152,7 @@ namespace CUE.NET.Devices.Generic
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes the device.
|
/// Initializes the device.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void Initialize()
|
public abstract void Initialize();
|
||||||
{
|
|
||||||
DeviceRectangle = RectangleHelper.CreateRectangleFromRectangles((this).Select(x => x.LedRectangle));
|
|
||||||
SaveColors();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes the LED-Object with the specified id.
|
/// Initializes the LED-Object with the specified id.
|
||||||
@ -169,7 +164,7 @@ namespace CUE.NET.Devices.Generic
|
|||||||
{
|
{
|
||||||
if (LedMapping.ContainsKey(ledId)) return null;
|
if (LedMapping.ContainsKey(ledId)) return null;
|
||||||
|
|
||||||
CorsairLed led = new CorsairLed(this, ledId, ledRectangle);
|
CorsairLed led = new CorsairLed(ledId, ledRectangle);
|
||||||
LedMapping.Add(ledId, led);
|
LedMapping.Add(ledId, led);
|
||||||
return led;
|
return led;
|
||||||
}
|
}
|
||||||
@ -191,26 +186,19 @@ namespace CUE.NET.Devices.Generic
|
|||||||
/// Performs an update for all dirty keys, or all keys if flushLeds is set to true.
|
/// Performs an update for all dirty keys, or all keys if flushLeds is set to true.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="flushLeds">Specifies whether all keys (including clean ones) should be updated.</param>
|
/// <param name="flushLeds">Specifies whether all keys (including clean ones) should be updated.</param>
|
||||||
/// <param name="noRender">Only updates the hardware-leds skippin effects and the render-pass. Only use this if you know what that means!</param>
|
public void Update(bool flushLeds = false)
|
||||||
public void Update(bool flushLeds = false, bool noRender = false)
|
|
||||||
{
|
{
|
||||||
OnUpdating();
|
OnUpdating();
|
||||||
|
|
||||||
if (!noRender)
|
|
||||||
{
|
|
||||||
// Update effects
|
// Update effects
|
||||||
foreach (ILedGroup ledGroup in LedGroups)
|
foreach (ILedGroup ledGroup in LedGroups)
|
||||||
ledGroup.UpdateEffects();
|
ledGroup.UpdateEffects();
|
||||||
|
|
||||||
// Render brushes
|
// Render brushes
|
||||||
if (Brush != null)
|
|
||||||
Render(this);
|
Render(this);
|
||||||
else
|
|
||||||
ApplyColorData(_colorDataSave);
|
|
||||||
|
|
||||||
foreach (ILedGroup ledGroup in LedGroups.OrderBy(x => x.ZIndex))
|
foreach (ILedGroup ledGroup in LedGroups.OrderBy(x => x.ZIndex))
|
||||||
Render(ledGroup);
|
Render(ledGroup);
|
||||||
}
|
|
||||||
// Device-specific updates
|
// Device-specific updates
|
||||||
DeviceUpdate();
|
DeviceUpdate();
|
||||||
|
|
||||||
@ -237,12 +225,8 @@ namespace CUE.NET.Devices.Generic
|
|||||||
// ReSharper disable once MemberCanBeMadeStatic.Local - idc
|
// ReSharper disable once MemberCanBeMadeStatic.Local - idc
|
||||||
protected virtual void Render(ILedGroup ledGroup)
|
protected virtual void Render(ILedGroup ledGroup)
|
||||||
{
|
{
|
||||||
if (ledGroup == null) return;
|
|
||||||
|
|
||||||
IList<CorsairLed> leds = ledGroup.GetLeds().ToList();
|
IList<CorsairLed> leds = ledGroup.GetLeds().ToList();
|
||||||
|
|
||||||
IBrush brush = ledGroup.Brush;
|
IBrush brush = ledGroup.Brush;
|
||||||
if (brush == null) return;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -254,10 +238,10 @@ namespace CUE.NET.Devices.Generic
|
|||||||
float offsetY = -brushRectangle.Y;
|
float offsetY = -brushRectangle.Y;
|
||||||
brushRectangle.X = 0;
|
brushRectangle.X = 0;
|
||||||
brushRectangle.Y = 0;
|
brushRectangle.Y = 0;
|
||||||
brush.PerformRender(brushRectangle, leds.Select(x => new BrushRenderTarget(x.Id, x.LedRectangle.Move(offsetX, offsetY))));
|
brush.PerformRender(brushRectangle, leds.Select(x => new BrushRenderTarget(x.Id, x.LedRectangle.GetCenter(offsetX, offsetY))));
|
||||||
break;
|
break;
|
||||||
case BrushCalculationMode.Absolute:
|
case BrushCalculationMode.Absolute:
|
||||||
brush.PerformRender(DeviceRectangle, leds.Select(x => new BrushRenderTarget(x.Id, x.LedRectangle)));
|
brush.PerformRender(DeviceRectangle, leds.Select(x => new BrushRenderTarget(x.Id, x.LedRectangle.GetCenter())));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new ArgumentException();
|
throw new ArgumentException();
|
||||||
@ -304,63 +288,6 @@ namespace CUE.NET.Devices.Generic
|
|||||||
OnLedsUpdated(updateRequests);
|
OnLedsUpdated(updateRequests);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public void SyncColors()
|
|
||||||
{
|
|
||||||
Dictionary<CorsairLedId, CorsairColor> colorData = GetColors();
|
|
||||||
ApplyColorData(colorData);
|
|
||||||
Update(true, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public void SaveColors()
|
|
||||||
{
|
|
||||||
_colorDataSave = GetColors();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public void RestoreColors()
|
|
||||||
{
|
|
||||||
ApplyColorData(_colorDataSave);
|
|
||||||
Update(true, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ApplyColorData(Dictionary<CorsairLedId, CorsairColor> colorData)
|
|
||||||
{
|
|
||||||
if (colorData == null) return;
|
|
||||||
|
|
||||||
foreach (KeyValuePair<CorsairLedId, CorsairColor> corsairColor in _colorDataSave)
|
|
||||||
LedMapping[corsairColor.Key].Color = corsairColor.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Dictionary<CorsairLedId, CorsairColor> GetColors()
|
|
||||||
{
|
|
||||||
int structSize = Marshal.SizeOf(typeof(_CorsairLedColor));
|
|
||||||
IntPtr ptr = Marshal.AllocHGlobal(structSize * LedMapping.Count);
|
|
||||||
IntPtr addPtr = new IntPtr(ptr.ToInt64());
|
|
||||||
foreach (KeyValuePair<CorsairLedId, CorsairLed> led in LedMapping)
|
|
||||||
{
|
|
||||||
_CorsairLedColor color = new _CorsairLedColor { ledId = (int)led.Value.Id };
|
|
||||||
Marshal.StructureToPtr(color, addPtr, false);
|
|
||||||
addPtr = new IntPtr(addPtr.ToInt64() + structSize);
|
|
||||||
}
|
|
||||||
_CUESDK.CorsairGetLedsColors(LedMapping.Count, ptr);
|
|
||||||
|
|
||||||
IntPtr readPtr = ptr;
|
|
||||||
Dictionary<CorsairLedId, CorsairColor> colorData = new Dictionary<CorsairLedId, CorsairColor>();
|
|
||||||
for (int i = 0; i < LedMapping.Count; i++)
|
|
||||||
{
|
|
||||||
_CorsairLedColor ledColor = (_CorsairLedColor)Marshal.PtrToStructure(readPtr, typeof(_CorsairLedColor));
|
|
||||||
colorData.Add((CorsairLedId)ledColor.ledId, new CorsairColor((byte)ledColor.r, (byte)ledColor.g, (byte)ledColor.b));
|
|
||||||
|
|
||||||
readPtr = new IntPtr(readPtr.ToInt64() + structSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
Marshal.FreeHGlobal(ptr);
|
|
||||||
|
|
||||||
return colorData;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region LedGroup
|
#region LedGroup
|
||||||
@ -413,12 +340,6 @@ namespace CUE.NET.Devices.Generic
|
|||||||
|
|
||||||
#region Effects
|
#region Effects
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets a list of all active effects of this target.
|
|
||||||
/// For this device this is always null.
|
|
||||||
/// </summary>
|
|
||||||
public IList<IEffect<ILedGroup>> Effects => null;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// NOT IMPLEMENTED: Effects can't be applied directly to the device. Add it to the Brush or create a ledgroup instead.
|
/// NOT IMPLEMENTED: Effects can't be applied directly to the device. Add it to the Brush or create a ledgroup instead.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -474,7 +395,7 @@ namespace CUE.NET.Devices.Generic
|
|||||||
{
|
{
|
||||||
long lastUpdateTicks = _lastUpdate.Ticks;
|
long lastUpdateTicks = _lastUpdate.Ticks;
|
||||||
_lastUpdate = DateTime.Now;
|
_lastUpdate = DateTime.Now;
|
||||||
Updating?.Invoke(this, new UpdatingEventArgs((DateTime.Now.Ticks - lastUpdateTicks) / 10000000f));
|
Updating?.Invoke(this, new UpdatingEventArgs((float)((DateTime.Now.Ticks - lastUpdateTicks) / 10000000f)));
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|||||||
@ -2,77 +2,35 @@
|
|||||||
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global
|
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global
|
||||||
// ReSharper disable UnusedMember.Global
|
// ReSharper disable UnusedMember.Global
|
||||||
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
|
||||||
namespace CUE.NET.Devices.Generic
|
namespace CUE.NET.Devices.Generic
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Represents an ARGB (alpha, red, green, blue) color used by CUE.NET.
|
|
||||||
/// </summary>
|
|
||||||
[DebuggerDisplay("[A: {A}, R: {R}, G: {G}, B: {B}]")]
|
|
||||||
public class CorsairColor
|
public class CorsairColor
|
||||||
{
|
{
|
||||||
#region Constants
|
#region Constants
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets an transparent color [A: 0, R: 0, G: 0, B: 0]
|
|
||||||
/// </summary>
|
|
||||||
public static CorsairColor Transparent => Color.Transparent;
|
public static CorsairColor Transparent => Color.Transparent;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the alpha component value of this <see cref="CorsairColor"/>.
|
|
||||||
/// </summary>
|
|
||||||
public byte A { get; set; }
|
public byte A { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the red component value of this <see cref="CorsairColor"/>.
|
|
||||||
/// </summary>
|
|
||||||
public byte R { get; set; }
|
public byte R { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the green component value of this <see cref="CorsairColor"/>.
|
|
||||||
/// </summary>
|
|
||||||
public byte G { get; set; }
|
public byte G { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the blue component value of this <see cref="CorsairColor"/>.
|
|
||||||
/// </summary>
|
|
||||||
public byte B { get; set; }
|
public byte B { get; set; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="CorsairColor"/> class.
|
|
||||||
/// The class created by this constructor equals <see cref="Transparent"/>.
|
|
||||||
/// </summary>
|
|
||||||
public CorsairColor()
|
public CorsairColor()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
/// <summary>
|
public CorsairColor(byte r, byte g, byte b) : this(255, r, g, b)
|
||||||
/// Initializes a new instance of the <see cref="CorsairColor"/> class using only RGB-Values.
|
|
||||||
/// Alpha defaults to 255.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="r">The red component value of this <see cref="CorsairColor"/>.</param>
|
|
||||||
/// <param name="g">The green component value of this <see cref="CorsairColor"/>.</param>
|
|
||||||
/// <param name="b">The blue component value of this <see cref="CorsairColor"/>.</param>
|
|
||||||
public CorsairColor(byte r, byte g, byte b)
|
|
||||||
: this(255, r, g, b)
|
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="CorsairColor"/> class using ARGB-values.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="a">The alpha component value of this <see cref="CorsairColor"/>.</param>
|
|
||||||
/// <param name="r">The red component value of this <see cref="CorsairColor"/>.</param>
|
|
||||||
/// <param name="g">The green component value of this <see cref="CorsairColor"/>.</param>
|
|
||||||
/// <param name="b">The blue component value of this <see cref="CorsairColor"/>.</param>
|
|
||||||
public CorsairColor(byte a, byte r, byte g, byte b)
|
public CorsairColor(byte a, byte r, byte g, byte b)
|
||||||
{
|
{
|
||||||
this.A = a;
|
this.A = a;
|
||||||
@ -81,97 +39,15 @@ namespace CUE.NET.Devices.Generic
|
|||||||
this.B = b;
|
this.B = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="CorsairColor"/> class by cloning a existing <see cref="CorsairColor"/>.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="color">The <see cref="CorsairColor"/> the values are copied from.</param>
|
|
||||||
public CorsairColor(CorsairColor color)
|
|
||||||
: this(color.A, color.R, color.G, color.B)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Operators
|
#region Operators
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Converts the individual byte-values of this <see cref="CorsairColor"/> to a human-readable string.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string that contains the individual byte-values of this <see cref="CorsairColor"/>. For example "[A: 255, R: 255, G: 0, B: 0]".</returns>
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
return $"[A: {A}, R: {R}, G: {G}, B: {B}]";
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Tests whether the specified object is a <see cref="CorsairColor" /> and is equivalent to this <see cref="CorsairColor" />.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="obj">The object to test.</param>
|
|
||||||
/// <returns>true if <paramref name="obj" /> is a <see cref="CorsairColor" /> equivalent to this <see cref="CorsairColor" /> ; otherwise, false.</returns>
|
|
||||||
public override bool Equals(object obj)
|
|
||||||
{
|
|
||||||
CorsairColor compareColor = obj as CorsairColor;
|
|
||||||
if (ReferenceEquals(compareColor, null))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (ReferenceEquals(this, compareColor))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (GetType() != compareColor.GetType())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return (compareColor.A == A) && (compareColor.R == R) && (compareColor.G == G) && (compareColor.B == B);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a hash code for this <see cref="CorsairColor" />.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>An integer value that specifies the hash code for this <see cref="CorsairColor" />.</returns>
|
|
||||||
public override int GetHashCode()
|
|
||||||
{
|
|
||||||
unchecked
|
|
||||||
{
|
|
||||||
int hashCode = A.GetHashCode();
|
|
||||||
hashCode = (hashCode * 397) ^ R.GetHashCode();
|
|
||||||
hashCode = (hashCode * 397) ^ G.GetHashCode();
|
|
||||||
hashCode = (hashCode * 397) ^ B.GetHashCode();
|
|
||||||
return hashCode;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a value that indicates whether two specified <see cref="CorsairColor" /> are equal.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="color1">The first <see cref="CorsairColor" /> color to compare.</param>
|
|
||||||
/// <param name="color2">The second <see cref="CorsairColor" /> color to compare.</param>
|
|
||||||
/// <returns>true if <paramref name="color1" /> and <paramref name="color2" /> are equal; otherwise, false.</returns>
|
|
||||||
public static bool operator ==(CorsairColor color1, CorsairColor color2)
|
|
||||||
{
|
|
||||||
return ReferenceEquals(color1, null) ? ReferenceEquals(color2, null) : color1.Equals(color2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a value that indicates whether two specified <see cref="CorsairColor" /> are equal.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="color1">The first <see cref="CorsairColor" /> color to compare.</param>
|
|
||||||
/// <param name="color2">The second <see cref="CorsairColor" /> color to compare.</param>
|
|
||||||
/// <returns>true if <paramref name="color1" /> and <paramref name="color2" /> are not equal; otherwise, false.</returns>
|
|
||||||
public static bool operator !=(CorsairColor color1, CorsairColor color2)
|
|
||||||
{
|
|
||||||
return !(color1 == color2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Converts a <see cref="Color" /> to a <see cref="CorsairColor" />.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="color">The <see cref="Color"/> to convert.</param>
|
|
||||||
public static implicit operator CorsairColor(Color color)
|
public static implicit operator CorsairColor(Color color)
|
||||||
{
|
{
|
||||||
return new CorsairColor(color.A, color.R, color.G, color.B);
|
return new CorsairColor(color.A, color.R, color.G, color.B);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Converts a <see cref="CorsairColor" /> to a <see cref="Color" />.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="color">The <see cref="CorsairColor"/> to convert.</param>
|
|
||||||
public static implicit operator Color(CorsairColor color)
|
public static implicit operator Color(CorsairColor color)
|
||||||
{
|
{
|
||||||
return Color.FromArgb(color.A, color.R, color.G, color.B);
|
return Color.FromArgb(color.A, color.R, color.G, color.B);
|
||||||
|
|||||||
@ -2,7 +2,6 @@
|
|||||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global
|
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global
|
||||||
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using CUE.NET.Devices.Generic.Enums;
|
using CUE.NET.Devices.Generic.Enums;
|
||||||
using CUE.NET.Helper;
|
using CUE.NET.Helper;
|
||||||
@ -12,20 +11,14 @@ namespace CUE.NET.Devices.Generic
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a single LED of a CUE-device.
|
/// Represents a single LED of a CUE-device.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DebuggerDisplay("{Id} {Color}")]
|
|
||||||
public class CorsairLed
|
public class CorsairLed
|
||||||
{
|
{
|
||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the Device this <see cref="CorsairLed"/> is associated with.
|
|
||||||
/// </summary>
|
|
||||||
public ICueDevice Device { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the key-ID of the Led.
|
/// Gets the key-ID of the Led.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CorsairLedId Id { get; }
|
public CorsairLedId Id { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a rectangle representing the physical location of the led.
|
/// Gets a rectangle representing the physical location of the led.
|
||||||
@ -59,7 +52,7 @@ namespace CUE.NET.Devices.Generic
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets if the color of this LED can be changed.
|
/// Gets or sets if the color of this LED can be changed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsLocked { get; set; }
|
public bool IsLocked { get; set; } = false;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -68,12 +61,10 @@ namespace CUE.NET.Devices.Generic
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="CorsairLed"/> class.
|
/// Initializes a new instance of the <see cref="CorsairLed"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="device">The <see cref="ICueDevice"/> the <see cref="CorsairLed"/> is associated with.</param>
|
/// <param name="id">The ID of the LED</param>
|
||||||
/// <param name="id">The <see cref="CorsairLedId"/> of the <see cref="CorsairLed"/>.</param>
|
/// <param name="ledRectangle">The rectangle representing the physical location of the LED.</param>
|
||||||
/// <param name="ledRectangle">The rectangle representing the physical location of the <see cref="CorsairLed"/>.</param>
|
internal CorsairLed(CorsairLedId id, RectangleF ledRectangle)
|
||||||
internal CorsairLed(ICueDevice device, CorsairLedId id, RectangleF ledRectangle)
|
|
||||||
{
|
{
|
||||||
this.Device = device;
|
|
||||||
this.Id = id;
|
this.Id = id;
|
||||||
this.LedRectangle = ledRectangle;
|
this.LedRectangle = ledRectangle;
|
||||||
}
|
}
|
||||||
@ -82,15 +73,6 @@ namespace CUE.NET.Devices.Generic
|
|||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Converts the Id and the <see cref="Color"/> of this <see cref="CorsairLed"/> to a human-readable string.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A string that contains the Id and the <see cref="Color"/> of this <see cref="CorsairLed"/>. For example "Enter [A: 255, R: 255, G: 0, B: 0]".</returns>
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
return $"{Id} {Color}";
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Updates the LED to the requested color.
|
/// Updates the LED to the requested color.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -110,27 +92,5 @@ namespace CUE.NET.Devices.Generic
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Operators
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Converts a <see cref="CorsairLed" /> to a <see cref="CorsairLedId" />.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="led">The <see cref="CorsairLed"/> to convert.</param>
|
|
||||||
public static implicit operator CorsairLedId(CorsairLed led)
|
|
||||||
{
|
|
||||||
return led?.Id ?? CorsairLedId.Invalid;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Converts a <see cref="CorsairLed" /> to a <see cref="CorsairColor" />.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="led">The <see cref="CorsairLed"/> to convert.</param>
|
|
||||||
public static implicit operator CorsairColor(CorsairLed led)
|
|
||||||
{
|
|
||||||
return led?.Color;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
// ReSharper disable InconsistentNaming
|
// ReSharper disable InconsistentNaming
|
||||||
// ReSharper disable UnusedMember.Global
|
// ReSharper disable UnusedMember.Global
|
||||||
|
|
||||||
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
|
|
||||||
|
|
||||||
namespace CUE.NET.Devices.Generic.Enums
|
namespace CUE.NET.Devices.Generic.Enums
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
// ReSharper disable InconsistentNaming
|
// ReSharper disable InconsistentNaming
|
||||||
// ReSharper disable UnusedMember.Global
|
// ReSharper disable UnusedMember.Global
|
||||||
|
|
||||||
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
|
|
||||||
|
|
||||||
namespace CUE.NET.Devices.Generic.Enums
|
namespace CUE.NET.Devices.Generic.Enums
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -10,12 +8,10 @@ namespace CUE.NET.Devices.Generic.Enums
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public enum CorsairDeviceType
|
public enum CorsairDeviceType
|
||||||
{
|
{
|
||||||
|
|
||||||
Unknown = 0,
|
Unknown = 0,
|
||||||
Mouse = 1,
|
Mouse = 1,
|
||||||
Keyboard = 2,
|
Keyboard = 2,
|
||||||
Headset = 3,
|
Headset = 3,
|
||||||
Mousemat = 4,
|
Mousemat = 4
|
||||||
HeadsetStand = 5
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,46 +0,0 @@
|
|||||||
// ReSharper disable InconsistentNaming
|
|
||||||
|
|
||||||
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
|
|
||||||
|
|
||||||
namespace CUE.NET.Devices.Generic.Enums
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Contains list of all KeyIds available for all corsair devices.
|
|
||||||
/// </summary>
|
|
||||||
public enum CorsairKeyId
|
|
||||||
{
|
|
||||||
Invalid = 0,
|
|
||||||
|
|
||||||
G1 = 1,
|
|
||||||
G2 = 2,
|
|
||||||
G3 = 3,
|
|
||||||
G4 = 4,
|
|
||||||
G5 = 5,
|
|
||||||
G6 = 6,
|
|
||||||
G7 = 7,
|
|
||||||
G8 = 8,
|
|
||||||
G9 = 9,
|
|
||||||
G10 = 10,
|
|
||||||
G11 = 11,
|
|
||||||
G12 = 12,
|
|
||||||
G13 = 13,
|
|
||||||
G14 = 14,
|
|
||||||
G15 = 15,
|
|
||||||
G16 = 16,
|
|
||||||
G17 = 17,
|
|
||||||
G18 = 18,
|
|
||||||
|
|
||||||
M1 = 19,
|
|
||||||
M2 = 20,
|
|
||||||
M3 = 21,
|
|
||||||
M4 = 22,
|
|
||||||
M5 = 23,
|
|
||||||
M6 = 24,
|
|
||||||
M7 = 25,
|
|
||||||
M8 = 26,
|
|
||||||
M9 = 27,
|
|
||||||
M10 = 28,
|
|
||||||
M11 = 29,
|
|
||||||
M12 = 30,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,7 +1,5 @@
|
|||||||
// ReSharper disable InconsistentNaming
|
// ReSharper disable InconsistentNaming
|
||||||
|
|
||||||
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
|
|
||||||
|
|
||||||
namespace CUE.NET.Devices.Generic.Enums
|
namespace CUE.NET.Devices.Generic.Enums
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -162,8 +160,6 @@ namespace CUE.NET.Devices.Generic.Enums
|
|||||||
B2 = 149,
|
B2 = 149,
|
||||||
B3 = 150,
|
B3 = 150,
|
||||||
B4 = 151,
|
B4 = 151,
|
||||||
B5 = 189,
|
|
||||||
B6 = 190,
|
|
||||||
|
|
||||||
LeftLogo = 152,
|
LeftLogo = 152,
|
||||||
RightLogo = 153,
|
RightLogo = 153,
|
||||||
@ -184,36 +180,6 @@ namespace CUE.NET.Devices.Generic.Enums
|
|||||||
Zone12 = 166,
|
Zone12 = 166,
|
||||||
Zone13 = 167,
|
Zone13 = 167,
|
||||||
Zone14 = 168,
|
Zone14 = 168,
|
||||||
Zone15 = 169,
|
Zone15 = 169
|
||||||
|
|
||||||
Lightbar1 = 170,
|
|
||||||
Lightbar2 = 171,
|
|
||||||
Lightbar3 = 172,
|
|
||||||
Lightbar4 = 173,
|
|
||||||
Lightbar5 = 174,
|
|
||||||
Lightbar6 = 175,
|
|
||||||
Lightbar7 = 176,
|
|
||||||
Lightbar8 = 177,
|
|
||||||
Lightbar9 = 178,
|
|
||||||
Lightbar10 = 179,
|
|
||||||
Lightbar11 = 180,
|
|
||||||
Lightbar12 = 181,
|
|
||||||
Lightbar13 = 182,
|
|
||||||
Lightbar14 = 183,
|
|
||||||
Lightbar15 = 184,
|
|
||||||
Lightbar16 = 185,
|
|
||||||
Lightbar17 = 186,
|
|
||||||
Lightbar18 = 187,
|
|
||||||
Lightbar19 = 188,
|
|
||||||
|
|
||||||
HeadsetStandZone1 = 191,
|
|
||||||
HeadsetStandZone2 = 192,
|
|
||||||
HeadsetStandZone3 = 193,
|
|
||||||
HeadsetStandZone4 = 194,
|
|
||||||
HeadsetStandZone5 = 195,
|
|
||||||
HeadsetStandZone6 = 196,
|
|
||||||
HeadsetStandZone7 = 197,
|
|
||||||
HeadsetStandZone8 = 198,
|
|
||||||
HeadsetStandZone9 = 199,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@ using System;
|
|||||||
namespace CUE.NET.Devices.Generic.EventArgs
|
namespace CUE.NET.Devices.Generic.EventArgs
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents the information supplied with an <see cref="ICueDevice.Exception"/>-event.
|
/// Represents the information supplied with an Exception-event.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ExceptionEventArgs : System.EventArgs
|
public class ExceptionEventArgs : System.EventArgs
|
||||||
{
|
{
|
||||||
|
|||||||
@ -5,26 +5,16 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace CUE.NET.Devices.Generic.EventArgs
|
namespace CUE.NET.Devices.Generic.EventArgs
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Represents the information supplied with an <see cref="ICueDevice.LedsUpdated"/>-event.
|
|
||||||
/// </summary>
|
|
||||||
public class LedsUpdatedEventArgs : System.EventArgs
|
public class LedsUpdatedEventArgs : System.EventArgs
|
||||||
{
|
{
|
||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets a list of <see cref="LedUpateRequest"/> from the updated leds.
|
|
||||||
/// </summary>
|
|
||||||
public IEnumerable<LedUpateRequest> UpdatedLeds { get; }
|
public IEnumerable<LedUpateRequest> UpdatedLeds { get; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="LedsUpdatedEventArgs"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="updatedLeds">The updated leds.</param>
|
|
||||||
public LedsUpdatedEventArgs(IEnumerable<LedUpateRequest> updatedLeds)
|
public LedsUpdatedEventArgs(IEnumerable<LedUpateRequest> updatedLeds)
|
||||||
{
|
{
|
||||||
this.UpdatedLeds = updatedLeds;
|
this.UpdatedLeds = updatedLeds;
|
||||||
|
|||||||
@ -5,26 +5,16 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace CUE.NET.Devices.Generic.EventArgs
|
namespace CUE.NET.Devices.Generic.EventArgs
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Represents the information supplied with an <see cref="ICueDevice.LedsUpdating"/>-event.
|
|
||||||
/// </summary>
|
|
||||||
public class LedsUpdatingEventArgs : System.EventArgs
|
public class LedsUpdatingEventArgs : System.EventArgs
|
||||||
{
|
{
|
||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets a list of <see cref="LedUpateRequest"/> from the updating leds.
|
|
||||||
/// </summary>
|
|
||||||
public ICollection<LedUpateRequest> UpdatingLeds { get; }
|
public ICollection<LedUpateRequest> UpdatingLeds { get; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="LedsUpdatingEventArgs"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="updatingLeds">The updating leds.</param>
|
|
||||||
public LedsUpdatingEventArgs(ICollection<LedUpateRequest> updatingLeds)
|
public LedsUpdatingEventArgs(ICollection<LedUpateRequest> updatingLeds)
|
||||||
{
|
{
|
||||||
this.UpdatingLeds = updatingLeds;
|
this.UpdatingLeds = updatingLeds;
|
||||||
|
|||||||
@ -1,8 +1,5 @@
|
|||||||
namespace CUE.NET.Devices.Generic.EventArgs
|
namespace CUE.NET.Devices.Generic.EventArgs
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Represents the information supplied with an <see cref="ICueDevice.Updated"/>-event.
|
|
||||||
/// </summary>
|
|
||||||
public class UpdatedEventArgs : System.EventArgs
|
public class UpdatedEventArgs : System.EventArgs
|
||||||
{ }
|
{ }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,26 +3,16 @@
|
|||||||
|
|
||||||
namespace CUE.NET.Devices.Generic.EventArgs
|
namespace CUE.NET.Devices.Generic.EventArgs
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Represents the information supplied with an <see cref="ICueDevice.Updating"/>-event.
|
|
||||||
/// </summary>
|
|
||||||
public class UpdatingEventArgs : System.EventArgs
|
public class UpdatingEventArgs : System.EventArgs
|
||||||
{
|
{
|
||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the elapsed time (in seconds) sonce the last update.
|
|
||||||
/// </summary>
|
|
||||||
public float DeltaTime { get; }
|
public float DeltaTime { get; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="UpdatingEventArgs"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="deltaTime">The elapsed time (in seconds) sonce the last update.</param>
|
|
||||||
public UpdatingEventArgs(float deltaTime)
|
public UpdatingEventArgs(float deltaTime)
|
||||||
{
|
{
|
||||||
this.DeltaTime = deltaTime;
|
this.DeltaTime = deltaTime;
|
||||||
|
|||||||
@ -45,8 +45,6 @@ namespace CUE.NET.Devices.Headset
|
|||||||
{
|
{
|
||||||
InitializeLed(CorsairHeadsetLedId.LeftLogo, new RectangleF(0, 0, 1, 1));
|
InitializeLed(CorsairHeadsetLedId.LeftLogo, new RectangleF(0, 0, 1, 1));
|
||||||
InitializeLed(CorsairHeadsetLedId.RightLogo, new RectangleF(1, 0, 1, 1));
|
InitializeLed(CorsairHeadsetLedId.RightLogo, new RectangleF(1, 0, 1, 1));
|
||||||
|
|
||||||
base.Initialize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
// ReSharper disable UnusedMember.Global
|
// ReSharper disable UnusedMember.Global
|
||||||
// ReSharper disable InconsistentNaming
|
// ReSharper disable InconsistentNaming
|
||||||
|
|
||||||
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
|
|
||||||
|
|
||||||
using CUE.NET.Devices.Generic.Enums;
|
using CUE.NET.Devices.Generic.Enums;
|
||||||
|
|
||||||
namespace CUE.NET.Devices.Headset.Enums
|
namespace CUE.NET.Devices.Headset.Enums
|
||||||
|
|||||||
@ -1,91 +0,0 @@
|
|||||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
|
||||||
// ReSharper disable MemberCanBePrivate.Global
|
|
||||||
// ReSharper disable UnusedMember.Global
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using CUE.NET.Devices.Generic;
|
|
||||||
using CUE.NET.Devices.Generic.Enums;
|
|
||||||
using CUE.NET.Exceptions;
|
|
||||||
using CUE.NET.Native;
|
|
||||||
|
|
||||||
namespace CUE.NET.Devices.HeadsetStand
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Represents the SDK for a corsair headset stand.
|
|
||||||
/// </summary>
|
|
||||||
public class CorsairHeadsetStand : AbstractCueDevice
|
|
||||||
{
|
|
||||||
#region Properties & Fields
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets specific information provided by CUE for the headset stand.
|
|
||||||
/// </summary>
|
|
||||||
public CorsairHeadsetStandDeviceInfo HeadsetStandDeviceInfo { get; }
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Constructors
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="CorsairHeadsetStand"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="info">The specific information provided by CUE for the headset stand</param>
|
|
||||||
internal CorsairHeadsetStand(CorsairHeadsetStandDeviceInfo info)
|
|
||||||
: base(info)
|
|
||||||
{
|
|
||||||
this.HeadsetStandDeviceInfo = info;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Methods
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes the headset stand.
|
|
||||||
/// </summary>
|
|
||||||
public override void Initialize()
|
|
||||||
{
|
|
||||||
int deviceCount = _CUESDK.CorsairGetDeviceCount();
|
|
||||||
|
|
||||||
// Get headset stand device index
|
|
||||||
int headsetStandIndex = -1;
|
|
||||||
for (int i = 0; i < deviceCount; i++)
|
|
||||||
{
|
|
||||||
_CorsairDeviceInfo nativeDeviceInfo = (_CorsairDeviceInfo)Marshal.PtrToStructure(_CUESDK.CorsairGetDeviceInfo(i), typeof(_CorsairDeviceInfo));
|
|
||||||
GenericDeviceInfo info = new GenericDeviceInfo(nativeDeviceInfo);
|
|
||||||
if (info.Type != CorsairDeviceType.HeadsetStand)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
headsetStandIndex = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (headsetStandIndex < 0)
|
|
||||||
throw new WrapperException("Can't determine headset stand device index");
|
|
||||||
|
|
||||||
_CorsairLedPositions nativeLedPositions = (_CorsairLedPositions)Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositionsByDeviceIndex(headsetStandIndex), typeof(_CorsairLedPositions));
|
|
||||||
int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition));
|
|
||||||
IntPtr ptr = nativeLedPositions.pLedPosition;
|
|
||||||
|
|
||||||
// Put the positions in an array for sorting later on
|
|
||||||
List<_CorsairLedPosition> positions = new List<_CorsairLedPosition>();
|
|
||||||
for (int i = 0; i < nativeLedPositions.numberOfLed; i++)
|
|
||||||
{
|
|
||||||
_CorsairLedPosition ledPosition = (_CorsairLedPosition)Marshal.PtrToStructure(ptr, typeof(_CorsairLedPosition));
|
|
||||||
ptr = new IntPtr(ptr.ToInt64() + structSize);
|
|
||||||
positions.Add(ledPosition);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sort for easy iteration by clients
|
|
||||||
foreach (_CorsairLedPosition ledPosition in positions.OrderBy(p => p.ledId))
|
|
||||||
InitializeLed(ledPosition.ledId, new RectangleF((float)ledPosition.left, (float)ledPosition.top, (float)ledPosition.width, (float)ledPosition.height));
|
|
||||||
|
|
||||||
base.Initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,26 +0,0 @@
|
|||||||
// ReSharper disable MemberCanBePrivate.Global
|
|
||||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
|
||||||
|
|
||||||
using CUE.NET.Devices.Generic;
|
|
||||||
using CUE.NET.Native;
|
|
||||||
|
|
||||||
namespace CUE.NET.Devices.HeadsetStand
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Represents specific information for a CUE headset stand.
|
|
||||||
/// </summary>
|
|
||||||
public class CorsairHeadsetStandDeviceInfo : GenericDeviceInfo
|
|
||||||
{
|
|
||||||
#region Constructors
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Internal constructor of managed <see cref="CorsairHeadsetStandDeviceInfo" />.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="nativeInfo">The native <see cref="_CorsairDeviceInfo" />-struct</param>
|
|
||||||
internal CorsairHeadsetStandDeviceInfo(_CorsairDeviceInfo nativeInfo)
|
|
||||||
: base(nativeInfo)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,26 +0,0 @@
|
|||||||
// ReSharper disable UnusedMember.Global
|
|
||||||
// ReSharper disable InconsistentNaming
|
|
||||||
|
|
||||||
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
|
|
||||||
|
|
||||||
using CUE.NET.Devices.Generic.Enums;
|
|
||||||
|
|
||||||
namespace CUE.NET.Devices.HeadsetStand.Enums
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Contains list of all LEDs available for corsair headset stands.
|
|
||||||
/// </summary>
|
|
||||||
public static class CorsairHeadsetStandLedId
|
|
||||||
{
|
|
||||||
public const CorsairLedId Invalid = CorsairLedId.Invalid;
|
|
||||||
public const CorsairLedId HeadsetStandZone1 = CorsairLedId.HeadsetStandZone1;
|
|
||||||
public const CorsairLedId HeadsetStandZone2 = CorsairLedId.HeadsetStandZone2;
|
|
||||||
public const CorsairLedId HeadsetStandZone3 = CorsairLedId.HeadsetStandZone3;
|
|
||||||
public const CorsairLedId HeadsetStandZone4 = CorsairLedId.HeadsetStandZone4;
|
|
||||||
public const CorsairLedId HeadsetStandZone5 = CorsairLedId.HeadsetStandZone5;
|
|
||||||
public const CorsairLedId HeadsetStandZone6 = CorsairLedId.HeadsetStandZone6;
|
|
||||||
public const CorsairLedId HeadsetStandZone7 = CorsairLedId.HeadsetStandZone7;
|
|
||||||
public const CorsairLedId HeadsetStandZone8 = CorsairLedId.HeadsetStandZone8;
|
|
||||||
public const CorsairLedId HeadsetStandZone9 = CorsairLedId.HeadsetStandZone9;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -140,26 +140,10 @@ namespace CUE.NET.Devices
|
|||||||
void Initialize();
|
void Initialize();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Performs an update for all dirty keys, or all keys if flushLeds is set to true.
|
/// Perform an update for all dirty keys, or all keys if flushLeds is set to true.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="flushLeds">Specifies whether all keys (including clean ones) should be updated.</param>
|
/// <param name="flushLeds">Specifies whether all keys (including clean ones) should be updated.</param>
|
||||||
/// <param name="noRender">Only updates the hardware-leds skippin effects and the render-pass. Only use this if you know what that means!</param>
|
void Update(bool flushLeds = false);
|
||||||
void Update(bool flushLeds = false, bool noRender = false);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Reads the currently active colors from the device and sync them with the internal state.
|
|
||||||
/// </summary>
|
|
||||||
void SyncColors();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Saves the currently active colors from the device.
|
|
||||||
/// </summary>
|
|
||||||
void SaveColors();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Restores the last saved colors.
|
|
||||||
/// </summary>
|
|
||||||
void RestoreColors();
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Attaches the given ledgroup.
|
/// Attaches the given ledgroup.
|
||||||
|
|||||||
@ -7,7 +7,6 @@ using System;
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using CUE.NET.Devices.Generic;
|
using CUE.NET.Devices.Generic;
|
||||||
using CUE.NET.Devices.Generic.Enums;
|
|
||||||
using CUE.NET.Native;
|
using CUE.NET.Native;
|
||||||
|
|
||||||
namespace CUE.NET.Devices.Keyboard
|
namespace CUE.NET.Devices.Keyboard
|
||||||
@ -24,26 +23,6 @@ namespace CUE.NET.Devices.Keyboard
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public CorsairKeyboardDeviceInfo KeyboardDeviceInfo { get; }
|
public CorsairKeyboardDeviceInfo KeyboardDeviceInfo { get; }
|
||||||
|
|
||||||
#region Indexers
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the <see cref="CorsairLed" /> representing the given character by calling the SDK-method 'CorsairGetLedIdForKeyName'.<br />
|
|
||||||
/// Note that this currently only works for letters.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="key">The character of the key.</param>
|
|
||||||
/// <returns>The led representing the given character or null if no led is found.</returns>
|
|
||||||
public CorsairLed this[char key]
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
CorsairLedId ledId = _CUESDK.CorsairGetLedIdForKeyName(key);
|
|
||||||
CorsairLed led;
|
|
||||||
return LedMapping.TryGetValue(ledId, out led) ? led : null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
@ -77,8 +56,6 @@ namespace CUE.NET.Devices.Keyboard
|
|||||||
|
|
||||||
ptr = new IntPtr(ptr.ToInt64() + structSize);
|
ptr = new IntPtr(ptr.ToInt64() + structSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
base.Initialize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
namespace CUE.NET.Devices.Keyboard.Enums
|
namespace CUE.NET.Devices.Keyboard.Enums
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Contains a list of all brush calculation modes.
|
/// Contains list of all brush calculation modes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public enum BrushCalculationMode
|
public enum BrushCalculationMode
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,36 +0,0 @@
|
|||||||
// ReSharper disable UnusedMember.Global
|
|
||||||
// ReSharper disable InconsistentNaming
|
|
||||||
|
|
||||||
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
|
|
||||||
|
|
||||||
using CUE.NET.Devices.Generic.Enums;
|
|
||||||
|
|
||||||
namespace CUE.NET.Devices.Keyboard.Enums
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Contains list of all LEDs available for corsair keyboards.
|
|
||||||
/// </summary>
|
|
||||||
public static class CorsairKeyboardKeyId
|
|
||||||
{
|
|
||||||
public const CorsairKeyId Invalid = CorsairKeyId.Invalid;
|
|
||||||
|
|
||||||
public const CorsairKeyId G1 = CorsairKeyId.G1;
|
|
||||||
public const CorsairKeyId G2 = CorsairKeyId.G2;
|
|
||||||
public const CorsairKeyId G3 = CorsairKeyId.G3;
|
|
||||||
public const CorsairKeyId G4 = CorsairKeyId.G4;
|
|
||||||
public const CorsairKeyId G5 = CorsairKeyId.G5;
|
|
||||||
public const CorsairKeyId G6 = CorsairKeyId.G6;
|
|
||||||
public const CorsairKeyId G7 = CorsairKeyId.G7;
|
|
||||||
public const CorsairKeyId G8 = CorsairKeyId.G8;
|
|
||||||
public const CorsairKeyId G9 = CorsairKeyId.G9;
|
|
||||||
public const CorsairKeyId G10 = CorsairKeyId.G10;
|
|
||||||
public const CorsairKeyId G11 = CorsairKeyId.G11;
|
|
||||||
public const CorsairKeyId G12 = CorsairKeyId.G12;
|
|
||||||
public const CorsairKeyId G13 = CorsairKeyId.G13;
|
|
||||||
public const CorsairKeyId G14 = CorsairKeyId.G14;
|
|
||||||
public const CorsairKeyId G15 = CorsairKeyId.G15;
|
|
||||||
public const CorsairKeyId G16 = CorsairKeyId.G16;
|
|
||||||
public const CorsairKeyId G17 = CorsairKeyId.G17;
|
|
||||||
public const CorsairKeyId G18 = CorsairKeyId.G18;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,8 +1,6 @@
|
|||||||
// ReSharper disable UnusedMember.Global
|
// ReSharper disable UnusedMember.Global
|
||||||
// ReSharper disable InconsistentNaming
|
// ReSharper disable InconsistentNaming
|
||||||
|
|
||||||
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
|
|
||||||
|
|
||||||
using CUE.NET.Devices.Generic.Enums;
|
using CUE.NET.Devices.Generic.Enums;
|
||||||
|
|
||||||
namespace CUE.NET.Devices.Keyboard.Enums
|
namespace CUE.NET.Devices.Keyboard.Enums
|
||||||
@ -161,24 +159,5 @@ namespace CUE.NET.Devices.Keyboard.Enums
|
|||||||
public const CorsairLedId International4 = CorsairLedId.International4;
|
public const CorsairLedId International4 = CorsairLedId.International4;
|
||||||
public const CorsairLedId Fn = CorsairLedId.Fn;
|
public const CorsairLedId Fn = CorsairLedId.Fn;
|
||||||
public const CorsairLedId Logo = CorsairLedId.Logo;
|
public const CorsairLedId Logo = CorsairLedId.Logo;
|
||||||
public const CorsairLedId Lightbar1 = CorsairLedId.Lightbar1;
|
|
||||||
public const CorsairLedId Lightbar2 = CorsairLedId.Lightbar2;
|
|
||||||
public const CorsairLedId Lightbar3 = CorsairLedId.Lightbar3;
|
|
||||||
public const CorsairLedId Lightbar4 = CorsairLedId.Lightbar4;
|
|
||||||
public const CorsairLedId Lightbar5 = CorsairLedId.Lightbar5;
|
|
||||||
public const CorsairLedId Lightbar6 = CorsairLedId.Lightbar6;
|
|
||||||
public const CorsairLedId Lightbar7 = CorsairLedId.Lightbar7;
|
|
||||||
public const CorsairLedId Lightbar8 = CorsairLedId.Lightbar8;
|
|
||||||
public const CorsairLedId Lightbar9 = CorsairLedId.Lightbar9;
|
|
||||||
public const CorsairLedId Lightbar10 = CorsairLedId.Lightbar10;
|
|
||||||
public const CorsairLedId Lightbar11 = CorsairLedId.Lightbar11;
|
|
||||||
public const CorsairLedId Lightbar12 = CorsairLedId.Lightbar12;
|
|
||||||
public const CorsairLedId Lightbar13 = CorsairLedId.Lightbar13;
|
|
||||||
public const CorsairLedId Lightbar14 = CorsairLedId.Lightbar14;
|
|
||||||
public const CorsairLedId Lightbar15 = CorsairLedId.Lightbar15;
|
|
||||||
public const CorsairLedId Lightbar16 = CorsairLedId.Lightbar16;
|
|
||||||
public const CorsairLedId Lightbar17 = CorsairLedId.Lightbar17;
|
|
||||||
public const CorsairLedId Lightbar18 = CorsairLedId.Lightbar18;
|
|
||||||
public const CorsairLedId Lightbar19 = CorsairLedId.Lightbar19;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
// ReSharper disable InconsistentNaming
|
// ReSharper disable InconsistentNaming
|
||||||
// ReSharper disable UnusedMember.Global
|
// ReSharper disable UnusedMember.Global
|
||||||
|
|
||||||
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
|
|
||||||
|
|
||||||
namespace CUE.NET.Devices.Keyboard.Enums
|
namespace CUE.NET.Devices.Keyboard.Enums
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -2,16 +2,10 @@
|
|||||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
// ReSharper disable UnusedMember.Global
|
// ReSharper disable UnusedMember.Global
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using CUE.NET.Devices.Generic;
|
using CUE.NET.Devices.Generic;
|
||||||
using CUE.NET.Devices.Generic.Enums;
|
|
||||||
using CUE.NET.Devices.Mouse.Enums;
|
using CUE.NET.Devices.Mouse.Enums;
|
||||||
using CUE.NET.Exceptions;
|
using CUE.NET.Exceptions;
|
||||||
using CUE.NET.Native;
|
|
||||||
|
|
||||||
namespace CUE.NET.Devices.Mouse
|
namespace CUE.NET.Devices.Mouse
|
||||||
{
|
{
|
||||||
@ -50,14 +44,6 @@ namespace CUE.NET.Devices.Mouse
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
// Glaive is a special flake that doesn't follow the default layout
|
|
||||||
if (MouseDeviceInfo.Model == "GLAIVE RGB")
|
|
||||||
{
|
|
||||||
InitializeLed(CorsairMouseLedId.B1, new RectangleF(0, 0, 1, 1)); // Logo
|
|
||||||
InitializeLed(CorsairMouseLedId.B2, new RectangleF(2, 0, 1, 1)); // Front
|
|
||||||
InitializeLed(CorsairMouseLedId.B5, new RectangleF(3, 0, 1, 1)); // Sides
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
switch (MouseDeviceInfo.PhysicalLayout)
|
switch (MouseDeviceInfo.PhysicalLayout)
|
||||||
{
|
{
|
||||||
case CorsairPhysicalMouseLayout.Zones1:
|
case CorsairPhysicalMouseLayout.Zones1:
|
||||||
@ -81,8 +67,6 @@ namespace CUE.NET.Devices.Mouse
|
|||||||
default:
|
default:
|
||||||
throw new WrapperException($"Can't initial mouse with layout '{MouseDeviceInfo.PhysicalLayout}'");
|
throw new WrapperException($"Can't initial mouse with layout '{MouseDeviceInfo.PhysicalLayout}'");
|
||||||
}
|
}
|
||||||
|
|
||||||
base.Initialize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -1,30 +0,0 @@
|
|||||||
// ReSharper disable UnusedMember.Global
|
|
||||||
// ReSharper disable InconsistentNaming
|
|
||||||
|
|
||||||
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
|
|
||||||
|
|
||||||
using CUE.NET.Devices.Generic.Enums;
|
|
||||||
|
|
||||||
namespace CUE.NET.Devices.Mouse.Enums
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Contains list of all LEDs available for corsair mice.
|
|
||||||
/// </summary>
|
|
||||||
public static class CorsairMouseKeyId
|
|
||||||
{
|
|
||||||
public const CorsairKeyId Invalid = CorsairKeyId.Invalid;
|
|
||||||
|
|
||||||
public const CorsairKeyId M1 = CorsairKeyId.M1;
|
|
||||||
public const CorsairKeyId M2 = CorsairKeyId.M2;
|
|
||||||
public const CorsairKeyId M3 = CorsairKeyId.M3;
|
|
||||||
public const CorsairKeyId M4 = CorsairKeyId.M4;
|
|
||||||
public const CorsairKeyId M5 = CorsairKeyId.M5;
|
|
||||||
public const CorsairKeyId M6 = CorsairKeyId.M6;
|
|
||||||
public const CorsairKeyId M7 = CorsairKeyId.M7;
|
|
||||||
public const CorsairKeyId M8 = CorsairKeyId.M8;
|
|
||||||
public const CorsairKeyId M9 = CorsairKeyId.M9;
|
|
||||||
public const CorsairKeyId M10 = CorsairKeyId.M10;
|
|
||||||
public const CorsairKeyId M11 = CorsairKeyId.M11;
|
|
||||||
public const CorsairKeyId M12 = CorsairKeyId.M12;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,8 +1,6 @@
|
|||||||
// ReSharper disable UnusedMember.Global
|
// ReSharper disable UnusedMember.Global
|
||||||
// ReSharper disable InconsistentNaming
|
// ReSharper disable InconsistentNaming
|
||||||
|
|
||||||
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
|
|
||||||
|
|
||||||
using CUE.NET.Devices.Generic.Enums;
|
using CUE.NET.Devices.Generic.Enums;
|
||||||
|
|
||||||
namespace CUE.NET.Devices.Mouse.Enums
|
namespace CUE.NET.Devices.Mouse.Enums
|
||||||
@ -17,7 +15,5 @@ namespace CUE.NET.Devices.Mouse.Enums
|
|||||||
public const CorsairLedId B2 = CorsairLedId.B2;
|
public const CorsairLedId B2 = CorsairLedId.B2;
|
||||||
public const CorsairLedId B3 = CorsairLedId.B3;
|
public const CorsairLedId B3 = CorsairLedId.B3;
|
||||||
public const CorsairLedId B4 = CorsairLedId.B4;
|
public const CorsairLedId B4 = CorsairLedId.B4;
|
||||||
public const CorsairLedId B5 = CorsairLedId.B5;
|
|
||||||
public const CorsairLedId B6 = CorsairLedId.B6;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -82,8 +82,6 @@ namespace CUE.NET.Devices.Mousemat
|
|||||||
// Sort for easy iteration by clients
|
// Sort for easy iteration by clients
|
||||||
foreach (_CorsairLedPosition ledPosition in positions.OrderBy(p => p.ledId))
|
foreach (_CorsairLedPosition ledPosition in positions.OrderBy(p => p.ledId))
|
||||||
InitializeLed(ledPosition.ledId, new RectangleF((float)ledPosition.left, (float)ledPosition.top, (float)ledPosition.width, (float)ledPosition.height));
|
InitializeLed(ledPosition.ledId, new RectangleF((float)ledPosition.left, (float)ledPosition.top, (float)ledPosition.width, (float)ledPosition.height));
|
||||||
|
|
||||||
base.Initialize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
// ReSharper disable UnusedMember.Global
|
// ReSharper disable UnusedMember.Global
|
||||||
// ReSharper disable InconsistentNaming
|
// ReSharper disable InconsistentNaming
|
||||||
|
|
||||||
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
|
|
||||||
|
|
||||||
using CUE.NET.Devices.Generic.Enums;
|
using CUE.NET.Devices.Generic.Enums;
|
||||||
|
|
||||||
namespace CUE.NET.Devices.Mousemat.Enums
|
namespace CUE.NET.Devices.Mousemat.Enums
|
||||||
|
|||||||
@ -16,15 +16,12 @@ namespace CUE.NET.Effects
|
|||||||
{
|
{
|
||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|
||||||
/// <summary>
|
protected IList<EffectTimeContainer> EffectTimes = new List<EffectTimeContainer>();
|
||||||
/// Gets a list of <see cref="EffectTimeContainer"/> storing the attached effects.
|
|
||||||
/// </summary>
|
|
||||||
protected IList<EffectTimeContainer> EffectTimes { get; } = new List<EffectTimeContainer>();
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets all <see cref="IEffect{T}" /> attached to this target.
|
/// Gets all <see cref="IEffect{T}" /> attached to this target.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IList<IEffect<T>> Effects => EffectTimes.Select(x => x.Effect).Cast<IEffect<T>>().ToList();
|
protected IList<IEffect<T>> Effects => EffectTimes.Select(x => x.Effect).Cast<IEffect<T>>().ToList();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the strongly-typed target used for the effect.
|
/// Gets the strongly-typed target used for the effect.
|
||||||
|
|||||||
@ -16,26 +16,26 @@ namespace CUE.NET.Effects
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the attack-time (in seconds) of the effect. (default: 0.2f)<br />
|
/// Gets or sets the attack-time (in seconds) of the effect. (default: 0.2f)<br />
|
||||||
/// This is close to a synthesizer envelope. (See <see href="http://en.wikipedia.org/wiki/Synthesizer#ADSR_envelope" /> as reference)
|
/// This is close to a synthesizer envelope. (See <see cref="http://en.wikipedia.org/wiki/Synthesizer#ADSR_envelope" /> as reference)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float Attack { get; set; } = 0.2f;
|
public float Attack { get; set; } = 0.2f;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the decay-time (in seconds) of the effect. (default: 0f)<br />
|
/// Gets or sets the decay-time (in seconds) of the effect. (default: 0f)<br />
|
||||||
/// This is close to a synthesizer envelope. (See <see href="http://en.wikipedia.org/wiki/Synthesizer#ADSR_envelope" /> as reference)
|
/// This is close to a synthesizer envelope. (See <see cref="http://en.wikipedia.org/wiki/Synthesizer#ADSR_envelope" /> as reference)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float Decay { get; set; } = 0f;
|
public float Decay { get; set; } = 0f;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the sustain-time (in seconds) of the effect. (default: 0.3f)<br />
|
/// Gets or sets the sustain-time (in seconds) of the effect. (default: 0.3f)<br />
|
||||||
/// This is close to a synthesizer envelope. (See <see href="http://en.wikipedia.org/wiki/Synthesizer#ADSR_envelope" /> as reference)<br />
|
/// This is close to a synthesizer envelope. (See <see cref="http://en.wikipedia.org/wiki/Synthesizer#ADSR_envelope" /> as reference)<br />
|
||||||
/// Note that this value for naming reasons represents the time NOT the level.
|
/// Note that this value for naming reasons represents the time NOT the level.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float Sustain { get; set; } = 0.3f;
|
public float Sustain { get; set; } = 0.3f;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the release-time (in seconds) of the effect. (default: 0.2f)<br />
|
/// Gets or sets the release-time (in seconds) of the effect. (default: 0.2f)<br />
|
||||||
/// This is close to a synthesizer envelope. (See <see href="http://en.wikipedia.org/wiki/Synthesizer#ADSR_envelope" /> as reference)
|
/// This is close to a synthesizer envelope. (See <see cref="http://en.wikipedia.org/wiki/Synthesizer#ADSR_envelope" /> as reference)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float Release { get; set; } = 0.2f;
|
public float Release { get; set; } = 0.2f;
|
||||||
|
|
||||||
@ -76,7 +76,6 @@ namespace CUE.NET.Effects
|
|||||||
_currentPhaseValue -= deltaTime;
|
_currentPhaseValue -= deltaTime;
|
||||||
|
|
||||||
// Using ifs instead of a switch allows to skip phases with time 0.
|
// Using ifs instead of a switch allows to skip phases with time 0.
|
||||||
// ReSharper disable InvertIf
|
|
||||||
|
|
||||||
if (_currentPhase == ADSRPhase.Attack)
|
if (_currentPhase == ADSRPhase.Attack)
|
||||||
if (_currentPhaseValue > 0f)
|
if (_currentPhaseValue > 0f)
|
||||||
@ -124,8 +123,6 @@ namespace CUE.NET.Effects
|
|||||||
_currentPhaseValue = Attack;
|
_currentPhaseValue = Attack;
|
||||||
_currentPhase = ADSRPhase.Attack;
|
_currentPhase = ADSRPhase.Attack;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReSharper restore InvertIf
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -1,25 +1,14 @@
|
|||||||
// ReSharper disable UnusedMember.Global
|
// ReSharper disable UnusedMember.Global
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace CUE.NET.Effects
|
namespace CUE.NET.Effects
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a basic effect-target.
|
/// Represents a basic effect-target.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T">The type this target represents.</typeparam>
|
/// <typeparam name="T">The type this target represents.</typeparam>
|
||||||
public interface IEffectTarget<T>
|
public interface IEffectTarget<out T>
|
||||||
where T : IEffectTarget<T>
|
where T : IEffectTarget<T>
|
||||||
{
|
{
|
||||||
#region Properties & Fields
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets a list of all active effects of this target.
|
|
||||||
/// </summary>
|
|
||||||
IList<IEffect<T>> Effects { get; }
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -1,102 +0,0 @@
|
|||||||
using CUE.NET.Brushes;
|
|
||||||
using CUE.NET.Gradients;
|
|
||||||
|
|
||||||
namespace CUE.NET.Effects
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Represents an effect which allows to move an gradient by modifying his offset.
|
|
||||||
/// </summary>
|
|
||||||
public class MoveGradientEffect : AbstractBrushEffect<IGradientBrush>
|
|
||||||
{
|
|
||||||
#region Properties & Fields
|
|
||||||
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global
|
|
||||||
// ReSharper disable MemberCanBePrivate.Global
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the direction the gradient is moved.
|
|
||||||
/// True leads to an offset-increment (normaly moving to the right), false to an offset-decrement (normaly moving to the left).
|
|
||||||
/// </summary>
|
|
||||||
public bool Direction { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the speed of the movement in units per second.
|
|
||||||
/// The meaning of units differs for the different gradients, but 360 units will always be one complete cycle:
|
|
||||||
/// LinearGradient: 360 unit = 1 offset.
|
|
||||||
/// RainbowGradient: 1 unit = 1 degree.
|
|
||||||
/// </summary>
|
|
||||||
public float Speed { get; set; }
|
|
||||||
|
|
||||||
// ReSharper restore MemberCanBePrivate.Global
|
|
||||||
// ReSharper restore AutoPropertyCanBeMadeGetOnly.Global
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Constructors
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="speed"></param>
|
|
||||||
/// <param name="direction"></param>
|
|
||||||
public MoveGradientEffect(float speed = 180f, bool direction = true)
|
|
||||||
{
|
|
||||||
this.Speed = speed;
|
|
||||||
this.Direction = direction;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Methods
|
|
||||||
/// <summary>
|
|
||||||
/// Updates the effect.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="deltaTime">The elapsed time (in seconds) since the last update.</param>
|
|
||||||
public override void Update(float deltaTime)
|
|
||||||
{
|
|
||||||
float movement = Speed * deltaTime;
|
|
||||||
|
|
||||||
if (!Direction)
|
|
||||||
movement = -movement;
|
|
||||||
|
|
||||||
// ReSharper disable once CanBeReplacedWithTryCastAndCheckForNull
|
|
||||||
if (Brush.Gradient is LinearGradient)
|
|
||||||
{
|
|
||||||
LinearGradient linearGradient = (LinearGradient)Brush.Gradient;
|
|
||||||
|
|
||||||
movement /= 360f;
|
|
||||||
|
|
||||||
foreach (GradientStop gradientStop in linearGradient.GradientStops)
|
|
||||||
{
|
|
||||||
gradientStop.Offset = gradientStop.Offset + movement;
|
|
||||||
|
|
||||||
if (gradientStop.Offset > 1f)
|
|
||||||
gradientStop.Offset -= 1f;
|
|
||||||
else if (gradientStop.Offset < 0)
|
|
||||||
gradientStop.Offset += 1f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (Brush.Gradient is RainbowGradient)
|
|
||||||
{
|
|
||||||
RainbowGradient rainbowGradient = (RainbowGradient)Brush.Gradient;
|
|
||||||
|
|
||||||
// RainbowGradient is calculated inverse but the movement should be the same for all.
|
|
||||||
movement *= -1;
|
|
||||||
|
|
||||||
rainbowGradient.StartHue += movement;
|
|
||||||
rainbowGradient.EndHue += movement;
|
|
||||||
|
|
||||||
if (rainbowGradient.StartHue > 360f && rainbowGradient.EndHue > 360f)
|
|
||||||
{
|
|
||||||
rainbowGradient.StartHue -= 360f;
|
|
||||||
rainbowGradient.EndHue -= 360f;
|
|
||||||
}
|
|
||||||
else if (rainbowGradient.StartHue < -360f && rainbowGradient.EndHue < -360f)
|
|
||||||
{
|
|
||||||
rainbowGradient.StartHue += 360f;
|
|
||||||
rainbowGradient.EndHue += 360f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,41 +0,0 @@
|
|||||||
// ReSharper disable MemberCanBePrivate.Global
|
|
||||||
|
|
||||||
using CUE.NET.Devices.Generic.Enums;
|
|
||||||
|
|
||||||
namespace CUE.NET.EventArgs
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Represents the data provided by the <see cref="CueSDK.KeyPressed"/>-event.
|
|
||||||
/// </summary>
|
|
||||||
public class KeyPressedEventArgs : System.EventArgs
|
|
||||||
{
|
|
||||||
#region Properties & Fields
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the id of the key.
|
|
||||||
/// </summary>
|
|
||||||
public CorsairKeyId KeyId { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the current status of the key (true = pressed, flase = released).
|
|
||||||
/// </summary>
|
|
||||||
public bool IsPressed { get; }
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Constructors
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="KeyPressedEventArgs"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="keyId">The id of the key.</param>
|
|
||||||
/// <param name="isPressed">The current status of the key (true = pressed, flase = released).</param>
|
|
||||||
public KeyPressedEventArgs(CorsairKeyId keyId, bool isPressed)
|
|
||||||
{
|
|
||||||
this.KeyId = keyId;
|
|
||||||
this.IsPressed = isPressed;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,99 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Drawing;
|
|
||||||
using CUE.NET.Brushes;
|
|
||||||
using CUE.NET.ColorCorrection;
|
|
||||||
using CUE.NET.Devices.Generic;
|
|
||||||
using CUE.NET.Helper;
|
|
||||||
using Example_Ambilight_full.TakeAsIs;
|
|
||||||
using Example_Ambilight_full.TakeAsIs.Model;
|
|
||||||
using Example_Ambilight_full.TakeAsIs.Model.Extensions;
|
|
||||||
using Example_Ambilight_full.TakeAsIs.ScreenCapturing;
|
|
||||||
|
|
||||||
namespace Example_Ambilight_full
|
|
||||||
{
|
|
||||||
public abstract class AbstractAmbilightBrush : AbstractBrush
|
|
||||||
{
|
|
||||||
#region Properties & Fields
|
|
||||||
|
|
||||||
protected readonly IScreenCapture ScreenCapture;
|
|
||||||
protected readonly AmbilightSettings Settings;
|
|
||||||
|
|
||||||
protected byte[] ScreenPixelData;
|
|
||||||
|
|
||||||
protected int SourceWidth;
|
|
||||||
protected int SourceHeight;
|
|
||||||
|
|
||||||
protected int OffsetLeft;
|
|
||||||
protected int OffsetRight;
|
|
||||||
protected int OffsetTop;
|
|
||||||
protected int OffsetBottom;
|
|
||||||
|
|
||||||
protected int EffectiveSourceWidth;
|
|
||||||
protected int EffectiveSourceHeight;
|
|
||||||
|
|
||||||
protected int Increment;
|
|
||||||
protected float KeyWidthProportion;
|
|
||||||
protected float KeyHeightProportion;
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Constructors
|
|
||||||
|
|
||||||
public AbstractAmbilightBrush(IScreenCapture screenCapture, AmbilightSettings settings)
|
|
||||||
{
|
|
||||||
this.ScreenCapture = screenCapture;
|
|
||||||
this.Settings = settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Methods
|
|
||||||
|
|
||||||
public override void PerformRender(RectangleF rectangle, IEnumerable<BrushRenderTarget> renderTargets)
|
|
||||||
{
|
|
||||||
ScreenPixelData = ScreenCapture.CaptureScreen();
|
|
||||||
|
|
||||||
SourceWidth = ScreenCapture.Width;
|
|
||||||
SourceHeight = ScreenCapture.Height;
|
|
||||||
|
|
||||||
OffsetLeft = Settings.OffsetLeft + (Settings.BlackBarDetectionMode.HasFlag(BlackBarDetectionMode.Left)
|
|
||||||
? ScreenPixelData.DetectBlackBarLeft(SourceWidth, SourceHeight, Settings.OffsetLeft, Settings.OffsetRight, Settings.OffsetTop, Settings.OffsetBottom)
|
|
||||||
: 0);
|
|
||||||
OffsetRight = Settings.OffsetRight + (Settings.BlackBarDetectionMode.HasFlag(BlackBarDetectionMode.Right)
|
|
||||||
? ScreenPixelData.DetectBlackBarRight(SourceWidth, SourceHeight, Settings.OffsetLeft, Settings.OffsetRight, Settings.OffsetTop, Settings.OffsetBottom)
|
|
||||||
: 0);
|
|
||||||
OffsetTop = Settings.OffsetTop + (Settings.BlackBarDetectionMode.HasFlag(BlackBarDetectionMode.Top)
|
|
||||||
? ScreenPixelData.DetectBlackBarTop(SourceWidth, SourceHeight, Settings.OffsetLeft, Settings.OffsetRight, Settings.OffsetTop, Settings.OffsetBottom)
|
|
||||||
: 0);
|
|
||||||
OffsetBottom = Settings.OffsetBottom + (Settings.BlackBarDetectionMode.HasFlag(BlackBarDetectionMode.Bottom)
|
|
||||||
? ScreenPixelData.DetectBlackBarBottom(SourceWidth, SourceHeight, Settings.OffsetLeft, Settings.OffsetRight, Settings.OffsetTop, Settings.OffsetBottom)
|
|
||||||
: 0);
|
|
||||||
|
|
||||||
EffectiveSourceWidth = SourceWidth - OffsetLeft - OffsetRight;
|
|
||||||
EffectiveSourceHeight = (int)Math.Round((SourceHeight - OffsetTop - OffsetBottom) * (Settings.MirroredAmount / 100.0));
|
|
||||||
|
|
||||||
Increment = Math.Max(1, Math.Min(20, Settings.Downsampling));
|
|
||||||
|
|
||||||
KeyWidthProportion = EffectiveSourceWidth / rectangle.Width;
|
|
||||||
KeyHeightProportion = EffectiveSourceHeight / rectangle.Height;
|
|
||||||
|
|
||||||
Opacity = Settings.SmoothMode == SmoothMode.Low ? 0.25f : (Settings.SmoothMode == SmoothMode.Medium ? 0.075f : (Settings.SmoothMode == SmoothMode.High ? 0.025f : 1f /*None*/));
|
|
||||||
|
|
||||||
base.PerformRender(rectangle, renderTargets);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override CorsairColor FinalizeColor(CorsairColor color)
|
|
||||||
{
|
|
||||||
// Apply our gamma-correction
|
|
||||||
((GammaCorrection)Settings.Gamma).ApplyTo(color);
|
|
||||||
|
|
||||||
float lightness = (float)Math.Max((Settings.MinLightness / 100.0), (color.GetHSVValue() * ((double)Brightness < 0.0 ? 0.0f : ((double)Brightness > 1.0 ? 1f : Brightness))));
|
|
||||||
byte alpha = (byte)((double)color.A * ((double)Opacity < 0.0 ? 0.0 : ((double)Opacity > 1.0 ? 1.0 : (double)Opacity)));
|
|
||||||
|
|
||||||
return ColorHelper.ColorFromHSV(color.GetHSVHue(), color.GetHSVSaturation(), lightness, alpha);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,68 +0,0 @@
|
|||||||
using System.Drawing;
|
|
||||||
using CUE.NET;
|
|
||||||
using CUE.NET.Brushes;
|
|
||||||
using CUE.NET.Devices.Generic.Enums;
|
|
||||||
using Example_Ambilight_full.TakeAsIs;
|
|
||||||
using Example_Ambilight_full.TakeAsIs.Model;
|
|
||||||
using Example_Ambilight_full.TakeAsIs.ScreenCapturing;
|
|
||||||
|
|
||||||
namespace Example_Ambilight_full
|
|
||||||
{
|
|
||||||
public class Ambilight
|
|
||||||
{
|
|
||||||
#region Properties & Fields
|
|
||||||
|
|
||||||
private readonly IScreenCapture _screenCapture;
|
|
||||||
private readonly AmbilightSettings _settings;
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Constructors
|
|
||||||
|
|
||||||
public Ambilight(IScreenCapture screenCapture, AmbilightSettings settings)
|
|
||||||
{
|
|
||||||
this._screenCapture = screenCapture;
|
|
||||||
this._settings = settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Methods
|
|
||||||
|
|
||||||
public bool Initialize()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
CueSDK.Initialize();
|
|
||||||
CueSDK.UpdateMode = UpdateMode.Continuous;
|
|
||||||
CueSDK.UpdateFrequency = 1f / _settings.UpdateRate;
|
|
||||||
|
|
||||||
SetAmbilightBrush();
|
|
||||||
_settings.AmbienceCreatorTypeChanged += (sender, args) => SetAmbilightBrush();
|
|
||||||
}
|
|
||||||
catch { return false; }
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SetAmbilightBrush()
|
|
||||||
{
|
|
||||||
IBrush ambilightBrush;
|
|
||||||
switch (_settings.AmbienceCreatorType)
|
|
||||||
{
|
|
||||||
case AmbienceCreatorType.Mirror:
|
|
||||||
ambilightBrush = new AmbilightMirrorBrush(_screenCapture, _settings);
|
|
||||||
break;
|
|
||||||
case AmbienceCreatorType.Extend:
|
|
||||||
ambilightBrush = new AmbilightExtendBrush(_screenCapture, _settings);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ambilightBrush = new SolidColorBrush(Color.Black);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
CueSDK.KeyboardSDK.Brush = ambilightBrush;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,58 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Drawing;
|
|
||||||
using CUE.NET.Brushes;
|
|
||||||
using CUE.NET.Devices.Generic;
|
|
||||||
using Example_Ambilight_full.TakeAsIs;
|
|
||||||
using Example_Ambilight_full.TakeAsIs.Model;
|
|
||||||
using Example_Ambilight_full.TakeAsIs.ScreenCapturing;
|
|
||||||
|
|
||||||
namespace Example_Ambilight_full
|
|
||||||
{
|
|
||||||
public class AmbilightExtendBrush : AbstractAmbilightBrush
|
|
||||||
{
|
|
||||||
#region Constructors
|
|
||||||
|
|
||||||
public AmbilightExtendBrush(IScreenCapture screenCapture, AmbilightSettings settings)
|
|
||||||
: base(screenCapture, settings)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Methods
|
|
||||||
|
|
||||||
protected override CorsairColor GetColorAtPoint(RectangleF rectangle, BrushRenderTarget renderTarget)
|
|
||||||
{
|
|
||||||
float keyWidth = renderTarget.Rectangle.Width;
|
|
||||||
|
|
||||||
int widthPixels = Math.Max(1, (int)(KeyWidthProportion * keyWidth));
|
|
||||||
|
|
||||||
int r = 0;
|
|
||||||
int g = 0;
|
|
||||||
int b = 0;
|
|
||||||
int counter = 0;
|
|
||||||
|
|
||||||
int widthOffset = Settings.FlipMode.HasFlag(FlipMode.Horizontal)
|
|
||||||
? (int)((SourceWidth - OffsetRight) - (KeyWidthProportion * (renderTarget.Point.X + (keyWidth / 2f))))
|
|
||||||
: (int)(OffsetLeft + (KeyWidthProportion * (renderTarget.Point.X - (keyWidth / 2f))));
|
|
||||||
int heightOffset = SourceHeight - OffsetBottom - EffectiveSourceHeight; // DarthAffe 05.11.2016: Vertical flipping doesn't mather in Extend-Mode
|
|
||||||
|
|
||||||
// DarthAffe 06.11.2016: Validate offsets - rounding errors might cause problems (heightOffset is safe calculated -> no need to validate)
|
|
||||||
widthOffset = Math.Max(0, Math.Min(SourceWidth - widthPixels, widthOffset));
|
|
||||||
|
|
||||||
for (int y = 0; y < EffectiveSourceHeight; y += Increment)
|
|
||||||
for (int x = 0; x < widthPixels; x += Increment)
|
|
||||||
{
|
|
||||||
int offset = ((((heightOffset + y) * SourceWidth) + widthOffset + x) * 4);
|
|
||||||
|
|
||||||
b += ScreenPixelData[offset];
|
|
||||||
g += ScreenPixelData[offset + 1];
|
|
||||||
r += ScreenPixelData[offset + 2];
|
|
||||||
counter++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new CorsairColor((byte)(r / counter), (byte)(g / counter), (byte)(b / counter));
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,63 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Drawing;
|
|
||||||
using CUE.NET.Brushes;
|
|
||||||
using CUE.NET.Devices.Generic;
|
|
||||||
using Example_Ambilight_full.TakeAsIs;
|
|
||||||
using Example_Ambilight_full.TakeAsIs.Model;
|
|
||||||
using Example_Ambilight_full.TakeAsIs.ScreenCapturing;
|
|
||||||
|
|
||||||
namespace Example_Ambilight_full
|
|
||||||
{
|
|
||||||
public class AmbilightMirrorBrush : AbstractAmbilightBrush
|
|
||||||
{
|
|
||||||
#region Constructors
|
|
||||||
|
|
||||||
public AmbilightMirrorBrush(IScreenCapture screenCapture, AmbilightSettings settings)
|
|
||||||
: base(screenCapture, settings)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Methods
|
|
||||||
|
|
||||||
protected override CorsairColor GetColorAtPoint(RectangleF rectangle, BrushRenderTarget renderTarget)
|
|
||||||
{
|
|
||||||
float keyWidth = renderTarget.Rectangle.Width;
|
|
||||||
float keyHeight = renderTarget.Rectangle.Height;
|
|
||||||
|
|
||||||
int widthPixels = Math.Max(1, (int)(KeyWidthProportion * keyWidth));
|
|
||||||
int heightPixels = Math.Max(1, (int)(KeyHeightProportion * keyHeight));
|
|
||||||
|
|
||||||
int r = 0;
|
|
||||||
int g = 0;
|
|
||||||
int b = 0;
|
|
||||||
int counter = 0;
|
|
||||||
|
|
||||||
int widthOffset = Settings.FlipMode.HasFlag(FlipMode.Horizontal)
|
|
||||||
? ((SourceWidth - OffsetRight) - (int)(KeyWidthProportion * (renderTarget.Point.X + (keyWidth / 2f))))
|
|
||||||
: (OffsetLeft + (int)(KeyWidthProportion * (renderTarget.Point.X - (keyWidth / 2f))));
|
|
||||||
int heightOffset = Settings.FlipMode.HasFlag(FlipMode.Vertical)
|
|
||||||
? ((SourceHeight - OffsetBottom) - (int)(KeyHeightProportion * (renderTarget.Point.Y + (keyHeight / 2f))))
|
|
||||||
: ((SourceHeight - OffsetBottom - EffectiveSourceHeight) + (int)(KeyHeightProportion * (renderTarget.Point.Y - (keyHeight / 2f))));
|
|
||||||
|
|
||||||
// DarthAffe 06.11.2016: Validate offsets - rounding errors might cause problems
|
|
||||||
widthOffset = Math.Max(0, Math.Min(SourceWidth - widthPixels, widthOffset));
|
|
||||||
heightOffset = Math.Max(0, Math.Min(SourceHeight - heightPixels, heightOffset));
|
|
||||||
|
|
||||||
for (int y = 0; y < heightPixels; y += Increment)
|
|
||||||
for (int x = 0; x < widthPixels; x += Increment)
|
|
||||||
{
|
|
||||||
int offset = ((((heightOffset + y) * SourceWidth) + widthOffset + x) * 4);
|
|
||||||
|
|
||||||
b += ScreenPixelData[offset];
|
|
||||||
g += ScreenPixelData[offset + 1];
|
|
||||||
r += ScreenPixelData[offset + 2];
|
|
||||||
counter++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new CorsairColor((byte)(r / counter), (byte)(g / counter), (byte)(b / counter));
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<configuration>
|
|
||||||
<startup>
|
|
||||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
|
|
||||||
</startup>
|
|
||||||
</configuration>
|
|
||||||
@ -1,17 +0,0 @@
|
|||||||
<Application x:Class="Example_Ambilight_full.App"
|
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
|
||||||
|
|
||||||
<Application.Resources>
|
|
||||||
<ResourceDictionary>
|
|
||||||
<ResourceDictionary.MergedDictionaries>
|
|
||||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
|
|
||||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
|
|
||||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
|
|
||||||
|
|
||||||
<ResourceDictionary Source="TakeAsIs/UI/Taskbar.xaml" />
|
|
||||||
</ResourceDictionary.MergedDictionaries>
|
|
||||||
</ResourceDictionary>
|
|
||||||
</Application.Resources>
|
|
||||||
|
|
||||||
</Application>
|
|
||||||
@ -1,67 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Windows;
|
|
||||||
using Example_Ambilight_full.TakeAsIs;
|
|
||||||
using Example_Ambilight_full.TakeAsIs.Helper;
|
|
||||||
using Example_Ambilight_full.TakeAsIs.ScreenCapturing;
|
|
||||||
using Example_Ambilight_full.TakeAsIs.UI;
|
|
||||||
using Hardcodet.Wpf.TaskbarNotification;
|
|
||||||
|
|
||||||
namespace Example_Ambilight_full
|
|
||||||
{
|
|
||||||
public partial class App : Application
|
|
||||||
{
|
|
||||||
#region Constants
|
|
||||||
|
|
||||||
private const string PATH_SETTINGS = "Settings.xaml";
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Properties & Fields
|
|
||||||
|
|
||||||
private TaskbarIcon _taskBar;
|
|
||||||
private AmbilightSettings _settings;
|
|
||||||
private Ambilight _ambilight;
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Methods
|
|
||||||
|
|
||||||
protected override void OnStartup(StartupEventArgs e)
|
|
||||||
{
|
|
||||||
base.OnStartup(e);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_settings = SerializationHelper.LoadObjectFromFile<AmbilightSettings>(PATH_SETTINGS) ??
|
|
||||||
new AmbilightSettings();
|
|
||||||
IScreenCapture screenCapture = new DX9ScreenCapture();
|
|
||||||
|
|
||||||
// DarthAffe 05.11.2016: This could be done way cleaner ...
|
|
||||||
_taskBar = FindResource("Taskbar") as TaskbarIcon;
|
|
||||||
FrameworkElement configView = _taskBar?.TrayPopup as ConfigView;
|
|
||||||
if (configView == null)
|
|
||||||
Shutdown();
|
|
||||||
else
|
|
||||||
configView.DataContext = new ConfigViewModel(_settings);
|
|
||||||
|
|
||||||
_ambilight = new Ambilight(screenCapture, _settings);
|
|
||||||
if (!_ambilight.Initialize())
|
|
||||||
throw new ApplicationException();
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
MessageBox.Show("An error occured while starting the Keyboard-Ambilight.\r\nPlease double check if CUE is running and 'Enable SDK' is checked.", "Can't start Keyboard-Ambilight");
|
|
||||||
Shutdown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnExit(ExitEventArgs e)
|
|
||||||
{
|
|
||||||
base.OnExit(e);
|
|
||||||
|
|
||||||
SerializationHelper.SaveObjectToFile(_settings, PATH_SETTINGS);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,169 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
|
||||||
<PropertyGroup>
|
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
|
||||||
<ProjectGuid>{6D7BAF89-A705-4FFA-A3A2-AF93EC3A909C}</ProjectGuid>
|
|
||||||
<OutputType>WinExe</OutputType>
|
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
|
||||||
<RootNamespace>Example_Ambilight_full</RootNamespace>
|
|
||||||
<AssemblyName>Example_Ambilight_full</AssemblyName>
|
|
||||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
|
||||||
<FileAlignment>512</FileAlignment>
|
|
||||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
|
||||||
<TargetFrameworkProfile />
|
|
||||||
<NuGetPackageImportStamp>
|
|
||||||
</NuGetPackageImportStamp>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
|
||||||
<DebugSymbols>true</DebugSymbols>
|
|
||||||
<DebugType>full</DebugType>
|
|
||||||
<Optimize>false</Optimize>
|
|
||||||
<OutputPath>bin\Debug\</OutputPath>
|
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
|
||||||
<DebugType>pdbonly</DebugType>
|
|
||||||
<Optimize>true</Optimize>
|
|
||||||
<OutputPath>bin\Release\</OutputPath>
|
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup>
|
|
||||||
<ApplicationIcon>Resources\ambilight.ico</ApplicationIcon>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="CUE.NET, Version=1.1.3.0, Culture=neutral, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\..\..\packages\CUE.NET.1.1.3.0\lib\net45\CUE.NET.dll</HintPath>
|
|
||||||
<Private>True</Private>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Hardcodet.Wpf.TaskbarNotification, Version=1.0.5.0, Culture=neutral, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\..\..\packages\Hardcodet.NotifyIcon.Wpf.1.0.8\lib\net45\Hardcodet.Wpf.TaskbarNotification.dll</HintPath>
|
|
||||||
<Private>True</Private>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="MahApps.Metro, Version=1.4.0.0, Culture=neutral, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\..\..\packages\MahApps.Metro.1.4.0-ALPHA026\lib\net45\MahApps.Metro.dll</HintPath>
|
|
||||||
<Private>True</Private>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="SharpDX, Version=3.1.1.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\..\..\packages\SharpDX.3.1.1\lib\net45\SharpDX.dll</HintPath>
|
|
||||||
<Private>True</Private>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="SharpDX.Direct3D9, Version=3.1.1.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\..\..\packages\SharpDX.Direct3D9.3.1.1\lib\net45\SharpDX.Direct3D9.dll</HintPath>
|
|
||||||
<Private>True</Private>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="System" />
|
|
||||||
<Reference Include="System.Data" />
|
|
||||||
<Reference Include="System.Drawing" />
|
|
||||||
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\..\..\packages\MahApps.Metro.1.4.0-ALPHA026\lib\net45\System.Windows.Interactivity.dll</HintPath>
|
|
||||||
<Private>True</Private>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="System.Xml" />
|
|
||||||
<Reference Include="Microsoft.CSharp" />
|
|
||||||
<Reference Include="System.Core" />
|
|
||||||
<Reference Include="System.Xml.Linq" />
|
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
|
||||||
<Reference Include="System.Net.Http" />
|
|
||||||
<Reference Include="System.Xaml">
|
|
||||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="WindowsBase" />
|
|
||||||
<Reference Include="PresentationCore" />
|
|
||||||
<Reference Include="PresentationFramework" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ApplicationDefinition Include="App.xaml">
|
|
||||||
<Generator>MSBuild:Compile</Generator>
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
</ApplicationDefinition>
|
|
||||||
<Compile Include="Ambilight.cs" />
|
|
||||||
<Compile Include="AbstractAmbilightBrush.cs" />
|
|
||||||
<Compile Include="AmbilightExtendBrush.cs" />
|
|
||||||
<Compile Include="AmbilightMirrorBrush.cs" />
|
|
||||||
<Compile Include="App.xaml.cs">
|
|
||||||
<DependentUpon>App.xaml</DependentUpon>
|
|
||||||
<SubType>Code</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="TakeAsIs\AmbilightSettings.cs" />
|
|
||||||
<Compile Include="TakeAsIs\Helper\CheckboxEnumFlagHelper.cs" />
|
|
||||||
<Compile Include="TakeAsIs\Helper\SerializationHelper.cs" />
|
|
||||||
<Compile Include="TakeAsIs\Model\AmbienceCreatorType.cs" />
|
|
||||||
<Compile Include="TakeAsIs\Model\BlackBarDetectionMode.cs" />
|
|
||||||
<Compile Include="TakeAsIs\Model\Extensions\EnumExtension.cs" />
|
|
||||||
<Compile Include="TakeAsIs\Model\Extensions\PixelDataExtension.cs" />
|
|
||||||
<Compile Include="TakeAsIs\Model\FlipMode.cs" />
|
|
||||||
<Compile Include="TakeAsIs\Model\SmoothMode.cs" />
|
|
||||||
<Compile Include="TakeAsIs\ScreenCapturing\DX9ScreenCapture.cs" />
|
|
||||||
<Compile Include="TakeAsIs\ScreenCapturing\IScreenCapture.cs" />
|
|
||||||
<Compile Include="TakeAsIs\UI\ActionCommand.cs" />
|
|
||||||
<Compile Include="TakeAsIs\UI\ConfigViewModel.cs" />
|
|
||||||
<Compile Include="TakeAsIs\UI\ConfigView.xaml.cs">
|
|
||||||
<DependentUpon>ConfigView.xaml</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="TakeAsIs\UI\EnumDescriptionConverter.cs" />
|
|
||||||
<Page Include="TakeAsIs\UI\ConfigView.xaml">
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
<Generator>MSBuild:Compile</Generator>
|
|
||||||
</Page>
|
|
||||||
<Page Include="TakeAsIs\UI\Taskbar.xaml">
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
<Generator>MSBuild:Compile</Generator>
|
|
||||||
</Page>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Include="Properties\AssemblyInfo.cs">
|
|
||||||
<SubType>Code</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Properties\Resources.Designer.cs">
|
|
||||||
<AutoGen>True</AutoGen>
|
|
||||||
<DesignTime>True</DesignTime>
|
|
||||||
<DependentUpon>Resources.resx</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Properties\Settings.Designer.cs">
|
|
||||||
<AutoGen>True</AutoGen>
|
|
||||||
<DependentUpon>Settings.settings</DependentUpon>
|
|
||||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
|
||||||
</Compile>
|
|
||||||
<EmbeddedResource Include="Properties\Resources.resx">
|
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
|
||||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
|
||||||
</EmbeddedResource>
|
|
||||||
<None Include="packages.config" />
|
|
||||||
<None Include="Properties\Settings.settings">
|
|
||||||
<Generator>SettingsSingleFileGenerator</Generator>
|
|
||||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
|
||||||
</None>
|
|
||||||
<AppDesigner Include="Properties\" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="App.config" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Resource Include="Resources\ambilight.ico" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
|
||||||
<Import Project="..\..\..\packages\CUE.NET.1.1.3.0\build\net45\CUE.NET.targets" Condition="Exists('..\..\..\packages\CUE.NET.1.1.3.0\build\net45\CUE.NET.targets')" />
|
|
||||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
|
||||||
<PropertyGroup>
|
|
||||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Error Condition="!Exists('..\..\..\packages\CUE.NET.1.1.3.0\build\net45\CUE.NET.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\CUE.NET.1.1.3.0\build\net45\CUE.NET.targets'))" />
|
|
||||||
</Target>
|
|
||||||
<!-- 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.
|
|
||||||
<Target Name="BeforeBuild">
|
|
||||||
</Target>
|
|
||||||
<Target Name="AfterBuild">
|
|
||||||
</Target>
|
|
||||||
-->
|
|
||||||
</Project>
|
|
||||||
@ -1,53 +0,0 @@
|
|||||||
using System.Reflection;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Windows;
|
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
|
||||||
// set of attributes. Change these attribute values to modify the information
|
|
||||||
// associated with an assembly.
|
|
||||||
[assembly: AssemblyTitle("Example_Ambilight_full")]
|
|
||||||
[assembly: AssemblyDescription("")]
|
|
||||||
[assembly: AssemblyConfiguration("")]
|
|
||||||
[assembly: AssemblyCompany("")]
|
|
||||||
[assembly: AssemblyProduct("Example_Ambilight_full")]
|
|
||||||
[assembly: AssemblyCopyright("Copyright © Wyrez 2017")]
|
|
||||||
[assembly: AssemblyTrademark("")]
|
|
||||||
[assembly: AssemblyCulture("")]
|
|
||||||
|
|
||||||
// Setting ComVisible to false makes the types in this assembly not visible
|
|
||||||
// to COM components. If you need to access a type in this assembly from
|
|
||||||
// COM, set the ComVisible attribute to true on that type.
|
|
||||||
[assembly: ComVisible(false)]
|
|
||||||
|
|
||||||
//In order to begin building localizable applications, set
|
|
||||||
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
|
|
||||||
//inside a <PropertyGroup>. For example, if you are using US english
|
|
||||||
//in your source files, set the <UICulture> to en-US. Then uncomment
|
|
||||||
//the NeutralResourceLanguage attribute below. Update the "en-US" in
|
|
||||||
//the line below to match the UICulture setting in the project file.
|
|
||||||
|
|
||||||
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
|
||||||
|
|
||||||
|
|
||||||
[assembly: ThemeInfo(
|
|
||||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
|
||||||
//(used if a resource is not found in the page,
|
|
||||||
// or application resource dictionaries)
|
|
||||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
|
||||||
//(used if a resource is not found in the page,
|
|
||||||
// app, or any theme specific resource dictionaries)
|
|
||||||
)]
|
|
||||||
|
|
||||||
|
|
||||||
// Version information for an assembly consists of the following four values:
|
|
||||||
//
|
|
||||||
// Major Version
|
|
||||||
// Minor Version
|
|
||||||
// Build Number
|
|
||||||
// Revision
|
|
||||||
//
|
|
||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
|
||||||
// by using the '*' as shown below:
|
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
|
||||||
[assembly: AssemblyVersion("1.0.1.3")]
|
|
||||||
[assembly: AssemblyFileVersion("1.0.1.3")]
|
|
||||||
@ -1,63 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
// <auto-generated>
|
|
||||||
// This code was generated by a tool.
|
|
||||||
// Runtime Version:4.0.30319.42000
|
|
||||||
//
|
|
||||||
// Changes to this file may cause incorrect behavior and will be lost if
|
|
||||||
// the code is regenerated.
|
|
||||||
// </auto-generated>
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
namespace Example_Ambilight_full.Properties {
|
|
||||||
using System;
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
|
||||||
/// </summary>
|
|
||||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
|
||||||
// class via a tool like ResGen or Visual Studio.
|
|
||||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
|
||||||
// with the /str option, or rebuild your VS project.
|
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
|
||||||
internal class Resources {
|
|
||||||
|
|
||||||
private static global::System.Resources.ResourceManager resourceMan;
|
|
||||||
|
|
||||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
|
||||||
|
|
||||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
|
||||||
internal Resources() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns the cached ResourceManager instance used by this class.
|
|
||||||
/// </summary>
|
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
|
||||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
|
||||||
get {
|
|
||||||
if (object.ReferenceEquals(resourceMan, null)) {
|
|
||||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Example_Ambilight_full.Properties.Resources", typeof(Resources).Assembly);
|
|
||||||
resourceMan = temp;
|
|
||||||
}
|
|
||||||
return resourceMan;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Overrides the current thread's CurrentUICulture property for all
|
|
||||||
/// resource lookups using this strongly typed resource class.
|
|
||||||
/// </summary>
|
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
|
||||||
internal static global::System.Globalization.CultureInfo Culture {
|
|
||||||
get {
|
|
||||||
return resourceCulture;
|
|
||||||
}
|
|
||||||
set {
|
|
||||||
resourceCulture = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,117 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
||||||
@ -1,26 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
// <auto-generated>
|
|
||||||
// This code was generated by a tool.
|
|
||||||
// Runtime Version:4.0.30319.42000
|
|
||||||
//
|
|
||||||
// Changes to this file may cause incorrect behavior and will be lost if
|
|
||||||
// the code is regenerated.
|
|
||||||
// </auto-generated>
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
namespace Example_Ambilight_full.Properties {
|
|
||||||
|
|
||||||
|
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
|
|
||||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
|
||||||
|
|
||||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
|
||||||
|
|
||||||
public static Settings Default {
|
|
||||||
get {
|
|
||||||
return defaultInstance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
<?xml version='1.0' encoding='utf-8'?>
|
|
||||||
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
|
|
||||||
<Profiles>
|
|
||||||
<Profile Name="(Default)" />
|
|
||||||
</Profiles>
|
|
||||||
<Settings />
|
|
||||||
</SettingsFile>
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.4 KiB |
@ -1,50 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Example_Ambilight_full.TakeAsIs.Model;
|
|
||||||
|
|
||||||
namespace Example_Ambilight_full.TakeAsIs
|
|
||||||
{
|
|
||||||
public class AmbilightSettings
|
|
||||||
{
|
|
||||||
private AmbienceCreatorType _ambienceCreatorType = AmbienceCreatorType.Mirror;
|
|
||||||
|
|
||||||
#region Properties & Fields
|
|
||||||
|
|
||||||
public AmbienceCreatorType AmbienceCreatorType
|
|
||||||
{
|
|
||||||
get { return _ambienceCreatorType; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
// ReSharper disable once InvertIf
|
|
||||||
if (_ambienceCreatorType != value)
|
|
||||||
{
|
|
||||||
_ambienceCreatorType = value;
|
|
||||||
AmbienceCreatorTypeChanged?.Invoke(this, new EventArgs());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int UpdateRate { get; set; } = 20;
|
|
||||||
public int OffsetLeft { get; set; } = 0;
|
|
||||||
public int OffsetRight { get; set; } = 0;
|
|
||||||
public int OffsetTop { get; set; } = 0;
|
|
||||||
public int OffsetBottom { get; set; } = 0;
|
|
||||||
|
|
||||||
public int Downsampling { get; set; } = 2;
|
|
||||||
public double MirroredAmount { get; set; } = 10;
|
|
||||||
|
|
||||||
public SmoothMode SmoothMode { get; set; } = SmoothMode.Low;
|
|
||||||
public BlackBarDetectionMode BlackBarDetectionMode { get; set; } = BlackBarDetectionMode.Bottom;
|
|
||||||
public FlipMode FlipMode { get; set; } = FlipMode.Vertical;
|
|
||||||
|
|
||||||
public double MinLightness { get; set; } = 0;
|
|
||||||
public float Gamma { get; set; } = 1f;
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Events
|
|
||||||
|
|
||||||
public event EventHandler AmbienceCreatorTypeChanged;
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,93 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Controls;
|
|
||||||
using Example_Ambilight_full.TakeAsIs.Model.Extensions;
|
|
||||||
|
|
||||||
namespace Example_Ambilight_full.TakeAsIs.Helper
|
|
||||||
{
|
|
||||||
public class CheckboxEnumFlagHelper
|
|
||||||
{
|
|
||||||
#region DependencyProperties
|
|
||||||
// ReSharper disable InconsistentNaming
|
|
||||||
|
|
||||||
public static readonly DependencyProperty FlagsProperty = DependencyProperty.RegisterAttached(
|
|
||||||
"Flags", typeof(Enum), typeof(CheckboxEnumFlagHelper), new FrameworkPropertyMetadata(default(Enum), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, FlagsChanged));
|
|
||||||
|
|
||||||
public static void SetFlags(DependencyObject element, Enum value)
|
|
||||||
{
|
|
||||||
element.SetValue(FlagsProperty, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Enum GetFlags(DependencyObject element)
|
|
||||||
{
|
|
||||||
return (Enum)element.GetValue(FlagsProperty);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static readonly DependencyProperty ValueProperty = DependencyProperty.RegisterAttached(
|
|
||||||
"Value", typeof(Enum), typeof(CheckboxEnumFlagHelper), new PropertyMetadata(default(Enum), ValueChanged));
|
|
||||||
|
|
||||||
public static void SetValue(DependencyObject element, Enum value)
|
|
||||||
{
|
|
||||||
element.SetValue(ValueProperty, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Enum GetValue(DependencyObject element)
|
|
||||||
{
|
|
||||||
return (Enum)element.GetValue(ValueProperty);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ReSharper restore InconsistentNaming
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Methods
|
|
||||||
|
|
||||||
private static void FlagsChanged(DependencyObject dependencyObject,
|
|
||||||
DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
|
|
||||||
{
|
|
||||||
UpdateTarget(dependencyObject as CheckBox, dependencyPropertyChangedEventArgs.NewValue as Enum);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void ValueChanged(DependencyObject dependencyObject,
|
|
||||||
DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
|
|
||||||
{
|
|
||||||
CheckBox checkbox = dependencyObject as CheckBox;
|
|
||||||
if (checkbox == null) return;
|
|
||||||
|
|
||||||
checkbox.Checked -= UpdateSource;
|
|
||||||
checkbox.Unchecked -= UpdateSource;
|
|
||||||
|
|
||||||
if (dependencyPropertyChangedEventArgs.NewValue != null)
|
|
||||||
{
|
|
||||||
checkbox.Checked += UpdateSource;
|
|
||||||
checkbox.Unchecked += UpdateSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdateTarget(checkbox, GetFlags(checkbox));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void UpdateTarget(CheckBox checkbox, Enum flags)
|
|
||||||
{
|
|
||||||
if (checkbox == null) return;
|
|
||||||
|
|
||||||
Enum value = GetValue(checkbox);
|
|
||||||
checkbox.IsChecked = value != null && (flags?.HasFlag(value) ?? false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void UpdateSource(object sender, RoutedEventArgs routedEventArgs)
|
|
||||||
{
|
|
||||||
CheckBox checkbox = sender as CheckBox;
|
|
||||||
if (checkbox == null) return;
|
|
||||||
|
|
||||||
Enum flags = GetFlags(checkbox);
|
|
||||||
Enum value = GetValue(checkbox);
|
|
||||||
if (value == null) return;
|
|
||||||
|
|
||||||
if (checkbox.IsChecked ?? false)
|
|
||||||
SetFlags(checkbox, flags == null ? value : flags.SetFlag(value, true, flags.GetType()));
|
|
||||||
else
|
|
||||||
SetFlags(checkbox, flags?.SetFlag(value, false, flags.GetType()));
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,50 +0,0 @@
|
|||||||
using System.IO;
|
|
||||||
using System.Xml;
|
|
||||||
using System.Xml.Serialization;
|
|
||||||
|
|
||||||
namespace Example_Ambilight_full.TakeAsIs.Helper
|
|
||||||
{
|
|
||||||
public static class SerializationHelper
|
|
||||||
{
|
|
||||||
public static void SaveObjectToFile<T>(T serializableObject, string path)
|
|
||||||
{
|
|
||||||
if (serializableObject == null) return;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
XmlDocument xmlDocument = new XmlDocument();
|
|
||||||
XmlSerializer serializer = new XmlSerializer(serializableObject.GetType());
|
|
||||||
using (MemoryStream stream = new MemoryStream())
|
|
||||||
{
|
|
||||||
serializer.Serialize(stream, serializableObject);
|
|
||||||
stream.Seek(0, SeekOrigin.Begin);
|
|
||||||
xmlDocument.Load(stream);
|
|
||||||
xmlDocument.Save(path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch {/* Catch'em all */}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static T LoadObjectFromFile<T>(string fileName)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(fileName)) return default(T);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
XmlDocument xmlDocument = new XmlDocument();
|
|
||||||
xmlDocument.Load(fileName);
|
|
||||||
string xmlString = xmlDocument.OuterXml;
|
|
||||||
|
|
||||||
using (StringReader sr = new StringReader(xmlString))
|
|
||||||
{
|
|
||||||
XmlSerializer serializer = new XmlSerializer(typeof(T));
|
|
||||||
using (XmlReader reader = new XmlTextReader(sr))
|
|
||||||
return (T)serializer.Deserialize(reader);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch {/* Catch'em all */}
|
|
||||||
|
|
||||||
return default(T);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,13 +0,0 @@
|
|||||||
using System.ComponentModel;
|
|
||||||
|
|
||||||
namespace Example_Ambilight_full.TakeAsIs.Model
|
|
||||||
{
|
|
||||||
public enum AmbienceCreatorType
|
|
||||||
{
|
|
||||||
[Description("Mirror")]
|
|
||||||
Mirror,
|
|
||||||
|
|
||||||
[Description("Extend")]
|
|
||||||
Extend
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,14 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace Example_Ambilight_full.TakeAsIs.Model
|
|
||||||
{
|
|
||||||
[Flags]
|
|
||||||
public enum BlackBarDetectionMode
|
|
||||||
{
|
|
||||||
None = 0,
|
|
||||||
Left = 1 << 0,
|
|
||||||
Right = 1 << 1,
|
|
||||||
Top = 1 << 2,
|
|
||||||
Bottom = 1 << 3,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,26 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace Example_Ambilight_full.TakeAsIs.Model.Extensions
|
|
||||||
{
|
|
||||||
public static class EnumExtension
|
|
||||||
{
|
|
||||||
#region Methods
|
|
||||||
|
|
||||||
public static Enum SetFlag(this Enum e, Enum value, bool set, Type t)
|
|
||||||
{
|
|
||||||
if (e == null || value == null || t == null) return e;
|
|
||||||
|
|
||||||
int eValue = Convert.ToInt32(e);
|
|
||||||
int valueValue = Convert.ToInt32(value);
|
|
||||||
|
|
||||||
if (set)
|
|
||||||
eValue |= valueValue;
|
|
||||||
else
|
|
||||||
eValue &= ~valueValue;
|
|
||||||
|
|
||||||
return (Enum)Enum.ToObject(t, eValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,89 +0,0 @@
|
|||||||
namespace Example_Ambilight_full.TakeAsIs.Model.Extensions
|
|
||||||
{
|
|
||||||
public static class PixelDataExtension
|
|
||||||
{
|
|
||||||
#region Methods
|
|
||||||
|
|
||||||
public static int DetectBlackBarLeft(this byte[] pixels, int width, int height, int offsetLeft, int offsetRight, int offsetTop, int offsetBottom)
|
|
||||||
{
|
|
||||||
int bottomBorder = height - offsetBottom;
|
|
||||||
int rightBorder = width - offsetRight;
|
|
||||||
|
|
||||||
int blackBarWidth = 0;
|
|
||||||
for (int x = rightBorder - 1; x >= offsetLeft; x--)
|
|
||||||
{
|
|
||||||
for (int y = offsetTop; y < bottomBorder; y++)
|
|
||||||
{
|
|
||||||
int offset = ((y * width) + x) * 4;
|
|
||||||
if (pixels[offset] > 15 || pixels[offset + 1] > 15 || pixels[offset + 2] > 15)
|
|
||||||
return blackBarWidth;
|
|
||||||
}
|
|
||||||
blackBarWidth++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return width;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int DetectBlackBarRight(this byte[] pixels, int width, int height, int offsetLeft, int offsetRight, int offsetTop, int offsetBottom)
|
|
||||||
{
|
|
||||||
int bottomBorder = height - offsetBottom;
|
|
||||||
int rightBorder = width - offsetRight;
|
|
||||||
|
|
||||||
int blackBarWidth = 0;
|
|
||||||
for (int x = offsetLeft; x < rightBorder; x++)
|
|
||||||
{
|
|
||||||
for (int y = offsetTop; y < bottomBorder; y++)
|
|
||||||
{
|
|
||||||
int offset = ((y * width) + x) * 4;
|
|
||||||
if (pixels[offset] > 15 || pixels[offset + 1] > 15 || pixels[offset + 2] > 15)
|
|
||||||
return blackBarWidth;
|
|
||||||
}
|
|
||||||
blackBarWidth++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return width;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int DetectBlackBarTop(this byte[] pixels, int width, int height, int offsetLeft, int offsetRight, int offsetTop, int offsetBottom)
|
|
||||||
{
|
|
||||||
int bottomBorder = height - offsetBottom;
|
|
||||||
int rightBorder = width - offsetRight;
|
|
||||||
|
|
||||||
int blackBarHeight = 0;
|
|
||||||
for (int y = offsetTop; y < bottomBorder; y++)
|
|
||||||
{
|
|
||||||
for (int x = offsetLeft; x < rightBorder; x++)
|
|
||||||
{
|
|
||||||
int offset = ((y * width) + x) * 4;
|
|
||||||
if (pixels[offset] > 15 || pixels[offset + 1] > 15 || pixels[offset + 2] > 15)
|
|
||||||
return blackBarHeight;
|
|
||||||
}
|
|
||||||
blackBarHeight++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return height;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int DetectBlackBarBottom(this byte[] pixels, int width, int height, int offsetLeft, int offsetRight, int offsetTop, int offsetBottom)
|
|
||||||
{
|
|
||||||
int bottomBorder = height - offsetBottom;
|
|
||||||
int rightBorder = width - offsetRight;
|
|
||||||
|
|
||||||
int blackBarHeight = 0;
|
|
||||||
for (int y = bottomBorder - 1; y >= offsetTop; y--)
|
|
||||||
{
|
|
||||||
for (int x = offsetLeft; x < rightBorder; x++)
|
|
||||||
{
|
|
||||||
int offset = ((y * width) + x) * 4;
|
|
||||||
if (pixels[offset] > 15 || pixels[offset + 1] > 15 || pixels[offset + 2] > 15)
|
|
||||||
return blackBarHeight;
|
|
||||||
}
|
|
||||||
blackBarHeight++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return height;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,12 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace Example_Ambilight_full.TakeAsIs.Model
|
|
||||||
{
|
|
||||||
[Flags]
|
|
||||||
public enum FlipMode
|
|
||||||
{
|
|
||||||
None = 0,
|
|
||||||
Vertical = 1 << 0,
|
|
||||||
Horizontal = 1 << 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,19 +0,0 @@
|
|||||||
using System.ComponentModel;
|
|
||||||
|
|
||||||
namespace Example_Ambilight_full.TakeAsIs.Model
|
|
||||||
{
|
|
||||||
public enum SmoothMode
|
|
||||||
{
|
|
||||||
[Description("None")]
|
|
||||||
None,
|
|
||||||
|
|
||||||
[Description("Low")]
|
|
||||||
Low,
|
|
||||||
|
|
||||||
[Description("Medium")]
|
|
||||||
Medium,
|
|
||||||
|
|
||||||
[Description("High")]
|
|
||||||
High
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,86 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Windows.Media;
|
|
||||||
using Microsoft.Win32;
|
|
||||||
using SharpDX;
|
|
||||||
using SharpDX.Direct3D9;
|
|
||||||
|
|
||||||
namespace Example_Ambilight_full.TakeAsIs.ScreenCapturing
|
|
||||||
{
|
|
||||||
public class DX9ScreenCapture : IScreenCapture
|
|
||||||
{
|
|
||||||
#region Properties & Fields
|
|
||||||
|
|
||||||
private Device _device;
|
|
||||||
private Surface _surface;
|
|
||||||
private byte[] _buffer;
|
|
||||||
|
|
||||||
public int Width { get; }
|
|
||||||
public int Height { get; }
|
|
||||||
public PixelFormat PixelFormat => PixelFormats.Bgr24;
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Constructors
|
|
||||||
|
|
||||||
public DX9ScreenCapture()
|
|
||||||
{
|
|
||||||
Width = (int)System.Windows.SystemParameters.PrimaryScreenWidth;
|
|
||||||
Height = (int)System.Windows.SystemParameters.PrimaryScreenHeight;
|
|
||||||
|
|
||||||
//DarthAffe 08.04.2017: Fix for system using windows-scaling. The primary screen size is reported 'wrong'.
|
|
||||||
double scaling = GetScaling();
|
|
||||||
if (Math.Abs(scaling - 1.0) > 0.01)
|
|
||||||
{
|
|
||||||
Width = (int)(Width / scaling);
|
|
||||||
Height = (int)(Height / scaling);
|
|
||||||
}
|
|
||||||
|
|
||||||
PresentParameters presentParams = new PresentParameters(Width, Height)
|
|
||||||
{
|
|
||||||
Windowed = true,
|
|
||||||
SwapEffect = SwapEffect.Discard
|
|
||||||
};
|
|
||||||
|
|
||||||
_device = new Device(new Direct3D(), 0, DeviceType.Hardware, IntPtr.Zero, CreateFlags.SoftwareVertexProcessing, presentParams);
|
|
||||||
_surface = Surface.CreateOffscreenPlain(_device, Width, Height, Format.A8R8G8B8, Pool.Scratch);
|
|
||||||
_buffer = new byte[Width * Height * 4];
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Methods
|
|
||||||
|
|
||||||
private double GetScaling()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
int currentDpi = (int)Registry.GetValue("HKEY_CURRENT_USER\\Control Panel\\Desktop", "LogPixels", 96);
|
|
||||||
return 96.0 / currentDpi;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
return 1.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] CaptureScreen()
|
|
||||||
{
|
|
||||||
_device.GetFrontBufferData(0, _surface);
|
|
||||||
|
|
||||||
DataRectangle dr = _surface.LockRectangle(LockFlags.None);
|
|
||||||
Marshal.Copy(dr.DataPointer, _buffer, 0, _buffer.Length);
|
|
||||||
_surface.UnlockRectangle();
|
|
||||||
|
|
||||||
return _buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
_device?.Dispose();
|
|
||||||
_surface?.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,18 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Windows.Media;
|
|
||||||
|
|
||||||
namespace Example_Ambilight_full.TakeAsIs.ScreenCapturing
|
|
||||||
{
|
|
||||||
public interface IScreenCapture : IDisposable
|
|
||||||
{
|
|
||||||
int Width { get; }
|
|
||||||
int Height { get; }
|
|
||||||
PixelFormat PixelFormat { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// As Pixel-Data BGRA
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>The Pixel-Data</returns>
|
|
||||||
byte[] CaptureScreen();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,50 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Windows.Input;
|
|
||||||
|
|
||||||
namespace Example_Ambilight_full.TakeAsIs.UI
|
|
||||||
{
|
|
||||||
public class ActionCommand : ICommand
|
|
||||||
{
|
|
||||||
#region Properties & Fields
|
|
||||||
|
|
||||||
private readonly Func<bool> _canExecute;
|
|
||||||
private readonly Action _command;
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Constructors
|
|
||||||
|
|
||||||
public ActionCommand(Action command, Func<bool> canExecute = null)
|
|
||||||
{
|
|
||||||
this._command = command;
|
|
||||||
this._canExecute = canExecute;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Methods
|
|
||||||
|
|
||||||
public bool CanExecute(object parameter)
|
|
||||||
{
|
|
||||||
return _canExecute?.Invoke() ?? true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Execute(object parameter)
|
|
||||||
{
|
|
||||||
_command?.Invoke();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RaiseCanExecuteChanged()
|
|
||||||
{
|
|
||||||
CanExecuteChanged?.Invoke(this, new EventArgs());
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Events
|
|
||||||
|
|
||||||
public event EventHandler CanExecuteChanged;
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,179 +0,0 @@
|
|||||||
<UserControl x:Class="Example_Ambilight_full.TakeAsIs.UI.ConfigView"
|
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
xmlns:helper="clr-namespace:Example_Ambilight_full.TakeAsIs.Helper"
|
|
||||||
xmlns:model="clr-namespace:Example_Ambilight_full.TakeAsIs.Model"
|
|
||||||
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
|
|
||||||
xmlns:system="clr-namespace:System;assembly=mscorlib"
|
|
||||||
xmlns:ui="clr-namespace:Example_Ambilight_full.TakeAsIs.UI">
|
|
||||||
|
|
||||||
<!-- Quick'n'Dirty - you really shouldn't implement a View like this ... -->
|
|
||||||
|
|
||||||
<UserControl.Resources>
|
|
||||||
<ui:EnumDescriptionConverter x:Key="HEnumDescriptionConverter" />
|
|
||||||
|
|
||||||
<ObjectDataProvider x:Key="SmoothModeEnumValues" ObjectType="{x:Type system:Enum}" MethodName="GetValues">
|
|
||||||
<ObjectDataProvider.MethodParameters>
|
|
||||||
<x:Type TypeName="model:SmoothMode" />
|
|
||||||
</ObjectDataProvider.MethodParameters>
|
|
||||||
</ObjectDataProvider>
|
|
||||||
|
|
||||||
<ObjectDataProvider x:Key="AmbienceCreatorTypeValues" ObjectType="{x:Type system:Enum}" MethodName="GetValues">
|
|
||||||
<ObjectDataProvider.MethodParameters>
|
|
||||||
<x:Type TypeName="model:AmbienceCreatorType" />
|
|
||||||
</ObjectDataProvider.MethodParameters>
|
|
||||||
</ObjectDataProvider>
|
|
||||||
|
|
||||||
<Style TargetType="ComboBox" BasedOn="{StaticResource {x:Type ComboBox}}">
|
|
||||||
<Setter Property="VerticalAlignment" Value="Center" />
|
|
||||||
<Setter Property="ItemTemplate">
|
|
||||||
<Setter.Value>
|
|
||||||
<DataTemplate>
|
|
||||||
<TextBlock Text="{Binding Converter={StaticResource HEnumDescriptionConverter}}" />
|
|
||||||
</DataTemplate>
|
|
||||||
</Setter.Value>
|
|
||||||
</Setter>
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<Style TargetType="TextBlock" BasedOn="{StaticResource {x:Type TextBlock}}">
|
|
||||||
<Setter Property="VerticalAlignment" Value="Center" />
|
|
||||||
<Setter Property="Margin" Value="0,0,4,0" />
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<Style TargetType="controls:NumericUpDown" BasedOn="{StaticResource {x:Type controls:NumericUpDown}}">
|
|
||||||
<Setter Property="VerticalAlignment" Value="Center" />
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<Style TargetType="CheckBox" BasedOn="{StaticResource {x:Type CheckBox}}">
|
|
||||||
<Setter Property="VerticalAlignment" Value="Center" />
|
|
||||||
</Style>
|
|
||||||
</UserControl.Resources>
|
|
||||||
|
|
||||||
<Border Padding="16" Background="#CECECE" BorderBrush="#2E2E2E" BorderThickness="2">
|
|
||||||
<Grid>
|
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition Width="Auto" />
|
|
||||||
<ColumnDefinition Width="160" />
|
|
||||||
<ColumnDefinition Width="32" />
|
|
||||||
<ColumnDefinition Width="Auto" />
|
|
||||||
<ColumnDefinition Width="160" />
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="32" />
|
|
||||||
<RowDefinition Height="32" />
|
|
||||||
<RowDefinition Height="32" />
|
|
||||||
<RowDefinition Height="32" />
|
|
||||||
<RowDefinition Height="32" />
|
|
||||||
<RowDefinition Height="32" />
|
|
||||||
<RowDefinition Height="32" />
|
|
||||||
<RowDefinition Height="32" />
|
|
||||||
<RowDefinition Height="32" />
|
|
||||||
<RowDefinition Height="32" />
|
|
||||||
<RowDefinition Height="32" />
|
|
||||||
<RowDefinition Height="32" />
|
|
||||||
<RowDefinition Height="32" />
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
|
|
||||||
<!-- Update-Rate-->
|
|
||||||
<TextBlock Grid.Row="0" Grid.Column="0" Text="Update-Rate (FPS):" />
|
|
||||||
<controls:NumericUpDown Grid.Row="0" Grid.Column="1"
|
|
||||||
Minimum="1" Maximum="60"
|
|
||||||
Value="{Binding Path=UpdateRate, Mode=TwoWay}" />
|
|
||||||
|
|
||||||
<!-- AmbienceCreatorType & Downsampling-->
|
|
||||||
<TextBlock Grid.Row="1" Grid.Column="0" Text="Ambilight-Mode:"/>
|
|
||||||
<ComboBox Grid.Row="1" Grid.Column="1"
|
|
||||||
ItemsSource="{Binding Source={StaticResource AmbienceCreatorTypeValues}}"
|
|
||||||
SelectedItem="{Binding Path=Settings.AmbienceCreatorType}" />
|
|
||||||
|
|
||||||
<TextBlock Grid.Row="1" Grid.Column="3" Text="Downsampling:" />
|
|
||||||
<controls:NumericUpDown Grid.Row="1" Grid.Column="4"
|
|
||||||
Minimum="1" Maximum="20"
|
|
||||||
Value="{Binding Path=Settings.Downsampling, Mode=TwoWay}" />
|
|
||||||
|
|
||||||
<!-- MirrorAmount & Gamma-->
|
|
||||||
<TextBlock Grid.Row="2" Grid.Column="0" Text="Mirrored Amount (%):" />
|
|
||||||
<controls:NumericUpDown Grid.Row="2" Grid.Column="1"
|
|
||||||
Minimum="0" Maximum="100"
|
|
||||||
Value="{Binding Path=Settings.MirroredAmount, Mode=TwoWay}" />
|
|
||||||
|
|
||||||
<TextBlock Grid.Row="2" Grid.Column="3" Text="Gamma:" />
|
|
||||||
<controls:NumericUpDown Grid.Row="2" Grid.Column="4"
|
|
||||||
Minimum="0.1" Maximum="10"
|
|
||||||
HasDecimals="True" Interval="0.1" StringFormat="F1"
|
|
||||||
Value="{Binding Path=Settings.Gamma, Mode=TwoWay}" />
|
|
||||||
|
|
||||||
<!-- SmoothMode -->
|
|
||||||
<TextBlock Grid.Row="3" Grid.Column="0" Text="Smoothing:" />
|
|
||||||
<ComboBox Grid.Row="3" Grid.Column="1"
|
|
||||||
ItemsSource="{Binding Source={StaticResource SmoothModeEnumValues}}"
|
|
||||||
SelectedItem="{Binding Path=Settings.SmoothMode}" />
|
|
||||||
|
|
||||||
<!-- Min Lightness -->
|
|
||||||
<TextBlock Grid.Row="3" Grid.Column="3" Text="Min Lightness (%):" />
|
|
||||||
<controls:NumericUpDown Grid.Row="3" Grid.Column="4"
|
|
||||||
Minimum="0" Maximum="100"
|
|
||||||
Value="{Binding Path=Settings.MinLightness, Mode=TwoWay}" />
|
|
||||||
|
|
||||||
<!-- FlipMode -->
|
|
||||||
<TextBlock Grid.Row="4" Grid.Column="0" Text="Flip Horizontal:" />
|
|
||||||
<CheckBox Grid.Row="4" Grid.Column="1"
|
|
||||||
helper:CheckboxEnumFlagHelper.Value="{x:Static model:FlipMode.Horizontal}"
|
|
||||||
helper:CheckboxEnumFlagHelper.Flags="{Binding Path=Settings.FlipMode}" />
|
|
||||||
|
|
||||||
<TextBlock Grid.Row="4" Grid.Column="3" Text="Flip Vertical:" />
|
|
||||||
<CheckBox Grid.Row="4" Grid.Column="4"
|
|
||||||
helper:CheckboxEnumFlagHelper.Value="{x:Static model:FlipMode.Vertical}"
|
|
||||||
helper:CheckboxEnumFlagHelper.Flags="{Binding Path=Settings.FlipMode}" />
|
|
||||||
|
|
||||||
<!-- Horizontal offsets -->
|
|
||||||
<TextBlock Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="4" FontWeight="Black" Text="Offset" />
|
|
||||||
|
|
||||||
<TextBlock Grid.Row="6" Grid.Column="0" Text="Left:" />
|
|
||||||
<controls:NumericUpDown Grid.Row="6" Grid.Column="1"
|
|
||||||
Minimum="0"
|
|
||||||
Value="{Binding Path=Settings.OffsetLeft, Mode=TwoWay}" />
|
|
||||||
|
|
||||||
<TextBlock Grid.Row="6" Grid.Column="3" Text="Right:" />
|
|
||||||
<controls:NumericUpDown Grid.Row="6" Grid.Column="4"
|
|
||||||
Minimum="0"
|
|
||||||
Value="{Binding Path=Settings.OffsetRight, Mode=TwoWay}" />
|
|
||||||
|
|
||||||
<!-- Vertical offsets -->
|
|
||||||
<TextBlock Grid.Row="7" Grid.Column="0" Text="Top:" />
|
|
||||||
<controls:NumericUpDown Grid.Row="7" Grid.Column="1" Minimum="0"
|
|
||||||
Value="{Binding Path=Settings.OffsetTop, Mode=TwoWay}" />
|
|
||||||
|
|
||||||
<TextBlock Grid.Row="7" Grid.Column="3" Text="Bottom:"/>
|
|
||||||
<controls:NumericUpDown Grid.Row="7" Grid.Column="4" Minimum="0"
|
|
||||||
Value="{Binding Path=Settings.OffsetBottom, Mode=TwoWay}" />
|
|
||||||
|
|
||||||
<!-- Horizontal BlackBar-detection -->
|
|
||||||
<TextBlock Grid.Row="8" Grid.Column="0" Grid.ColumnSpan="4" FontWeight="Black" Text="Black-Bar detection" />
|
|
||||||
|
|
||||||
<TextBlock Grid.Row="9" Grid.Column="0" Text="Left:" />
|
|
||||||
<CheckBox Grid.Row="9" Grid.Column="1"
|
|
||||||
helper:CheckboxEnumFlagHelper.Value="{x:Static model:BlackBarDetectionMode.Left}"
|
|
||||||
helper:CheckboxEnumFlagHelper.Flags="{Binding Path=Settings.BlackBarDetectionMode}" />
|
|
||||||
|
|
||||||
<TextBlock Grid.Row="9" Grid.Column="3" Text="Right:" />
|
|
||||||
<CheckBox Grid.Row="9" Grid.Column="4"
|
|
||||||
helper:CheckboxEnumFlagHelper.Value="{x:Static model:BlackBarDetectionMode.Right}"
|
|
||||||
helper:CheckboxEnumFlagHelper.Flags="{Binding Path=Settings.BlackBarDetectionMode}" />
|
|
||||||
|
|
||||||
<!-- Vertical BlackBar-detection -->
|
|
||||||
<TextBlock Grid.Row="10" Grid.Column="0" Text="Top:" />
|
|
||||||
<CheckBox Grid.Row="10" Grid.Column="1"
|
|
||||||
helper:CheckboxEnumFlagHelper.Value="{x:Static model:BlackBarDetectionMode.Top}"
|
|
||||||
helper:CheckboxEnumFlagHelper.Flags="{Binding Path=Settings.BlackBarDetectionMode}" />
|
|
||||||
|
|
||||||
<TextBlock Grid.Row="10" Grid.Column="3" Text="Bottom:" />
|
|
||||||
<CheckBox Grid.Row="10" Grid.Column="4"
|
|
||||||
helper:CheckboxEnumFlagHelper.Value="{x:Static model:BlackBarDetectionMode.Bottom}"
|
|
||||||
helper:CheckboxEnumFlagHelper.Flags="{Binding Path=Settings.BlackBarDetectionMode}" />
|
|
||||||
|
|
||||||
<Button Grid.Row="12" Grid.Column="4" Command="{Binding ExitCommand}" Content="Exit" />
|
|
||||||
</Grid>
|
|
||||||
</Border>
|
|
||||||
</UserControl>
|
|
||||||
@ -1,28 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Controls;
|
|
||||||
using System.Windows.Data;
|
|
||||||
using System.Windows.Documents;
|
|
||||||
using System.Windows.Input;
|
|
||||||
using System.Windows.Media;
|
|
||||||
using System.Windows.Media.Imaging;
|
|
||||||
using System.Windows.Navigation;
|
|
||||||
using System.Windows.Shapes;
|
|
||||||
|
|
||||||
namespace Example_Ambilight_full.TakeAsIs.UI
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Interaction logic for ConfigView.xaml
|
|
||||||
/// </summary>
|
|
||||||
public partial class ConfigView : UserControl
|
|
||||||
{
|
|
||||||
public ConfigView()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,50 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Windows;
|
|
||||||
using CUE.NET;
|
|
||||||
|
|
||||||
namespace Example_Ambilight_full.TakeAsIs.UI
|
|
||||||
{
|
|
||||||
public class ConfigViewModel
|
|
||||||
{
|
|
||||||
#region Properties & Fields
|
|
||||||
|
|
||||||
public AmbilightSettings Settings { get; }
|
|
||||||
|
|
||||||
public int UpdateRate
|
|
||||||
{
|
|
||||||
get => (int)Math.Round(1f / CueSDK.UpdateFrequency);
|
|
||||||
set
|
|
||||||
{
|
|
||||||
Settings.UpdateRate = value;
|
|
||||||
CueSDK.UpdateFrequency = 1f / value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Commands
|
|
||||||
|
|
||||||
private ActionCommand _exitCommand;
|
|
||||||
public ActionCommand ExitCommand => _exitCommand ?? (_exitCommand = new ActionCommand(Exit));
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Constructors
|
|
||||||
|
|
||||||
public ConfigViewModel(AmbilightSettings settings)
|
|
||||||
{
|
|
||||||
this.Settings = settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Methods
|
|
||||||
|
|
||||||
private void Exit()
|
|
||||||
{
|
|
||||||
Application.Current.Shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,39 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Globalization;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Windows.Data;
|
|
||||||
|
|
||||||
namespace Example_Ambilight_full.TakeAsIs.UI
|
|
||||||
{
|
|
||||||
public class EnumDescriptionConverter : IValueConverter
|
|
||||||
{
|
|
||||||
#region Methods
|
|
||||||
|
|
||||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
||||||
{
|
|
||||||
Enum myEnum = (Enum)value;
|
|
||||||
string description = GetEnumDescription(myEnum);
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
||||||
{
|
|
||||||
return string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
private string GetEnumDescription(Enum enumObj)
|
|
||||||
{
|
|
||||||
FieldInfo fieldInfo = enumObj.GetType().GetField(enumObj.ToString());
|
|
||||||
object[] attribArray = fieldInfo.GetCustomAttributes(false);
|
|
||||||
|
|
||||||
if (attribArray.Length == 0)
|
|
||||||
return enumObj.ToString();
|
|
||||||
|
|
||||||
DescriptionAttribute attrib = attribArray[0] as DescriptionAttribute;
|
|
||||||
return attrib?.Description;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,16 +0,0 @@
|
|||||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
|
||||||
xmlns:ui="clr-namespace:Example_Ambilight_full.TakeAsIs.UI">
|
|
||||||
|
|
||||||
<tb:TaskbarIcon x:Key="Taskbar"
|
|
||||||
ToolTipText="Keyboard-Ambilight"
|
|
||||||
IconSource="../../Resources/ambilight.ico"
|
|
||||||
PopupActivation="All">
|
|
||||||
|
|
||||||
<tb:TaskbarIcon.TrayPopup>
|
|
||||||
<ui:ConfigView />
|
|
||||||
</tb:TaskbarIcon.TrayPopup>
|
|
||||||
</tb:TaskbarIcon>
|
|
||||||
|
|
||||||
</ResourceDictionary>
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<packages>
|
|
||||||
<package id="CUE.NET" version="1.1.3.0" targetFramework="net45" />
|
|
||||||
<package id="Hardcodet.NotifyIcon.Wpf" version="1.0.8" targetFramework="net45" />
|
|
||||||
<package id="MahApps.Metro" version="1.4.0-ALPHA026" targetFramework="net45" />
|
|
||||||
<package id="SharpDX" version="3.1.1" targetFramework="net45" />
|
|
||||||
<package id="SharpDX.Direct3D9" version="3.1.1" targetFramework="net45" />
|
|
||||||
</packages>
|
|
||||||
@ -10,7 +10,7 @@ using System.Windows;
|
|||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("Wyrez")]
|
[assembly: AssemblyCompany("Wyrez")]
|
||||||
[assembly: AssemblyProduct("Example_AudioAnalyzer_full")]
|
[assembly: AssemblyProduct("Example_AudioAnalyzer_full")]
|
||||||
[assembly: AssemblyCopyright("Copyright © Wyrez 2017")]
|
[assembly: AssemblyCopyright("Copyright © Wyrez 2016")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
@ -49,5 +49,5 @@ using System.Windows;
|
|||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.1.0.1")]
|
[assembly: AssemblyVersion("1.1.0.0")]
|
||||||
[assembly: AssemblyFileVersion("1.1.0.1")]
|
[assembly: AssemblyFileVersion("1.1.0.0")]
|
||||||
|
|||||||
37
Examples/SimpleDevTest/MoveRainbowEffect.cs
Normal file
37
Examples/SimpleDevTest/MoveRainbowEffect.cs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
using CUE.NET.Brushes;
|
||||||
|
using CUE.NET.Effects;
|
||||||
|
using CUE.NET.Gradients;
|
||||||
|
|
||||||
|
namespace SimpleDevTest
|
||||||
|
{
|
||||||
|
public class MoveRainbowEffect : AbstractBrushEffect<IGradientBrush>
|
||||||
|
{
|
||||||
|
#region Properties & Fields
|
||||||
|
|
||||||
|
public float DegreePerSecond { get; set; } = 30f;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructors
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
|
||||||
|
public override void Update(float deltaTime)
|
||||||
|
{
|
||||||
|
float value = DegreePerSecond * deltaTime;
|
||||||
|
|
||||||
|
//DarthAffe 11.09.2016: Only to test! This will overflow if run for a longer time!!!
|
||||||
|
((RainbowGradient)Brush.Gradient).StartHue += value;
|
||||||
|
((RainbowGradient)Brush.Gradient).EndHue += value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool CanBeAppliedTo(IBrush target)
|
||||||
|
{
|
||||||
|
return (target as IGradientBrush)?.Gradient is RainbowGradient;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -7,7 +7,6 @@ using System.Threading.Tasks;
|
|||||||
using CUE.NET;
|
using CUE.NET;
|
||||||
using CUE.NET.Brushes;
|
using CUE.NET.Brushes;
|
||||||
using CUE.NET.Devices;
|
using CUE.NET.Devices;
|
||||||
using CUE.NET.Devices.Generic;
|
|
||||||
using CUE.NET.Devices.Generic.Enums;
|
using CUE.NET.Devices.Generic.Enums;
|
||||||
using CUE.NET.Effects;
|
using CUE.NET.Effects;
|
||||||
using CUE.NET.Exceptions;
|
using CUE.NET.Exceptions;
|
||||||
@ -33,69 +32,19 @@ namespace SimpleDevTest
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
bool test = CueSDK.IsSDKAvailable();
|
|
||||||
|
|
||||||
// Initialize CUE-SDK
|
// Initialize CUE-SDK
|
||||||
CueSDK.Initialize();
|
CueSDK.Initialize();
|
||||||
Console.WriteLine("Initialized with " + CueSDK.LoadedArchitecture + "-SDK");
|
Console.WriteLine("Initialized with " + CueSDK.LoadedArchitecture + "-SDK");
|
||||||
|
|
||||||
CueSDK.EnableKeypressCallback();
|
|
||||||
|
|
||||||
CueSDK.KeyPressed += (sender, eventArgs) => Console.WriteLine($"Key {eventArgs.KeyId} {(eventArgs.IsPressed ? "pressed" : "released")}");
|
|
||||||
|
|
||||||
//CueSDK.KeyboardSDK.Brush = (SolidColorBrush)Color.Black;
|
|
||||||
//CueSDK.KeyboardSDK[CorsairLedId.Z].Color = Color.Red;
|
|
||||||
//CueSDK.KeyboardSDK[CorsairLedId.Z].IsLocked = true;
|
|
||||||
|
|
||||||
float thirdKeyboardWidth = CueSDK.KeyboardSDK.DeviceRectangle.Width / 3f;
|
|
||||||
ILedGroup left = new RectangleLedGroup(CueSDK.KeyboardSDK, new RectangleF(CueSDK.KeyboardSDK.DeviceRectangle.X, CueSDK.KeyboardSDK.DeviceRectangle.Y, thirdKeyboardWidth, CueSDK.KeyboardSDK.DeviceRectangle.Height));
|
|
||||||
ILedGroup mid = new RectangleLedGroup(CueSDK.KeyboardSDK, new RectangleF(CueSDK.KeyboardSDK.DeviceRectangle.X + thirdKeyboardWidth, CueSDK.KeyboardSDK.DeviceRectangle.Y, thirdKeyboardWidth, CueSDK.KeyboardSDK.DeviceRectangle.Height));
|
|
||||||
ILedGroup right = new RectangleLedGroup(CueSDK.KeyboardSDK, new RectangleF(CueSDK.KeyboardSDK.DeviceRectangle.X + thirdKeyboardWidth * 2, CueSDK.KeyboardSDK.DeviceRectangle.Y, thirdKeyboardWidth, CueSDK.KeyboardSDK.DeviceRectangle.Height));
|
|
||||||
|
|
||||||
//CueSDK.KeyboardSDK.Brush = new LinearGradientBrush(new LinearGradient(true, new GradientStop(0, Color.Blue), new GradientStop(0.5f, Color.Red)));
|
|
||||||
left.Brush = new ConicalGradientBrush(new PointF(0.6f, 0.7f), new RainbowGradient(360, 0));
|
|
||||||
left.Brush.AddEffect(new MoveGradientEffect());
|
|
||||||
left.Brush.AddEffect(new FlashEffect { Attack = 2, Sustain = 1f, Release = 2, Interval = 1f });
|
|
||||||
|
|
||||||
mid.Brush = new ConicalGradientBrush(new PointF(0.5f, 0.3f), new RainbowGradient());
|
|
||||||
mid.Brush.AddEffect(new MoveGradientEffect());
|
|
||||||
mid.Brush.AddEffect(new FlashEffect { Attack = 2, Sustain = 1f, Release = 2, Interval = 1f });
|
|
||||||
|
|
||||||
right.Brush = new ConicalGradientBrush(new PointF(0.4f, 0.7f), new RainbowGradient(360, 0));
|
|
||||||
right.Brush.AddEffect(new MoveGradientEffect());
|
|
||||||
right.Brush.AddEffect(new FlashEffect { Attack = 2, Sustain = 1f, Release = 2, Interval = 1f });
|
|
||||||
|
|
||||||
//float halfKeyboardWidth = CueSDK.KeyboardSDK.DeviceRectangle.Width / 2f;
|
|
||||||
//ILedGroup left = new RectangleLedGroup(CueSDK.KeyboardSDK, new RectangleF(CueSDK.KeyboardSDK.DeviceRectangle.X, CueSDK.KeyboardSDK.DeviceRectangle.Y, halfKeyboardWidth, CueSDK.KeyboardSDK.DeviceRectangle.Height));
|
|
||||||
//ILedGroup right = new RectangleLedGroup(CueSDK.KeyboardSDK, new RectangleF(CueSDK.KeyboardSDK.DeviceRectangle.X + halfKeyboardWidth, CueSDK.KeyboardSDK.DeviceRectangle.Y, halfKeyboardWidth, CueSDK.KeyboardSDK.DeviceRectangle.Height));
|
|
||||||
|
|
||||||
////CueSDK.KeyboardSDK.Brush = new LinearGradientBrush(new LinearGradient(true, new GradientStop(0, Color.Blue), new GradientStop(0.5f, Color.Red)));
|
|
||||||
//left.Brush = new ConicalGradientBrush(new PointF(0.6f, 0.6f), new RainbowGradient(360, 0));
|
|
||||||
//left.Brush.AddEffect(new MoveGradientEffect());
|
|
||||||
|
|
||||||
//right.Brush = new ConicalGradientBrush(new PointF(0.4f, 0.6f), new RainbowGradient());
|
|
||||||
//right.Brush.AddEffect(new MoveGradientEffect());
|
|
||||||
|
|
||||||
CueSDK.UpdateMode = UpdateMode.Continuous;
|
CueSDK.UpdateMode = UpdateMode.Continuous;
|
||||||
|
|
||||||
Wait(5);
|
IBrush rainbowBrush = new LinearGradientBrush(new RainbowGradient());
|
||||||
CueSDK.UpdateMode = UpdateMode.Manual;
|
rainbowBrush.AddEffect(new FlashEffect { Attack = 5f, Sustain = 1f, Decay = 0, Release = 5f, Interval = 1f });
|
||||||
for (int i = 0; i < 100000; i++)
|
rainbowBrush.AddEffect(new MoveRainbowEffect());
|
||||||
{
|
rainbowBrush.AddEffect(new RemoveRedEffect());
|
||||||
CueSDK.Reinitialize();
|
|
||||||
Console.WriteLine(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
Console.WriteLine("done!");
|
foreach (ICueDevice device in CueSDK.InitializedDevices)
|
||||||
Wait(5);
|
AddTestBrush(device, rainbowBrush);
|
||||||
|
|
||||||
//IBrush rainbowBrush = new LinearGradientBrush(new RainbowGradient());
|
|
||||||
//rainbowBrush.AddEffect(new FlashEffect { Attack = 5f, Sustain = 1f, Decay = 0, Release = 5f, Interval = 1f });
|
|
||||||
//rainbowBrush.AddEffect(new MoveRainbowEffect());
|
|
||||||
//rainbowBrush.AddEffect(new RemoveRedEffect());
|
|
||||||
|
|
||||||
//foreach (ICueDevice device in CueSDK.InitializedDevices)
|
|
||||||
// AddTestBrush(device, rainbowBrush);
|
|
||||||
|
|
||||||
//// Get connected keyboard or throw exception if there is no light controllable keyboard connected
|
//// Get connected keyboard or throw exception if there is no light controllable keyboard connected
|
||||||
//CorsairKeyboard keyboard = CueSDK.KeyboardSDK;
|
//CorsairKeyboard keyboard = CueSDK.KeyboardSDK;
|
||||||
|
|||||||
@ -9,7 +9,7 @@ using System.Runtime.InteropServices;
|
|||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("Wyrez")]
|
[assembly: AssemblyCompany("Wyrez")]
|
||||||
[assembly: AssemblyProduct("SimpleDevTest")]
|
[assembly: AssemblyProduct("SimpleDevTest")]
|
||||||
[assembly: AssemblyCopyright("Copyright © Wyrez 2017")]
|
[assembly: AssemblyCopyright("Copyright © Wyrez 2016")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
|
|||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.2.0.1")]
|
[assembly: AssemblyVersion("1.1.0.0")]
|
||||||
[assembly: AssemblyFileVersion("1.2.0.1")]
|
[assembly: AssemblyFileVersion("1.1.0.0")]
|
||||||
|
|||||||
@ -47,6 +47,7 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="MoveRainbowEffect.cs" />
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="RemoveRedEffect.cs" />
|
<Compile Include="RemoveRedEffect.cs" />
|
||||||
|
|||||||
@ -1,6 +1,4 @@
|
|||||||
// ReSharper disable MemberCanBeProtected.Global
|
// ReSharper disable MemberCanBeProtected.Global
|
||||||
// ReSharper disable MemberCanBePrivate.Global
|
|
||||||
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global
|
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -20,13 +18,6 @@ namespace CUE.NET.Gradients
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public IList<GradientStop> GradientStops { get; } = new List<GradientStop>();
|
public IList<GradientStop> GradientStops { get; } = new List<GradientStop>();
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets if the Gradient wraps around if there isn't a second stop to take.
|
|
||||||
/// Example: There is a stop at offset 0f, 0.5f and 0.75f.
|
|
||||||
/// Without wrapping offset 1f will be calculated the same as 0.75f. With wrapping it would be the same as 0f.
|
|
||||||
/// </summary>
|
|
||||||
public bool WrapGradient { get; set; }
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
@ -47,19 +38,6 @@ namespace CUE.NET.Gradients
|
|||||||
GradientStops.Add(gradientStop);
|
GradientStops.Add(gradientStop);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="AbstractGradient"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="wrapGradient">Specifies whether the gradient should wrapp or not (see <see cref="WrapGradient"/> for an example of what this means).</param>
|
|
||||||
/// <param name="gradientStops">The stops with which the gradient should be initialized.</param>
|
|
||||||
protected AbstractGradient(bool wrapGradient, params GradientStop[] gradientStops)
|
|
||||||
{
|
|
||||||
this.WrapGradient = wrapGradient;
|
|
||||||
|
|
||||||
foreach (GradientStop gradientStop in gradientStops)
|
|
||||||
GradientStops.Add(gradientStop);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
@ -76,7 +54,10 @@ namespace CUE.NET.Gradients
|
|||||||
return max;
|
return max;
|
||||||
|
|
||||||
float min = GradientStops.Min(n => n.Offset);
|
float min = GradientStops.Min(n => n.Offset);
|
||||||
return offset < min ? min : offset;
|
if (offset < min)
|
||||||
|
return min;
|
||||||
|
|
||||||
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
// ReSharper disable UnusedMember.Global
|
// ReSharper disable UnusedMember.Global
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using CUE.NET.Devices.Generic;
|
using CUE.NET.Devices.Generic;
|
||||||
|
|
||||||
@ -27,15 +26,6 @@ namespace CUE.NET.Gradients
|
|||||||
: base(gradientStops)
|
: base(gradientStops)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="AbstractGradient"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="wrapGradient">Specifies whether the gradient should wrapp or not (see <see cref="AbstractGradient.WrapGradient"/> for an example of what this means).</param>
|
|
||||||
/// <param name="gradientStops">The stops with which the gradient should be initialized.</param>
|
|
||||||
public LinearGradient(bool wrapGradient, params GradientStop[] gradientStops)
|
|
||||||
: base(wrapGradient, gradientStops)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
@ -47,36 +37,13 @@ namespace CUE.NET.Gradients
|
|||||||
/// <returns>The color at the specific offset.</returns>
|
/// <returns>The color at the specific offset.</returns>
|
||||||
public override CorsairColor GetColor(float offset)
|
public override CorsairColor GetColor(float offset)
|
||||||
{
|
{
|
||||||
if (GradientStops.Count == 0) return CorsairColor.Transparent;
|
if (!GradientStops.Any()) return CorsairColor.Transparent;
|
||||||
if (GradientStops.Count == 1) return GradientStops.First().Color;
|
if (GradientStops.Count == 1) return GradientStops.First().Color;
|
||||||
|
|
||||||
GradientStop gsBefore;
|
|
||||||
GradientStop gsAfter;
|
|
||||||
|
|
||||||
IList<GradientStop> orderedStops = GradientStops.OrderBy(x => x.Offset).ToList();
|
|
||||||
if (WrapGradient)
|
|
||||||
{
|
|
||||||
gsBefore = orderedStops.LastOrDefault(n => n.Offset <= offset);
|
|
||||||
if (gsBefore == null)
|
|
||||||
{
|
|
||||||
GradientStop lastStop = orderedStops[orderedStops.Count - 1];
|
|
||||||
gsBefore = new GradientStop(lastStop.Offset - 1f, lastStop.Color);
|
|
||||||
}
|
|
||||||
|
|
||||||
gsAfter = orderedStops.FirstOrDefault(n => n.Offset >= offset);
|
|
||||||
if (gsAfter == null)
|
|
||||||
{
|
|
||||||
GradientStop firstStop = orderedStops[0];
|
|
||||||
gsAfter = new GradientStop(firstStop.Offset + 1f, firstStop.Color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
offset = ClipOffset(offset);
|
offset = ClipOffset(offset);
|
||||||
|
|
||||||
gsBefore = orderedStops.Last(n => n.Offset <= offset);
|
GradientStop gsBefore = GradientStops.Where(n => n.Offset <= offset).OrderBy(n => n.Offset).Last();
|
||||||
gsAfter = orderedStops.First(n => n.Offset >= offset);
|
GradientStop gsAfter = GradientStops.Where(n => n.Offset >= offset).OrderBy(n => n.Offset).First();
|
||||||
}
|
|
||||||
|
|
||||||
float blendFactor = 0f;
|
float blendFactor = 0f;
|
||||||
if (!gsBefore.Offset.Equals(gsAfter.Offset))
|
if (!gsBefore.Offset.Equals(gsAfter.Offset))
|
||||||
|
|||||||
@ -8,7 +8,7 @@ namespace CUE.NET.Gradients
|
|||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a rainbow gradient which circles through all colors of the HUE-color-space.<br />
|
/// Represents a rainbow gradient which circles through all colors of the HUE-color-space.<br />
|
||||||
/// See <see href="http://upload.wikimedia.org/wikipedia/commons/a/ad/HueScale.svg" /> as reference.
|
/// See <see cref="http://upload.wikimedia.org/wikipedia/commons/a/ad/HueScale.svg" /> as reference
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class RainbowGradient : IGradient
|
public class RainbowGradient : IGradient
|
||||||
{
|
{
|
||||||
@ -43,6 +43,8 @@ namespace CUE.NET.Gradients
|
|||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the color on the rainbow at the given offset.
|
/// Gets the color on the rainbow at the given offset.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -56,7 +58,5 @@ namespace CUE.NET.Gradients
|
|||||||
hue += 360;
|
hue += 360;
|
||||||
return ColorHelper.ColorFromHSV(hue, 1f, 1f);
|
return ColorHelper.ColorFromHSV(hue, 1f, 1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,7 +19,6 @@ namespace CUE.NET.Groups.Extensions
|
|||||||
public static ListLedGroup ToListLedGroup(this AbstractLedGroup ledGroup)
|
public static ListLedGroup ToListLedGroup(this AbstractLedGroup ledGroup)
|
||||||
{
|
{
|
||||||
ListLedGroup listLedGroup = ledGroup as ListLedGroup;
|
ListLedGroup listLedGroup = ledGroup as ListLedGroup;
|
||||||
// ReSharper disable once InvertIf
|
|
||||||
if (listLedGroup == null)
|
if (listLedGroup == null)
|
||||||
{
|
{
|
||||||
bool wasAttached = ledGroup.Detach();
|
bool wasAttached = ledGroup.Detach();
|
||||||
|
|||||||
@ -8,9 +8,6 @@ using CUE.NET.Effects;
|
|||||||
|
|
||||||
namespace CUE.NET.Groups
|
namespace CUE.NET.Groups
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Represents a basic led-group.
|
|
||||||
/// </summary>
|
|
||||||
public interface ILedGroup : IEffectTarget<ILedGroup>
|
public interface ILedGroup : IEffectTarget<ILedGroup>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -15,9 +15,6 @@ namespace CUE.NET.Groups
|
|||||||
{
|
{
|
||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the strongly-typed target used for the effect.
|
|
||||||
/// </summary>
|
|
||||||
protected override ILedGroup EffectTarget => this;
|
protected override ILedGroup EffectTarget => this;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -35,19 +35,10 @@ namespace CUE.NET.Groups
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private float _minOverlayPercentage;
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the minimal percentage overlay a LED must have with the <see cref="Rectangle" /> to be taken into the ledgroup.
|
/// Gets or sets the minimal percentage overlay a LED must have with the <see cref="Rectangle" /> to be taken into the ledgroup.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float MinOverlayPercentage
|
public float MinOverlayPercentage { get; set; }
|
||||||
{
|
|
||||||
get { return _minOverlayPercentage; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_minOverlayPercentage = value;
|
|
||||||
_ledCache = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -107,10 +98,6 @@ namespace CUE.NET.Groups
|
|||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets a list containing all LEDs of this group.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>The list containing all LEDs of this group.</returns>
|
|
||||||
public override IEnumerable<CorsairLed> GetLeds()
|
public override IEnumerable<CorsairLed> GetLeds()
|
||||||
{
|
{
|
||||||
return _ledCache ?? (_ledCache = Device.Where(x => RectangleHelper.CalculateIntersectPercentage(x.LedRectangle, Rectangle) >= MinOverlayPercentage).ToList());
|
return _ledCache ?? (_ledCache = Device.Where(x => RectangleHelper.CalculateIntersectPercentage(x.LedRectangle, Rectangle) >= MinOverlayPercentage).ToList());
|
||||||
|
|||||||
@ -13,7 +13,7 @@ namespace CUE.NET.Helper
|
|||||||
#region byte/float conversion
|
#region byte/float conversion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Converts the alpha-value of the <see cref="CorsairColor"/> to a float value in the range [0..1].
|
/// Converts the alpha-value of the <see cref="CorsairColor"/> to an float value int the range [0..1].
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="color">The color to take the alpha-value from.</param>
|
/// <param name="color">The color to take the alpha-value from.</param>
|
||||||
/// <returns>The float-value in the range of [0..1]</returns>
|
/// <returns>The float-value in the range of [0..1]</returns>
|
||||||
@ -23,7 +23,7 @@ namespace CUE.NET.Helper
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Converts the red-value of the <see cref="CorsairColor"/> to a float value in the range [0..1].
|
/// Converts the red-value of the <see cref="CorsairColor"/> to an float value int the range [0..1].
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="color">The color to take the red-value from.</param>
|
/// <param name="color">The color to take the red-value from.</param>
|
||||||
/// <returns>The float-value in the range of [0..1]</returns>
|
/// <returns>The float-value in the range of [0..1]</returns>
|
||||||
@ -33,7 +33,7 @@ namespace CUE.NET.Helper
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Converts the green-value of the <see cref="CorsairColor"/> to a float value in the range [0..1].
|
/// Converts the green-value of the <see cref="CorsairColor"/> to an float value int the range [0..1].
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="color">The color to take the green-value from.</param>
|
/// <param name="color">The color to take the green-value from.</param>
|
||||||
/// <returns>The float-value in the range of [0..1]</returns>
|
/// <returns>The float-value in the range of [0..1]</returns>
|
||||||
@ -43,7 +43,7 @@ namespace CUE.NET.Helper
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Converts the blue-value of the <see cref="CorsairColor"/> to a float value in the range [0..1].
|
/// Converts the blue-value of the <see cref="CorsairColor"/> to an float value int the range [0..1].
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="color">The color to take the blue-value from.</param>
|
/// <param name="color">The color to take the blue-value from.</param>
|
||||||
/// <returns>The float-value in the range of [0..1]</returns>
|
/// <returns>The float-value in the range of [0..1]</returns>
|
||||||
@ -65,12 +65,7 @@ namespace CUE.NET.Helper
|
|||||||
return new CorsairColor(GetIntColorFromFloat(a), GetIntColorFromFloat(r), GetIntColorFromFloat(g), GetIntColorFromFloat(b));
|
return new CorsairColor(GetIntColorFromFloat(a), GetIntColorFromFloat(r), GetIntColorFromFloat(g), GetIntColorFromFloat(b));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
private static byte GetIntColorFromFloat(float f)
|
||||||
/// Converts the given float-value to a integer-color in the range [0..255].
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="f">The float color-value</param>
|
|
||||||
/// <returns>The integer-value int the range [0..255].</returns>
|
|
||||||
public static byte GetIntColorFromFloat(float f)
|
|
||||||
{
|
{
|
||||||
// ReSharper disable once RedundantCast - never trust this ...
|
// ReSharper disable once RedundantCast - never trust this ...
|
||||||
float calcF = (float)Math.Max(0f, Math.Min(1f, f));
|
float calcF = (float)Math.Max(0f, Math.Min(1f, f));
|
||||||
@ -89,7 +84,6 @@ namespace CUE.NET.Helper
|
|||||||
/// <returns>The resulting color.</returns>
|
/// <returns>The resulting color.</returns>
|
||||||
public static CorsairColor Blend(this CorsairColor bg, CorsairColor fg)
|
public static CorsairColor Blend(this CorsairColor bg, CorsairColor fg)
|
||||||
{
|
{
|
||||||
// ReSharper disable once ConvertIfStatementToSwitchStatement
|
|
||||||
if (fg.A == 255)
|
if (fg.A == 255)
|
||||||
return fg;
|
return fg;
|
||||||
|
|
||||||
@ -120,7 +114,7 @@ namespace CUE.NET.Helper
|
|||||||
float min = Math.Min(Math.Min(color.R, color.G), color.B);
|
float min = Math.Min(Math.Min(color.R, color.G), color.B);
|
||||||
float max = Math.Max(Math.Max(color.R, color.G), color.B);
|
float max = Math.Max(Math.Max(color.R, color.G), color.B);
|
||||||
|
|
||||||
float hue;
|
float hue = 0f;
|
||||||
if (Math.Abs(max - color.R) < float.Epsilon) // r is max
|
if (Math.Abs(max - color.R) < float.Epsilon) // r is max
|
||||||
hue = (color.G - color.B) / (max - min);
|
hue = (color.G - color.B) / (max - min);
|
||||||
else if (Math.Abs(max - color.G) < float.Epsilon) // g is max
|
else if (Math.Abs(max - color.G) < float.Epsilon) // g is max
|
||||||
|
|||||||
@ -10,19 +10,7 @@ namespace CUE.NET.Helper
|
|||||||
public static class RectangleHelper
|
public static class RectangleHelper
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Moves a rectangle by a adding an offset.
|
/// Calculates the center-point of a rectangle adding a offset.
|
||||||
/// </summary>
|
|
||||||
/// <param name="rectangle">The rectangle.</param>
|
|
||||||
/// <param name="offsetX">The offset for the x-value</param>
|
|
||||||
/// <param name="offsetY">The offset for the y-value</param>
|
|
||||||
/// <returns>The moved rectangle.</returns>
|
|
||||||
public static RectangleF Move(this RectangleF rectangle, float offsetX = 0f, float offsetY = 0f)
|
|
||||||
{
|
|
||||||
return new RectangleF(rectangle.X + offsetX, rectangle.Y + offsetY, rectangle.Width, rectangle.Height);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Calculates the center-point of a rectangle adding an offset.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="rectangle">The rectangle.</param>
|
/// <param name="rectangle">The rectangle.</param>
|
||||||
/// <param name="offsetX">The offset for the x-value</param>
|
/// <param name="offsetX">The offset for the x-value</param>
|
||||||
|
|||||||
@ -2,12 +2,8 @@
|
|||||||
// ReSharper disable UnusedMember.Global
|
// ReSharper disable UnusedMember.Global
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using CUE.NET.Devices.Generic.Enums;
|
using CUE.NET.Devices.Generic.Enums;
|
||||||
using CUE.NET.Exceptions;
|
|
||||||
|
|
||||||
namespace CUE.NET.Native
|
namespace CUE.NET.Native
|
||||||
{
|
{
|
||||||
@ -23,6 +19,11 @@ namespace CUE.NET.Native
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string LoadedArchitecture { get; private set; }
|
internal static string LoadedArchitecture { get; private set; }
|
||||||
|
|
||||||
|
static _CUESDK()
|
||||||
|
{
|
||||||
|
LoadCUESDK();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reloads the SDK.
|
/// Reloads the SDK.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -36,24 +37,10 @@ namespace CUE.NET.Native
|
|||||||
{
|
{
|
||||||
if (_dllHandle != IntPtr.Zero) return;
|
if (_dllHandle != IntPtr.Zero) return;
|
||||||
|
|
||||||
LoadedArchitecture = LoadedArchitecture = Environment.Is64BitProcess ? "x64" : "x86";
|
|
||||||
|
|
||||||
// HACK: Load library at runtime to support both, x86 and x64 with one managed dll
|
// HACK: Load library at runtime to support both, x86 and x64 with one managed dll
|
||||||
List<string> possiblePathList = Environment.Is64BitProcess ? CueSDK.PossibleX64NativePaths : CueSDK.PossibleX86NativePaths;
|
_dllHandle = LoadLibrary((LoadedArchitecture = Environment.Is64BitProcess ? "x64" : "x86") + "/CUESDK_2015.dll");
|
||||||
string dllPath = null;
|
|
||||||
foreach (string path in possiblePathList)
|
|
||||||
if (File.Exists(path))
|
|
||||||
{
|
|
||||||
dllPath = path;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dllPath == null) throw new WrapperException($"Can't find the CUE-SDK at one of the expected locations:\r\n '{string.Join("\r\n", possiblePathList.Select(Path.GetFullPath))}'");
|
|
||||||
|
|
||||||
_dllHandle = LoadLibrary(dllPath);
|
|
||||||
|
|
||||||
_corsairSetLedsColorsPointer = (CorsairSetLedsColorsPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairSetLedsColors"), typeof(CorsairSetLedsColorsPointer));
|
_corsairSetLedsColorsPointer = (CorsairSetLedsColorsPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairSetLedsColors"), typeof(CorsairSetLedsColorsPointer));
|
||||||
_corsairGetLedsColorsPointer = (CorsairGetLedsColorsPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetLedsColors"), typeof(CorsairGetLedsColorsPointer));
|
|
||||||
_corsairGetDeviceCountPointer = (CorsairGetDeviceCountPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetDeviceCount"), typeof(CorsairGetDeviceCountPointer));
|
_corsairGetDeviceCountPointer = (CorsairGetDeviceCountPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetDeviceCount"), typeof(CorsairGetDeviceCountPointer));
|
||||||
_corsairGetDeviceInfoPointer = (CorsairGetDeviceInfoPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetDeviceInfo"), typeof(CorsairGetDeviceInfoPointer));
|
_corsairGetDeviceInfoPointer = (CorsairGetDeviceInfoPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetDeviceInfo"), typeof(CorsairGetDeviceInfoPointer));
|
||||||
_corsairGetLedPositionsPointer = (CorsairGetLedPositionsPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetLedPositions"), typeof(CorsairGetLedPositionsPointer));
|
_corsairGetLedPositionsPointer = (CorsairGetLedPositionsPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetLedPositions"), typeof(CorsairGetLedPositionsPointer));
|
||||||
@ -63,7 +50,6 @@ namespace CUE.NET.Native
|
|||||||
_corsairReleaseControlPointer = (CorsairReleaseControlPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairReleaseControl"), typeof(CorsairReleaseControlPointer));
|
_corsairReleaseControlPointer = (CorsairReleaseControlPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairReleaseControl"), typeof(CorsairReleaseControlPointer));
|
||||||
_corsairPerformProtocolHandshakePointer = (CorsairPerformProtocolHandshakePointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairPerformProtocolHandshake"), typeof(CorsairPerformProtocolHandshakePointer));
|
_corsairPerformProtocolHandshakePointer = (CorsairPerformProtocolHandshakePointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairPerformProtocolHandshake"), typeof(CorsairPerformProtocolHandshakePointer));
|
||||||
_corsairGetLastErrorPointer = (CorsairGetLastErrorPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetLastError"), typeof(CorsairGetLastErrorPointer));
|
_corsairGetLastErrorPointer = (CorsairGetLastErrorPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetLastError"), typeof(CorsairGetLastErrorPointer));
|
||||||
_corsairRegisterKeypressCallbackPointer = (CorsairRegisterKeypressCallbackPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairRegisterKeypressCallback"), typeof(CorsairRegisterKeypressCallbackPointer));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void UnloadCUESDK()
|
private static void UnloadCUESDK()
|
||||||
@ -91,7 +77,6 @@ namespace CUE.NET.Native
|
|||||||
#region Pointers
|
#region Pointers
|
||||||
|
|
||||||
private static CorsairSetLedsColorsPointer _corsairSetLedsColorsPointer;
|
private static CorsairSetLedsColorsPointer _corsairSetLedsColorsPointer;
|
||||||
private static CorsairGetLedsColorsPointer _corsairGetLedsColorsPointer;
|
|
||||||
private static CorsairGetDeviceCountPointer _corsairGetDeviceCountPointer;
|
private static CorsairGetDeviceCountPointer _corsairGetDeviceCountPointer;
|
||||||
private static CorsairGetDeviceInfoPointer _corsairGetDeviceInfoPointer;
|
private static CorsairGetDeviceInfoPointer _corsairGetDeviceInfoPointer;
|
||||||
private static CorsairGetLedPositionsPointer _corsairGetLedPositionsPointer;
|
private static CorsairGetLedPositionsPointer _corsairGetLedPositionsPointer;
|
||||||
@ -101,7 +86,6 @@ namespace CUE.NET.Native
|
|||||||
private static CorsairReleaseControlPointer _corsairReleaseControlPointer;
|
private static CorsairReleaseControlPointer _corsairReleaseControlPointer;
|
||||||
private static CorsairPerformProtocolHandshakePointer _corsairPerformProtocolHandshakePointer;
|
private static CorsairPerformProtocolHandshakePointer _corsairPerformProtocolHandshakePointer;
|
||||||
private static CorsairGetLastErrorPointer _corsairGetLastErrorPointer;
|
private static CorsairGetLastErrorPointer _corsairGetLastErrorPointer;
|
||||||
private static CorsairRegisterKeypressCallbackPointer _corsairRegisterKeypressCallbackPointer;
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -110,9 +94,6 @@ namespace CUE.NET.Native
|
|||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
private delegate bool CorsairSetLedsColorsPointer(int size, IntPtr ledsColors);
|
private delegate bool CorsairSetLedsColorsPointer(int size, IntPtr ledsColors);
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
||||||
private delegate bool CorsairGetLedsColorsPointer(int size, IntPtr ledsColors);
|
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
private delegate int CorsairGetDeviceCountPointer();
|
private delegate int CorsairGetDeviceCountPointer();
|
||||||
|
|
||||||
@ -140,9 +121,6 @@ namespace CUE.NET.Native
|
|||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
private delegate CorsairError CorsairGetLastErrorPointer();
|
private delegate CorsairError CorsairGetLastErrorPointer();
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
||||||
private delegate bool CorsairRegisterKeypressCallbackPointer(IntPtr callback, IntPtr context);
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
// ReSharper disable EventExceptionNotDocumented
|
// ReSharper disable EventExceptionNotDocumented
|
||||||
@ -155,14 +133,6 @@ namespace CUE.NET.Native
|
|||||||
return _corsairSetLedsColorsPointer(size, ledsColors);
|
return _corsairSetLedsColorsPointer(size, ledsColors);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// CUE-SDK: get current color for the list of requested LEDs.
|
|
||||||
/// </summary>
|
|
||||||
internal static bool CorsairGetLedsColors(int size, IntPtr ledsColors)
|
|
||||||
{
|
|
||||||
return _corsairGetLedsColorsPointer(size, ledsColors);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// CUE-SDK: returns number of connected Corsair devices that support lighting control.
|
/// CUE-SDK: returns number of connected Corsair devices that support lighting control.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -236,11 +206,6 @@ namespace CUE.NET.Native
|
|||||||
return _corsairGetLastErrorPointer();
|
return _corsairGetLastErrorPointer();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static bool CorsairRegisterKeypressCallback(IntPtr callback, IntPtr context)
|
|
||||||
{
|
|
||||||
return _corsairRegisterKeypressCallbackPointer(callback, context);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ReSharper restore EventExceptionNotDocumented
|
// ReSharper restore EventExceptionNotDocumented
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -2,7 +2,6 @@
|
|||||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
// ReSharper disable UnusedMember.Global
|
// ReSharper disable UnusedMember.Global
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -14,7 +13,6 @@ namespace CUE.NET.Profiles
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a CUE profile.
|
/// Represents a CUE profile.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Obsolete("Only works with CUE 1.")]
|
|
||||||
public class CueProfile
|
public class CueProfile
|
||||||
{
|
{
|
||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using CUE.NET.Brushes;
|
using CUE.NET.Brushes;
|
||||||
@ -9,7 +8,6 @@ namespace CUE.NET.Profiles
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a device of a CUE profile.
|
/// Represents a device of a CUE profile.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Obsolete("Only works with CUE 1.")]
|
|
||||||
internal class CueProfileDevice
|
internal class CueProfileDevice
|
||||||
{
|
{
|
||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|||||||
@ -12,7 +12,6 @@ namespace CUE.NET.Profiles
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a mode of a CUE profile.
|
/// Represents a mode of a CUE profile.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Obsolete("Only works with CUE 1.")]
|
|
||||||
internal class CueProfileMode
|
internal class CueProfileMode
|
||||||
{
|
{
|
||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|||||||
@ -12,7 +12,6 @@ namespace CUE.NET.Profiles
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents the SDK for CUE profiles.
|
/// Represents the SDK for CUE profiles.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Obsolete("Only works with CUE 1.")]
|
|
||||||
public static class CueProfiles
|
public static class CueProfiles
|
||||||
{
|
{
|
||||||
#region Constants
|
#region Constants
|
||||||
@ -63,7 +62,6 @@ namespace CUE.NET.Profiles
|
|||||||
public static CueProfile LoadProfileByName(string name = null)
|
public static CueProfile LoadProfileByName(string name = null)
|
||||||
{
|
{
|
||||||
string id = null;
|
string id = null;
|
||||||
// ReSharper disable once InvertIf
|
|
||||||
if (name != null && !_profileNameMapping.TryGetValue(name, out id))
|
if (name != null && !_profileNameMapping.TryGetValue(name, out id))
|
||||||
{
|
{
|
||||||
LoadProfileNames(); // Reload and try again
|
LoadProfileNames(); // Reload and try again
|
||||||
|
|||||||
@ -9,7 +9,7 @@ using System.Runtime.InteropServices;
|
|||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("Wyrez")]
|
[assembly: AssemblyCompany("Wyrez")]
|
||||||
[assembly: AssemblyProduct("CUE.NET")]
|
[assembly: AssemblyProduct("CUE.NET")]
|
||||||
[assembly: AssemblyCopyright("Copyright © Wyrez 2017")]
|
[assembly: AssemblyCopyright("Copyright © Wyrez 2016")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
|
|||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.2.0.1")]
|
[assembly: AssemblyVersion("1.1.0.0")]
|
||||||
[assembly: AssemblyFileVersion("1.2.0.1")]
|
[assembly: AssemblyFileVersion("1.1.0.0")]
|
||||||
|
|||||||
@ -1,6 +1,3 @@
|
|||||||
**CUE.NET is considered done now and will be no longer actively developed.
|
|
||||||
It is superseded by [RGB.NET](https://github.com/DarthAffe/RGB.NET). Feel free to join the [discord-channel](https://discord.gg/9kytURv) if you're interested what's happening there :)**
|
|
||||||
|
|
||||||
# CUE.NET
|
# CUE.NET
|
||||||
C# (.NET) Wrapper library around the Corsair CUE-SDK
|
C# (.NET) Wrapper library around the Corsair CUE-SDK
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user