Esempio n. 1
0
        /// <summary>
        /// Конвертировать стиль в XElement
        /// </summary>
        private static XElement ConvertToXElement(this IntellectualEntityStyle style)
        {
            var styleXel = new XElement("UserStyle");

            styleXel.SetAttributeValue(nameof(style.Name), style.Name);
            styleXel.SetAttributeValue(nameof(style.Description), style.Description);
            styleXel.SetAttributeValue(nameof(style.Guid), style.Guid);

            foreach (var entityProperty in style.Properties)
            {
                if (entityProperty.Name == "Scale")
                {
                    var propXel = new XElement("Property");
                    propXel.SetAttributeValue("Name", entityProperty.Name);
                    propXel.SetAttributeValue("Value", ((AnnotationScale)entityProperty.Value).Name);
                    styleXel.Add(propXel);
                }
                else
                {
                    var propXel = new XElement("Property");
                    propXel.SetAttributeValue("Name", entityProperty.Name);
                    propXel.SetAttributeValue("Value", entityProperty.Value);
                    styleXel.Add(propXel);
                }
            }

            if (LayerUtils.HasLayer(style.GetLayerNameProperty()))
            {
                styleXel.Add(LayerUtils.SetLayerXml(LayerUtils.GetLayerTableRecordByLayerName(style.GetLayerNameProperty())));
            }
            else if (style.LayerXmlData != null)
            {
                styleXel.Add(style.LayerXmlData);
            }

            // add text style
            if (TextStyleUtils.HasTextStyle(style.GetTextStyleProperty()))
            {
                styleXel.Add(TextStyleUtils.SetTextStyleTableRecordXElement(TextStyleUtils.GetTextStyleTableRecordByName(style.GetTextStyleProperty())));
            }
            else if (style.TextStyleXmlData != null)
            {
                styleXel.Add(style.TextStyleXmlData);
            }

            return(styleXel);
        }