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/SigmaDrawerWellElement/WellSectionBendSetting.cs

370 lines
11 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Design;
using System.Xml.Serialization;
using GeoSigma.SigmaDrawerStyle;
using GeoSigma.SigmaDrawerStyle.Converter;
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
//bend对象映射类
[XmlRoot("Pcg")]
[TypeConverter(typeof(PropertySorter))]
public class WellSectionBendDataSetting
{
private const string Category = "\t\t连层属性";
[XmlIgnore]
[Category(Category)]
[DisplayName("连层样式")]
[PropertyOrder(1)]
[TypeConverter(typeof(YesNoConverter))]
[ListBoxEditor("BendStyle")]
[Editor(typeof(PropertyEditorListBox), typeof(UITypeEditor))]
public string styleName
{
get => this.bend.StyleName;
set => this.bend.StyleName = value;
}
[XmlIgnore]
[Category(Category)]
[DisplayName("连层上边界线")]
[PropertyOrder(2)]
[Editor(typeof(PropertyEditorWellCurveStyle), typeof(UITypeEditor))]
public WellLineStyle bendTopLine
{
get => new WellLineStyle()
{
Width = this.bend.BendPens.TopPen.Width,
Color = this.bend.BendPens.TopPen.Color,
Style = this.bend.BendPens.TopPen.Style,
};
set
{
bend.BendPens.TopPen.Width = value.Width;
bend.BendPens.TopPen.Color = value.Color;
bend.BendPens.TopPen.Style = value.Style;
}
}
[XmlIgnore]
[Category(Category)]
[DisplayName("连层下边界线")]
[PropertyOrder(3)]
[Editor(typeof(PropertyEditorWellCurveStyle), typeof(UITypeEditor))]
public WellLineStyle bendBottomLine
{
get => new WellLineStyle()
{
Width = this.bend.BendPens.BottomPen.Width,
Color = this.bend.BendPens.BottomPen.Color,
Style = this.bend.BendPens.BottomPen.Style,
};
set
{
this.bend.BendPens.BottomPen.Width = value.Width;
this.bend.BendPens.BottomPen.Color = value.Color;
this.bend.BendPens.BottomPen.Style = value.Style;
}
}
[XmlIgnore]
[Category(Category)]
[DisplayName("左侧颜色填充"), PropertyOrder(4)]
[TypeConverter(typeof(YesNoConverter))]
public bool IsLeft
{
get => BendFillStyleHelper.IsUseFillColor(this.bend,"L");
set => BendFillStyleHelper.SetIsFillColor(this.bend, value,"L");
}
[XmlIgnore]
[Category(Category)]
[DisplayName("左侧填充颜色")]
[PropertyOrder(5)]
[Editor(typeof(PropertyEditorColor), typeof(UITypeEditor))]
public Color leftClr
{
get => BendFillStyleHelper.GetFillColor(this.bend, "L");
set => BendFillStyleHelper.SetFillColor(this.bend,"L",value);
}
[XmlIgnore]
[Category(Category)]
[DisplayName("右侧颜色填充"), PropertyOrder(6)]
[TypeConverter(typeof(YesNoConverter))]
public bool IsRight
{
get => BendFillStyleHelper.IsUseFillColor(this.bend, "R");
set => BendFillStyleHelper.SetIsFillColor(this.bend, value, "R");
}
[XmlIgnore]
[Category(Category)]
[DisplayName("右侧填充颜色")]
[PropertyOrder(7)]
[Editor(typeof(PropertyEditorColor), typeof(UITypeEditor))]
public Color rightClr
{
get => BendFillStyleHelper.GetFillColor(this.bend, "R");
set => BendFillStyleHelper.SetFillColor(this.bend, "R", value);
}
[XmlElement("Stratum")]
[Browsable(false)]
public Stratum bend { get; set; }
}
public class BendFillStyleHelper
{
public static bool IsUseFillColor(Stratum bend,string lr)
{
bool b = false;
//if(bend.BendBrushs.FillStyles.Count>0)
for (int i = 0; i < bend.BendBrushs.FillStyles.Count; i++)
{
char[] chars = { ',' };
string[] strs = bend.BendBrushs.FillStyles[i].BrushStyle.Split(chars);
if (strs.Length > 1)
{
if (string.Compare(strs[0], lr, StringComparison.OrdinalIgnoreCase) == 0)
{
if (strs[1] == "0") //表示使用指定颜色填充
b = false;
else
b = true;
break;
}
}
}
return b;
}
public static void SetIsFillColor(Stratum bend, bool b, string lr)
{
for (int i = 0; i < bend.BendBrushs.FillStyles.Count; i++)
{
char[] chars = { ',' };
string[] strs = bend.BendBrushs.FillStyles[i].BrushStyle.Split(chars);
if (strs.Length > 1)
{
if (string.Compare(strs[0], lr, StringComparison.OrdinalIgnoreCase) == 0)
{
if (b)
bend.BendBrushs.FillStyles[i].BrushStyle = lr + ",1";// R,0";
else
bend.BendBrushs.FillStyles[i].BrushStyle = lr + ",0"; ;
break;
}
}
}
}
public static Color GetFillColor(Stratum bend,string lr)
{
Color color = Color.FromArgb(255, 255, 255, 255);
for (int i = 0; i < bend.BendBrushs.FillStyles.Count; i++)
{
char[] chars = { ',' };
string[] strs = bend.BendBrushs.FillStyles[i].BrushStyle.Split(chars);
if (strs.Length > 1)
{
if (string.Compare(strs[0], lr, StringComparison.OrdinalIgnoreCase) == 0)
{
color = ColorTranslator2.FromHtml(bend.BendBrushs.FillStyles[i].BackColor);
break;
}
}
}
return color;
}
public static void SetFillColor(Stratum bend,string lr,Color clr)
{
for (int i = 0; i < bend.BendBrushs.FillStyles.Count; i++)
{
char[] chars = { ',' };
string[] strs = bend.BendBrushs.FillStyles[i].BrushStyle.Split(chars);
if (strs.Length > 1)
{
if (string.Compare(strs[0], lr, StringComparison.OrdinalIgnoreCase) == 0)
{
bend.BendBrushs.FillStyles[i].BackColor = ColorTranslator2.ToHtml(clr);
break;
}
}
}
}
}
//bend数据映射类
public class Stratum
{
[XmlAttribute("ID")]
public string ID { get; set; }
[XmlAttribute("BendSlotType")]
public string BendSlotType { get; set; }
[XmlAttribute("LeftLayerIndex")]
public int LeftLayerIndex { get; set; }
[XmlAttribute("LeftLayer")]
public string LeftLayer { get; set; }
[XmlAttribute("LeftWell")]
public string LeftWell { get; set; }
[XmlAttribute("RightLayerIndex")]
public int RightLayerIndex { get; set; }
[XmlAttribute("RightLayer")]
public string RightLayer { get; set; }
[XmlAttribute("RightWell")]
public string RightWell { get; set; }
[XmlAttribute("EndPos")]
public double EndPos { get; set; }
[XmlAttribute("EndDepth")]
public double EndDepth { get; set; }
[XmlAttribute("FillPatternScale")]
public int FillPatternScale { get; set; }
[XmlElement("BendPens")]
public BendPens BendPens { get; set; }
[XmlElement("BendBrushs")]
public BendBrushs BendBrushs { get; set; }
[XmlElement("BendControls")]
public BendControls BendControls { get; set; }
[XmlElement("BendBorders")]
public BendBorders BendBorders { get; set; }
[XmlElement("FaultControls")]
public FaultControls FaultControls { get; set; }
[XmlAttribute("StyleName")]
public string StyleName { get; set; }
}
public class BendPens
{
[XmlElement("TopPen")]
public WellLineStyle TopPen { get; set; }
[XmlElement("BottomPen")]
public WellLineStyle BottomPen { get; set; }
}
public class BendBrushs
{
[XmlElement("FillStyle")]
public List<FillStyle> FillStyles { get; set; }
}
public class FillStyle
{
[XmlAttribute("BrushStyle")]
public string BrushStyle { get; set; }
[XmlAttribute("BackColor")]
public string BackColor { get; set; }
[XmlAttribute("ForeColor")]
public string ForeColor { get; set; }
[XmlAttribute("Visible")]
public int Visible { get; set; }
}
public class BendControls
{
[XmlElement("BendControl")]
public List<BendControl> BendControlList { get; set; }
}
public class BendControl
{
[XmlAttribute("X")]
public double X { get; set; }
[XmlAttribute("Y")]
public double Y { get; set; }
[XmlAttribute("Level")]
public int Level { get; set; }
}
public class BendBorders
{
[XmlElement("TopBorder")]
public Border TopBorder { get; set; }
[XmlElement("BottomBorder")]
public Border BottomBorder { get; set; }
}
public class Border
{
[XmlAttribute("IsAnomaly")]
public bool IsAnomaly { get; set; }
[XmlAttribute("Color")]
public string Color { get; set; }
[XmlAttribute("Width")]
public int Width { get; set; }
[XmlElement("Point")]
public List<BendPoint> Points { get; set; }
}
public class BendPoint
{
[XmlAttribute("X")]
public double X { get; set; }
[XmlAttribute("Y")]
public double Y { get; set; }
}
public class FaultControls
{
[XmlElement("FaultControl")]
public List<FaultControl> FaultControlList { get; set; }
}
public class FaultControl
{
[XmlAttribute("ID")]
public int ID { get; set; }
[XmlAttribute("UThrow")]
public double UThrow { get; set; }
[XmlAttribute("DThrow")]
public double DThrow { get; set; }
}
}