|
|
|
|
|
using System.Drawing;
|
|
|
|
|
|
using GeoSigma.SigmaDrawerStyle;
|
|
|
|
|
|
|
|
|
|
|
|
namespace GeoSigma.SigmaDrawerElement
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 提供 WellLayerStyle 与 WellFontEx 之间的字体信息转换方法
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class LayerStyleHelper
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 从指定的样式对象提取字体信息
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="style">层样式对象</param>
|
|
|
|
|
|
/// <returns>表示字体样式的对象</returns>
|
|
|
|
|
|
public static WellFontEx GetFontEx(WellLayerStyle style)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (style == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var font = new Font(style.TextFace, style.TextSize);
|
|
|
|
|
|
var fontEx = WellFontEx.FromFont(font);
|
|
|
|
|
|
fontEx.FontColor = ColorTranslator2.FromHtml(style.TextColor);
|
|
|
|
|
|
return fontEx;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 根据指定的对象,设置样式中的字体相关属性
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="style">层样式对象</param>
|
|
|
|
|
|
/// <param name="fontEx">字体样式对象</param>
|
|
|
|
|
|
public static void SetFontEx(WellLayerStyle style, WellFontEx fontEx)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (style == null || fontEx == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var font = WellFontEx.ToFont(fontEx);
|
|
|
|
|
|
style.TextFace = fontEx.FontName;
|
|
|
|
|
|
style.TextSize = font.Size;
|
|
|
|
|
|
style.TextColor = ColorTranslator2.ToHtml(fontEx.FontColor);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 从指定样式对象提取边框线信息
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="style">样式对象</param>
|
|
|
|
|
|
/// <returns>边框线对象</returns>
|
|
|
|
|
|
public static WellLineStyle GetWellLineStyle(WellLayerStyle style)
|
|
|
|
|
|
{
|
|
|
|
|
|
return new WellLineStyle()
|
|
|
|
|
|
{
|
|
|
|
|
|
Width = style.BorderWidth,
|
|
|
|
|
|
Color = ColorTranslator2.FromHtml(style.BorderColor),
|
|
|
|
|
|
Style = string.Empty,
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 根据指定的对象,设置样式中的边框线相关属性
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="style">层样式对象</param>
|
|
|
|
|
|
/// <param name="lineStyle">边框线</param>
|
|
|
|
|
|
public static void SetWellLineStyle(WellLayerStyle style, WellLineStyle lineStyle)
|
|
|
|
|
|
{
|
|
|
|
|
|
style.BorderWidth = lineStyle.Width;
|
|
|
|
|
|
style.BorderColor = ColorTranslator2.ToHtml(lineStyle.Color);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|