using System; using System.Collections.Generic; using System.ComponentModel; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml; using System.Xml.Serialization; namespace GeoSigma.SigmaDrawerStyle { /// /// 文件导入,井位坐标 /// public class WellPositionProperty : IPropertyFileImport { private IRectangularCSGridPropertyChange iChange; private string horizon = "无"; private string xStart = "无"; private string xEnd = "无"; private string yStart = "无"; private string yEnd = "无"; private string wellName = "无"; /// /// Initializes a new instance of the class. /// public WellPositionProperty() { } /// /// Initializes a new instance of the class. /// /// public WellPositionProperty(IRectangularCSGridPropertyChange iChange) { } [Browsable(false)] public string ColumnLength { get; set; } [Category("\t属性"), DisplayName("\t\t\t\t\t\t层位"), Description("需要:井口坐标、目的层坐标")] [TypeConverter(typeof(Converter.WellPositionPropertyCorrespondConvert))] public string Horizon { get { return horizon; } set { horizon = value; } } [Category("\t属性"), DisplayName("\t\t\t\t\t井口X"), Description("需要:井口坐标、目的层坐标")] [TypeConverter(typeof(Converter.WellPositionPropertyCorrespondConvert))] public string XStart { get { return xStart; } set { xStart = value; } } [Category("\t属性"), DisplayName("\t\t\t\t井口Y"), Description("需要:井口坐标、目的层坐标")] [TypeConverter(typeof(Converter.WellPositionPropertyCorrespondConvert))] public string YStart { get { return yStart; } set { yStart = value; } } [Category("\t属性"), DisplayName("\t\t\t井底X"), Description("需要:井口坐标、目的层坐标")] [TypeConverter(typeof(Converter.WellPositionPropertyCorrespondConvert))] public string XEnd { get { return xEnd; } set { xEnd = value; } } [Category("\t属性"), DisplayName("\t\t井底Y"), Description("需要:井口坐标、目的层坐标")] [TypeConverter(typeof(Converter.WellPositionPropertyCorrespondConvert))] public string YEnd { get { return yEnd; } set { yEnd = value; } } [Category("\t属性"), DisplayName("\t名称"), Description("需要:井口坐标、目的层坐标")] [TypeConverter(typeof(Converter.WellPositionPropertyCorrespondConvert))] public string WellName { get { return wellName; } set { wellName = value; } } /// /// 输出Xml数据 /// /// public string SerialXml() { string strData = ""; XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.IndentChars = " "; settings.NewLineChars = "\r\n"; settings.Encoding = Encoding.Default; // 去除xml声明 settings.OmitXmlDeclaration = true; System.IO.MemoryStream mem = new MemoryStream(); using (XmlWriter writer = XmlWriter.Create(mem, settings)) { //去除默认命名空间xmlns:xsd和xmlns:xsi XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); ns.Add(string.Empty, string.Empty); XmlSerializer formatter = new XmlSerializer(this.GetType()); formatter.Serialize(writer, this, ns); } return Encoding.Default.GetString(mem.ToArray()); } } }