using System;
|
using System.Collections.Generic;
|
using System.Drawing;
|
using System.Linq;
|
using System.Text;
|
using System.Xml.Linq;
|
|
namespace Eventech.DynPicture.Model
|
{
|
/// <summary>
|
/// 默认参数
|
/// </summary>
|
public class ConfigInfo
|
{
|
#region 点
|
/// <summary>
|
/// 牟定方式
|
/// </summary>
|
public ePointAnchor PointAnchor { get; set; }
|
#endregion
|
#region 字体
|
|
/// <summary>
|
/// 字体名称
|
/// </summary>
|
public string FontName
|
{
|
get { return _fontName; }
|
set { _fontName = value; }
|
}
|
private string _fontName = "宋体";
|
|
/// <summary>
|
/// 字体大小
|
/// </summary>
|
public float FontSize
|
{
|
get { return _fontSize; }
|
set { _fontSize = value; }
|
}
|
private float _fontSize = 9f;
|
|
/// <summary>
|
/// 字体颜色
|
/// </summary>
|
public Color FontColor
|
{
|
get { return _fontColor; }
|
set { _fontColor = value; }
|
}
|
private Color _fontColor = Color.Black;
|
|
/// <summary>
|
/// 是否粗体
|
/// </summary>
|
public bool IsBold
|
{
|
get { return _isBold; }
|
set { _isBold = value; }
|
}
|
private bool _isBold = false;
|
|
/// <summary>
|
/// 是否斜体
|
/// </summary>
|
public bool IsItalic
|
{
|
get { return _isItalic; }
|
set { _isItalic = value; }
|
}
|
private bool _isItalic = false;
|
|
/// <summary>
|
/// 旋转角度
|
/// </summary>
|
public float TextAngle
|
{
|
get { return _textAngle; }
|
set { _textAngle = value; }
|
}
|
private float _textAngle = 0;
|
|
#endregion
|
|
#region 文本框
|
|
/// <summary>
|
/// 文本边框宽度
|
/// </summary>
|
public float TextBoxBorderWidth
|
{
|
get { return _textBoxBorderWidth; }
|
set { _textBoxBorderWidth = value; }
|
}
|
private float _textBoxBorderWidth = 1f;
|
|
/// <summary>
|
/// 文本框颜色
|
/// </summary>
|
public Color TextBoxBorderColor
|
{
|
get { return _textBoxBorderColor; }
|
set { _textBoxBorderColor = value; }
|
}
|
private Color _textBoxBorderColor = Color.Black;
|
|
/// <summary>
|
/// 背景颜色是否透明
|
/// </summary>
|
public bool TextBoxBackgroundTransparent
|
{
|
get { return _textBoxBackgroundTransparent; }
|
set { _textBoxBackgroundTransparent = value; }
|
}
|
private bool _textBoxBackgroundTransparent = true;
|
|
/// <summary>
|
/// 背景颜色
|
/// </summary>
|
public Color TextBoxBackgroundColor
|
{
|
get { return _textBoxBackgroundColor; }
|
set { _textBoxBackgroundColor = value; }
|
}
|
private Color _textBoxBackgroundColor = Color.White;
|
|
/// <summary>
|
/// 文本框宽度
|
/// </summary>
|
public float TextBoxWidth
|
{
|
get { return _textBoxWidth; }
|
set { _textBoxWidth = value; }
|
}
|
private float _textBoxWidth = 100;
|
|
/// <summary>
|
/// 文本框高度
|
/// </summary>
|
public float TextBoxHeight
|
{
|
get { return _textBoxHeight; }
|
set { _textBoxHeight = value; }
|
}
|
private float _textBoxHeight = 30;
|
|
/// <summary>
|
/// 文本水平对齐方式
|
/// </summary>
|
public StringAlignment TextHAlignment
|
{
|
get { return _textHAlignment; }
|
set { _textHAlignment = value; }
|
}
|
private StringAlignment _textHAlignment = StringAlignment.Center;
|
|
/// <summary>
|
/// 文本垂直对齐方式
|
/// </summary>
|
public StringAlignment TextVAlignment
|
{
|
get { return _textVAlignment; }
|
set { _textVAlignment = value; }
|
}
|
private StringAlignment _textVAlignment = StringAlignment.Center;
|
|
|
#endregion
|
|
#region 线
|
|
/// <summary>
|
/// 线宽
|
/// </summary>
|
public float LineWidth
|
{
|
get { return _lineWidth; }
|
set { _lineWidth = value; }
|
}
|
private float _lineWidth = 1;
|
|
/// <summary>
|
/// 线颜色
|
/// </summary>
|
public Color LineColor
|
{
|
get { return _lineColor; }
|
set { _lineColor = value; }
|
}
|
private Color _lineColor = Color.Black;
|
|
/// <summary>
|
/// 线影响区域
|
/// </summary>
|
public float LineShadow
|
{
|
get { return _lineShadow; }
|
set { _lineShadow = value; }
|
}
|
private float _lineShadow = 5f;
|
|
/// <summary>
|
/// 线延申长度
|
/// </summary>
|
public float LineExtendLength
|
{
|
get { return _lineExtendLength; }
|
set { _lineExtendLength = value; }
|
}
|
private float _lineExtendLength = 10f;
|
|
|
|
|
#endregion
|
|
#region 箭头
|
|
/// <summary>
|
/// 箭头长度
|
/// </summary>
|
public float ArrowLength
|
{
|
get { return _arrowLength; }
|
set { _arrowLength = value; }
|
}
|
private float _arrowLength = 15f;
|
|
/// <summary>
|
/// 箭头宽度
|
/// </summary>
|
public float ArrowWidth
|
{
|
get { return _arrowWidth; }
|
set { _arrowWidth = value; }
|
}
|
private float _arrowWidth = 10f;
|
|
/// <summary>
|
/// 箭头颜色
|
/// </summary>
|
public Color ArrowColor
|
{
|
get { return _arrowColor; }
|
set { _arrowColor = value; }
|
}
|
private Color _arrowColor = Color.Black;
|
|
/// <summary>
|
/// 箭头方向
|
/// </summary>
|
public eArrowDirection ArrowDirection
|
{
|
get { return _arrowDirection; }
|
set { _arrowDirection = value; }
|
}
|
private eArrowDirection _arrowDirection =eArrowDirection.Inner;
|
|
|
#endregion
|
|
#region Highlight
|
/// <summary>
|
/// 高亮边框颜色
|
/// </summary>
|
public Color HighlightBorderColor
|
{
|
get { return _highlightBorderColor; }
|
set { _highlightBorderColor = value; }
|
}
|
private Color _highlightBorderColor = Color.Red;
|
|
/// <summary>
|
/// 高亮边框宽度
|
/// </summary>
|
public float HighlightBorderWidth
|
{
|
get { return _highlightBorderWidth; }
|
set { _highlightBorderWidth = value; }
|
}
|
private float _highlightBorderWidth = 1f;
|
|
|
#endregion
|
|
|
/// <summary>
|
/// 转化为XElement
|
/// </summary>
|
/// <returns></returns>
|
public XElement ToXElement()
|
{
|
var xele = new XElement("Root");
|
|
#region 点
|
var pointXele = new XElement("Point");
|
pointXele.SetAttributeValue("PointAnchor", (int)this.PointAnchor);
|
xele.Add(pointXele);
|
#endregion
|
|
#region Font
|
var fontXele = new XElement("Font");
|
fontXele.SetAttributeValue("FontName", this.FontName);
|
fontXele.SetAttributeValue("FontSize", this.FontSize);
|
fontXele.SetAttributeValue("FontColor", ColorTranslator.ToHtml(this.FontColor));
|
fontXele.SetAttributeValue("IsBold", this.IsBold ? 1 : 0);
|
fontXele.SetAttributeValue("IsItalic", this.IsItalic ? 1 : 0);
|
fontXele.SetAttributeValue("TextAngle", this.TextAngle);
|
xele.Add(fontXele);
|
#endregion
|
|
#region TextBox
|
var textBoxXele = new XElement("TextBox");
|
textBoxXele.SetAttributeValue("TextBoxBorderWidth", this.TextBoxBorderWidth);
|
textBoxXele.SetAttributeValue("TextBoxBorderColor", ColorTranslator.ToHtml(this.TextBoxBorderColor));
|
textBoxXele.SetAttributeValue("TextBoxBackgroundTransparent", this.TextBoxBackgroundTransparent ? 1 : 0);
|
textBoxXele.SetAttributeValue("TextBoxBackgroundColor", ColorTranslator.ToHtml(this.TextBoxBackgroundColor));
|
textBoxXele.SetAttributeValue("TextBoxWidth", this.TextBoxWidth);
|
textBoxXele.SetAttributeValue("TextBoxHeight", this.TextBoxHeight);
|
textBoxXele.SetAttributeValue("TextHAlignment", (int)this.TextHAlignment);
|
textBoxXele.SetAttributeValue("TextVAlignment", (int)this.TextVAlignment);
|
xele.Add(textBoxXele);
|
#endregion
|
|
#region Line
|
var lineXele = new XElement("Line");
|
lineXele.SetAttributeValue("LineWidth", this.LineWidth);
|
lineXele.SetAttributeValue("LineColor", ColorTranslator.ToHtml(this.LineColor));
|
lineXele.SetAttributeValue("LineShadow", this.LineShadow);
|
lineXele.SetAttributeValue("LineExtendLength", this.LineExtendLength);
|
xele.Add(lineXele);
|
#endregion
|
|
#region Arrow
|
var arrowXele = new XElement("Arrow");
|
arrowXele.SetAttributeValue("ArrowLength", this.ArrowLength);
|
arrowXele.SetAttributeValue("ArrowWidth", this.ArrowWidth);
|
arrowXele.SetAttributeValue("ArrowColor", ColorTranslator.ToHtml(this.ArrowColor));
|
arrowXele.SetAttributeValue("ArrowDirection", (int)this.ArrowDirection);
|
xele.Add(arrowXele);
|
#endregion
|
|
#region Highlight
|
var highlightXele = new XElement("Highlight");
|
highlightXele.SetAttributeValue("HighlightBorderColor",ColorTranslator.ToHtml(this.HighlightBorderColor));
|
highlightXele.SetAttributeValue("HighlightBorderWidth",this.HighlightBorderWidth);
|
#endregion
|
|
return xele;
|
}
|
|
public static ConfigInfo GetConfigInfo(XElement xele)
|
{
|
try
|
{
|
var defaltParas = new ConfigInfo();
|
|
#region 点
|
var pointXele = xele.Element("Point");
|
defaltParas.PointAnchor = (ePointAnchor)int.Parse(pointXele.Attribute("PointAnchor").Value);
|
xele.Add(pointXele);
|
#endregion
|
|
#region font
|
var fontXele = xele.Element("Font");
|
defaltParas.FontName = fontXele.Attribute("FontName").Value;
|
defaltParas.FontSize = float.Parse(fontXele.Attribute("FontSize").Value);
|
defaltParas.FontColor = ColorTranslator.FromHtml(fontXele.Attribute("FontColor").Value);
|
defaltParas.IsBold = Convert.ToInt32(fontXele.Attribute("IsBold").Value) == 1 ? true : false;
|
defaltParas.IsItalic = Convert.ToInt32(fontXele.Attribute("IsItalic").Value) == 1 ? true : false;
|
defaltParas.TextAngle = float.Parse(fontXele.Attribute("TextAngle").Value);
|
#endregion
|
|
#region textBox
|
var textBoxXele = xele.Element("TextBox");
|
defaltParas.TextBoxBorderWidth = float.Parse(textBoxXele.Attribute("TextBoxBorderWidth").Value);
|
defaltParas.TextBoxBorderColor = ColorTranslator.FromHtml(textBoxXele.Attribute("TextBoxBorderColor").Value);
|
defaltParas.TextBoxBackgroundTransparent = Convert.ToInt32(textBoxXele.Attribute("TextBoxBackgroundTransparent").Value) == 1 ? true : false;
|
defaltParas.TextBoxBackgroundColor = ColorTranslator.FromHtml(textBoxXele.Attribute("TextBoxBackgroundColor").Value);
|
defaltParas.TextBoxWidth = float.Parse(textBoxXele.Attribute("TextBoxWidth").Value);
|
defaltParas.TextBoxHeight = float.Parse(textBoxXele.Attribute("TextBoxHeight").Value);
|
defaltParas.TextHAlignment = (StringAlignment)int.Parse(textBoxXele.Attribute("TextHAlignment").Value);
|
defaltParas.TextVAlignment= (StringAlignment)int.Parse(textBoxXele.Attribute("TextVAlignment").Value);
|
#endregion
|
|
#region line
|
var lineXele = xele.Element("Line");
|
defaltParas.LineWidth = float.Parse(lineXele.Attribute("LineWidth").Value);
|
defaltParas.LineColor = ColorTranslator.FromHtml(lineXele.Attribute("LineColor").Value);
|
defaltParas.LineShadow = float.Parse(lineXele.Attribute("LineShadow").Value);
|
defaltParas.LineExtendLength = float.Parse(lineXele.Attribute("LineExtendLength").Value);
|
#endregion
|
|
#region arrow
|
var arrowXele = xele.Element("Arrow");
|
defaltParas.ArrowLength = float.Parse(arrowXele.Attribute("ArrowLength").Value);
|
defaltParas.ArrowWidth = float.Parse(arrowXele.Attribute("ArrowWidth").Value);
|
defaltParas.ArrowColor = ColorTranslator.FromHtml(arrowXele.Attribute("ArrowColor").Value);
|
defaltParas.ArrowDirection = (eArrowDirection)int.Parse(arrowXele.Attribute("ArrowDirection").Value);
|
#endregion
|
|
#region Highlight
|
var highlightXele = xele.Element("Highlight");
|
defaltParas.HighlightBorderColor = ColorTranslator.FromHtml(highlightXele.Attribute("HighlightBorderColor").Value);
|
defaltParas.HighlightBorderWidth = float.Parse(highlightXele.Attribute("HighlightBorderWidth").Value);
|
#endregion
|
|
return defaltParas;
|
}
|
catch
|
{
|
return new ConfigInfo();
|
}
|
}
|
|
|
}
|
}
|