|
|
|
|
using ESRI.ArcGIS.Carto;
|
|
|
|
|
using Kingo.Plugin.ShapeToKOApp.XSDClass;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Kingo.Plugin.ShapeToKOApp.KoDataBase
|
|
|
|
|
{
|
|
|
|
|
public class LabelStyleConvert
|
|
|
|
|
{
|
|
|
|
|
public List<LabelingInfo> EsriLabelToCustomLabels(IAnnotateLayerPropertiesCollection labelCollection)
|
|
|
|
|
{
|
|
|
|
|
List<LabelingInfo> lstInfo = new List<LabelingInfo>();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (labelCollection == null || labelCollection.Count <= 0) return lstInfo;
|
|
|
|
|
IAnnotateLayerProperties antemp = new LabelEngineLayerPropertiesClass();
|
|
|
|
|
IElementCollection el = new ElementCollectionClass();
|
|
|
|
|
IElementCollection el1 = new ElementCollectionClass();
|
|
|
|
|
for (int i = 0; i < labelCollection.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
labelCollection.QueryItem(i, out antemp, out el, out el1);
|
|
|
|
|
lstInfo.Add(EsriLabelToCustomLabel(antemp));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
return lstInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public LabelingInfo EsriLabelToCustomLabel(IAnnotateLayerProperties labelPro)
|
|
|
|
|
{
|
|
|
|
|
LabelingInfo lbInfo = new LabelingInfo();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
ILabelEngineLayerProperties iLabelLayerPro = labelPro as ILabelEngineLayerProperties;
|
|
|
|
|
if (iLabelLayerPro == null) return null;
|
|
|
|
|
lbInfo.LabelExpression = iLabelLayerPro.Expression;
|
|
|
|
|
//lbInfo.LabelPlacement=iLabelLayerPro
|
|
|
|
|
lbInfo.Where = labelPro.WhereClause;
|
|
|
|
|
lbInfo.MaxScale = (int)labelPro.AnnotationMaximumScale;
|
|
|
|
|
lbInfo.MinScale = (int)labelPro.AnnotationMinimumScale;
|
|
|
|
|
//lbInfo.UseCodedValues=labelPro.u
|
|
|
|
|
SymbolConvert symbolConvert = new SymbolConvert();
|
|
|
|
|
lbInfo.Symbol = symbolConvert.EsriTextSymbolToCustomTSSymbol((ESRI.ArcGIS.Display.ISymbol)iLabelLayerPro.Symbol);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return lbInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IAnnotateLayerProperties CustomLabelToEsriLabel(LabelingInfo labelInfo, ESRI.ArcGIS.Geometry.esriGeometryType gemoType)
|
|
|
|
|
{
|
|
|
|
|
IBasicOverposterLayerProperties4 pBasicOverposterlayerProps4 = new BasicOverposterLayerPropertiesClass();
|
|
|
|
|
switch (gemoType)//判断图层类型
|
|
|
|
|
{
|
|
|
|
|
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon:
|
|
|
|
|
pBasicOverposterlayerProps4.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolygon;
|
|
|
|
|
break;
|
|
|
|
|
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint:
|
|
|
|
|
pBasicOverposterlayerProps4.FeatureType = esriBasicOverposterFeatureType.esriOverposterPoint;
|
|
|
|
|
break;
|
|
|
|
|
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline:
|
|
|
|
|
pBasicOverposterlayerProps4.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolyline;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
pBasicOverposterlayerProps4.PointPlacementMethod = esriOverposterPointPlacementMethod.esriRotationField;
|
|
|
|
|
//pBasicOverposterlayerProps4.RotationField = angleField;
|
|
|
|
|
|
|
|
|
|
ILabelEngineLayerProperties pLabelEnginelayerProps = new LabelEngineLayerPropertiesClass();
|
|
|
|
|
pLabelEnginelayerProps.Expression = labelInfo.LabelExpression;
|
|
|
|
|
//pLabelEnginelayerProps.
|
|
|
|
|
SymbolConvert symbolConvert = new SymbolConvert();
|
|
|
|
|
pLabelEnginelayerProps.Symbol = symbolConvert.CustomTSSymbolToEsriTextSymbol(labelInfo.Symbol);
|
|
|
|
|
pLabelEnginelayerProps.BasicOverposterLayerProperties = pBasicOverposterlayerProps4 as IBasicOverposterLayerProperties;
|
|
|
|
|
IAnnotateLayerProperties annotate = (IAnnotateLayerProperties)pLabelEnginelayerProps;
|
|
|
|
|
annotate.WhereClause = labelInfo.Where;
|
|
|
|
|
annotate.AnnotationMaximumScale = labelInfo.MaxScale;
|
|
|
|
|
annotate.AnnotationMinimumScale = labelInfo.MinScale;
|
|
|
|
|
return annotate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IAnnotateLayerPropertiesCollection CustomLabelsToEsriLabels(List<LabelingInfo> labelInfos, ESRI.ArcGIS.Geometry.esriGeometryType gemoType)
|
|
|
|
|
{
|
|
|
|
|
IAnnotateLayerPropertiesCollection lstInfo = new AnnotateLayerPropertiesCollectionClass();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (labelInfos == null || labelInfos.Count <= 0) return lstInfo;
|
|
|
|
|
foreach (LabelingInfo item in labelInfos)
|
|
|
|
|
{
|
|
|
|
|
lstInfo.Add(CustomLabelToEsriLabel(item, gemoType));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
return lstInfo;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|