using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml.Serialization; using GeoSigma.SigmaDrawerStyle; using GeoSigmaDrawLib; using SigmaDrawerElement.Descriptor; using SigmaDrawerStyle; namespace SigmaDrawerElement { [TypeConverter(typeof(PropertySorter))] public class DrawerEllipse : ElementBase { public DrawerEllipse() { ElementType = DrawElementType.ELEMENT_ELLIPSE; } [Browsable(false)] [XmlAttribute("Color")] public int ColorRef; [XmlIgnore] [Category("圆"), DisplayName("颜色"), PropertyOrder(4)] public Color LineColor { get { return ColorTranslator.FromWin32(ColorRef); } set { ColorRef = ColorTranslator.ToWin32(value); } } [XmlElement("Coordinate")] [Browsable(false)] [TypeConverter(typeof(GeoSigma.SigmaDrawerStyle.Converter.BaseExpandableConverter))] public CircleCoordinate Coordinate { get; set; } = new CircleCoordinate(); [XmlIgnore] [Category("圆"), DisplayName("圆心坐标"), PropertyOrder(0)] [TypeConverter(typeof(PropertyPointConvert))] public PropertyPoint CenterPoint { get => Coordinate.CenterPoint; set => Coordinate.CenterPoint = value; } [XmlIgnore] [Category("圆"), DisplayName("半径"), PropertyOrder(1)] [TypeConverter(typeof(PropertyRadiusConvert))] public PropertyRadius RadiusSize { get => Coordinate.RadiusSize; set => Coordinate.RadiusSize = value; } #region Other [Browsable(false)] [XmlElement("Other")] [TypeConverter(typeof(GeoSigma.SigmaDrawerStyle.Converter.BaseExpandableConverter))] public EllipsOther Other { get; set; } = new EllipsOther(); [XmlIgnore] [Category("圆"), DisplayName("曲线宽度"), PropertyOrder(2)] public double Width { get => Other.Width; set => Other.Width = value; } [XmlIgnore] [Category("圆"), DisplayName("宽度定位"), PropertyOrder(3)] [TypeConverter(typeof(SigmaDrawerElement.Converter.EllipseStyleConverter))] public int WidthStyle { get { return Other.Style & (int)EllipseStyle.ELLIPSE_WIDTH_ALL; } set { Other.Style &= ~(int)EllipseStyle.ELLIPSE_WIDTH_ALL; Other.Style |= value; } } #endregion } public class EllipsOther { [XmlAttribute] public double Width { get; set; } = 1; [XmlAttribute] public int Style { get; set; } = (int)EllipseStyle.ELLIPSE_WIDTH_CENTER; } public class CircleCoordinate { [XmlText] [Browsable(false)] public string Text { get { return $"{CenterPoint.X},{CenterPoint.Y} {CenterPoint.X + RadiusSize.X},{CenterPoint.Y + RadiusSize.Y}"; } set { var arr = value.Split(new string[] { ",", " ", "\t" }, StringSplitOptions.RemoveEmptyEntries); if (arr.Length == 4) { CenterPoint = new PropertyPoint(Convert.ToDouble(arr[0]), Convert.ToDouble(arr[1])); var xMax = Convert.ToDouble(arr[2]); var yMax = Convert.ToDouble(arr[3]); RadiusSize = new PropertyRadius(xMax - CenterPoint.X, yMax - CenterPoint.Y); } } } [XmlIgnore] public PropertyPoint CenterPoint { get; set; } = new PropertyPoint(); [XmlIgnore] public PropertyRadius RadiusSize { get; set; } = new PropertyRadius(); } }