|
|
|
|
using ESRI.ArcGIS.Display;
|
|
|
|
|
using KGIS.Framework.Utils;
|
|
|
|
|
using Kingo.Framework.LayerStyleConvert.XSDClass;
|
|
|
|
|
using stdole;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Kingo.Framework.LayerStyleConvert.Common
|
|
|
|
|
{
|
|
|
|
|
public class AnnotationConvret
|
|
|
|
|
{
|
|
|
|
|
private static AnnotationConvret _instance = null;
|
|
|
|
|
static object lockObj = new object();
|
|
|
|
|
public static AnnotationConvret Instance()
|
|
|
|
|
{
|
|
|
|
|
lock (lockObj)
|
|
|
|
|
{
|
|
|
|
|
if (_instance == null)
|
|
|
|
|
_instance = new AnnotationConvret();
|
|
|
|
|
}
|
|
|
|
|
return _instance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public SimpleTextSymbol GetTextSymbol(ESRI.ArcGIS.Display.ITextSymbol textSymbol)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
SimpleTextSymbol simpleTextSymbol = null;
|
|
|
|
|
if (textSymbol != null)
|
|
|
|
|
{
|
|
|
|
|
simpleTextSymbol = new SimpleTextSymbol
|
|
|
|
|
{
|
|
|
|
|
Color = GetInt4ColorFromColor(textSymbol.Color as ESRI.ArcGIS.Display.IRgbColor),
|
|
|
|
|
Angle = textSymbol.Angle,
|
|
|
|
|
FontDisp = GetFontDispFromFont(textSymbol.Font)
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
return simpleTextSymbol;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("获取标注样式异常:" + ex.Message);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ESRI.ArcGIS.Display.ITextSymbol GetSimpleTextSymbol(SimpleTextSymbol simpleTextSymbol)
|
|
|
|
|
{
|
|
|
|
|
ESRI.ArcGIS.Display.ITextSymbol textSymbol = null;
|
|
|
|
|
if (simpleTextSymbol != null)
|
|
|
|
|
{
|
|
|
|
|
IRgbColor pRgbColor = new RgbColor
|
|
|
|
|
{
|
|
|
|
|
Red = simpleTextSymbol.Color[0],//
|
|
|
|
|
Green = simpleTextSymbol.Color[1],
|
|
|
|
|
Blue = simpleTextSymbol.Color[2],
|
|
|
|
|
};
|
|
|
|
|
IFontDisp pFontDisp = new StdFont() as IFontDisp;
|
|
|
|
|
pFontDisp.Bold = simpleTextSymbol.FontDisp.FontBold;//黑体
|
|
|
|
|
pFontDisp.Name = simpleTextSymbol.FontDisp.FontName;
|
|
|
|
|
pFontDisp.Size = simpleTextSymbol.FontDisp.FontSize;
|
|
|
|
|
textSymbol = new TextSymbol
|
|
|
|
|
{
|
|
|
|
|
Angle = simpleTextSymbol.Angle,
|
|
|
|
|
Color = pRgbColor,
|
|
|
|
|
Font = pFontDisp
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
return textSymbol;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static FontDisp GetFontDispFromFont(IFontDisp fontDisp)
|
|
|
|
|
{
|
|
|
|
|
FontDisp font = null;
|
|
|
|
|
if (fontDisp != null)
|
|
|
|
|
{
|
|
|
|
|
font = new FontDisp();
|
|
|
|
|
font.FontBold = fontDisp.Bold;
|
|
|
|
|
font.FontName = fontDisp.Name;
|
|
|
|
|
font.FontSize = fontDisp.Size;
|
|
|
|
|
}
|
|
|
|
|
return font;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static int[] GetInt4ColorFromColor(ESRI.ArcGIS.Display.IRgbColor color)
|
|
|
|
|
{
|
|
|
|
|
int[] array = new int[4];
|
|
|
|
|
if (color == null) return array;
|
|
|
|
|
array[0] = (int)color.Red;
|
|
|
|
|
array[1] = (int)color.Green;
|
|
|
|
|
array[2] = (int)color.Blue;
|
|
|
|
|
array[3] = 0;
|
|
|
|
|
return array;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|