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.

415 lines
13 KiB
C#

1 month ago
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
1 month ago
#if WEB_SERVICE
1 month ago
#else
using System.Drawing.Design;
#endif
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
using GeoSigmaDrawLib;
using SigmaDrawerStyle;
namespace GeoSigma.SigmaDrawerStyle
{
[XmlRoot("ScaleSymbol")]
[TypeConverter(typeof(PropertySorter))]
public class CurveScaleSymbol : CurveView
{
/// <summary>
/// 属性类别排序
/// </summary>
private List<string> categorys = new List<string>() { "基础属性", "桩号", "其它" };
/// <summary>
/// Initializes a new instance of the <see cref="CurveScaleSymbol"/> class.
/// </summary>
public CurveScaleSymbol()
{
TypeName = "刻度";
}
[XmlIgnore]
[Browsable(false)]
1 month ago
#if WEB_SERVICE
1 month ago
#else
[Editor("UCDraw.Editor.MarkEditor, UCDraw", typeof(UITypeEditor))]
#endif
1 month ago
public string MarkName
1 month ago
{
get
{
return Base.MarkName;
}
set
{
Base.MarkName = value;
}
}
private SymbolNameWrapper symbolEditor = new SymbolNameWrapper();
[XmlIgnore]
[Category("基础属性"), DisplayName("\t\t\t\t\t\t\t\t刻度符号"), Description("刻度符号")]
1 month ago
#if WEB_SERVICE
1 month ago
#else
[Editor("GeoSigma.SigmaDrawerStyle.PropertyEditorSymbol, GeoSigma.SigmaDrawerStyle", typeof(UITypeEditor))]
#endif
public SymbolNameWrapper SymbolEditor
{
get
{
symbolEditor.SymbolName = MarkName;
symbolEditor.DrawerGeo = Geo;
1 month ago
1 month ago
return symbolEditor;
}
set
{
symbolEditor = value;
this.Geo = (GeoSigmaXY)symbolEditor.DrawerGeo;
MarkName = symbolEditor.SymbolName;
}
}
[XmlIgnore]
[Category("基础属性"), DisplayName("\t\t\t\t\t\t\t步长"), Description("步长")]
[TypeConverterAttribute(typeof(PropertyDoubleConverter))]
public double Step
{
get
{
return Locate.Step;
}
set
{
Locate.Step = value;
}
}
[XmlIgnore]
[Category("基础属性"), DisplayName("\t\t\t\t\t\t尺寸"), Description("尺寸")]
[TypeConverterAttribute(typeof(PropertySizeConvert))]
public SizeF LocateSize
{
get
{
return new SizeF((float)Base.Width, (float)Base.Height);
}
set
{
Base.Width = value.Width;
Base.Height = value.Height;
}
}
[XmlIgnore]
[Category("基础属性"), DisplayName("\t\t\t\t\t\t角度"), Description("角度")]
[TypeConverter(typeof(PropertyDoubleConverter))]
public double Angle
{
get
{
return Base.Angle;
}
set
{
Base.Angle = value;
}
}
[XmlIgnore]
[Category("桩号"), DisplayName("\t\t\t\t开始桩号"), Description("开始桩号")]
[TypeConverter(typeof(PropertyDoubleConverter))]
public double LocateBegin
{
get
{
return Locate.Begin;
}
set
{
Locate.Begin = value;
}
}
[XmlIgnore]
[Category("桩号"), DisplayName("\t\t\t结束桩号"), Description("结束桩号")]
[TypeConverter(typeof(PropertyDoubleConverter))]
public double LocateEnd
{
get
{
return Locate.End;
}
set
{
Locate.End = value;
}
}
[XmlIgnore]
[Category("桩号"), DisplayName("\t\t偏移"), Description("偏移")]
[TypeConverter(typeof(PropertyDoubleConverter))]
public double YOffset
{
get
{
return Offset.Y;
}
set
{
Offset = new PropertyPoint(0, value);
}
}
[XmlIgnore]
[Category("其它"), DisplayName("\t\t\t\t\t桩号取整"), Description("桩号取整")]
[TypeConverter(typeof(Converter.YesNoConverter))]
public bool IsInteger
{
get
{
return (Other.Style & (int)CurveLocalStyle.PLINE_LOCAT_TO_INT) != 0 ? true : false;
}
set
{
if (value == true)
{
Other.Style |= (int)CurveLocalStyle.PLINE_LOCAT_TO_INT;
}
else
{
Other.Style &= ~(int)CurveLocalStyle.PLINE_LOCAT_TO_INT;
}
}
}
[XmlIgnore]
[Category("其它"), DisplayName("\t\t\t\t统一刻度"), Description("统一刻度")]
[TypeConverter(typeof(Converter.YesNoConverter))]
public bool IsScaleSame
{
get
{
return (Other.Style & (int)CurveLocalStyle.PLINE_LOCAT_SCALEONE) != 0 ? true : false;
}
set
{
if (value == true)
{
Other.Style |= (int)CurveLocalStyle.PLINE_LOCAT_SCALEONE;
}
else
{
Other.Style &= ~(int)CurveLocalStyle.PLINE_LOCAT_SCALEONE;
}
}
}
[XmlIgnore]
[Category("其它"), DisplayName("\t\t\t统一方向"), Description("统一方向")]
[TypeConverter(typeof(Converter.YesNoConverter))]
public bool IsDirectionSame
{
get
{
return (Other.Style & (int)CurveLocalStyle.PLINE_LOCAT_DIRECTION) != 0 ? true : false;
}
set
{
if (value == true)
{
Other.Style |= (int)CurveLocalStyle.PLINE_LOCAT_DIRECTION;
}
else
{
Other.Style &= ~(int)CurveLocalStyle.PLINE_LOCAT_DIRECTION;
}
}
}
[XmlIgnore]
[Category("其它"), DisplayName("\t\t标注在节点"), Description("标注在节点")]
[TypeConverter(typeof(Converter.YesNoConverter))]
public bool IsOnNode
{
get
{
return (Other.Style & (int)CurveLocalStyle.PLINE_LOCAT_NODE) != 0 ? true : false;
}
set
{
if (value == true)
{
Other.Style |= (int)CurveLocalStyle.PLINE_LOCAT_NODE;
}
else
{
Other.Style &= ~(int)CurveLocalStyle.PLINE_LOCAT_NODE;
}
}
}
[XmlIgnore]
[Category("其它"), DisplayName("\t显示首位"), Description("显示首位")]
[TypeConverter(typeof(Converter.YesNoConverter))]
public bool ShowHeadTail
{
get
{
return (Other.Style & (int)CurveLocalStyle.PLINE_LOCAT_HEAD_TAIL) != 0 ? true : false;
}
set
{
if (value == true)
{
Other.Style |= (int)CurveLocalStyle.PLINE_LOCAT_HEAD_TAIL;
}
else
{
Other.Style &= ~(int)CurveLocalStyle.PLINE_LOCAT_HEAD_TAIL;
}
}
}
[XmlIgnore]
[Category("其它"), DisplayName("显示方式"), Description("显示方式")]
[TypeConverter(typeof(Converter.LineTypeConverter))]
public int CurveType
{
get
{
return Other.Style & (int)LineType.PLINE_TYPE_ALL;
}
set
{
Other.Style &= ~((int)LineType.PLINE_TYPE_ALL);
Other.Style |= value;
}
}
////////////////////////////////////////////////////////////////
/// <summary>
/// 偏移
/// </summary>
[XmlElement("Offset")]
[Browsable(false)]
public PropertyPoint Offset { get; set; } = new PropertyPoint();
[Browsable(false)]
public ScaleSymbol Base { get; set; } = new ScaleSymbol();
//[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
[Browsable(false)]
public SymbolLocate Locate { get; set; } = new SymbolLocate();
[Browsable(false)]
[XmlElement("Other")]
public SymbolOther Other { get; set; } = new SymbolOther();
}
public class ScaleSymbol : LocationBase
{
[XmlAttribute("MarkName")]
public string MarkName { get; set; }
}
public class ScaleSymbolBase
{
[XmlAttribute]
public double Height { get; set; }
[XmlAttribute]
public double Width { get; set; }
[XmlAttribute]
public double Angle { get; set; }
}
public class SymbolLocateConvert : TypeConverter
{
public override bool CanConvertTo(ITypeDescriptorContext context, System.Type destinationType)
{
if (destinationType == typeof(string))
{
return true;
}
if (destinationType == typeof(SymbolLocate))
return true;
return base.CanConvertTo(context, destinationType);
}
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture,
object value, System.Type destinationType)
{
if (destinationType == typeof(System.String) && value != null)
{
SymbolLocate ll = (SymbolLocate)value;
return "" + ll.Begin + "," + ll.End + "," + ll.Step;
}
if (destinationType == typeof(LocationLocate))
{
return new SymbolLocate((SymbolLocate)value);
}
return base.ConvertTo(context, culture, value, destinationType);
}
public override bool CanConvertFrom(ITypeDescriptorContext context, System.Type sourceType)
{
if (sourceType == typeof(string))
return true;
return base.CanConvertFrom(context, sourceType);
}
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
if (value is string)
{
try
{
string s = (string)value;
string[] lstValue = s.Split(',');
SymbolLocate ll = new SymbolLocate();
ll.Begin = double.Parse(lstValue[0]);
ll.End = double.Parse(lstValue[1]);
ll.Step = double.Parse(lstValue[2]);
return ll;
}
catch
{
throw new ArgumentException("输入错误,无法将“" + (string)value +
"”转换为 SymbolLocate 类型");
}
}
return base.ConvertFrom(context, culture, value);
}
public override bool GetPropertiesSupported(ITypeDescriptorContext context)
{
return true;
}
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
{
return TypeDescriptor.GetProperties(value, attributes);
}
}
[TypeConverterAttribute(typeof(SymbolLocateConvert))]
public class SymbolLocate
{
/// <summary>
/// Initializes a new instance of the <see cref="SymbolLocate"/> class.
/// </summary>
public SymbolLocate()
{ }
/// <summary>
/// Initializes a new instance of the <see cref="SymbolLocate"/> class.
/// </summary>
/// <param name="other"></param>
public SymbolLocate(SymbolLocate other)
{
Begin = other.Begin;
End = other.End;
Step = other.Step;
}
[XmlAttribute]
[NotifyParentProperty(true)]
public double Begin { get; set; } = -1000;
[XmlAttribute]
[NotifyParentProperty(true)]
public double End { get; set; } = -2000;
[XmlAttribute]
[NotifyParentProperty(true)]
public double Step { get; set; } = 200;
}
public class SymbolOther
{
[XmlAttribute]
public int Style { get; set; }
[XmlAttribute]
public int Decimal { get; set; }
}
}