using System.Drawing; using GeoSigma.SigmaDrawerStyle; namespace GeoSigma.SigmaDrawerElement { /// /// 提供 WellLayerStyle 与 WellFontEx 之间的字体信息转换方法 /// public class LayerStyleHelper { /// /// 从指定的样式对象提取字体信息 /// /// 层样式对象 /// 表示字体样式的对象 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; } /// /// 根据指定的对象,设置样式中的字体相关属性 /// /// 层样式对象 /// 字体样式对象 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); } /// /// 从指定样式对象提取边框线信息 /// /// 样式对象 /// 边框线对象 public static WellLineStyle GetWellLineStyle(WellLayerStyle style) { return new WellLineStyle() { Width = style.BorderWidth, Color = ColorTranslator2.FromHtml(style.BorderColor), Style = string.Empty, }; } /// /// 根据指定的对象,设置样式中的边框线相关属性 /// /// 层样式对象 /// 边框线 public static void SetWellLineStyle(WellLayerStyle style, WellLineStyle lineStyle) { style.BorderWidth = lineStyle.Width; style.BorderColor = ColorTranslator2.ToHtml(lineStyle.Color); } } }