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.

486 lines
14 KiB
C#

1 month ago
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using SigmaDrawerStyle;
1 month ago
#if WEB_SERVICE
1 month ago
#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>
1 month ago
private List<string> categorys = new List<string>() { "基础属性", "文字", "线属性", "桩号" , "其他"};
1 month ago
/// <summary>
/// Initializes a new instance of the <see cref="CurveInNameAny"/> class.
/// </summary>
public CurveInNameAny()
{
TypeName = "任意处写名字";
}
1 month ago
[XmlIgnore]
[Category("其他"), DisplayName("小数位数"), Description("小数位数"), PropertyOrder(1)]
public int DecimalName
{
get
{
return Text.DecimalName;
}
set
{
Text.DecimalName = value;
}
}
1 month ago
[XmlIgnore]
1 month ago
[Category("\t桩号"), DisplayName("桩号列表"), Description("桩号列表"), PropertyOrder(1)]
1 month ago
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]
1 month ago
[Category("\t\t\t文字"), DisplayName("高度"), PropertyOrder(1)]
1 month ago
[TypeConverter(typeof(PropertyDoubleConverter))]
public double TextHeight
{
get
{
return Text.Height;
}
set
{
Text.Height = value;
}
}
[XmlIgnore]
1 month ago
[Category("\t\t\t文字"), DisplayName("类型"), PropertyOrder(2)]
1 month ago
[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]
1 month ago
[Category("\t\t\t文字"), DisplayName("数量"), PropertyOrder(3)]
1 month ago
[TypeConverter(typeof(PropertyIntConverter))]
public int NameNum
{
get
{
return (int)(Text.NumOrStep + 0.0001);
}
set
{
Text.NumOrStep = value;
}
}
[Browsable(true)]
[XmlIgnore]
1 month ago
[Category("\t\t\t文字"), DisplayName("步长"), PropertyOrder(4)]
1 month ago
[TypeConverter(typeof(Converter.CurveNameLineTypeConverter))]
public double Step
{
get
{
return Text.NumOrStep;
}
set
{
Text.NumOrStep = value;
}
}
[XmlIgnore]
1 month ago
[Category("\t\t\t文字"), DisplayName("偏移"), PropertyOrder(5)]
1 month ago
[TypeConverter(typeof(Converter.CurveNameLineTypeConverter))]
public double Offset
{
get
{
return Text.Offset;
}
set
{
Text.Offset = value;
}
}
[XmlIgnore]
1 month ago
[Category("\t\t\t文字"), DisplayName("颜色"), PropertyOrder(6)]
#if WEB_SERVICE
1 month ago
#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]
1 month ago
[Category("\t\t\t文字"), DisplayName("自动缩小字体"), PropertyOrder(7)]
1 month ago
[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]
1 month ago
[Category("\t\t线属性"), DisplayName("宽度"), PropertyOrder(8)]
1 month ago
[TypeConverter(typeof(Converter.CurveNameLineTypeConverter))]
public double Width
{
get
{
return Curve.Width;
}
set
{
Curve.Width = value;
}
}
[XmlIgnore]
1 month ago
[Category("\t\t线属性"), DisplayName("颜色"), PropertyOrder(9)]
#if WEB_SERVICE
1 month ago
#else
[Editor(typeof(PropertyEditorColor), typeof(UITypeEditor))]
#endif
1 month ago
//[TypeConverter(typeof(PropertyColorIndicatorConvert))]
1 month ago
public Color CurveColor
{
get
{
return ColorTranslator.FromWin32(Curve.ColorRef);
}
set
{
Curve.ColorRef = ColorTranslator.ToWin32(value);
}
}
1 month ago
[Category("\t\t线属性"), DisplayName("样式"), PropertyOrder(10)]
[TypeConverter(typeof(Converter.CurveLineStyleConverter))]
public CurveLineStyle CurveStyle
1 month ago
{
get
{
1 month ago
if (hasLineType(LineType.PLINE_ZERO))
{
return CurveLineStyle.Default;
}
if (hasLineType(LineType.PLINE_NODRAW))
{
return CurveLineStyle.NoDraw;
}
if (hasLineType(LineType.PLINE_CLOSE))
{
return CurveLineStyle.Close;
}
return CurveLineStyle.Default;
1 month ago
}
1 month ago
1 month ago
set
{
1 month ago
clearLineType(LineType.PLINE_ZERO);
clearLineType(LineType.PLINE_NODRAW);
clearLineType(LineType.PLINE_CLOSE);
if (value == CurveLineStyle.NoDraw)
{
setLineType(LineType.PLINE_NODRAW);
}
if (value == CurveLineStyle.Close)
{
setLineType(LineType.PLINE_CLOSE);
}
1 month ago
}
}
[XmlIgnore]
1 month ago
[Category("\t\t线属性"), DisplayName("线端"), PropertyOrder(11)]
[TypeConverter(typeof(Converter.CurveCapConverter))]
public CurveCap CurveLineCap
1 month ago
{
get
{
1 month ago
return hasLineType(LineType.PLINE_SMOOTH_HEAD) ? CurveCap.Round : CurveCap.Square;
1 month ago
}
set
{
1 month ago
if (value == CurveCap.Round)
1 month ago
{
1 month ago
setLineType(LineType.PLINE_SMOOTH_HEAD);
1 month ago
}
else
{
1 month ago
clearLineType(LineType.PLINE_SMOOTH_HEAD);
}
}
}
[XmlIgnore]
[Category("\t\t线属性"), DisplayName("平滑"), PropertyOrder(12)]
[TypeConverter(typeof(Converter.CurveSmoothnessConverter))]
public CurveSmoothness CurveSmoothness
{
get
{
if (hasLineType(LineType.PLINE_BEZIER))
{
return CurveSmoothness.Bezier;
}
if (hasLineType(LineType.PLINE_SPLINE))
{
return CurveSmoothness.Spline;
}
return CurveSmoothness.None;
}
set
{
// 清理,因为我们这里使用枚举表示,选中其中一个之后,其它的都要清理掉
clearLineType(LineType.PLINE_BEZIER);
clearLineType(LineType.PLINE_SPLINE);
if (value == CurveSmoothness.Bezier)
{
setLineType(LineType.PLINE_BEZIER);
}
else if (value == CurveSmoothness.Spline)
{
setLineType(LineType.PLINE_SPLINE);
}
}
}
[XmlIgnore]
[Category("\t\t线属性"), DisplayName("透明"), PropertyOrder(13)]
[TypeConverter(typeof(Converter.CurveAlphaModeConverter))]
public CurveAlphaMode CurveAlphaMode
{
get
{
if (hasLineType(LineType.PLINE_TRANSPARENT))
{
return CurveAlphaMode.Transparent;
}
if (hasLineType(LineType.PLINE_TRANSPARENT_VALUE))
{
return CurveAlphaMode.Alphand;
}
return CurveAlphaMode.None;
}
set
{
clearLineType(LineType.PLINE_TRANSPARENT);
clearLineType(LineType.PLINE_TRANSPARENT_VALUE);
if (value == CurveAlphaMode.Transparent)
{
setLineType(LineType.PLINE_TRANSPARENT);
}
else if (value == CurveAlphaMode.Alphand)
{
setLineType(LineType.PLINE_TRANSPARENT_VALUE);
1 month ago
}
}
}
1 month ago
1 month ago
//[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]
1 month ago
[Category("\t\t线属性"), DisplayName("光滑步长"), PropertyOrder(12)]
1 month ago
[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();
1 month ago
private bool hasLineType(LineType lineType)
{
return (Style.Value & (int)lineType) != 0;
}
private void setLineType(LineType lineType)
{
Style.Value |= (int)lineType;
}
private void clearLineType(LineType lineType)
{
Style.Value &= ~(int)lineType;
}
1 month ago
//[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; }
1 month ago
// 存储小数位数默认为0
[XmlAttribute]
public int DecimalName { get; set; } = -1;
1 month ago
}
public class InNameAnyLocation
{
[XmlAttribute]
public string Value { get; set; } = "1000";
}
}