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.

353 lines
9.9 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using SigmaDrawerStyle;
#if NET8_0
#else
using System.Drawing.Design;
#endif
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace GeoSigma.SigmaDrawerStyle
{
[TypeConverter(typeof(PropertySorter))]
[XmlRoot("InNameAny")]
public class CurveInNameAny : CurveView
{
/// <summary>
/// 属性类别排序
/// </summary>
private List<string> categorys = new List<string>() { "基础属性", "文字", "线属性", "桩号" };
/// <summary>
/// Initializes a new instance of the <see cref="CurveInNameAny"/> class.
/// </summary>
public CurveInNameAny()
{
TypeName = "任意处写名字";
}
[XmlIgnore]
[Category("桩号"), DisplayName("桩号列表"), Description("桩号列表"), PropertyOrder(13)]
public string LocateList
{
get
{
return Location.Value;
}
set
{
Location.Value = value;
}
}
//private Font _TextFont;
//[XmlIgnore]
//[Category("\t文字"), DisplayName("\t\t\t\t\t\t\t字体")]
//[TypeConverterAttribute(typeof(FontPropertyConvert))]
//public Font TextFont
//{
// get
// {
// _TextFont=Font.FromLogFont(NameFont);
// return _TextFont;
// }
// set
// {
// _TextFont=value;
// NameFont=LogFontConverter.convert(_TextFont);
// }
//}
[XmlIgnore]
[Category("文字"), DisplayName("高度"), PropertyOrder(1)]
[TypeConverter(typeof(PropertyDoubleConverter))]
public double TextHeight
{
get
{
return Text.Height;
}
set
{
Text.Height = value;
}
}
[XmlIgnore]
[Category("文字"), DisplayName("类型"), PropertyOrder(2)]
[TypeConverter(typeof(Converter.CurveNameLineTypeConverter))]
public int InNameType
{//数目或步长
get
{
return Style.Value & ((int)LineType.PLINE_MARK_NAME_NUM | (int)LineType.PLINE_MARK_NAME_STEP);
}
set
{
Style.Value &= ~((int)LineType.PLINE_MARK_NAME_NUM | (int)LineType.PLINE_MARK_NAME_STEP);
Style.Value |= value;
}
}
[XmlIgnore]
[Category("文字"), DisplayName("数量"), PropertyOrder(3)]
[TypeConverter(typeof(PropertyIntConverter))]
public int NameNum
{
get
{
return (int)(Text.NumOrStep + 0.0001);
}
set
{
Text.NumOrStep = value;
}
}
[Browsable(true)]
[XmlIgnore]
[Category("文字"), DisplayName("步长"), PropertyOrder(4)]
[TypeConverter(typeof(Converter.CurveNameLineTypeConverter))]
public double Step
{
get
{
return Text.NumOrStep;
}
set
{
Text.NumOrStep = value;
}
}
[XmlIgnore]
[Category("文字"), DisplayName("偏移"), PropertyOrder(5)]
[TypeConverter(typeof(Converter.CurveNameLineTypeConverter))]
public double Offset
{
get
{
return Text.Offset;
}
set
{
Text.Offset = value;
}
}
[XmlIgnore]
[Category("文字"), DisplayName("颜色"), PropertyOrder(6)]
#if NET8_0
#else
[Editor(typeof(PropertyEditorColor), typeof(UITypeEditor))]
#endif
[TypeConverter(typeof(PropertyColorIndicatorConvert))]
public Color TextColor
{
get
{
return ColorTranslator.FromWin32(Text.ColorRef);
}
set
{
Text.ColorRef = ColorTranslator.ToWin32(value);
}
}
[XmlIgnore]
[Category("文字"), DisplayName("自动缩小字体"), PropertyOrder(7)]
[TypeConverter(typeof(Converter.YesNoConverter))]
public bool AutoDecrease
{
get
{
if ((Style.Value & (int)Constants.PLINE_IN_NAME_AUTO_DECREASE) != 0)
return true;
return false;
}
set
{
if (value == true)
{
Style.Value |= (int)Constants.PLINE_IN_NAME_AUTO_DECREASE;
}
else
{
Style.Value &= ~(int)Constants.PLINE_IN_NAME_AUTO_DECREASE;
}
}
}
[XmlIgnore]
[Category("线属性"), DisplayName("宽度"), PropertyOrder(8)]
[TypeConverter(typeof(Converter.CurveNameLineTypeConverter))]
public double Width
{
get
{
return Curve.Width;
}
set
{
Curve.Width = value;
}
}
[XmlIgnore]
[Category("线属性"), DisplayName("颜色"), PropertyOrder(9)]
#if NET8_0
#else
[Editor(typeof(PropertyEditorColor), typeof(UITypeEditor))]
#endif
[TypeConverter(typeof(PropertyColorIndicatorConvert))]
public Color CurveColor
{
get
{
return ColorTranslator.FromWin32(Curve.ColorRef);
}
set
{
Curve.ColorRef = ColorTranslator.ToWin32(value);
}
}
[XmlIgnore]
[Category("线属性"), DisplayName("显示方式"), PropertyOrder(10)]
[TypeConverter(typeof(Converter.LineTypeConverter))]
public int CurveType
{
get
{
return Style.Value & (int)LineType.PLINE_TYPE_ALL;
}
set
{
Style.Value &= ~((int)LineType.PLINE_TYPE_ALL);
Style.Value |= value;
}
}
private bool smoothHead = true;
[XmlIgnore]
[Category("线属性"), DisplayName("圆头显示"), PropertyOrder(11)]
[TypeConverter(typeof(Converter.YesNoConverter))]
public bool SmoothHead
{
get
{
return smoothHead;
// return (Style.Value&(int)LineType.PLINE_SMOOTH_HEAD)!=0;
}
set
{
smoothHead = value;
if (value)
{
Style.Value |= (int)LineType.PLINE_SMOOTH_HEAD;
}
else
{
Style.Value &= ~(int)LineType.PLINE_SMOOTH_HEAD;
}
}
}
//[XmlIgnore]
//[Category("\t基础属性"), DisplayName("\t\t\t\t虚线(有线长度 无线长度 ...)")]
//public string VirtureValues
//{
// get
// {
// return _VirtureType.VirtureValues;
// }
// set
// {
// _VirtureType.VirtureValues=value;
// }
//}
//[XmlIgnore]
//[Category("\t线属性"), DisplayName("\t\t\t仅拐点处虚线")]
//public bool OnlyNodeVirture
//{
// get
// {
// return _VirtureType.OnlyNodeVirture;
// }
// set
// {
// _VirtureType.OnlyNodeVirture=value;
// }
//}
//[XmlIgnore]
//[Category("\t线属性"), DisplayName("\t\t平行间距")]
//public double Offset
//{
// get
// {
// return _Base.Offset;
// }
// set
// {
// _Base.Offset=value;
// }
//}
[XmlIgnore]
[Category("线属性"), DisplayName("光滑步长"), PropertyOrder(12)]
[TypeConverter(typeof(PropertyDoubleConverter))]
public double SmoothStep
{
get
{
return Curve.SmoothStep;
}
set
{
Curve.SmoothStep = value;
}
}
[Browsable(false)]
public InNameStyle Style { get; set; } = new InNameStyle();
[Browsable(false)]
public InNameAnyText Text { get; set; } = new InNameAnyText();
[Browsable(false)]
public InNameCurve Curve { get; set; } = new InNameCurve();
[Browsable(false)]
public InNameAnyLocation Location { get; set; } = new InNameAnyLocation();
//[Browsable(false)]
//[XmlElement("Font")]
//public LogFont NameFont { get; set; }
//private Font _TextFont;
//[XmlIgnore]
//[Category("\t名字"), DisplayName("\t\t\t\t\t\t\t字体")]
//public Font TextFont
//{
// get
// {
// _TextFont=Font.FromLogFont(NameFont);
// return _TextFont;
// }
// set
// {
// _TextFont=value;
// NameFont=new LogFont();
// _TextFont.ToLogFont(NameFont);
// }
//}
}
public class InNameAnyText
{
[XmlAttribute]
public double Height { get; set; } = 200;
[XmlAttribute("Color")]
public int ColorRef { get; set; }
[XmlAttribute]
public double NumOrStep { get; set; }
[XmlAttribute]
public double Offset { get; set; }
}
public class InNameAnyLocation
{
[XmlAttribute]
public string Value { get; set; } = "1000";
}
}