You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kev/Drawer/UCDraw/SigmaDrawerElement/DrawerElementProperty.cs

102 lines
3.1 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System.Xml;
using System.Xml.Serialization;
using GeoSigma.SigmaDrawerStyle;
using GeoSigmaDrawLib;
namespace SigmaDrawerElement
{
[XmlRoot("Element")]
public class DrawerElementProperty
{
private string _colorRgb;
[XmlAttribute("Color")]
public string ColorRgb
{
get { return _colorRgb; }
set
{
_colorRgb = value;
SyncColorToElement();
}
}
private ElementBase _element;
[XmlElement("Point", typeof(DrawerPoint))]
[XmlElement("Xyz", typeof(DrawerXyz))]
[XmlElement("TwoPoint", typeof(DrawerPointTwoName))]
[XmlElement("CrossPoint", typeof(DrawerPointCrossName))]
[XmlElement("Pline", typeof(DrawerPline))]
[XmlElement("Surface", typeof(DrawerSurface))]
[XmlElement("Text", typeof(DrawerText))]
[XmlElement("Ellipse", typeof(DrawerEllipse))]
[XmlElement("Arc", typeof(DrawerArc))]
[XmlElement("Proportion", typeof(DrawerProportion))]
[XmlElement("Frame", typeof(DrawerFrame))]
[XmlElement("FGrid", typeof(DrawerFrameGrid))]
[XmlElement("FNetting", typeof(DrawerFrameNet))]
[XmlElement("Donut", typeof(DrawerDonut))]
[XmlElement("Circle", typeof(DrawerCircle))]
[XmlElement("Section", typeof(DrawerSeismicSection))]
[XmlElement("WellGroup", typeof(DrawerWellGroup))]
[XmlElement("Block", typeof(DrawerGroup))]
[XmlElement("Axis", typeof(DrawerScaleRuler))]
public ElementBase Element
{
get { return _element; }
set
{
_element = value;
SyncColorToElement();
}
}
private void SyncColorToElement()
{
// 如果还没读取到 Element 或者还没读取到 Color什么都不做
if (_element == null || string.IsNullOrEmpty(_colorRgb)) return;
if (int.TryParse(_colorRgb, out int colorVal))
{
// 判断当前 Element 是不是 DrawerFrameNet 类型
if (_element is DrawerFrameNet net)
{
net.XmlColorProxy = colorVal;
}
}
}
[XmlIgnore]
public DrawElementType ElementType
{
get
{
if (Element != null) return Element.ElementType;
return DrawElementType.ELEMENT_UNKNOWN;
}
set
{
if (Element != null) Element.ElementType = ElementType;
}
}
[XmlIgnore]
public int ColorRef { get; set; }
[XmlAttribute("Layer")]
public string Layer { get; set; }
[XmlAttribute("Visibility")]
public string Visibility { get; set; }
[XmlAttribute("Type")]
public string TypeName { get; set; }
[XmlElement("HowToViewCurve")]
public DrawerCurveStyle CurveStyle { get; set; }
[XmlElement("HowToViewPoint")]
public DrawerPointStyle PointStyle { get; set; }
}
}