diff --git a/Documentation/DeviceLayout.xsd b/Documentation/DeviceLayout.xsd new file mode 100644 index 0000000..8b708ee --- /dev/null +++ b/Documentation/DeviceLayout.xsd @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/RGB.NET.Core/Devices/Layout/DeviceLayout.cs b/RGB.NET.Core/Devices/Layout/DeviceLayout.cs new file mode 100644 index 0000000..9122617 --- /dev/null +++ b/RGB.NET.Core/Devices/Layout/DeviceLayout.cs @@ -0,0 +1,104 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Xml.Serialization; + +namespace RGB.NET.Core.Layout +{ + /// + /// Represents the serializable layout of a . + /// + [Serializable] + [XmlRoot("Device")] + public class DeviceLayout + { + #region Properties & Fields + + /// + /// Gets or sets the name of the . + /// + [XmlElement("Name")] + public string Name { get; set; } + + /// + /// Gets or sets the description of the . + /// + [XmlElement("Description")] + public string Description { get; set; } + + /// + /// Gets or sets the of the . + /// + [XmlElement("Type")] + public RGBDeviceType Type { get; set; } + + /// + /// Gets or sets the of the . + /// + [XmlElement("Lighting")] + public LayoutLighting Lighting { get; set; } + + /// + /// Gets or sets the vendor of the . + /// + [XmlElement("Vendor")] + public string Vendor { get; set; } + + /// + /// Gets or sets the model of the . + /// + [XmlElement("Model")] + public string Model { get; set; } + + /// + /// Gets or sets the of the . + /// + [XmlElement("Shape")] + public LayoutShape Shape { get; set; } + + /// + /// Gets or sets the width of the . + /// + [XmlElement("Width")] + public double Width { get; set; } + + /// + /// Gets or sets the height of the . + /// + [XmlElement("Height")] + public double Height { get; set; } + + /// + /// Gets or sets a list of representing all the of the . + /// + [XmlArray("Leds")] + public List Leds { get; set; } = new List(); + + #endregion + + #region Methods + + /// + /// Creates a new from the given xml. + /// + /// The path to the xml file. + /// The deserialized . + public static DeviceLayout Load(string path) + { + if (!File.Exists(path)) return null; + + try + { + XmlSerializer serializer = new XmlSerializer(typeof(DeviceLayout)); + using (StreamReader reader = new StreamReader(path)) + return serializer.Deserialize(reader) as DeviceLayout; + } + catch + { + return null; + } + } + + #endregion + } +} diff --git a/RGB.NET.Core/Devices/Layout/LayoutLighting.cs b/RGB.NET.Core/Devices/Layout/LayoutLighting.cs new file mode 100644 index 0000000..1170d95 --- /dev/null +++ b/RGB.NET.Core/Devices/Layout/LayoutLighting.cs @@ -0,0 +1,18 @@ +namespace RGB.NET.Core.Layout +{ + /// + /// Contains a list of different lightning-modes used by . + /// + public enum LayoutLighting + { + /// + /// The supports per-key-lightning. + /// + Key = 0, + + /// + /// The supports per-keyboard-lightning. + /// + Keyboard = 1, + } +} diff --git a/RGB.NET.Core/Devices/Layout/LayoutShape.cs b/RGB.NET.Core/Devices/Layout/LayoutShape.cs new file mode 100644 index 0000000..db6b081 --- /dev/null +++ b/RGB.NET.Core/Devices/Layout/LayoutShape.cs @@ -0,0 +1,16 @@ +using System; + +namespace RGB.NET.Core.Layout +{ + /// + /// Contains a list of different shapes used by . + /// + [Serializable] + public enum LayoutShape + { + /// + /// A simple rectangle. + /// + Rectangle = 0 + } +} diff --git a/RGB.NET.Core/Devices/Layout/LedLayout.cs b/RGB.NET.Core/Devices/Layout/LedLayout.cs new file mode 100644 index 0000000..9224240 --- /dev/null +++ b/RGB.NET.Core/Devices/Layout/LedLayout.cs @@ -0,0 +1,53 @@ +using System; +using System.Xml.Serialization; + +namespace RGB.NET.Core.Layout +{ + /// + /// Represents the serializable layout of a . + /// + [Serializable] + [XmlType("Led")] + public class LedLayout + { + #region Properties & Fields + + /// + /// Gets or sets the Id of the . + /// + [XmlElement("Id")] + public string Id { get; set; } + + /// + /// Gets or sets the of the . + /// + [XmlElement("Shape")] + public LayoutShape Shape { get; set; } + + /// + /// Gets or sets the x-position of the . + /// + [XmlElement("X")] + public double X { get; set; } + + /// + /// Gets or sets the y-position of the . + /// + [XmlElement("Y")] + public double Y { get; set; } + + /// + /// Gets or sets the width of the . + /// + [XmlElement("Width")] + public double Width { get; set; } + + /// + /// Gets or sets the height of the . + /// + [XmlElement("Height")] + public double Height { get; set; } + + #endregion + } +} diff --git a/RGB.NET.Core/Devices/RGBDeviceType.cs b/RGB.NET.Core/Devices/RGBDeviceType.cs index de234dd..012ee60 100644 --- a/RGB.NET.Core/Devices/RGBDeviceType.cs +++ b/RGB.NET.Core/Devices/RGBDeviceType.cs @@ -1,7 +1,7 @@ namespace RGB.NET.Core { /// - /// Contains list of different types of device. + /// Contains a list of different types of device. /// public enum RGBDeviceType { diff --git a/RGB.NET.Core/RGB.NET.Core.csproj b/RGB.NET.Core/RGB.NET.Core.csproj index f219385..4d0a1e5 100644 --- a/RGB.NET.Core/RGB.NET.Core.csproj +++ b/RGB.NET.Core/RGB.NET.Core.csproj @@ -48,6 +48,10 @@ + + + +