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.

318 lines
8.3 KiB
C#

// <copyright file="CurveProperty.cs" company="PlaceholderCompany">
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
#if NET8_0
#else
using System.Drawing.Design;
#endif
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
using SigmaDrawerStyle;
namespace GeoSigma.SigmaDrawerStyle
{
/// <summary>
/// 曲线属性
/// </summary>
[XmlRoot("Property")]
[TypeConverter(typeof(PropertySorter))]
public class CurveProperty : CurveArrow
{
/// <summary>
/// Initializes a new instance of the <see cref="CurveProperty"/> class.
/// </summary>
public CurveProperty()
{
_VirtureType.OnlyNodeVirture = false;
TypeName = "常规";
CurveType = 0;
SmoothHead = true;
_WaveStyle.T = 30000;
_WaveStyle.A = 20000;
_WaveStyle.dnum = 10;
}
private ViewBase _Base;
[XmlElement("Base")]
[Browsable(false)]
public ViewBase Base
{
get
{
return _Base;
}
set { _Base = value; }
}
private CurveVirtureType _VirtureType;
[XmlElement("VirtualLine")]
[Browsable(false)]
public CurveVirtureType VirtureType
{
get
{
return _VirtureType;
}
set
{
_VirtureType = value;
}
}
private CurveWaveStyle _WaveStyle;
[XmlElement("Wave")]
[Browsable(false)]
public CurveWaveStyle WaveStyle
{
get
{
return _WaveStyle;
}
set
{
_WaveStyle = value;
}
}
[XmlIgnore]
[Category("基础属性"), /*CategoryOrder(0),*/ DisplayName("宽度"), PropertyOrder(1)]
[TypeConverter(typeof(PropertyDoubleConverter))]
public double Width
{
get
{
return Base.Width;
}
set
{
_Base.Width = value;
}
}
[XmlIgnore]
[Category("基础属性"), /*CategoryOrder(0),*/ DisplayName("颜色"), PropertyOrder(2)]
#if NET8_0
#else
[Editor(typeof(PropertyEditorColor), typeof(UITypeEditor))]
#endif
[TypeConverter(typeof(PropertyColorIndicatorConvert))]
public Color LineColor
{
get
{
return ColorTranslator.FromWin32(_Base.ColorRef);
}
set
{
_Base.ColorRef = ColorTranslator.ToWin32(value);
}
}
[XmlIgnore]
[Category("基础属性"), DisplayName("显示方式"), PropertyOrder(3)]
[TypeConverter(typeof(Converter.LineTypeConverter))]
public int CurveType
{
get
{
return _Base.Style & (int)LineType.PLINE_TYPE_ALL;
}
set
{
// _Base.Style = value;
_Base.Style &= ~((int)LineType.PLINE_TYPE_ALL);
_Base.Style |= value;
}
}
[XmlIgnore]
[Category("基础属性"), DisplayName("圆头显示"), PropertyOrder(4)]
[TypeConverter(typeof(Converter.YesNoConverter))]
public bool SmoothHead
{
get
{
return (_Base.Style & (int)LineType.PLINE_SMOOTH_HEAD) != 0;
}
set
{
if (value)
{
_Base.Style |= (int)LineType.PLINE_SMOOTH_HEAD;
}
else
{
_Base.Style &= ~(int)LineType.PLINE_SMOOTH_HEAD;
}
}
}
[XmlIgnore]
[Category("基础属性"), DisplayName("虚线(有线长度 无线长度 ...)"), PropertyOrder(5)]
public string VirtureValues
{
get
{
return _VirtureType.VirtureValues;
}
set
{
_VirtureType.VirtureValues = value;
}
}
[XmlIgnore]
[Category("基础属性"), DisplayName("仅拐点处虚线"), PropertyOrder(6)]
[TypeConverter(typeof(Converter.YesNoConverter))]
public bool OnlyNodeVirture
{
get
{
return _VirtureType.OnlyNodeVirture;
}
set
{
_VirtureType.OnlyNodeVirture = value;
}
}
[XmlIgnore]
[Category("基础属性"), DisplayName("平行间距"), PropertyOrder(7)]
[TypeConverter(typeof(PropertyDoubleConverter))]
public double Offset
{
get
{
return _Base.Offset;
}
set
{
_Base.Offset = value;
}
}
[XmlIgnore]
[Category("基础属性"), DisplayName("光滑步长"), PropertyOrder(8)]
[TypeConverter(typeof(PropertyDoubleConverter))]
public double SmoothStep
{
get
{
return _Base.SmoothStep;
}
set
{
_Base.SmoothStep = value;
}
}
private int alpha = 255;
/// <summary>
/// 透明属性
/// </summary>
[Category("透明属性"), DisplayName("透明度"), PropertyOrder(1), ReadOnly(false)]
public int Alpha
{
get
{
return alpha;
}
set
{
if (value < 0)
{
alpha = 0;
}
else if (value > 255)
{
alpha = 255;
}
else
{
alpha = value;
}
}
}
[XmlIgnore]
[Category("波浪线属性"), DisplayName("周期"), PropertyOrder(1), ReadOnly(false)]
[TypeConverter(typeof(PropertyDoubleConverter))]
public double WaveT
{
get
{
return _WaveStyle.T;
}
set
{
_WaveStyle.T = value;
}
}
[XmlIgnore]
[Category("波浪线属性"), DisplayName("振幅"), PropertyOrder(2),ReadOnly(false)]
[TypeConverter(typeof(PropertyDoubleConverter))]
public double WaveA
{
get
{
return _WaveStyle.A;
}
set
{
_WaveStyle.A = value;
}
}
[XmlIgnore]
[Category("波浪线属性"), DisplayName("采样点数"), PropertyOrder(3), ReadOnly(false)]
[TypeConverter(typeof(PropertyIntConverter))]
public int WaveNum
{
get
{
return _WaveStyle.dnum;
}
set
{
_WaveStyle.dnum = value;
}
}
/// <summary>
/// 属性类别排序
/// </summary>
private List<string> categorys = new List<string>() {"基础属性", "波浪线属性", "透明属性" };
}
public struct ViewBase
{
[XmlAttribute("Width")]
public double Width;
[XmlAttribute("Color")]
public int ColorRef;
[XmlAttribute("Style")]
public int Style;
[XmlAttribute("SmoothStep")]
public double SmoothStep;
[XmlAttribute("Offset")]
public double Offset;
}
public struct CurveVirtureType
{
[XmlAttribute("Number")]
public int Num;
[XmlAttribute("IsNode")]
public bool OnlyNodeVirture;
[XmlAttribute("Value")]
public string VirtureValues;
}
public struct CurveWaveStyle
{
[XmlAttribute("T")]
public double T; //采样周期
[XmlAttribute("A")]
public double A; //振幅
[XmlAttribute("N")]
public int dnum; //一个周期内采样点个数
};
}