using ESRI.ArcGIS.Carto; using ESRI.ArcGIS.Display; using ESRI.ArcGIS.Geometry; using KGIS.Framework.Maps; using KGIS.Framework.Platform; using KGIS.Plugin.LayerProperty.Enum; using KGIS.Plugin.LayerProperty.Utils; using KGIS.Plugin.LayerProperty.View; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace KGIS.Plugin.LayerProperty.Services { public class LayerPropertyService : ILayerPropertyService { public void SetLayerStyle(object pLayer) { if (pLayer is ILayer) { ILayer layer = pLayer as ILayer; if (layer.Name == "遥感影像" || layer.Name == "参考影像") { return; } //假设layer是一个IFeatureLayer,获取IGeoFeatureLayer IGeoFeatureLayer geoLayer = layer as IGeoFeatureLayer; if (geoLayer == null) { //如果不是矢量图层 跳出 return; } //BUG-03412 图层目录中双击图层样式后,弹出的符号选择和图斑变更中要一样的 //if (!System.IO.File.Exists(SysAppPath.GetAppLayerConfigsPath())) // { ISymbol symbol = null; IFeatureLayer2 featureLayer = layer as IFeatureLayer2; ISimpleRenderer simpleRenderer = (featureLayer as IGeoFeatureLayer).Renderer as ISimpleRenderer; esriGeometryType geoType = featureLayer.ShapeType; if (simpleRenderer != null) { symbol = simpleRenderer.Symbol; } else { symbol = RenderUtil.GetDefaultSymbol(geoType); } FormSymbolSelector pFrmSS = new FormSymbolSelector() { ShowIcon = true, ShowInTaskbar = true }; pFrmSS.Init(); FeatureLayer pFeatureLayer = pLayer as FeatureLayer; switch (pFeatureLayer.FeatureClass.ShapeType) { case esriGeometryType.esriGeometryPoint: pFrmSS.Init(esriStyleClass.MarkerSymbols, ref symbol); break; case esriGeometryType.esriGeometryPolyline: pFrmSS.Init(esriStyleClass.LineSymbols,ref symbol); break; case esriGeometryType.esriGeometryPolygon: pFrmSS.Init(esriStyleClass.FillSymbols,ref symbol); break; } if (pFrmSS.ShowDialog() == System.Windows.Forms.DialogResult.OK) { //设置符号化 //构造SimpleRenderer ISimpleRenderer renderer = new SimpleRendererClass(); //renderer.Label = ""; //假设sym是一个和该图层中Geometry类型对应的符号; renderer.Symbol = pFrmSS.ResultSymbol as ISymbol; //为图层设置渲染,注意需要刷新该图层。 geoLayer.Renderer = (IFeatureRenderer)renderer; Platform.Instance.SendMsg(new KGIS.Framework.Utils.Interface.NotifyMsgPackage() { MsgType = "SaveProject" }); } //} //else //{ // UCLayerStyleSet styleView = new UCLayerStyleSet(pLayer as ILayer); // styleView.ShowInTaskbar = false; // styleView.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen; // styleView.Width = 700; // styleView.Height = 180; // styleView.ShowInMainWindow(true); //} } } } }