/// <summary> /// Initializes a StyleShowControlCategory. /// </summary> /// <param name="StyleCategory"> The source <see cref="StyleCategory"/>. </param> public StyleShowControlCategory(StyleCategory StyleCategory) : base ( from style in StyleCategory.Styles select new StyleShowControl { Style2 = style } ) { this.Name = StyleCategory.Name; this.Strings = StyleCategory.Strings; }
/// <summary> /// Saves the entire <see cref="StyleCategory"/> to a XDocument. /// </summary> /// <param name="elementName"> The element name. </param> /// <param name="StyleCategory"> The source data. </param> /// <returns> The saved XDocument. </returns> public static XElement SaveStyleCategory(string elementName, StyleCategory StyleCategory) { XElement element = new XElement(elementName); element.Add(new XAttribute("Name", StyleCategory.Name)); element.Add ( from Style in StyleCategory.Styles select XML.SaveStyle("Style", Style) ); return(element); }
/// <summary> /// Loads a <see cref="StyleCategory"/> from an XElement. /// </summary> /// <param name="element"> The source XElement. </param> /// <returns> The loaded <see cref="IStyle"/>s. </returns> public static StyleCategory LoadStyleCategory(XElement element) { StyleCategory StyleCategory = new StyleCategory(); if (element.Attribute("Name") is XAttribute name) { StyleCategory.Name = name.Value; } StyleCategory.Styles = ( from Style in element.Elements("Style") select XML.LoadStyle(Style) ).ToList(); return(StyleCategory); }
/// <summary> /// Loads a <see cref="StyleCategory"/> from an XElement. /// </summary> /// <param name="element"> The source XElement. </param> /// <returns> The loaded <see cref="IStyle"/>s. </returns> private static StyleCategory LoadStyleCategory(XElement element) { StyleCategory styleCategory = new StyleCategory(); if (element.Attribute("Name") is XAttribute name) { styleCategory.Name = name.Value; } if (element.Element("Strings") is XElement strings) { styleCategory.Strings = Retouch_Photo2.Elements.XML.LoadStrings(strings); } styleCategory.Styles = ( from style in element.Elements("Style") select XML.LoadStyle(style) ).ToList(); return(styleCategory); }
/// <summary> /// Saves the entire <see cref="StyleCategory"/> to a XDocument. /// </summary> /// <param name="elementName"> The element name. </param> /// <param name="styleCategory"> The source data. </param> /// <returns> The saved XDocument. </returns> private static XElement SaveStyleCategory(string elementName, StyleCategory styleCategory) { XElement element = new XElement(elementName); if ((styleCategory.Name is null) == false) { element.Add(new XAttribute("Name", styleCategory.Name)); } if ((styleCategory.Strings is null) == false) { element.Add(Retouch_Photo2.Elements.XML.SaveStrings("Strings", styleCategory.Strings)); } element.Add ( from style in styleCategory.Styles select XML.SaveStyle("Style", style) ); return(element); }