using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using System.Drawing;
#if WEB_SERVICE
#else
using System.Drawing.Design;
#endif
namespace GeoSigma.SigmaDrawerStyle
{
public interface IRectangularNetGridPropertyChange
{
//提供这个接口的目的:改变子属性值,父属性未立即改变。
//例如,改变步长,但x,y未立即改变。需要点击'x,y'后,'x,y'才会改变。
//解决这个问题的方法:通知外界,属性已经改变了。外部代码,接到通知后,全部刷新属性。
//
void RCSGridPropertyChange();
}
public class NetStep
{
private IRectangularNetGridPropertyChange iChange;
///
/// Initializes a new instance of the class.
///
///
///
///
public NetStep(double x, double y, IRectangularNetGridPropertyChange iChange)
{
this.iChange = iChange;
this.x = x;
this.y = y;
}
//需重写此方法.这个结果会显示是网格步长后面.
public override string ToString()
{
return x.ToString() + "," + y.ToString();
}
private double x;
private double y;
[DisplayName("\t\t\t\t\t\t经度步长(分)")]
public double X
{
get => x;
set
{
x = value;
iChange.RCSGridPropertyChange();
}
}
[DisplayName("\t\t\t\t\t\t纬度步长(分)")]
public double Y
{
get => y;
set
{
y = value;
iChange.RCSGridPropertyChange();
}
}
}
public class NetBase
{
private IRectangularNetGridPropertyChange iChange;
///
/// Initializes a new instance of the class.
///
///
///
///
public NetBase(double x, double y, IRectangularNetGridPropertyChange iChange)
{
this.iChange = iChange;
}
private double x;
private double y;
public double X
{
get => x;
set
{
x = value;
iChange.RCSGridPropertyChange();
}
}
public double Y
{
get => y;
set
{
y = value;
iChange.RCSGridPropertyChange();
}
}
public override string ToString()
{
return x.ToString() + "," + y.ToString();
}
}
public class NetCoefficient
{
private IRectangularNetGridPropertyChange iChange;
///
/// Initializes a new instance of the class.
///
///
///
///
public NetCoefficient(double x, double y, IRectangularNetGridPropertyChange iChange)
{
this.iChange = iChange;
}
private double x = 1;
private double y = 1;
public double X
{
get => x;
set
{
x = value;
iChange.RCSGridPropertyChange();
}
}
public double Y
{
get => y;
set
{
y = value;
iChange.RCSGridPropertyChange();
}
}
public override string ToString()
{
return x.ToString() + "," + y.ToString();
}
}
public class NetCoordinateRange
{
private IRectangularNetGridPropertyChange iChange;
///
/// Initializes a new instance of the class.
///
///
///
///
///
///
public NetCoordinateRange(double left, double top, double right, double bottom, IRectangularNetGridPropertyChange iChange)
{
this.iChange = iChange;
}
private double left = 0.0;
private double top = 0.0;
private double right = 0.0;
private double bottom = 0.0;
[DisplayName("\t\t\t\t\t\t\t\t\t左")]
public double Left
{
get => left;
set
{
left = value;
iChange.RCSGridPropertyChange();
}
}
[DisplayName("\t\t\t\t\t\t\t\t上")]
public double Top
{
get => top;
set
{
top = value;
iChange.RCSGridPropertyChange();
}
}
[DisplayName("\t\t\t\t\t\t\t右")]
public double Right
{
get => right;
set
{
right = value;
iChange.RCSGridPropertyChange();
}
}
[DisplayName("\t\t\t\t\t\t下")]
public double Bottom
{
get => bottom;
set
{
bottom = value;
iChange.RCSGridPropertyChange();
}
}
public override string ToString()
{
return left.ToString() + "," + top.ToString() + "," + right.ToString() + "," + bottom.ToString();
}
}
public class RectangularNetGridProperty
{
public enum SHOWMODE
{
曲线,
交点,
空
}
public enum SCALE
{
地理,
数学,
地理1,
地理2全部
}
public enum NOTATION_MODE
{
所有边,
左边上边,
上边右边,
右边下边,
下边左边
}
public enum OUTER_BORDER
{
否,
是
}
public enum BLACK_BORDER
{
否,
是
}
///
/// Initializes a new instance of the class.
///
///
public RectangularNetGridProperty(IRectangularNetGridPropertyChange iChange)
{
this.iChange = iChange;
step = new NetStep(25, 25, iChange);
coefficient = new NetCoefficient(1, 1, iChange);
baseNumber = new NetBase(0, 0, iChange);
coordRange = new NetCoordinateRange(0, 0, 0, 0, iChange);
showMode = SHOWMODE.曲线;
gridColor = Color.Black;
}
private IRectangularNetGridPropertyChange iChange;
private SHOWMODE showMode;
private NetStep step;
private Color gridColor;
private int textHeight = 200;
private SCALE textScale = SCALE.数学;
private NOTATION_MODE notatioinMode = NOTATION_MODE.所有边;
private NetBase baseNumber;
private NetCoefficient coefficient;
private NetCoordinateRange coordRange;
private OUTER_BORDER outerBorder = OUTER_BORDER.是;
private int borderThickness = 100;
private BLACK_BORDER blackOutterBorder = BLACK_BORDER.是;
private Color borderColor = Color.Black;
[Category("\t经纬网"), DisplayName("\t\t\t\t\t\t显示方式")]
public SHOWMODE ShowMode
{
get => showMode;
set
{
showMode = value;
iChange.RCSGridPropertyChange();
}
}
[Category("\t经纬网"), DisplayName("\t\t\t\t\t\t网格步长")]
[TypeConverter(typeof(ExpandableObjectConverter))]
public NetStep Step
{
get => step;
set
{
step = value;
iChange.RCSGridPropertyChange();
}
}
#if WEB_SERVICE
#else
[Editor(typeof(PropertyEditorColor), typeof(UITypeEditor))]
#endif
[Category("\t经纬网"), DisplayName("\t\t\t\t\t\t颜色")]
public Color GridColor
{
get => gridColor;
set
{
gridColor = value;
iChange.RCSGridPropertyChange();
}
}
[Category("文本"), DisplayName("\t\t\t\t\t\t文字高度")]
public int TextHeight
{
get => textHeight;
set
{
textHeight = value;
iChange.RCSGridPropertyChange();
}
}
[Category("文本"), DisplayName("\t\t\t\t\t\t标注方式")]
public NOTATION_MODE NotatioinMode
{
get => notatioinMode;
set
{
notatioinMode = value;
iChange.RCSGridPropertyChange();
}
}
[Category("高级设置"), DisplayName("\t\t\t\t\t\t坐标范围")]
[TypeConverter(typeof(ExpandableObjectConverter))]
public NetCoordinateRange CoordRange
{
get => coordRange;
set
{
coordRange = value;
iChange.RCSGridPropertyChange();
}
}
[Category("边框"), DisplayName("\t\t\t\t\t\t显示外边框")]
public OUTER_BORDER OuterBorder
{
get => outerBorder;
set
{
outerBorder = value;
iChange.RCSGridPropertyChange();
}
}
[Category("边框"), DisplayName("\t\t\t\t\t\t边框厚度")]
public int BorderThickness
{
get => borderThickness;
set
{
borderThickness = value;
iChange.RCSGridPropertyChange();
}
}
[Category("边框"), DisplayName("\t\t\t\t\t\t显示为黑边框")]
public BLACK_BORDER BlackOutterBorder
{
get => blackOutterBorder;
set
{
blackOutterBorder = value;
iChange.RCSGridPropertyChange();
}
}
[Category("边框"), DisplayName("\t\t\t\t\t\t颜色")]
#if WEB_SERVICE
#else
[Editor(typeof(PropertyEditorColor), typeof(UITypeEditor))]
#endif
public Color BorderColor
{
get => borderColor;
set
{
borderColor = value;
iChange.RCSGridPropertyChange();
}
}
public void FillData(ref GeoSigmaDrawLib.RectangularCSGridData data)
{
data.blackOutterBorder = (int)this.BlackOutterBorder;
data.borderColorR = this.BorderColor.R;
data.borderColorG = this.BorderColor.G;
data.borderColorB = this.BorderColor.B;
data.borderThickness = this.BorderThickness;
data.left = this.CoordRange.Left;
data.top = this.CoordRange.Top;
data.right = this.CoordRange.Right;
data.bottom = this.CoordRange.Bottom;
data.gridColorR = this.GridColor.R;
data.gridColorG = this.GridColor.G;
data.gridColorB = this.GridColor.B;
data.isShowOutBorder = (int)this.OuterBorder;
data.notatioinMode = (int)this.NotatioinMode;
data.showMode = (int)this.ShowMode;
data.stepX = this.Step.X;
data.stepY = this.Step.Y;
data.textHeight = this.TextHeight;
}
public void GetData(GeoSigmaDrawLib.RectangularCSGridData data)
{
this.BlackOutterBorder = (BLACK_BORDER)data.blackOutterBorder;
this.BorderColor = Color.FromArgb(data.borderColorR, data.borderColorG, data.borderColorB);
this.BorderThickness = data.borderThickness;
this.CoordRange.Left = data.left;
this.CoordRange.Top = data.top;
this.CoordRange.Right = data.right;
this.CoordRange.Bottom = data.bottom;
this.GridColor = Color.FromArgb(data.gridColorR, data.gridColorG, data.gridColorB);
this.OuterBorder = (OUTER_BORDER)data.isShowOutBorder;
this.NotatioinMode = (NOTATION_MODE)data.notatioinMode;
this.ShowMode = (SHOWMODE)data.showMode;
this.Step.X = data.stepX;
this.Step.Y = data.stepY;
this.TextHeight = data.textHeight;
}
}
}