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.

259 lines
7.7 KiB
C#

using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Design;
using System.Text;
using System.Xml.Serialization;
using GeoSigma.SigmaDrawerStyle;
using GeoSigmaDrawLib;
using SigmaDrawerStyle;
namespace GeoSigma.SigmaDrawerElement
{
#pragma warning disable SA1402 // File may only contain a single type
#pragma warning disable SA1600 // Elements should be documented
#pragma warning disable SA1649 // File name should match first type name
public class LithologyInfo
{
public string Color { get; set; }
public string OilGas { get; set; }
public string Content { get; set; }
public string Front { get; set; }
public string Structure { get; set; }
public string Lithology{ get; set; }
public static LithologyInfo Decode(string lithoCode)
{
GeoSigmaWellPoleXY.GetSymbolNamesForLithologyColor(out string[] colors);
GeoSigmaWellPoleXY.GetSymbolNamesForLithOilGas(out string[] oilGas);
GeoSigmaWellPoleXY.GetSymbolNamesForLithContent(out string[] contents);
GeoSigmaWellPoleXY.GetSymbolNamesForLithFront(out string[] fronts);
GeoSigmaWellPoleXY.GetSymbolNamesForLithConstitution(out string[] structures);
GeoSigmaWellPoleXY.GetSymbolNamesForLithology(out string[] lithologies);
var info = new LithologyInfo();
string remaining = lithoCode;
// 匹配 Color
info.Color = MatchFirst(remaining, colors, out int len1);
remaining = remaining.Substring(len1);
// 匹配 OilGas
info.OilGas = MatchFirst(remaining, oilGas, out int len2);
remaining = remaining.Substring(len2);
// 匹配 Content
info.Content = MatchFirst(remaining, contents, out int len3);
remaining = remaining.Substring(len3);
// 匹配 Front
info.Front = MatchFirst(remaining, fronts, out int len4);
remaining = remaining.Substring(len4);
// 匹配 Structure
info.Structure = MatchFirst(remaining, structures, out int len5);
remaining = remaining.Substring(len5);
// 匹配 Lithology
info.Lithology = MatchFirst(remaining, lithologies, out int len6);
return info;
}
private static string MatchFirst(string text, string[] candidates, out int length)
{
foreach (var c in candidates)
{
if (!string.IsNullOrEmpty(c) && text.StartsWith(c))
{
length = c.Length;
return c;
}
}
length = 0;
return string.Empty;
}
public string Encode()
{
return $"{Color}{OilGas}{Content}{Front}{Structure}{Lithology}";
}
}
/// <summary>
/// 编辑岩性信息
/// </summary>
[XmlRoot("Pcg")]
[TypeConverter(typeof(PropertySorter))]
public class WellLithologySection : baseInTrackObj
{
private const string lithItemCategory = "\t\t编辑岩性";
[XmlIgnore]
[Category(lithItemCategory)]
[DisplayName("顶深")]
[PropertyOrder(0)]
public double TopDepth
{
get => LithologyItem.Top;
set => LithologyItem.Top = value;
}
[XmlIgnore]
[Category(lithItemCategory)]
[DisplayName("底深")]
[PropertyOrder(1)]
public double BottomDepth
{
get => LithologyItem.Bottom;
set => LithologyItem.Bottom = value;
}
[XmlIgnore]
[Category(lithItemCategory)]
[DisplayName("颜色")]
[PropertyOrder(2)]
[ListBoxEditor("LithologyColor")]
[Editor(typeof(PropertyEditorListBox), typeof(UITypeEditor))]
public string Color
{
get => LithologyInfo.Color;
set
{
LithologyInfo.Color = value;
LithologyItem.LithoCode = LithologyInfo.Encode();
}
}
[XmlIgnore]
[Category(lithItemCategory)]
[DisplayName("含油气性")]
[PropertyOrder(3)]
[ListBoxEditor("OilGas")]
[Editor(typeof(PropertyEditorListBox), typeof(UITypeEditor))]
public string OilGasProperty
{
get => LithologyInfo.OilGas;
set
{
LithologyInfo.OilGas = value;
LithologyItem.LithoCode = LithologyInfo.Encode();
}
}
[XmlIgnore]
[Category(lithItemCategory)]
[DisplayName("含有物")]
[PropertyOrder(4)]
[ListBoxEditor("LithContent")]
[Editor(typeof(PropertyEditorListBox), typeof(UITypeEditor))]
public string Inclusion
{
get => lithologyInfo.Content;
set
{
LithologyInfo.Content = value;
LithologyItem.LithoCode = LithologyInfo.Encode();
}
}
[XmlIgnore]
[Category(lithItemCategory)]
[DisplayName("岩性前缀")]
[PropertyOrder(5)]
[ListBoxEditor("LithFront")]
[Editor(typeof(PropertyEditorListBox), typeof(UITypeEditor))]
public string LithologyPrefix
{
get => LithologyInfo.Front;
set
{
LithologyInfo.Front = value;
LithologyItem.LithoCode = LithologyInfo.Encode();
}
}
[XmlIgnore]
[Category(lithItemCategory)]
[DisplayName("构造")]
[PropertyOrder(6)]
[ListBoxEditor("LithConstitution")]
[Editor(typeof(PropertyEditorListBox), typeof(UITypeEditor))]
public string Structure
{
get => LithologyInfo.Structure;
set
{
LithologyInfo.Structure = value;
LithologyItem.LithoCode = LithologyInfo.Encode();
}
}
[XmlIgnore]
[Category(lithItemCategory)]
[DisplayName("岩性")]
[PropertyOrder(7)]
[ListBoxEditor("Lithology")]
[Editor(typeof(PropertyEditorListBox), typeof(UITypeEditor))]
public string Lithology
{
get => LithologyInfo.Lithology;
set
{
LithologyInfo.Lithology = value;
LithologyItem.LithoCode = LithologyInfo.Encode();
}
}
private LithologyInfo lithologyInfo;
private LithologyInfo LithologyInfo
{
get
{
if (lithologyInfo == null)
{
lithologyInfo = LithologyInfo.Decode(LithologyItem.LithoCode);
}
return lithologyInfo;
}
set
{
lithologyInfo = value;
}
}
[Browsable(false)]
[XmlAttribute("Version")]
public int Version { get; set; }
[Browsable(false)]
[XmlElement("Lithology")]
public WellLithologySectionLithology LithologyItem { get; set; }
}
public class WellLithologySectionLithology
{
[XmlAttribute("Name")]
public string Name { get; set; }
[XmlAttribute("LithoCode")]
public string LithoCode { get; set; }
[XmlAttribute("Top")]
public double Top { get; set; }
[XmlAttribute("Bottom")]
public double Bottom { get; set; }
[XmlElement("RenderStyle")]
public WellRenderStyle RenderStyle { get; set; }
}
#pragma warning restore SA1649 // File name should match first type name
#pragma warning restore SA1600 // Elements should be documented
#pragma warning restore SA1402 // File may only contain a single type
}