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.
972 lines
32 KiB
C#
972 lines
32 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Diagnostics;
|
|
using System.Drawing;
|
|
#if WEB_SERVICE
|
|
#else
|
|
using System.Drawing.Design;
|
|
#endif
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using System.Xml;
|
|
using System.Xml.Serialization;
|
|
using GeoSigma.SigmaDrawerStyle.Converter;
|
|
using GeoSigmaDrawLib;
|
|
using SigmaDrawerStyle;
|
|
|
|
namespace GeoSigma.SigmaDrawerStyle
|
|
{
|
|
[XmlRoot("HowToViewPoint")]
|
|
[TypeConverter(typeof(PropertySorter))]
|
|
public class DrawerPointStyle
|
|
{
|
|
private Font textFont;
|
|
|
|
/// <summary>
|
|
/// 属性类别排序
|
|
/// </summary>
|
|
private List<string> categorys = new List<string>() { "文本", "符号", "Z值", "杂项" };
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="DrawerPointStyle"/> class.
|
|
/// </summary>
|
|
public DrawerPointStyle()
|
|
{
|
|
textSize.FixScale = true;
|
|
zSize.FixScale = true;
|
|
|
|
if (text == null)
|
|
{
|
|
text = new PointText();
|
|
text.Style = (int)TextStyleFlags.alignRight |
|
|
(int)TextStyleFlags.alignTop |
|
|
(int)TextStyleFlags.frameNull;
|
|
}
|
|
this._BackColor.PropertyChanged += _BackColor_PropertyChanged;
|
|
this._SymbolBackColor.PropertyChanged += _SymbolBackColor_PropertyChanged;
|
|
this._SymbolForeColor.PropertyChanged += _SymbolForeColor_PropertyChanged;
|
|
this._ZBackColor.PropertyChanged += _ZBackColor_PropertyChanged;
|
|
}
|
|
|
|
private void _ZBackColor_PropertyChanged(object sender, PropertyChangedEventArgs e)
|
|
{
|
|
if (e.PropertyName.Equals("HaveColor"))
|
|
{
|
|
if (_ZBackColor.HaveColor != true)
|
|
{
|
|
textZ.Style = (textZ.Style &= ~(int)TextStyleFlags.backgroundColor);
|
|
}
|
|
else
|
|
{
|
|
textZ.Style = (textZ.Style |= (int)TextStyleFlags.backgroundColor);
|
|
}
|
|
}
|
|
if (e.PropertyName.Equals("ColorValue"))
|
|
{
|
|
textZ.BkColor = ColorTranslator.ToWin32(_ZBackColor.ColorValue);
|
|
}
|
|
else
|
|
{
|
|
if (_ZBackColor.HaveColor != true)
|
|
{
|
|
textZ.Style = (textZ.Style &= ~(int)TextStyleFlags.backgroundColor);
|
|
}
|
|
else
|
|
{
|
|
textZ.Style = (textZ.Style |= (int)TextStyleFlags.backgroundColor);
|
|
}
|
|
textZ.BkColor = ColorTranslator.ToWin32(_ZBackColor.ColorValue);
|
|
}
|
|
}
|
|
private void _SymbolForeColor_PropertyChanged(object sender, PropertyChangedEventArgs e)
|
|
{
|
|
if (e.PropertyName.Equals("HaveColor"))
|
|
{
|
|
Symbol.EnableFrColor = _SymbolForeColor.HaveColor ? 1 : 0;
|
|
return;
|
|
}
|
|
else if (e.PropertyName.Equals("ColorValue"))
|
|
{
|
|
Symbol.FrColor = ColorTranslator.ToWin32(_SymbolForeColor.ColorValue);
|
|
}
|
|
else
|
|
{
|
|
Symbol.EnableFrColor = _SymbolForeColor.HaveColor ? 1 : 0;
|
|
Symbol.FrColor = ColorTranslator.ToWin32(_SymbolForeColor.ColorValue);
|
|
}
|
|
}
|
|
private void _SymbolBackColor_PropertyChanged(object sender, PropertyChangedEventArgs e)
|
|
{
|
|
if (e.PropertyName.Equals("HaveColor"))
|
|
{
|
|
Symbol.EnableBkColor = _SymbolBackColor.HaveColor ? 1 : 0;
|
|
return;
|
|
}
|
|
else if (e.PropertyName.Equals("ColorValue"))
|
|
{
|
|
Symbol.BkColor = ColorTranslator.ToWin32(_SymbolBackColor.ColorValue);
|
|
}
|
|
else
|
|
{
|
|
Symbol.EnableBkColor = _SymbolBackColor.HaveColor ? 1 : 0;
|
|
Symbol.BkColor = ColorTranslator.ToWin32(_SymbolBackColor.ColorValue);
|
|
}
|
|
}
|
|
|
|
private void _BackColor_PropertyChanged(object sender, PropertyChangedEventArgs e)
|
|
{
|
|
// 透明,没有背景色
|
|
if (e.PropertyName.Equals("HaveColor"))
|
|
{
|
|
if (_BackColor.HaveColor != true)
|
|
{
|
|
text.Style = (text.Style &= ~(int)TextStyleFlags.backgroundColor);
|
|
}
|
|
else
|
|
{
|
|
text.Style = (text.Style |= (int)TextStyleFlags.backgroundColor);
|
|
}
|
|
return;
|
|
}
|
|
if (e.PropertyName.Equals("ColorValue"))
|
|
{
|
|
text.BkColor = ColorTranslator.ToWin32(_BackColor.ColorValue);
|
|
}
|
|
else
|
|
{
|
|
if (_BackColor.HaveColor != true)
|
|
{
|
|
text.Style = (text.Style &= ~(int)TextStyleFlags.backgroundColor);
|
|
}
|
|
else
|
|
{
|
|
text.Style = (text.Style |= (int)TextStyleFlags.backgroundColor);
|
|
}
|
|
text.BkColor = ColorTranslator.ToWin32(_BackColor.ColorValue);
|
|
}
|
|
}
|
|
[XmlIgnore]
|
|
[Browsable(false)]
|
|
public GeoSigmaXY Geo { get; set; } = null;
|
|
|
|
[XmlIgnore]
|
|
[Category("文本"), DisplayName("字体"), PropertyOrder(1)]
|
|
[TypeConverter(typeof(FontPropertyConvert))]
|
|
public Font TextFont
|
|
{
|
|
get
|
|
{
|
|
textFont = Font.FromLogFont(this.FontStyle);
|
|
//PropertyHelp.SetPropertyVisibility(_TextFont, "Unit", false);
|
|
return textFont;
|
|
}
|
|
set
|
|
{
|
|
textFont = value;
|
|
FontStyle = LogFontConverter.convert(textFont);
|
|
// _TextFont.ToLogFont(FontStyle);
|
|
}
|
|
}
|
|
|
|
private PropertySize textSize;
|
|
[XmlIgnore]
|
|
[Category("文本"), DisplayName("尺寸"), PropertyOrder(2)]
|
|
[TypeConverter(typeof(PropertyScaleSizeConvert))]
|
|
public PropertySize TextSize
|
|
{
|
|
get
|
|
{
|
|
this.textSize.Width = this.text.Width;
|
|
this.textSize.Height = this.text.Height;
|
|
return this.textSize;
|
|
}
|
|
set
|
|
{
|
|
/*
|
|
if (this.textSize.FixScale == true)
|
|
{
|
|
//double factor = (value.Height / this.textSize.Height) * (value.Width / this.textSize.Width);
|
|
decimal dFactorW = 1;
|
|
if (this.textSize.Width == 0)
|
|
{
|
|
this.text.Width = value.Width;
|
|
this.text.Height = value.Height;
|
|
this.textSize.FixScale = value.FixScale;
|
|
return;
|
|
}
|
|
if (this.textSize.Height == 0)
|
|
{
|
|
this.text.Width = value.Width;
|
|
this.text.Height = value.Height;
|
|
this.textSize.FixScale = value.FixScale;
|
|
return;
|
|
}
|
|
dFactorW = (decimal)(value.Width / this.textSize.Width);
|
|
decimal dFactorH = (decimal)(value.Height / this.textSize.Height);
|
|
if (dFactorW == 1m)
|
|
{
|
|
this.text.Width = Math.Round(this.text.Width * (double)dFactorH, 4, MidpointRounding.AwayFromZero);
|
|
this.text.Height = value.Height;
|
|
}
|
|
else if (dFactorH == 1m)
|
|
{
|
|
this.text.Width = value.Width;
|
|
this.text.Height = Math.Round(this.text.Height * (double)dFactorW, 4, MidpointRounding.AwayFromZero);
|
|
}
|
|
else
|
|
{
|
|
this.text.Width = value.Width;
|
|
this.text.Height = value.Height;
|
|
}
|
|
this.textSize.FixScale = value.FixScale;
|
|
return;
|
|
}*/
|
|
this.textSize = value;
|
|
this.text.Width = this.textSize.Width;
|
|
this.text.Height = this.textSize.Height;
|
|
}
|
|
}
|
|
|
|
private double _TextAngle;
|
|
[XmlIgnore]
|
|
[Category("文本"), DisplayName("角度"), PropertyOrder(3)]
|
|
public double TextAngle
|
|
{
|
|
get
|
|
{
|
|
_TextAngle = text.Angle;
|
|
return _TextAngle;
|
|
}
|
|
set
|
|
{
|
|
_TextAngle = value;
|
|
text.Angle = _TextAngle;
|
|
}
|
|
}
|
|
private PointF _Offset;
|
|
|
|
[XmlIgnore]
|
|
[Category("文本"), DisplayName("偏移"), PropertyOrder(4)]
|
|
public PropertyPoint Offset
|
|
{
|
|
get => text.Delt;
|
|
set => text.Delt = value;
|
|
}
|
|
|
|
private int _AlignHorizion = 0;
|
|
[XmlIgnore]
|
|
[Category("文本"), DisplayName("水平对齐"), PropertyOrder(5)]
|
|
[TypeConverter(typeof(Converter.AlignHorizionConverter))]
|
|
public int AlignHorizion
|
|
{
|
|
get
|
|
{
|
|
_AlignHorizion = text.Style & (int)TextStyleFlags.alignAllPosition;
|
|
return _AlignHorizion;
|
|
}
|
|
set
|
|
{
|
|
_AlignHorizion = value;
|
|
text.Style &= ~(int)TextStyleFlags.alignAllPosition;
|
|
text.Style |= _AlignHorizion;
|
|
}
|
|
}
|
|
|
|
private int _AlignVertical = 0;
|
|
[XmlIgnore]
|
|
[Category("文本"), DisplayName("垂直对齐"), PropertyOrder(6)]
|
|
[TypeConverter(typeof(Converter.AlignVerticalConverter))]
|
|
public int AlignVertical
|
|
{
|
|
get
|
|
{
|
|
_AlignVertical = text.Style & (int)TextStyleFlags.alignAllV;
|
|
return _AlignVertical;
|
|
}
|
|
set
|
|
{
|
|
_AlignVertical = value;
|
|
text.Style &= ~(int)TextStyleFlags.alignAllV;
|
|
text.Style |= _AlignVertical;
|
|
}
|
|
}
|
|
private int _BorderType = 0;
|
|
[XmlIgnore]
|
|
[Category("文本"), DisplayName("文字边框"), PropertyOrder(7)]
|
|
[TypeConverter(typeof(Converter.BorderTypeConverter))]
|
|
public int BorderType
|
|
{
|
|
get
|
|
{
|
|
_BorderType = text.Style & (int)TextStyleFlags.frameAll;
|
|
return _BorderType;
|
|
}
|
|
set
|
|
{
|
|
_BorderType = value;
|
|
text.Style &= ~(int)TextStyleFlags.frameAll;
|
|
text.Style |= _BorderType;
|
|
}
|
|
}
|
|
private Color? _ForeColor;
|
|
[XmlIgnore]
|
|
[Category("文本"), DisplayName("前景色"), PropertyOrder(8)]
|
|
#if WEB_SERVICE
|
|
#else
|
|
[Editor(typeof(PropertyEditorColor), typeof(UITypeEditor))]
|
|
#endif
|
|
|
|
[TypeConverter(typeof(PropertyColorIndicatorConvert))]
|
|
public Color? ForeColor
|
|
{
|
|
get
|
|
{
|
|
_ForeColor = ColorTranslator.FromWin32(text.FrColor);
|
|
return _ForeColor;
|
|
}
|
|
set
|
|
{
|
|
_ForeColor = value;
|
|
text.FrColor = ColorTranslator.ToWin32(_ForeColor.Value);
|
|
}
|
|
}
|
|
|
|
//private Color _BackColor;
|
|
//[XmlIgnore]
|
|
//[Category("\t文本"), DisplayName("背景色")]
|
|
//public Color BackColor
|
|
//{
|
|
// get
|
|
// {
|
|
// _BackColor = ColorTranslator.FromWin32(text.BkColor);
|
|
// // 不透明,有背景色
|
|
// if ((text.Style & (int)TextStyleFlags.backgroundColor)!=0)
|
|
// { }
|
|
// else
|
|
// {
|
|
// _BackColor = Color.Transparent;
|
|
// }
|
|
// return _BackColor;
|
|
// }
|
|
// set
|
|
// {
|
|
// // 透明,没有背景色
|
|
// if (value.Name.Equals("Transparent"))
|
|
// {
|
|
// text.Style = (text.Style &= ~(int)TextStyleFlags.backgroundColor);
|
|
// _BackColor = Color.Transparent;
|
|
// }
|
|
// else
|
|
// {
|
|
// text.Style = (text.Style |= (int)TextStyleFlags.backgroundColor);
|
|
// _BackColor = value;
|
|
// }
|
|
// text.BkColor = ColorTranslator.ToWin32(_BackColor);
|
|
// }
|
|
//}
|
|
private PropertyColorNullable _BackColor = new PropertyColorNullable();
|
|
[XmlIgnore]
|
|
[Category("文本"), DisplayName("背景颜色"), PropertyOrder(9)]
|
|
//[TypeConverter(typeof(ExpandableObjectConverter))]
|
|
[TypeConverter(typeof(PropertyColorNullable.PropertyColorNullableConvert))]
|
|
public PropertyColorNullable BackColor// { set; get; } = new PropertyColorNullable();
|
|
{
|
|
get
|
|
{
|
|
// 不透明,有背景色
|
|
try
|
|
{
|
|
if ((text.Style & (int)TextStyleFlags.backgroundColor) != 0)
|
|
{
|
|
_BackColor.HaveColor = true;
|
|
_BackColor.ColorValue = ColorTranslator.FromWin32(text.BkColor);
|
|
}
|
|
else
|
|
{
|
|
_BackColor.HaveColor = false;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Trace.WriteLine(ex.Message);
|
|
}
|
|
return _BackColor;
|
|
}
|
|
set
|
|
{
|
|
//_BackColor = value;
|
|
_BackColor.HaveColor = value.HaveColor;
|
|
_BackColor.ColorValue = value.ColorValue;
|
|
// 透明,没有背景色
|
|
if (value.HaveColor != true)
|
|
{
|
|
text.Style = (text.Style &= ~(int)TextStyleFlags.backgroundColor);
|
|
}
|
|
else
|
|
{
|
|
text.Style = (text.Style |= (int)TextStyleFlags.backgroundColor);
|
|
}
|
|
text.BkColor = ColorTranslator.ToWin32(_BackColor.ColorValue);
|
|
}
|
|
}
|
|
|
|
[XmlIgnore]
|
|
[Category("文本"), DisplayName("小数位数"), PropertyOrder(10)]
|
|
[TypeConverter(typeof(PropertyIntConverter))]
|
|
public int DecimalName
|
|
{
|
|
get
|
|
{
|
|
return text.DecimalName;
|
|
}
|
|
set
|
|
{
|
|
text.DecimalName = value;
|
|
}
|
|
}
|
|
|
|
private string _SymbolName;
|
|
[XmlIgnore]
|
|
[Browsable(false)]
|
|
public string SymbolName
|
|
{
|
|
get
|
|
{
|
|
_SymbolName = Symbol.Name;
|
|
return _SymbolName;
|
|
}
|
|
set
|
|
{
|
|
_SymbolName = value;
|
|
Symbol.Name = _SymbolName;
|
|
}
|
|
}
|
|
private SymbolNameWrapper symbolEditor = new SymbolNameWrapper();
|
|
[XmlIgnore]
|
|
[Category("符号"), DisplayName("名称"), PropertyOrder(1)]
|
|
//[Editor("UCDraw.Editor.MarkEditor, UCDraw", typeof(UITypeEditor))]
|
|
#if WEB_SERVICE
|
|
#else
|
|
[Editor("GeoSigma.SigmaDrawerStyle.PropertyEditorSymbol, GeoSigma.SigmaDrawerStyle", typeof(UITypeEditor))]
|
|
#endif
|
|
public SymbolNameWrapper SymbolEditor
|
|
{
|
|
get
|
|
{
|
|
symbolEditor.DrawerGeo = Geo;
|
|
symbolEditor.SymbolName = Symbol.Name == null ? string.Empty : Symbol.Name;
|
|
// _SymbolName = symbolEditor.SymbolName;
|
|
return symbolEditor;
|
|
}
|
|
set
|
|
{
|
|
symbolEditor = value;
|
|
symbolEditor.DrawerGeo = this.Geo;
|
|
// this.Geo = (GeoSigmaXY)(value.DrawerGeo);
|
|
Symbol.Name = symbolEditor.SymbolName;
|
|
}
|
|
}
|
|
|
|
private SizeF _SymbolSize;
|
|
[XmlIgnore]
|
|
[Category("符号"), DisplayName("尺寸"), PropertyOrder(2)]
|
|
[TypeConverter(typeof(PropertySizeConvert))]
|
|
public SizeF SymbolSize
|
|
{
|
|
get
|
|
{
|
|
_SymbolSize = new SizeF
|
|
{
|
|
Width = (float)Symbol.Width,
|
|
Height = (float)Symbol.Height,
|
|
};
|
|
return _SymbolSize;
|
|
}
|
|
set
|
|
{
|
|
_SymbolSize = value;
|
|
Symbol.Width = _SymbolSize.Width;
|
|
Symbol.Height = _SymbolSize.Height;
|
|
}
|
|
}
|
|
private double _SymbolAngle;
|
|
[XmlIgnore]
|
|
[Category("符号"), DisplayName("角度"), PropertyOrder(3)]
|
|
public double SymbolAngle
|
|
{
|
|
get
|
|
{
|
|
_SymbolAngle = Symbol.Angle;
|
|
return _SymbolAngle;
|
|
}
|
|
set
|
|
{
|
|
_SymbolAngle = value;
|
|
Symbol.Angle = _SymbolAngle;
|
|
}
|
|
}
|
|
|
|
private PropertyColorNullable _SymbolBackColor = new PropertyColorNullable();
|
|
[XmlIgnore]
|
|
[Browsable(true)]
|
|
[Category("符号"), DisplayName("符号背景"), Description("统一显示符号背景色"), ReadOnly(false), PropertyOrder(4)]
|
|
//[TypeConverter(typeof(ExpandableObjectConverter))]
|
|
[TypeConverter(typeof(PropertyColorNullable.PropertyColorNullableConvert))]
|
|
public PropertyColorNullable SymbolBackColor
|
|
{
|
|
get
|
|
{
|
|
if (Symbol.BkColor > 16777215)
|
|
{
|
|
_SymbolBackColor.ColorValue = Color.Transparent;
|
|
}
|
|
else
|
|
{
|
|
_SymbolBackColor.ColorValue = ColorTranslator.FromWin32(Symbol.BkColor);
|
|
}
|
|
_SymbolBackColor.HaveColor = (Symbol.EnableBkColor == 1);
|
|
return _SymbolBackColor;
|
|
}
|
|
set
|
|
{
|
|
_SymbolBackColor.ColorValue = value.ColorValue;
|
|
_SymbolBackColor.HaveColor = value.HaveColor;
|
|
Symbol.EnableBkColor = _SymbolBackColor.HaveColor ? 1 : 0;
|
|
Symbol.BkColor = ColorTranslator.ToWin32(_SymbolBackColor.ColorValue);
|
|
}
|
|
}
|
|
|
|
private PropertyColorNullable _SymbolForeColor = new PropertyColorNullable();
|
|
[XmlIgnore]
|
|
[Browsable(true)]
|
|
[Category("符号"), DisplayName("符号前景"), Description("统一显示符号前景色"), ReadOnly(false), PropertyOrder(5)]
|
|
//[TypeConverter(typeof(ExpandableObjectConverter))]
|
|
[TypeConverter(typeof(PropertyColorNullable.PropertyColorNullableConvert))]
|
|
public PropertyColorNullable SymbolForeColor
|
|
{
|
|
get
|
|
{
|
|
if (Symbol.FrColor > 16777215)
|
|
{
|
|
_SymbolForeColor.ColorValue = Color.Transparent;
|
|
}
|
|
else
|
|
{
|
|
_SymbolForeColor.ColorValue = ColorTranslator.FromWin32(Symbol.FrColor);
|
|
}
|
|
_SymbolForeColor.HaveColor = (Symbol.EnableFrColor == 1);
|
|
return _SymbolForeColor;
|
|
}
|
|
set
|
|
{
|
|
_SymbolForeColor.ColorValue = value.ColorValue;
|
|
_SymbolForeColor.HaveColor = value.HaveColor;
|
|
Symbol.EnableFrColor = _SymbolBackColor.HaveColor ? 1 : 0;
|
|
Symbol.FrColor = ColorTranslator.ToWin32(_SymbolForeColor.ColorValue);
|
|
}
|
|
}
|
|
|
|
private bool _CanMoveCoordinate = false;
|
|
[XmlIgnore]
|
|
[DisplayName("坐标可移动")]
|
|
[TypeConverter(typeof(Converter.YesNoConverter))]
|
|
public bool CanMoveCoordinate
|
|
{
|
|
get
|
|
{
|
|
int nFlag = text.Style & (int)TextStyleFlags.noCanMoveCoor;
|
|
_CanMoveCoordinate = !(nFlag != 0);
|
|
return _CanMoveCoordinate;
|
|
}
|
|
set
|
|
{
|
|
_CanMoveCoordinate = value;
|
|
if (_CanMoveCoordinate == true)
|
|
{
|
|
text.Style &= ~(int)TextStyleFlags.noCanMoveCoor;
|
|
}
|
|
else
|
|
{
|
|
text.Style |= (int)TextStyleFlags.noCanMoveCoor;
|
|
}
|
|
}
|
|
}
|
|
|
|
[Browsable(false)]
|
|
[XmlAttribute("Name")]
|
|
public string Name { get; set; }
|
|
[Browsable(false)]
|
|
[XmlElement("Font")]
|
|
public LogFont FontStyle { get; set; } = LogFont.Default;
|
|
[Browsable(false)]
|
|
[XmlElement("Symbol")]
|
|
public PointSymbol Symbol { get; set; } = new PointSymbol();
|
|
|
|
private PointText text;
|
|
[Browsable(false)]
|
|
[XmlElement("Text")]
|
|
public PointText Text
|
|
{
|
|
get
|
|
{
|
|
if (text == null)
|
|
{
|
|
text = new PointText();
|
|
text.Style = (int)TextStyleFlags.alignRight |
|
|
(int)TextStyleFlags.alignTop |
|
|
(int)TextStyleFlags.frameNull;
|
|
}
|
|
return text;
|
|
}
|
|
set
|
|
{
|
|
text = value;
|
|
}
|
|
}
|
|
|
|
private PointText textZ = new PointText();
|
|
[Browsable(false)]
|
|
[XmlElement("ZText")]
|
|
public PointText TextZ
|
|
{
|
|
get
|
|
{
|
|
if (textZ == null)
|
|
{
|
|
textZ = new PointText();
|
|
textZ.Style = (int)TextStyleFlags.alignRight |
|
|
(int)TextStyleFlags.alignTop |
|
|
(int)TextStyleFlags.frameNull;
|
|
}
|
|
return textZ;
|
|
}
|
|
set
|
|
{
|
|
textZ = value;
|
|
}
|
|
}
|
|
[Browsable(false)]
|
|
[XmlElement("ZFont")]
|
|
public LogFont FontStyleZ { get; set; } = LogFont.Default;
|
|
private Font textZFont;
|
|
[XmlIgnore]
|
|
[Category("Z值"), DisplayName("字体"), PropertyOrder(1)]
|
|
[TypeConverter(typeof(FontPropertyConvert))]
|
|
public Font TextZFont
|
|
{
|
|
get
|
|
{
|
|
textZFont = Font.FromLogFont(this.FontStyleZ);
|
|
return textZFont;
|
|
}
|
|
set
|
|
{
|
|
textZFont = value;
|
|
FontStyleZ = LogFontConverter.convert(textZFont);
|
|
}
|
|
}
|
|
// private bool _FixScale = true;
|
|
// [XmlIgnore]
|
|
// [Category("\t文本"), DisplayName("\t\t\t\t\t\t固定长宽比例")]
|
|
// [TypeConverter(typeof(Converter.YesNoConverter))]
|
|
// public bool FixScale { get=>_FixScale; set=>_FixScale = value; }
|
|
private PropertySize zSize;
|
|
|
|
[XmlIgnore]
|
|
[Category("Z值"), DisplayName("尺寸"), PropertyOrder(2)]
|
|
[TypeConverter(typeof(PropertyScaleSizeConvert))]
|
|
public PropertySize ZSize
|
|
{
|
|
get
|
|
{
|
|
this.zSize.Width = this.textZ.Width;
|
|
this.zSize.Height = this.textZ.Height;
|
|
|
|
return this.zSize;
|
|
}
|
|
|
|
set
|
|
{
|
|
/*
|
|
if (this.zSize.FixScale == true)
|
|
{
|
|
//double factor = (value.Height / this.textSize.Height) * (value.Width / this.textSize.Width);
|
|
decimal dFactorW = 1;
|
|
if (this.zSize.Width == 0)
|
|
{
|
|
this.textZ.Width = value.Width;
|
|
this.textZ.Height = value.Height;
|
|
this.zSize.FixScale = value.FixScale;
|
|
return;
|
|
}
|
|
if (this.zSize.Height == 0)
|
|
{
|
|
this.textZ.Width = value.Width;
|
|
this.textZ.Height = value.Height;
|
|
this.zSize.FixScale = value.FixScale;
|
|
return;
|
|
}
|
|
dFactorW = (decimal)(value.Width / this.zSize.Width);
|
|
decimal dFactorH = (decimal)(value.Height / this.zSize.Height);
|
|
if (dFactorW == 1m)
|
|
{
|
|
this.textZ.Width = Math.Round(this.textZ.Width * (double)dFactorH, 4, MidpointRounding.AwayFromZero);
|
|
this.textZ.Height = value.Height;
|
|
}
|
|
else if (dFactorH == 1m)
|
|
{
|
|
this.textZ.Width = value.Width;
|
|
this.textZ.Height = Math.Round(this.textZ.Height * (double)dFactorW, 4, MidpointRounding.AwayFromZero);
|
|
}
|
|
else
|
|
{
|
|
this.textZ.Width = value.Width;
|
|
this.textZ.Height = value.Height;
|
|
}
|
|
this.zSize.FixScale = value.FixScale;
|
|
return;
|
|
}
|
|
*/
|
|
this.zSize = value;
|
|
|
|
this.textZ.Width = this.zSize.Width;
|
|
this.textZ.Height = this.zSize.Height;
|
|
}
|
|
}
|
|
|
|
private double _ZAngle;
|
|
[XmlIgnore]
|
|
[Category("Z值"), DisplayName("角度"), PropertyOrder(3)]
|
|
public double ZAngle
|
|
{
|
|
get
|
|
{
|
|
_ZAngle = textZ.Angle;
|
|
return _ZAngle;
|
|
}
|
|
set
|
|
{
|
|
_ZAngle = value;
|
|
textZ.Angle = _ZAngle;
|
|
}
|
|
}
|
|
//private PointF _ZOffset;
|
|
|
|
[XmlIgnore]
|
|
[Category("Z值"), DisplayName("偏移"), PropertyOrder(4)]
|
|
public PropertyPoint ZOffset
|
|
{
|
|
get => textZ.Delt;
|
|
set => textZ.Delt = value;
|
|
}
|
|
|
|
private int _ZAlignHorizion = 0;
|
|
[XmlIgnore]
|
|
[Category("Z值"), DisplayName("水平对齐"), PropertyOrder(5)]
|
|
[TypeConverter(typeof(Converter.AlignHorizionConverter))]
|
|
public int ZAlignHorizion
|
|
{
|
|
get
|
|
{
|
|
_ZAlignHorizion = textZ.Style & (int)TextStyleFlags.alignAllPosition;
|
|
return _ZAlignHorizion;
|
|
}
|
|
set
|
|
{
|
|
_ZAlignHorizion = value;
|
|
textZ.Style &= ~(int)TextStyleFlags.alignAllPosition;
|
|
textZ.Style |= _ZAlignHorizion;
|
|
}
|
|
}
|
|
|
|
private int _ZAlignVertical = 0;
|
|
[XmlIgnore]
|
|
[Category("Z值"), DisplayName("垂直对齐"), PropertyOrder(6)]
|
|
[TypeConverter(typeof(Converter.AlignVerticalConverter))]
|
|
public int ZAlignVertical
|
|
{
|
|
get
|
|
{
|
|
_ZAlignVertical = textZ.Style & (int)TextStyleFlags.alignAllV;
|
|
return _ZAlignVertical;
|
|
}
|
|
set
|
|
{
|
|
_ZAlignVertical = value;
|
|
textZ.Style &= ~(int)TextStyleFlags.alignAllV;
|
|
textZ.Style |= _ZAlignVertical;
|
|
}
|
|
}
|
|
private int _ZBorderType = 0;
|
|
[XmlIgnore]
|
|
[Category("Z值"), DisplayName("文字边框"), PropertyOrder(7)]
|
|
[TypeConverter(typeof(Converter.BorderTypeConverter))]
|
|
public int ZBorderType
|
|
{
|
|
get
|
|
{
|
|
_ZBorderType = textZ.Style & (int)TextStyleFlags.frameAll;
|
|
return _ZBorderType;
|
|
}
|
|
set
|
|
{
|
|
_ZBorderType = value;
|
|
textZ.Style &= ~(int)TextStyleFlags.frameAll;
|
|
textZ.Style |= _ZBorderType;
|
|
}
|
|
}
|
|
private Color? _ZForeColor;
|
|
[XmlIgnore]
|
|
[Category("Z值"), DisplayName("前景色"), PropertyOrder(8)]
|
|
#if WEB_SERVICE
|
|
#else
|
|
[Editor(typeof(PropertyEditorColor), typeof(UITypeEditor))]
|
|
#endif
|
|
//[TypeConverter(typeof(PropertyColorIndicatorConvert))]
|
|
public Color? ZForeColor
|
|
{
|
|
get
|
|
{
|
|
_ZForeColor = ColorTranslator.FromWin32(textZ.FrColor);
|
|
return _ZForeColor;
|
|
}
|
|
set
|
|
{
|
|
_ZForeColor = value;
|
|
textZ.FrColor = ColorTranslator.ToWin32(_ZForeColor.Value);
|
|
}
|
|
}
|
|
|
|
private PropertyColorNullable _ZBackColor = new PropertyColorNullable();
|
|
[XmlIgnore]
|
|
[Category("Z值"), DisplayName("Z值背景"), PropertyOrder(9)]
|
|
[TypeConverter(typeof(PropertyColorNullable.PropertyColorNullableConvert))]
|
|
public PropertyColorNullable ZBackColor
|
|
{
|
|
get
|
|
{
|
|
// 不透明,有背景色
|
|
try
|
|
{
|
|
if ((textZ.Style & (int)TextStyleFlags.backgroundColor) != 0)
|
|
{
|
|
_ZBackColor.HaveColor = true;
|
|
_ZBackColor.ColorValue = ColorTranslator.FromWin32(textZ.BkColor);
|
|
}
|
|
else
|
|
{
|
|
_ZBackColor.HaveColor = false;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Trace.WriteLine(ex.Message);
|
|
}
|
|
return _ZBackColor;
|
|
}
|
|
set
|
|
{
|
|
//_BackColor = value;
|
|
_ZBackColor.HaveColor = value.HaveColor;
|
|
_ZBackColor.ColorValue = value.ColorValue;
|
|
// 透明,没有背景色
|
|
if (value.HaveColor != true)
|
|
{
|
|
textZ.Style = (textZ.Style &= ~(int)TextStyleFlags.backgroundColor);
|
|
}
|
|
else
|
|
{
|
|
textZ.Style = (textZ.Style |= (int)TextStyleFlags.backgroundColor);
|
|
}
|
|
textZ.BkColor = ColorTranslator.ToWin32(_ZBackColor.ColorValue);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 输出Xml数据
|
|
/// </summary>
|
|
public string SerialXml()
|
|
{
|
|
try
|
|
{
|
|
string strData = "";
|
|
XmlWriterSettings settings = new XmlWriterSettings();
|
|
settings.Indent = true;
|
|
settings.IndentChars = " ";
|
|
settings.NewLineChars = "\r\n";
|
|
settings.Encoding = Encoding.Default;
|
|
// 去除xml声明
|
|
settings.OmitXmlDeclaration = true;
|
|
|
|
// System.IO.MemoryStream mem = new MemoryStream();
|
|
using (var mem = new MemoryStream())
|
|
{
|
|
using (XmlWriter writer = XmlWriter.Create(mem, settings))
|
|
{
|
|
// 去除默认命名空间xmlns:xsd和xmlns:xsi
|
|
XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
|
|
ns.Add(string.Empty, string.Empty);
|
|
XmlSerializer formatter = new XmlSerializer(this.GetType());
|
|
formatter.Serialize(writer, this, ns);
|
|
}
|
|
mem.Position = 0; // 重置流位置
|
|
return Encoding.Default.GetString(mem.ToArray());
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Trace.WriteLine(ex.Message);
|
|
return string.Empty;
|
|
}
|
|
}
|
|
|
|
public virtual DrawerPointStyle DeserialXml(string xml)
|
|
{
|
|
XmlSerializer xs = new XmlSerializer(this.GetType());
|
|
using (StringReader sr = new StringReader(xml))
|
|
{
|
|
var obj = xs.Deserialize(sr) as DrawerPointStyle;
|
|
return obj;
|
|
}
|
|
}
|
|
|
|
public DrawerPointStyle Clone()
|
|
{
|
|
return DeserialXml(SerialXml());
|
|
}
|
|
}
|
|
|
|
public class SymbolNameWrapper
|
|
{
|
|
private GeoSigmaXY drawerGeo;
|
|
public GeoSigmaXY DrawerGeo
|
|
{
|
|
get
|
|
{
|
|
return drawerGeo;
|
|
}
|
|
set
|
|
{
|
|
drawerGeo = value;
|
|
}
|
|
}
|
|
public string SymbolName { get; set; } = string.Empty;
|
|
/// <inheritdoc/>
|
|
public override string ToString()
|
|
{
|
|
return SymbolName;
|
|
}
|
|
public bool IsEmpty()
|
|
{
|
|
if (DrawerGeo == null || String.IsNullOrEmpty(SymbolName))
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
}
|