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

Added code-documentation for the Profile-implementation

This commit is contained in:
Darth Affe 2016-02-07 10:26:35 +01:00
parent 089cada426
commit 6479de8d26
5 changed files with 89 additions and 0 deletions

View File

@ -5,6 +5,9 @@ using CUE.NET.Devices.Keyboard.Keys;
namespace CUE.NET.Brushes
{
/// <summary>
/// Represents a brush drawing the lighting of a CUE profile.
/// </summary>
public class ProfileBrush : AbstractBrush
{
#region Properties & Fields
@ -15,6 +18,10 @@ namespace CUE.NET.Brushes
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="ProfileBrush"/> class.
/// </summary>
/// <param name="keyLights">The light settings of the CUE profile.</param>
internal ProfileBrush(Dictionary<CorsairKeyboardKeyId, Color> keyLights)
{
this._keyLights = keyLights;
@ -24,6 +31,12 @@ namespace CUE.NET.Brushes
#region Methods
/// <summary>
/// Gets the color at an specific point getting the color of the key at the given point.
/// </summary>
/// <param name="rectangle">The rectangle in which the brush should be drawn.</param>
/// <param name="point">The point from which the color should be taken.</param>
/// <returns>The color of the key at the specified point.</returns>
public override Color GetColorAtPoint(RectangleF rectangle, PointF point)
{
CorsairKey key = CueSDK.KeyboardSDK[point];

View File

@ -10,15 +10,28 @@ using CUE.NET.Brushes;
namespace CUE.NET.Profiles
{
/// <summary>
/// Represents a CUE profile.
/// </summary>
public class CueProfile
{
#region Properties & Fields
private Dictionary<string, CueProfileDevice> _devices;
/// <summary>
/// Gets the Id of the profile.
/// </summary>
public string Id { get; }
/// <summary>
/// Gets the Name of the profile.
/// </summary>
public string Name { get; }
/// <summary>
/// Returns a list of strings containing the name of all modes available.
/// </summary>
public IEnumerable<string> Modes
{
get
@ -29,6 +42,11 @@ namespace CUE.NET.Profiles
}
}
/// <summary>
/// Returns the <see cref="ProfileBrush"/> for the given mode.
/// </summary>
/// <param name="mode">The mode to select.</param>
/// <returns>The <see cref="ProfileBrush"/> of the given mode.</returns>
public ProfileBrush this[string mode]
{
get
@ -53,6 +71,11 @@ namespace CUE.NET.Profiles
#region Methods
/// <summary>
/// Loads a CUE profile from the given file.
/// </summary>
/// <param name="file">The profile-file.</param>
/// <returns>The loaded <see cref="CueProfile" /> or null.</returns>
internal static CueProfile Load(string file)
{
// ReSharper disable PossibleNullReferenceException - Just let it fail - no need to check anything here ...

View File

@ -5,12 +5,21 @@ using CUE.NET.Brushes;
namespace CUE.NET.Profiles
{
/// <summary>
/// Represents a device of a CUE profile.
/// </summary>
internal class CueProfileDevice
{
#region Properties & Fields
/// <summary>
/// The name of the device.
/// </summary>
internal string Name { get; }
/// <summary>
/// Returns a list of strings containing the name of all modes available for this device.
/// </summary>
internal IEnumerable<string> Modes => _modes.Keys.ToList();
private Dictionary<string, CueProfileMode> _modes;
@ -19,6 +28,11 @@ namespace CUE.NET.Profiles
#region Brush Conversion
/// <summary>
/// Returns the <see cref="ProfileBrush"/> for the given mode.
/// </summary>
/// <param name="mode">The mode to select.</param>
/// <returns>The <see cref="ProfileBrush"/> of the given mode.</returns>
internal ProfileBrush this[string mode]
{
get
@ -44,6 +58,11 @@ namespace CUE.NET.Profiles
#region Methods
/// <summary>
/// Loads a device of a CUE profile from the given XML-node.
/// </summary>
/// <param name="deviceRoot">The node containing the device.</param>
/// <returns>The loaded <see cref="CueProfileDevice" /> or null.</returns>
internal static CueProfileDevice Load(XElement deviceRoot)
{
// ReSharper disable PossibleNullReferenceException - Just let it fail - no need to check anything here ...

View File

@ -8,10 +8,16 @@ using CUE.NET.Devices.Keyboard.Enums;
namespace CUE.NET.Profiles
{
/// <summary>
/// Represents a mode of a CUE profile.
/// </summary>
internal class CueProfileMode
{
#region Properties & Fields
/// <summary>
/// Gets the name of the mode.
/// </summary>
internal string Name { get; }
private Dictionary<CorsairKeyboardKeyId, Color> _keyLights;
@ -20,6 +26,10 @@ namespace CUE.NET.Profiles
#region Brush Conversion
/// <summary>
/// Converts a <see cref="CueProfileMode" /> to a <see cref="ProfileBrush" />.
/// </summary>
/// <param name="profile">The profile mode to convert.</param>
public static implicit operator ProfileBrush(CueProfileMode profile)
{
return profile != null ? new ProfileBrush(profile._keyLights) : null;
@ -38,6 +48,11 @@ namespace CUE.NET.Profiles
#region Methods
/// <summary>
/// Loads a mode of a CUE profile from the given XML-node.
/// </summary>
/// <param name="modeRoot">The node containing the mode.</param>
/// <returns>The loaded <see cref="CueProfileMode" /> or null.</returns>
internal static CueProfileMode Load(XElement modeRoot)
{
// ReSharper disable PossibleNullReferenceException - Just let it fail - no need to check anything here ...

View File

@ -8,6 +8,9 @@ using System.Xml.Linq;
namespace CUE.NET.Profiles
{
/// <summary>
/// Represents the SDK for CUE profiles.
/// </summary>
public static class CueProfiles
{
#region Constants
@ -22,6 +25,9 @@ namespace CUE.NET.Profiles
private static Dictionary<string, string> _profileNameMapping = new Dictionary<string, string>();
/// <summary>
/// Gets a list containing the names of all existing profiles.
/// </summary>
public static List<string> ProfileNames
{
get
@ -31,6 +37,9 @@ namespace CUE.NET.Profiles
}
}
/// <summary>
/// Gets a list containing the ids of all existing profiles.
/// </summary>
public static List<string> ProfileIds
{
get
@ -44,6 +53,11 @@ namespace CUE.NET.Profiles
#region Methods
/// <summary>
/// Loads the profile with the given name.
/// </summary>
/// <param name="name">The name (the one given in CUE, not the filename) of the profile.</param>
/// <returns>The loaded <see cref="CueProfile" /> or null if it couldn't be loaded.</returns>
public static CueProfile LoadProfileByName(string name = null)
{
string id = null;
@ -57,6 +71,11 @@ namespace CUE.NET.Profiles
return LoadProfileByID(id);
}
/// <summary>
/// Loads the profile with the given id.
/// </summary>
/// <param name="id">The id of the profile.</param>
/// <returns>The loaded <see cref="CueProfile" /> or null if it couldn't be loaded.</returns>
public static CueProfile LoadProfileByID(string id = null)
{
if (id == null) id = GetDefaultProfileId();