// // Copyright (c) PlaceholderCompany. All rights reserved. // using System.Collections.Generic; using System.ComponentModel; using System.Xml.Serialization; using GeoSigma.SigmaDrawerStyle; using GeoSigmaDrawLib; using SigmaDrawerStyle; namespace SigmaDrawerElement { /// /// 点类图元 /// [TypeConverter(typeof(PropertySorter))] public class DrawerPoint : ElementBase, INotifyPropertyChanged { /// /// 属性类别排序 /// private List categorys = new List() { "基础属性", "数据", "其他", "杂项" }; /// /// Initializes a new instance of the class. /// public DrawerPoint() { ElementType = DrawElementType.ELEMENT_POINT; } /// /// Initializes a new instance of the class. /// /// 名称 /// 坐标X /// 坐标Y /// 坐标Z /// 角度 public DrawerPoint(string name, double x, double y, double z, double angle) { Name = name; X = x; Y = y; Z = z; Angle = angle; } // [Category("数据"), DisplayName("角度")] [Browsable(false)] [XmlElement("Base")] public DrawerPointBase Base { get; set; } = new DrawerPointBase(); [XmlIgnore] [Category("数据"), DisplayName("名字"), PropertyOrder(0)] public override string Name { get { return Base.Name; } set { if (Base.Name != value) { Base.Name = value; OnPropertyChanged(nameof(Name)); } } } [XmlIgnore] [Category("数据"), DisplayName("X"), PropertyOrder(1)] [TypeConverter(typeof(PropertyDoubleConverter))] public double X { get { return Base.X; } set { if (Base.X != value) { Base.X = value; OnPropertyChanged(nameof(X)); } } } [XmlIgnore] [Category("数据"), DisplayName("Y"), PropertyOrder(2)] [TypeConverter(typeof(PropertyDoubleConverter))] public double Y { get { return Base.Y; } set { if (Base.Y != value) { Base.Y = value; OnPropertyChanged(nameof(Y)); } } } [XmlIgnore] [Browsable(false)] [Category("数据"), DisplayName("Z"), PropertyOrder(3)] [TypeConverter(typeof(PropertyDoubleConverter))] public double Z { get { return Base.Z; } set { if (Base.Z != value) { Base.Z = value; OnPropertyChanged(nameof(Z)); } } } [XmlIgnore] [Category("数据"), DisplayName("Z"), PropertyOrder(3)] public string ZDisplay { get { if (Z == Constants.InvalidDouble) { return string.Empty; } else { return $"{Z}"; } } set { if (double.TryParse(value, out double z)) { Z = z; } else { Z = Constants.InvalidDouble; } } } [XmlIgnore] [Category("数据"), DisplayName("角度"), PropertyOrder(4)] [TypeConverter(typeof(PropertyDoubleConverter))] public double Angle { get { return Base.Angle; } set { Base.Angle = value; } } public void Offset(double dx, double dy) { this.X = this.X + dx; this.Y = this.Y + dy; } public event PropertyChangedEventHandler PropertyChanged; protected virtual void OnPropertyChanged(string propertyName) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } /// /// Dfd格式字符串 /// /// 字符串 public override string ToDfdString() { return $"3dPoint {X},{Y},{Z} {Angle} {Name}"; } public void CopyTo(DrawerPoint other) { if (other == null) { other = new DrawerPoint(); } base.CopyTo(other); other.Name = this.Name; other.X = this.X; other.Y = this.Y; other.Z = this.Z; other.Angle = this.Angle; } } public class DrawerPointBase { [XmlAttribute] public string Name { get; set; } [XmlAttribute] public double X { get; set; } [XmlAttribute] public double Y { get; set; } [XmlAttribute] public double Z { get; set; } = Constants.InvalidDouble; [XmlAttribute] public double Angle { get; set; } } }