private void 影像叠加ToolStripMenuItem_Click(object sender, System.EventArgs e) { ISceneGraph pSceneGraph = this.axSceneControl1.SceneGraph; IScene pScene = pSceneGraph.Scene; ILayer layer = pScene.get_Layer(0); ITinLayer tinLayer = layer as ITinLayer; layer = pScene.get_Layer(1); IRasterLayer rasterLayer = layer as IRasterLayer; ITinAdvanced tinAdvanced; ISurface surface; tinAdvanced = tinLayer.Dataset as ITinAdvanced; surface = tinAdvanced.Surface; ILayerExtensions layerExtensions = (ILayerExtensions)rasterLayer; I3DProperties i3dProperties = null; for (int i = 0; i < layerExtensions.ExtensionCount; i++) { if (layerExtensions.get_Extension(i) is I3DProperties) { i3dProperties = (I3DProperties)layerExtensions.get_Extension(i); } }//get 3d properties from extension i3dProperties.BaseOption = esriBaseOption.esriBaseSurface; i3dProperties.BaseSurface = surface; i3dProperties.Apply3DProperties(rasterLayer); pSceneGraph.RefreshViewers(); }
private void ExtrusionPropertyPage_Load(object sender, EventArgs e) { ILayerExtensions extensions = this.ilayer_0 as ILayerExtensions; this.cboExtrusionType.SelectedIndex = 0; for (int i = 0; i <= (extensions.ExtensionCount - 1); i++) { if (extensions.get_Extension(i) is I3DProperties) { I3DProperties properties = extensions.get_Extension(i) as I3DProperties; this.i3DProperties_0 = properties; if (this.i3DProperties_0.ExtrusionType == esriExtrusionType.esriExtrusionNone) { this.chkExtrusion.Checked = false; this.cboExtrusionType.Enabled = false; } else { this.chkExtrusion.Checked = true; this.cboExtrusionType.SelectedIndex = ((int)this.i3DProperties_0.ExtrusionType) - 1; } this.txtExtrusionValue.Text = this.i3DProperties_0.ExtrusionExpressionString; break; } } this.bool_0 = true; }
private void btnOK_Click(object sender, EventArgs e) { for (int i = 0; i < this.tabControl1.Controls.Count; i++) { if ( !((this.tabControl1.Controls[i] as TabPage).Controls[0] as ILayerAndStandaloneTablePropertyPage) .Apply()) { return; } } if (this.ibasicMap_0 is IScene) { ILayerExtensions extensions = this.object_0 as ILayerExtensions; for (int j = 0; j <= (extensions.ExtensionCount - 1); j++) { if (extensions.get_Extension(j) is I3DProperties) { (extensions.get_Extension(j) as I3DProperties).Apply3DProperties(this.object_0); break; } } } base.DialogResult = DialogResult.OK; }
private I3DProperties get3DProps(ITinLayer tinLayer) { I3DProperties _3DProps = null; ILayerExtensions lyrExt = tinLayer as ILayerExtensions; for (int i = 0; i < lyrExt.ExtensionCount; i++) { if (lyrExt.get_Extension(i) is I3DProperties) { _3DProps = lyrExt.get_Extension(i) as I3DProperties; } } return(_3DProps); }
public I3DProperties Get3DPropsFromLayer(ILayer pLyr) { ILayerExtensions pLyrExts = (ILayerExtensions)pLyr; I3DProperties p3DProp = null; for (int i = 0; i < pLyrExts.ExtensionCount; i++) { if (pLyrExts.get_Extension(i) is I3DProperties) { p3DProp = (I3DProperties)pLyrExts.get_Extension(i); } }//get 3d properties from extension return(p3DProp); }
private void Btn_ApplyRasterBaseSurface_Click(object sender, EventArgs e) { ILayer pBaseLayer = m_pTarScene.Layer[CbBoxBaseLayer.SelectedIndex]; ILayer pDisplayLayer = m_pTarLayer; IRasterSurface pBaseSurfaceRaster = new RasterSurface(); IRasterLayer pBaseRasterLayer = pBaseLayer as IRasterLayer; IRaster pBaseRaster = (IRaster)pBaseRasterLayer.Raster; IRasterBandCollection pBaseRasterBandCollection = pBaseRaster as IRasterBandCollection; IRasterBand pBaseRasterBand = pBaseRasterBandCollection.Item(0); pBaseSurfaceRaster.RasterBand = pBaseRasterBand; ISurface pBaseSurface = pBaseSurfaceRaster as ISurface; ILayerExtensions pLayerExtensions = pDisplayLayer as ILayerExtensions; I3DProperties p3DProperties = null; for (int i = 0; i < pLayerExtensions.ExtensionCount; i++) { object pCurExtension = pLayerExtensions.get_Extension(i); if (pCurExtension != null) { p3DProperties = (I3DProperties)pCurExtension; break; } } p3DProperties.BaseOption = esriBaseOption.esriBaseSurface; p3DProperties.BaseSurface = pBaseSurface; p3DProperties.Apply3DProperties(pDisplayLayer); p3DProperties.ZFactor = 1; m_pTarScene.SceneGraph.RefreshViewers(); }
public static ISurface GetBaseSurface(ILayer ilayer_0) { ISurface result = null; ILayerExtensions layerExtensions = ilayer_0 as ILayerExtensions; for (int i = 0; i <= layerExtensions.ExtensionCount - 1; i++) { if (layerExtensions.get_Extension(i) is I3DProperties) { I3DProperties i3DProperties = layerExtensions.get_Extension(i) as I3DProperties; if (i3DProperties.BaseOption == esriBaseOption.esriBaseSurface && i3DProperties.BaseSurface != null) { result = (i3DProperties.BaseSurface as ISurface); } return(result); } } return(result); }
private void SceneRenderPropertyPage_Load(object sender, EventArgs e) { ILayerExtensions extensions = this.ilayer_0 as ILayerExtensions; for (int i = 0; i <= (extensions.ExtensionCount - 1); i++) { if (extensions.get_Extension(i) is I3DProperties) { I3DProperties properties = extensions.get_Extension(i) as I3DProperties; this.i3DProperties_0 = properties; if (this.i3DProperties_0.RenderMode == esriRenderMode.esriRenderCache) { this.rdordoRenderCache.Checked = true; } else if (this.i3DProperties_0.RenderMode == esriRenderMode.esriRenderImmediate) { this.rdoRenderImmediate.Checked = true; } if (this.i3DProperties_0.RenderVisibility == esriRenderVisibility.esriRenderAlways) { this.rdoRenderAlways.Checked = true; } else if (this.i3DProperties_0.RenderVisibility == esriRenderVisibility.esriRenderWhenNavigating) { this.rdoRenderWhenNavigating.Checked = true; } else if (this.i3DProperties_0.RenderVisibility == esriRenderVisibility.esriRenderWhenStopped) { this.rdoRenderWhenStopped.Checked = true; } this.txtRenderRefreshRate.Value = (decimal)this.i3DProperties_0.RenderRefreshRate; this.chkIlluminate.Checked = this.i3DProperties_0.Illuminate; this.chkSmoothShading.Checked = this.i3DProperties_0.SmoothShading; this.cboDepthPriorityValue.SelectedIndex = this.i3DProperties_0.DepthPriorityValue - 1; break; } } this.bool_1 = true; }
private bool method_1(ILayer ilayer_0) { ILayerExtensions extensions = ilayer_0 as ILayerExtensions; if (extensions != null) { for (int i = 0; i < extensions.ExtensionCount; i++) { if (extensions.get_Extension(i) is I3DProperties) { return(true); } } } return(false); }
private void FrmSceneLayerOffest_Load(object sender, EventArgs e) { // 读取偏移高程 if (m_pSceneCtrl != null) { IScene pScene = m_pSceneCtrl.Scene; ILayerExtensions layerextensions = pLayer as ILayerExtensions; //I3DProperties properties = null; if (pLayer is IRasterLayer) { properties = new Raster3DPropertiesClass(); } if (pLayer is IFeatureLayer) { properties = new Feature3DPropertiesClass(); } if (pLayer is ITinLayer) { properties = new Tin3DPropertiesClass(); } object p3d; for (int j = 0; j < layerextensions.ExtensionCount; j++) { p3d = layerextensions.get_Extension(j); if (p3d != null) { properties = p3d as I3DProperties; if (properties != null) { break; } } } try { numericUpDownOffset.Value = Convert.ToDecimal(properties.OffsetExpressionString); } catch { } // properties.OffsetExpressionString = doubleInputOffset.Value.ToString(); //IActiveView iv = m_pSceneCtrl.Scene as IActiveView; //iv.PartialRefresh(esriViewDrawPhase.esriViewGeography, pLayer, null); } }
/// <summary> /// Removes the umbriel property set (propertyset with a name/value of LayerExtension/umbriel /// </summary> /// <param name="layerExtensions">ILayerExtensions</param> internal static void RemovePropertySet(ILayerExtensions layerExtensions) { if (UmbrielPropertySetExists(layerExtensions)) { for (int i = 0; i < layerExtensions.ExtensionCount; i++) { object layerExtension = layerExtensions.get_Extension(i); if (layerExtension is IPropertySet) { IPropertySet propertySet = (IPropertySet)layerExtension; string val = propertySet.GetProperty("LayerExtension").ToString(); if (val.Equals("umbriel", StringComparison.CurrentCultureIgnoreCase)) { layerExtensions.RemoveExtension(i); } } } } }
/// <summary> /// Searches ILayer's layerextensions for any PropertySets that contain name/value combo /// </summary> /// <param name="layer">The ILayer</param> /// <param name="propertysetname">The propertyset name.</param> /// <param name="propertysetvalue">The propertyset value.</param> /// <param name="comparison">The string comparison method</param> /// <returns>List of IPropertySet</returns> public static List <IPropertySet> FindExtensionPropertySet(this ILayer layer, string propertysetname, string propertysetvalue, StringComparison comparison) { List <IPropertySet> propertySets = new List <IPropertySet>(); ILayerExtensions layerExtensions = (ILayerExtensions)layer; try { if (layerExtensions.ExtensionCount > 0) { for (int i = 0; i < layerExtensions.ExtensionCount; i++) { object layerExtension = layerExtensions.get_Extension(i); if (layerExtension is IPropertySet) { IPropertySet propertySet = (IPropertySet)layerExtension; try { if (propertySet.GetProperty(propertysetname).ToString().Equals(propertysetvalue, comparison)) { propertySets.Add(propertySet); } } catch { } } } } return(propertySets); } catch (Exception ex) { Trace.WriteLine(ex.StackTrace); throw; } }
/// <summary> /// Determines if the Umbriel property set exists in the layer extensions /// </summary> /// <param name="layerExtensions">The layer extensions.</param> /// <returns>true if exists, false if it doont</returns> internal static bool UmbrielPropertySetExists(ILayerExtensions layerExtensions) { try { bool exists = false; if (layerExtensions.ExtensionCount > 0) { for (int i = 0; i < layerExtensions.ExtensionCount; i++) { object layerExtension = layerExtensions.get_Extension(i); if (layerExtension is IPropertySet) { IPropertySet propertySet = (IPropertySet)layerExtension; try { string val = propertySet.GetProperty("LayerExtension").ToString(); if (val.Equals("umbriel", StringComparison.CurrentCultureIgnoreCase)) { exists = true; } } catch { } } } } return(exists); } catch (Exception ex) { Trace.WriteLine(ex.StackTrace); throw; } }
public static I3DProperties Get3DPropsFromLayer(ILayer ilayer_0) { I3DProperties result; try { ILayerExtensions layerExtensions = ilayer_0 as ILayerExtensions; for (int i = 0; i <= layerExtensions.ExtensionCount - 1; i++) { I3DProperties i3DProperties = layerExtensions.get_Extension(i) as I3DProperties; if (i3DProperties != null) { result = i3DProperties; return(result); } } } catch { } result = null; return(result); }
private void buttonOK_Click(object sender, EventArgs e) { //高程底面 ILayer pBaseLayer = null; ISurface pSurface = null; if (m_pSceneCtrl != null) { try { // m_pSceneCtrl.LoadSxFile(ClsGDBDataCommon.GetParentPathofExe() +@"Resource\DefaultData\Default.sxd"); } catch { } //IScene pScene = new SceneClass(); //pScene.Name = "Scene"; //m_pSceneCtrl.Scene = pScene; IScene pScene = m_pSceneCtrl.Scene; pScene.Name = "Scene"; //ILayer pglayer = new GraphicsLayer3DClass(); //pScene.AddLayer(pglayer); //pScene.ActiveGraphicsLayer = new CompositeGraphicsLayerClass(); pScene.ExaggerationFactor = Convert.ToDouble(doubleInputExaFactor.Value.ToString()); while (pScene.LayerCount > 0) { pScene.DeleteLayer(pScene.get_Layer(0)); } // pScene.ClearLayers(); pScene.AddLayer(pScene.ActiveGraphicsLayer); GC.Collect(); for (int i = 0; i < m_pMapCtrl.Map.LayerCount; i++) { ILayer pMapLayer = m_pMapCtrl.Map.get_Layer(i); ILayer pLayer = pMapLayer; if (comboBoxExBaseHeightLayer.Items.Count > 0) { if (pLayer.Name == comboBoxExBaseHeightLayer.SelectedItem.ToString()) { pBaseLayer = pLayer; } } } if (pBaseLayer is IRasterLayer) { IRaster pRaster = ((IRasterLayer)pBaseLayer).Raster; IRasterBand pBand = ((IRasterBandCollection)pRaster).Item(0); IRasterSurface rsurface = new RasterSurface(); rsurface.RasterBand = pBand; //将dem的数据指定为surface pSurface = rsurface as ISurface; } if (pBaseLayer is ITinLayer) { ITin pTin = ((ITinLayer)pBaseLayer).Dataset; ITinSurface pTinSurface = pTin as ITinSurface; pSurface = pTinSurface as ISurface; } for (int i = 0; i < m_pMapCtrl.Map.LayerCount; i++) { ILayer pMapLayer = m_pMapCtrl.Map.get_Layer(i); ILayer pLayer = pMapLayer; string filepath = ""; string filename = ""; string sourcepath = GetDataLayerPath(pMapLayer as IDataLayer, ref filepath, ref filename); //if (pMapLayer is IRasterLayer) //{ // IRasterLayer prl = new RasterLayerClass(); // prl.CreateFromRaster(((IRasterLayer)pMapLayer).Raster); // pLayer = prl as ILayer; //} if (pMapLayer is IFeatureLayer) { // if (((IFeatureLayer)pMapLayer).FeatureClass.ShapeType != ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryMultiPatch) // { IFeatureLayer pfl = new FeatureLayerClass(); IFeatureClass pFc = ((IFeatureLayer)pMapLayer).FeatureClass; if (pFc != null) { pfl.FeatureClass = ((IFeatureLayer)pMapLayer).FeatureClass; pLayer = pfl as ILayer; pLayer.Name = pMapLayer.Name; ///////////////////////////////////////////////////////////////////// //后期添加,用于带进涂层渲染 ///////////////////////////////////////////////////////////////////// IGeoFeatureLayer pGeoFLayer = pfl as IGeoFeatureLayer; IGeoFeatureLayer pGFMapLayer = pMapLayer as IGeoFeatureLayer; if (pGFMapLayer != null) //注记图层为空 { pGeoFLayer.Renderer = pGFMapLayer.Renderer; ILegendInfo pLegend3D = (ILegendInfo)pGeoFLayer; for (int k = 0; k < pLegend3D.LegendGroupCount; k++) { ILegendGroup pLgroup = pLegend3D.LegendGroup[k]; for (int p = 0; p < pLgroup.ClassCount; p++) { ILegendClass pLClass = pLgroup.Class[p]; if (pLClass.Symbol is IMarkerSymbol) { IMarkerSymbol pSMSymbol = pLClass.Symbol as IMarkerSymbol; pSMSymbol.Size /= 20; } } } if (pFc.ShapeType == esriGeometryType.esriGeometryMultipoint || pFc.ShapeType == esriGeometryType.esriGeometryPoint) { if (pGFMapLayer.Renderer is IUniqueValueRenderer) { } } } } // } } #region 这段代码家的有点重复,如果不加有时候会弹出设置数据源的对话框 if (pLayer is IRasterLayer) { I3DProperties properties = null; properties = new Raster3DPropertiesClass(); ILayerExtensions layerextensions = pLayer as ILayerExtensions; object p3d; for (int j = 0; j < layerextensions.ExtensionCount; j++) { p3d = layerextensions.get_Extension(j); if (p3d != null) { properties = p3d as I3DProperties; if (properties != null) { break; } } } properties.BaseOption = esriBaseOption.esriBaseSurface; properties.BaseSurface = pSurface; //I、更改分辨率后,如何让分辨率设置发挥作用。主要是刷新的问题(使用IActiveView刷新、而不能使用Iscene及IScenegraph刷新) //II、分辨率数值在( 262144-268435456)范围之内,越大越清晰。使用3DProperties.MaxTextureMemory 方法 properties.MaxTextureMemory = 268435456; } #endregion pScene.AddLayer(pLayer); //if (((CheckBoxItem)itemPanelSetVisible.Items[i]).Checked == false) //{ // pLayer.Visible = false; //} //else //{ // pLayer.Visible = true; //} if (comboBoxExBaseHeightLayer.Items.Count > 0) { if (pLayer.Name == comboBoxExBaseHeightLayer.SelectedItem.ToString()) { pBaseLayer = pLayer; } } } } if (pSurface != null) { for (int i = 0; i < m_pSceneCtrl.Scene.LayerCount; i++) { ILayer pLayer = m_pSceneCtrl.Scene.get_Layer(i); ILayerExtensions layerextensions = m_pSceneCtrl.Scene.get_Layer(i) as ILayerExtensions; I3DProperties properties = null; if (pLayer is IRasterLayer) { properties = new Raster3DPropertiesClass(); } if (pLayer is IFeatureLayer) { properties = new Feature3DPropertiesClass(); } if (pLayer is ITinLayer) { properties = new Tin3DPropertiesClass(); } object p3d; for (int j = 0; j < layerextensions.ExtensionCount; j++) { p3d = layerextensions.get_Extension(j); if (p3d != null) { properties = p3d as I3DProperties; if (properties != null) { break; } } } if (!(pLayer is IFeatureLayer)) { properties.BaseOption = esriBaseOption.esriBaseSurface; properties.BaseSurface = pSurface; //I、更改分辨率后,如何让分辨率设置发挥作用。主要是刷新的问题(使用IActiveView刷新、而不能使用Iscene及IScenegraph刷新) //II、分辨率数值在( 262144-268435456)范围之内,越大越清晰。使用3DProperties.MaxTextureMemory 方法 properties.MaxTextureMemory = 268435456; } else { IFeatureLayer pFlayer = pLayer as IFeatureLayer; //multipatch的本身有高度信息 if (pFlayer.FeatureClass != null && pFlayer.FeatureClass.ShapeType != ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryMultiPatch) { bool needConstantHeight = false; /* * try * { * //把导航点转向角,视场角等信息都设置成不贴在表面而需要根据生产该信息的文件设置高度 * IFeatureClass fc = pFlayer.FeatureClass; * IFeatureCursor pFcursor = fc.Search(null, false); * int OriginalFeatureidx = fc.FindField("OriginalFeatureClass"); * int OriginalFeatureOIDidx = fc.FindField("OID"); * IFeature pF = pFcursor.NextFeature(); * IFeatureLayer pOFeatureLayer = null; * if (OriginalFeatureidx == -1|| OriginalFeatureOIDidx == -1) * { * pF = null; * } * else * { * if (pF != null) * { * //获取路径点图层名称 * string orignalname = pF.get_Value(OriginalFeatureidx).ToString(); * IMap pMap = m_pMapCtrl.Map; * for (int k = 0; k < pMap.LayerCount; k++) * { * if (pMap.get_Layer(k).Name.Equals(orignalname)) * { * pOFeatureLayer = pMap.get_Layer(k) as IFeatureLayer; * break; * } * } * if (pOFeatureLayer == null) * { * pF = null; * } * } * } * * while (pF != null) * { * //IFeatureClass pFClass = pOFeatureLayer.FeatureClass; * //pFClass.FindField(OriginalFeatureOIDidx); * * * pF = pFcursor.NextFeature(); * } * } * catch * { * ; * } */ if (needConstantHeight == false) { properties.BaseOption = esriBaseOption.esriBaseSurface; //I3DProperties2 pr = properties as I3DProperties2; //if (pr != null) //{ // pr.OffsetExpressionString = "0.005"; //} // properties.BaseOption = esriBaseOption.esriBaseExpression; properties.BaseSurface = pSurface; //I、更改分辨率后,如何让分辨率设置发挥作用。主要是刷新的问题(使用IActiveView刷新、而不能使用Iscene及IScenegraph刷新) //II、分辨率数值在( 262144-268435456)范围之内,越大越清晰。使用3DProperties.MaxTextureMemory 方法 properties.MaxTextureMemory = 268435456; } } } // properties.Apply3DProperties(domlayer); // ps.SceneGraph.RefreshViewers(); IActiveView iv = m_pSceneCtrl.Scene as IActiveView; iv.PartialRefresh(esriViewDrawPhase.esriViewGeography, pLayer, null); } } }
private void BaseHeightPropertyPage_Load(object sender, EventArgs e) { int num; for (num = 0; num < this.ibasicMap_0.LayerCount; num++) { ILayer layer = this.ibasicMap_0.get_Layer(num); ISurface surface = this.method_0(layer); if (surface != null) { this.cboSufer.Items.Add(new SuferWrap(surface)); } } ILayerExtensions extensions = this.ilayer_0 as ILayerExtensions; for (int i = 0; i <= (extensions.ExtensionCount - 1); i++) { if (extensions.get_Extension(i) is I3DProperties) { I3DProperties properties = extensions.get_Extension(i) as I3DProperties; this.i3DProperties_0 = properties; if (properties.BaseOption != esriBaseOption.esriBaseSurface) { if (properties.BaseOption == esriBaseOption.esriBaseExpression) { this.rdoBaseExpression.Checked = true; this.txtBaseExpression.Text = properties.BaseExpressionString; } else { this.rdoBaseShape.Checked = true; } } else if (properties.BaseSurface != null) { this.rdoBaseSurface.Checked = true; ISurface baseSurface = properties.BaseSurface as ISurface; bool flag = true; for (num = 0; num < this.cboSufer.Items.Count; num++) { if ((this.cboSufer.Items[num] as SuferWrap).Surface == baseSurface) { this.cboSufer.SelectedIndex = num; flag = false; break; } } if (flag) { this.cboSufer.Items.Add(new SuferWrap(baseSurface)); this.cboSufer.SelectedIndex = this.cboSufer.Items.Count - 1; } } this.txtOffset.Text = properties.OffsetExpressionString; this.txtZFeator.Text = properties.ZFactor.ToString(); break; } } if (this.ilayer_0 is IFeatureLayer) { IFeatureClass featureClass = (this.ilayer_0 as IFeatureLayer).FeatureClass; if (featureClass != null) { int index = featureClass.Fields.FindField(featureClass.ShapeFieldName); if (!featureClass.Fields.get_Field(index).GeometryDef.HasZ) { this.rdoBaseShape.Enabled = false; } else { this.rdoBaseShape.Enabled = true; if (this.rdoBaseShape.Checked) { this.rdoBaseExpression.Checked = true; } } } } else { this.rdoBaseShape.Enabled = false; if (this.rdoBaseShape.Checked) { this.rdoBaseExpression.Checked = true; } } if (this.cboSufer.Items.Count == 0) { this.rdoBaseSurface.Enabled = false; this.cboSufer.Enabled = false; if (this.rdoBaseSurface.Checked) { this.rdoBaseExpression.Checked = true; } } }
public void Execute(ESRI.ArcGIS.esriSystem.IArray paramvalues, ESRI.ArcGIS.esriSystem.ITrackCancel TrackCancel, ESRI.ArcGIS.Geoprocessing.IGPEnvironmentManager envMgr, ESRI.ArcGIS.Geodatabase.IGPMessages message) { try { IGPUtilities3 gpUtilities3 = new GPUtilitiesClass(); if (TrackCancel == null) { TrackCancel = new CancelTrackerClass(); } IGPParameter inputSourceLayerParameter = paramvalues.get_Element(in_sourcelayerNumber) as IGPParameter; IGPValue inputSourceLayerGPValue = gpUtilities3.UnpackGPValue(inputSourceLayerParameter) as IGPValue; IGPParameter inputTargetLayerParameter = paramvalues.get_Element(in_targetlayerNumber) as IGPParameter; IGPValue inputTargetLayerGPValue = gpUtilities3.UnpackGPValue(inputTargetLayerParameter) as IGPValue; ILayer sourceLayer = gpUtilities3.DecodeLayer(inputSourceLayerGPValue); ILayer targetLayer = gpUtilities3.DecodeLayer(inputTargetLayerGPValue); ILayerExtensions sourceLayerExtensions = sourceLayer as ILayerExtensions; if (sourceLayerExtensions == null) { message.AddWarning(resourceManager.GetString("GPTools_GPCopyLayerExtension_source_noext_support")); return; } ILayerExtensions targetLayerExtensions = targetLayer as ILayerExtensions; if (targetLayerExtensions == null) { message.AddWarning(resourceManager.GetString("GPTools_GPCopyLayerExtension_target_noext_support")); return; } // test if the feature classes already exists, // if they do and the environments settings are such that an overwrite is not allowed we need to abort at this point IGeoProcessorSettings gpSettings = (IGeoProcessorSettings)envMgr; if (gpSettings.OverwriteOutput == true) { } else { if (gpUtilities3.Exists(inputTargetLayerGPValue) == true) { message.AddError(120003, String.Format(resourceManager.GetString("GPTools_GPCopyLayerExtension_targetlayeralreadyexists"), inputTargetLayerGPValue.GetAsText())); return; } } for (int targetExtensionIndex = 0; targetExtensionIndex < targetLayerExtensions.ExtensionCount; targetExtensionIndex++) { targetLayerExtensions.RemoveExtension(targetExtensionIndex); } for (int sourceExtensionIndex = 0; sourceExtensionIndex < sourceLayerExtensions.ExtensionCount; sourceExtensionIndex++) { targetLayerExtensions.AddExtension(sourceLayerExtensions.get_Extension(sourceExtensionIndex)); } } catch (Exception ex) { message.AddError(120004, ex.Message); } }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { try { if (m_application == null) { return; } IDocument document = m_application.Document; ISxDocument sxDocument = (ISxDocument)(document); if (sxDocument != null) { m_scene = sxDocument.Scene; } if (m_scene == null) { return; } activeView = m_scene as IActiveView; //有图层选图层 if (m_scene.LayerCount == 0) { return; } //选择基准面 if (Common.SelectLayer(m_scene.Layers, out SelectedLyrIndex, true, "选择自定义表面") == false) { return; } //QI IRasterLayer baseRasterLayer = m_scene.Layer[SelectedLyrIndex[0]] as IRasterLayer; //不管选多少个只选第一个 if (baseRasterLayer == null) { throw new ArgumentNullException("自定义表面RasterLayer转换失败,为空。"); } IRaster raster = baseRasterLayer.Raster; if (raster == null) { throw new ArgumentNullException("自定义表面Raster转换失败,为空。"); } IRasterSurface rasterSurface = new RasterSurfaceClass(); rasterSurface.PutRaster(raster, 0); ISurface surface = rasterSurface as ISurface; //选择图层 if (Common.SelectLayer(m_scene.Layers, out SelectedLyrIndex, false, "选择要进行偏移的图层") == false) { return; } //选择倍数 NumSelect MultiNS = new NumSelect("输入夸大倍数", true); if (MultiNS.ShowDialog() != DialogResult.OK) { return; } double Multiplier = MultiNS.Result; //选择偏移量 NumSelect NS = new NumSelect(); if (NS.ShowDialog() != DialogResult.OK) { return; } double Offset = NS.Result; bool DisableCache = NS.DisableCache; //Create a CancelTracker. ITrackCancel pTrackCancel = new CancelTrackerClass(); //Create the ProgressDialog. This automatically displays the dialog IProgressDialogFactory pProgDlgFactory = new ProgressDialogFactoryClass(); IProgressDialog2 pProDlg = pProgDlgFactory.Create(pTrackCancel, m_application.hWnd) as IProgressDialog2; pProDlg.CancelEnabled = true; pProDlg.Title = "正在进行自定义表面设置及偏移调整"; pProDlg.Description = "设置中,请稍候..."; pProDlg.Animation = esriProgressAnimationTypes.esriProgressSpiral; IStepProgressor pStepPro = pProDlg as IStepProgressor; pStepPro.MinRange = 0; pStepPro.MaxRange = SelectedLyrIndex.Count; pStepPro.StepValue = 1; pStepPro.Message = "初始化中..."; bool bCont = true; //对每一个选中的图层进行操作 for (int i = 0; i < SelectedLyrIndex.Count; i++) { //m_application.StatusBar.set_Message(0, i.ToString()); pStepPro.Message = "已完成(" + i.ToString() + "/" + SelectedLyrIndex.Count.ToString() + ")"; bCont = pTrackCancel.Continue(); if (!bCont) { break; } //选中一个栅格图层 IRasterLayer rasterLayer = m_scene.Layer[SelectedLyrIndex[i]] as IRasterLayer; if (rasterLayer == null) { pStepPro.Message = "选中的图层非栅格图层..."; continue; } I3DProperties p3DProperties = null; ILayerExtensions layerExtensions = rasterLayer as ILayerExtensions; //遍历LayerExtensions找到I3DProperties for (int j = 0; j < layerExtensions.ExtensionCount; j++) { if (layerExtensions.get_Extension(j) is I3DProperties) { p3DProperties = layerExtensions.get_Extension(j) as I3DProperties; } } //设置I3DProperties p3DProperties.ZFactor = Multiplier; //系数 p3DProperties.BaseOption = esriBaseOption.esriBaseSurface; //基准面浮动 p3DProperties.BaseSurface = surface; //基准面 p3DProperties.OffsetExpressionString = Offset.ToString(); //偏移常量 if (DisableCache) { p3DProperties.RenderMode = esriRenderMode.esriRenderImmediate; //直接从文件渲染 p3DProperties.RenderVisibility = esriRenderVisibility.esriRenderWhenStopped; //停止导航时渲染 } p3DProperties.Apply3DProperties(rasterLayer); } pProDlg.HideDialog(); //========================================== //刷新,不起作用 if (activeView == null) { throw new Exception("活动视图为空! "); } if (m_sceneHookHelper.ActiveViewer == null) { throw new Exception("无活动视图!"); } activeView.Refresh(); m_sceneHookHelper.ActiveViewer.Redraw(true); //========================================== } catch (Exception err) { MessageBox.Show(err.ToString()); } }
private void frmLayerPropertyEx_Load(object sender, EventArgs e) { int num2; this.tabControl1.Controls.Clear(); ILayerAndStandaloneTablePropertyPage page = null; TabPage page2 = null; if (this.object_0 is ILayerExtensions) { int extensionCount = (this.object_0 as ILayerExtensions).ExtensionCount; for (num2 = 0; num2 < extensionCount; num2++) { (this.object_0 as ILayerExtensions).get_Extension(num2); } } if (this.object_0 is IGroupLayer) { page2 = new TabPage(); this.tabControl1.Controls.Add(page2); page2.Text = "常规"; page = new LayerGeneralPropertyCtrl { FocusMap = this.ibasicMap_0, SelectItem = this.object_0 }; (page as Control).Dock = DockStyle.Fill; page2.Controls.Add(page as Control); page2 = new TabPage(); this.tabControl1.Controls.Add(page2); page2.Text = "组合"; page = new GroupLayerPropertyPage { FocusMap = this.ibasicMap_0, SelectItem = this.object_0 }; (page as Control).Dock = DockStyle.Fill; page2.Controls.Add(page as Control); } else if (this.object_0 is IBasemapSubLayer) { page2 = new TabPage(); this.tabControl1.Controls.Add(page2); page2.Text = "常规"; page = new LayerGeneralPropertyCtrl { FocusMap = this.ibasicMap_0, SelectItem = this.object_0 }; (page as Control).Dock = DockStyle.Fill; page2.Controls.Add(page as Control); } else { if (this.object_0 is ILayer) { page2 = new TabPage(); this.tabControl1.Controls.Add(page2); page2.Text = "常规"; page = new LayerGeneralPropertyCtrl { FocusMap = this.ibasicMap_0, SelectItem = this.object_0 }; (page as Control).Dock = DockStyle.Fill; page2.Controls.Add(page as Control); if (this.object_0 is IDataLayer) { page2 = new TabPage(); this.tabControl1.Controls.Add(page2); page2.Text = "数据源"; page = new LayerDataSourcePropertyPage { FocusMap = this.ibasicMap_0, SelectItem = this.object_0 }; (page as Control).Dock = DockStyle.Fill; page2.Controls.Add(page as Control); } if (this.object_0 is IFeatureSelection) { page2 = new TabPage(); this.tabControl1.Controls.Add(page2); page2.Text = "选择集"; page = new FeatureSelectionSetCtrl(); (page as FeatureSelectionSetCtrl).StyleGallery = this.istyleGallery_0; page.FocusMap = this.ibasicMap_0; page.SelectItem = this.object_0; (page as Control).Dock = DockStyle.Fill; page2.Controls.Add(page as Control); } else if (this.object_0 is ITopologyErrorSelection) { page2 = new TabPage(); this.tabControl1.Controls.Add(page2); page2.Text = "选择集"; page = new TopologyErrorSelectionCtrl { FocusMap = this.ibasicMap_0, SelectItem = this.object_0 }; (page as Control).Dock = DockStyle.Fill; page2.Controls.Add(page as Control); } if (this.object_0 is ICadLayer) { page2 = new TabPage(); this.tabControl1.Controls.Add(page2); page2.Text = "图层"; page = new CADDrawingLayersPropertyPage { FocusMap = this.ibasicMap_0, SelectItem = this.object_0 }; (page as Control).Dock = DockStyle.Fill; page2.Controls.Add(page as Control); page2 = new TabPage(); this.tabControl1.Controls.Add(page2); page2.Text = "变换"; page = new CADTransformationPropertyPage { FocusMap = this.ibasicMap_0, SelectItem = this.object_0 }; (page as Control).Dock = DockStyle.Fill; page2.Controls.Add(page as Control); } else if (!(this.object_0 is ICompositeGraphicsLayer)) { page2 = new TabPage(); this.tabControl1.Controls.Add(page2); page2.Text = "显示"; page = new LayerDisplaySetCtrl { FocusMap = this.ibasicMap_0, SelectItem = this.object_0 }; (page as Control).Dock = DockStyle.Fill; page2.Controls.Add(page as Control); } if (this.object_0 is ITopologyLayer) { page2 = new TabPage(); this.tabControl1.Controls.Add(page2); page2.Text = "符号"; page = new ToplogyLayerSymbolCtrl { FocusMap = this.ibasicMap_0, SelectItem = this.object_0 }; (page as ToplogyLayerSymbolCtrl).StyleGallery = this.istyleGallery_0; (page as Control).Dock = DockStyle.Fill; page2.Controls.Add(page as Control); page2 = new TabPage(); this.tabControl1.Controls.Add(page2); page2.Text = "要素类"; page = new TopologyClassesPropertyPage { FocusMap = this.ibasicMap_0, SelectItem = this.object_0 }; (page as Control).Dock = DockStyle.Fill; page2.Controls.Add(page as Control); page2 = new TabPage(); this.tabControl1.Controls.Add(page2); page2.Text = "规则"; page = new TopologyRulesPropertyPage { FocusMap = this.ibasicMap_0, SelectItem = this.object_0 }; (page as Control).Dock = DockStyle.Fill; page2.Controls.Add(page as Control); } if (!(this.object_0 is IGeoFeatureLayer)) { if (this.object_0 is IRasterLayer) { page2 = new TabPage(); this.tabControl1.Controls.Add(page2); page2.Text = "符号"; page = new RasterRenderPropertyPage(); (page as RasterRenderPropertyPage).StyleGallery = this.istyleGallery_0; page.FocusMap = this.ibasicMap_0; page.SelectItem = this.object_0; (page as Control).Dock = DockStyle.Fill; page2.Controls.Add(page as Control); } } else { page2 = new TabPage(); this.tabControl1.Controls.Add(page2); page2.Text = "符号"; page = new LayerRenderCtrl(); (page as LayerRenderCtrl).StyleGallery = this.istyleGallery_0; page.FocusMap = this.ibasicMap_0; page.SelectItem = this.object_0; (page as Control).Dock = DockStyle.Fill; page2.Controls.Add(page as Control); page2 = new TabPage(); this.tabControl1.Controls.Add(page2); page2.Text = "定义查询"; page = new LayerDefinitionExpressionCtrl { FocusMap = this.ibasicMap_0, SelectItem = this.object_0 }; (page as Control).Dock = DockStyle.Fill; page2.Controls.Add(page as Control); if (this.ibasicMap_0 is IMap) { page2 = new TabPage(); this.tabControl1.Controls.Add(page2); page2.Text = "标注"; page = new LayerLabelPropertyCtrl { FocusMap = this.ibasicMap_0, SelectItem = this.object_0 }; (page as Control).Dock = DockStyle.Fill; page2.Controls.Add(page as Control); } if (this.object_0 is ILayerExtensions) { ILayerExtensions extensions = this.object_0 as ILayerExtensions; for (num2 = 0; num2 < extensions.ExtensionCount; num2++) { if (extensions.get_Extension(num2) is IHatchLayerExtension) { page2 = new TabPage(); this.tabControl1.Controls.Add(page2); page2.Text = "刻度线"; page = new HatchLayerExtensionPropertyPage { FocusMap = this.ibasicMap_0, SelectItem = this.object_0 }; (page as Control).Dock = DockStyle.Fill; page2.Controls.Add(page as Control); break; } } } } } else if (this.object_0 is IStandaloneTable) { page2 = new TabPage(); this.tabControl1.Controls.Add(page2); page2.Text = "定义查询"; page = new LayerDefinitionExpressionCtrl { FocusMap = this.ibasicMap_0, SelectItem = this.object_0 }; (page as Control).Dock = DockStyle.Fill; page2.Controls.Add(page as Control); } if (!(this.object_0 is ICadLayer) && !(this.object_0 is ITopologyLayer)) { if (this.object_0 is ITinLayer) { page2 = new TabPage(); this.tabControl1.Controls.Add(page2); page2.Text = "符号"; page = new TinLayerRenderPropertyPage { FocusMap = this.ibasicMap_0, SelectItem = this.object_0 }; (page as Control).Dock = DockStyle.Fill; page2.Controls.Add(page as Control); } else if (this.object_0 is ILayerFields) { try { if ((this.object_0 as ILayerFields).FieldCount > 0) { page2 = new TabPage(); this.tabControl1.Controls.Add(page2); page2.Text = "连接和关联"; page = new JoiningAndRelatingPropertyPage(); (page as JoiningAndRelatingPropertyPage).OnJoinAndRelationChange += new OnJoinAndRelationChangeHandler(this.method_0); page.FocusMap = this.ibasicMap_0; page.SelectItem = this.object_0; (page as Control).Dock = DockStyle.Fill; page2.Controls.Add(page as Control); } } catch { } } } if (this.object_0 is ILayerFields) { page2 = new TabPage(); this.tabControl1.Controls.Add(page2); page2.Text = "字段"; page = new LayerFieldsPage { FocusMap = this.ibasicMap_0, SelectItem = this.object_0 }; (page as Control).Dock = DockStyle.Fill; page2.Controls.Add(page as Control); } } if ((this.ibasicMap_0 is IScene) || this.method_1(this.object_0 as ILayer)) { page2 = new TabPage(); this.tabControl1.Controls.Add(page2); page2.Text = "基准高程"; page = new BaseHeightPropertyPage { FocusMap = this.ibasicMap_0, SelectItem = this.object_0 }; (page as Control).Dock = DockStyle.Fill; page2.Controls.Add(page as Control); page2 = new TabPage(); this.tabControl1.Controls.Add(page2); page = new SceneRenderPropertyPage(); page2.Text = (page as SceneRenderPropertyPage).Text; page.FocusMap = this.ibasicMap_0; page.SelectItem = this.object_0; (page as Control).Dock = DockStyle.Fill; page2.Controls.Add(page as Control); if (this.object_0 is IFeatureLayer) { page2 = new TabPage(); this.tabControl1.Controls.Add(page2); page = new ExtrusionPropertyPage(); page2.Text = (page as ExtrusionPropertyPage).Text; page.FocusMap = this.ibasicMap_0; page.SelectItem = this.object_0; (page as Control).Dock = DockStyle.Fill; page2.Controls.Add(page as Control); } } }