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 } }