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.

390 lines
10 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
#if WEB_SERVICE
#else
using System.Drawing.Design;
using System.Windows.Forms;
#endif
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
using GeoSigma;
using GeoSigma.SigmaDrawerStyle;
using GeoSigma.SigmaDrawerStyle.Converter;
using GeoSigmaDrawLib;
using SigmaDrawerStyle;
namespace SigmaDrawerElement
{
/// <summary>
/// 坐标框
/// </summary>
[TypeConverter(typeof(PropertySorter))]
public class DrawerFrameNet : ElementBase
{
/// <summary>
/// 属性类别排序
/// </summary>
private List<string> categorys = new List<string>() { "基础属性", "外边框", "高级", "其他", "杂项" };
public DrawerFrameNet()
{
ElementType = DrawElementType.ELEMENT_NET;
}
[XmlIgnore]
[Browsable(false)]
[Category("数据"), DisplayName("名字"), ReadOnly(true), PropertyOrder(1)]
public override string Name
{
get
{
return base.Name;
}
set
{
base.Name = value;
}
}
[XmlIgnore]
[Category("\t\t\t基础属性"), DisplayName("网格步长"), PropertyOrder(1)]
public PropertyPoint MarkSpace
{
get
{
return new PropertyPoint((float)Base.StepX, (float)Base.StepY);
}
set
{
Base.StepX = value.X;
Base.StepY = value.Y;
}
}
[XmlIgnore]
[Category("\t\t\t基础属性"), DisplayName("文字尺寸"), PropertyOrder(2)]
public double TextSize
{
get
{
return Base.Height;
}
set
{
Base.Height = value;
Base.Width = value * 0.4;
}
}
[XmlIgnore]
[Category("\t\t\t基础属性"), DisplayName("显示方式"), PropertyOrder(3)]
[TypeConverter(typeof(SigmaDrawerElement.Converter.FrameGridDisplayStyleConverter))]
public int DisplayStyle
{
get
{
return Base.Style & ((int)GridDisplayStyle.showLine |
(int)GridDisplayStyle.showCrossPoint |
(int)GridDisplayStyle.showNull);
}
set
{
Base.Style &= ~((int)GridDisplayStyle.showLine |
(int)GridDisplayStyle.showCrossPoint |
(int)GridDisplayStyle.showNull);
Base.Style |= value;
}
}
[XmlIgnore]
[Category("\t\t\t基础属性"), DisplayName("标注方式"), PropertyOrder(4)]
[TypeConverter(typeof(SigmaDrawerElement.Converter.FrameNetStyleConverter))]
public int TextMode
{
get
{
return Base.Style & (int)GridingStyle.markAllSide;
}
set
{
Base.Style &= ~(int)GridingStyle.markAllSide;
Base.Style |= value;
}
}
[XmlIgnore]
#if WEB_SERVICE
#else
[Editor(typeof(PropertyEditorColor), typeof(UITypeEditor))]
#endif
[Category("\t\t\t基础属性"), DisplayName("颜色"), PropertyOrder(5)]
public Color FrameNetColor
{
get
{
if (Base == null) Base = new FrameNetBase();
return ColorTranslator.FromWin32(Base.FrameNetColor);
}
set
{
if (Base == null) Base = new FrameNetBase();
Base.FrameNetColor = ColorTranslator.ToWin32(value);
}
}
[XmlAttribute("Color")]
[Browsable(false)] // 在属性窗口中隐藏,因为我们已经有了上面的 FrameNetColor
public int XmlColorProxy
{
get
{
if (Base == null) Base = new FrameNetBase();
return Base.FrameNetColor;
}
set
{
if (Base == null) Base = new FrameNetBase();
Base.FrameNetColor = value;
}
}
[XmlIgnore]
[Browsable(false)]
public DrawerCoordinateLBTR GridRange { get; set; }
//MarkBorder
[XmlIgnore]
[Category("\t高级"), DisplayName("坐标范围"), PropertyOrder(1)]
[TypeConverter(typeof(GeoSigma.SigmaDrawerStyle.Converter.BaseExpandableConverter))]
public DrawerRange RangeDelta
{
get
{
if (GridRange == null)
{
GridRange = new DrawerCoordinateLBTR();
}
return GridRange.RangeDelta;
}
set
{
GridRange.Create(value.Left, value.Right, value.Bottom, value.Top);
}
}
[XmlIgnore]
[Browsable(false)]
public DrawerCoordinateLBTR NetRange { get; set; }
[XmlIgnore]
[Category("\t高级"), DisplayName("经纬度范围"), PropertyOrder(2)]
[TypeConverter(typeof(GeoSigma.SigmaDrawerStyle.Converter.BaseExpandableConverter))]
[ReadOnly(true)]
public DrawerRange NetRanges
{
get
{
if (NetRange == null)
{
NetRange = new DrawerCoordinateLBTR();
NetRange.Create(Base.L1, Base.L2, Base.B1, Base.B2);
}
return NetRange.RangeDelta;
}
}
[XmlIgnore]
[Category("\t高级"), DisplayName("投影"), PropertyOrder(3)]
[ReadOnly(true)]
public string ProjStr
{
get
{
return Base.ProjectionStr;
}
}
[XmlIgnore]
[Category("\t\t外边框"), DisplayName("是否显示"), PropertyOrder(1)]
[TypeConverter(typeof(YesNoConverter))]
public bool EnableFrame
{
get
{
if (((int)Base.Style & (int)GridingStyle.showOutFrame) == 0)
{
return false;
}
else
{
return true;
}
}
set
{
if (value == true)
{
Base.Style |= (int)GridingStyle.showOutFrame;
}
else
{
Base.Style &= ~(int)GridingStyle.showOutFrame;
}
}
}
[XmlIgnore]
[Category("\t\t外边框"), DisplayName("厚度"), PropertyOrder(2)]
public double FrameThickness
{
get
{
return Frame.Thickness;
}
set
{
Frame.Thickness = value;
}
}
[XmlIgnore]
#if WEB_SERVICE
#else
[Editor(typeof(PropertyEditorColor), typeof(UITypeEditor))]
#endif
[Category("\t\t外边框"), DisplayName("颜色"), PropertyOrder(3)]
public Color FrameColor
{
get
{
return ColorTranslator.FromWin32(Frame.FrameColor);
}
set
{
Frame.FrameColor = ColorTranslator.ToWin32(value);
}
}
[XmlElement]
[Browsable(false)]
public string Coordinate
{
get
{
if (GridRange == null)
{
return string.Empty;
}
return GridRange.Text;
}
set
{
GridRange = new DrawerCoordinateLBTR();
GridRange.Text = value;
}
}
[Browsable(false)]
[XmlElement]
public FrameNetBase Base { get; set; }
[XmlElement]
[Browsable(false)]
public FrameNetOuter Frame { get; set; }
}
public class FrameNetBase
{
[XmlAttribute]
public double Height { get; set; } = 0.2;
[XmlAttribute]
public double Width { get; set; } = 0.08;
private double stepX = 10;
[XmlAttribute]
public double StepX
{
get
{
return stepX;
}
set
{
if (value > 0)
{
stepX = value;
}
else
{
#if WEB_SERVICE
#else
MessageBox.Show("输入值必须大于零");
#endif
}
}
}
[XmlAttribute]
private double stepY = 10;
[XmlAttribute]
public double StepY
{
get
{
return stepY;
}
set
{
if (value > 0)
{
stepY = value;
}
else
{
#if WEB_SERVICE
#else
MessageBox.Show("输入值必须大于零");
#endif
}
}
}
[XmlAttribute]
public string ProjectionStr { get; set; } = "";
[XmlAttribute]
public double L1 { get; set; } = 0.2;
[XmlAttribute]
public double L2 { get; set; } = 0.2;
[XmlAttribute]
public double B1 { get; set; } = 0.2;
[XmlAttribute]
public double B2 { get; set; } = 0.2;
[XmlAttribute]
public int Style { get; set; } = (int)GridDisplayStyle.showLine |
(int)GridingStyle.markAllSide |
(int)GridingStyle.showInFrame |
(int)GridingStyle.showText |
(int)GridingStyle.showOutFrame;
[XmlIgnore]
public int FrameNetColor { get; set; } = 0;
}
public class FrameNetOuter
{
[XmlAttribute]
public double Thickness { get; set; } = 0.1;
[XmlAttribute]
public bool BlackFrame { get; set; } = true;
[XmlAttribute]
public string MarkName { get; set; } = string.Empty;
[XmlAttribute]
public int Style { get; set; } = (int)FrameStyle.FRAME_BLACK_LINE
| (int)FrameStyle.modeCenter
| (int)FrameStyle.COORDINATE_LEFT_BOTTOM
| (int)FrameStyle.INSERT_DRAW_PLUS;
[XmlAttribute("Color")]
public int FrameColor { get; set; } = 0;
}
}