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.

248 lines
6.8 KiB
C#

1 month ago
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
#if NET8_0
#else
using System.Drawing.Design;
#endif
using System.Xml.Serialization;
using GeoSigma;
using GeoSigma.SigmaDrawerStyle;
using GeoSigma.SigmaDrawerStyle.Converter;
using GeoSigmaDrawLib;
using SigmaDrawerElement.Converter;
namespace SigmaDrawerElement
{
/// <summary>
/// 比例尺属性
/// </summary>
public class DrawerProportion : ElementBase
{
/// <summary>
/// 属性类别排序
/// </summary>
private List<string> categorys = new List<string>() { "基础属性", "比例尺", "文本", "其他", "杂项" };
/// <summary>
/// Initializes a new instance of the <see cref="DrawerProportion"/> class.
/// </summary>
public DrawerProportion()
{
ElementType = DrawElementType.ELEMENT_PROPORTION;
}
/// <summary>
/// Gets or sets the name.
/// </summary>
[XmlAttribute("Name")]
[Category("基础属性"), DisplayName("\t\t\t\t\t\t\t名称"), Browsable(false)]
public override string Name { get; set; }
[Category("比例尺"), DisplayName("\t\t\t\t\t\t\t\t\t坐标")]
[XmlElement("Coordinate")]
[TypeConverter(typeof(GeoSigma.SigmaDrawerStyle.Converter.BaseExpandableConverter))]
public DrawerCoordinateXY Coordinate { get; set; } = new DrawerCoordinateXY();
[Browsable(false)]
[XmlAttribute("Color")]
public int ColorRef;
/// <summary>
/// Gets or sets 线颜色
/// </summary>
[XmlIgnore]
#if NET8_0
#else
[Editor(typeof(PropertyEditorColor), typeof(UITypeEditor))]
#endif
[Category("比例尺"), DisplayName("颜色")]
public Color LineColor
{
get
{
return ColorTranslator.FromWin32(ColorRef);
}
set
{
ColorRef = ColorTranslator.ToWin32(value);
}
}
#region Other
public class PtOther
{
/// <summary>
/// Gets or sets the length of the scale.
/// </summary>
[XmlAttribute]
public double ScaleLength { get; set; }
[XmlAttribute]
public int Number { get; set; }
[XmlAttribute]
public int Style { get; set; }
[XmlAttribute]
public string Unit { get; set; }
[XmlAttribute]
public double ScaleHeight { get; set; }
}
[Browsable(false)]
[XmlElement("Other")]
[TypeConverter(typeof(GeoSigma.SigmaDrawerStyle.Converter.BaseExpandableConverter))]
public PtOther Other { get; set; } = new PtOther();
[XmlIgnore]
[Category("文本"), DisplayName("\t\t\t水平对齐")]
[TypeConverter(typeof(AlignHorizionConverter))]
public int AlignHorizion
{
get
{
return Other.Style & (int)TextStyleFlags.alignAllPosition;
}
set
{
Other.Style &= ~(int)TextStyleFlags.alignAllPosition;
Other.Style |= value;
}
}
[XmlIgnore]
[Category("比例尺"), DisplayName("\t\t\t\t\t\t\t显示模式")]
[TypeConverter(typeof(SigmaDrawerElement.Converter.ProportionStyleConverter))]
public int DisplayStyle
{
get
{
return Other.Style & (int)ProportionStyle.styleAll;
}
set
{
Other.Style &= ~(int)ProportionStyle.styleAll;
Other.Style |= value;
}
}
[XmlIgnore]
[Category("比例尺"), DisplayName("\t\t\t\t\t\t比例长度")]
public double ScaleLength
{
get => Other.ScaleLength;
set => Other.ScaleLength = value;
}
[XmlIgnore]
[Category("比例尺"), DisplayName("\t\t\t\t\t个数")]
public int Number
{
get => Other.Number;
set => Other.Number = value;
}
[XmlIgnore]
[Category("比例尺"), DisplayName("\t\t\t\t单位")]
[TypeConverter(typeof(ProportionUnitConverter))]
public string Unit
{
get => Other.Unit;
set => Other.Unit = value;
}
[XmlIgnore]
[Category("比例尺"), DisplayName("\t\t\t\t高度")]
public double ScaleHeight
{
get => Other.ScaleHeight;
set => Other.ScaleHeight = value;
}
#endregion
#region Text
public class PtText
{
[XmlAttribute]
public double Height { get; set; }
[XmlAttribute]
public double Width { get; set; }
[XmlAttribute]
public double Coefficient { get; set; }
[XmlAttribute]
public double Scale { get; set; }
}
[Browsable(false)]
[XmlElement("Text")]
[TypeConverter(typeof(GeoSigma.SigmaDrawerStyle.Converter.BaseExpandableConverter))]
public PtText Text { get; set; } = new PtText();
[XmlIgnore]
[Category("文本"), DisplayName("\t\t\t\t\t\t文本比例")]
public double Scale
{
get => Text.Scale;
set => Text.Scale = value;
}
[XmlIgnore]
[Category("文本"), DisplayName("\t文字高度")]
public double Height
{
get => Text.Height;
set
{
Text.Height = value;
//if (FixedTextScale)
{
if (Width != Text.Height * 0.4)
{
Width = Text.Height * 0.4;
}
}
}
}
/// <summary>
/// Gets or sets the 文字宽度.
/// </summary>
[XmlIgnore]
[Category("文本"), DisplayName("\t文字宽度"), Browsable(false)]
public double Width
{
get => Text.Width;
set
{
Text.Width = value;
//if (FixedTextScale)
{
if (Text.Height != Text.Width / 0.4)
{
Text.Height = Text.Width / 0.4;
}
}
}
}
private bool fixedTextScale = true;
[XmlIgnore]
[Category("文本"), DisplayName("固定比例")]
[TypeConverter(typeof(GeoSigma.SigmaDrawerStyle.Converter.YesNoConverter))]
public bool FixedTextScale
{
get
{
return fixedTextScale;
}
set
{
fixedTextScale = value;
}
}
#endregion
}
}