本人在ArcEngine里通过如下代码调出Coordinate System属性窗口(如图1),对坐标投影进行修改按确定后,本人怎么可以获取到修改后的投影?
代码如下:
void CoordinateSystem(ILayer pLayer)
{
try
{
//IMap pMap = new MapClass();
//pMap.AddLayer(pLayer);
IComPropertySheet PSheet = new ComPropertySheetClass();
PSheet.HideHelpButton = true;
ESRI.ArcGIS.esriSystem.ISet PSet = new ESRI.ArcGIS.esriSystem.SetClass();
//PSet.Add(pMap);
PSet.Add(pLayer);
PSheet.ClearCategoryIDs();
PSheet.AddCategoryID(new UIDClass());
IPropertyPage APage = null;
#region 数据框属性
APage = new ESRI.ArcGIS.CartoUI.MapProjectionPropPageClass();//坐标系
PSheet.AddPage(APage);
#endregion
PSheet.Title = “空间参考属性”;
//假设已经修改了内容,则更新地图
if (PSheet.EditProperties(PSet, 0))
{
ISpatialReference pSpatialRef = ArcGIS.Feature.GetSpatialReference(((IFeatureLayer)pLayer).FeatureClass);
string proName = pSpatialRef.Name;
}
}
catch (Exception ex)
{
}
}
图1如下:
代码如下:
void CoordinateSystem(ILayer pLayer)
{
try
{
//IMap pMap = new MapClass();
//pMap.AddLayer(pLayer);
IComPropertySheet PSheet = new ComPropertySheetClass();
PSheet.HideHelpButton = true;
ESRI.ArcGIS.esriSystem.ISet PSet = new ESRI.ArcGIS.esriSystem.SetClass();
//PSet.Add(pMap);
PSet.Add(pLayer);
PSheet.ClearCategoryIDs();
PSheet.AddCategoryID(new UIDClass());
IPropertyPage APage = null;
#region 数据框属性
APage = new ESRI.ArcGIS.CartoUI.MapProjectionPropPageClass();//坐标系
PSheet.AddPage(APage);
#endregion
PSheet.Title = “空间参考属性”;
//假设已经修改了内容,则更新地图
if (PSheet.EditProperties(PSet, 0))
{
ISpatialReference pSpatialRef = ArcGIS.Feature.GetSpatialReference(((IFeatureLayer)pLayer).FeatureClass);
string proName = pSpatialRef.Name;
}
}
catch (Exception ex)
{
}
}
图1如下:
解决方案
20
private bool SetupFeaturePropertySheet(ILayer layer) { if (layer == null) return false; ESRI.ArcGIS.Framework.IComPropertySheet pComPropSheet; pComPropSheet = new ESRI.ArcGIS.Framework.ComPropertySheet(); pComPropSheet.Title = layer.Name + " - 属性"; ESRI.ArcGIS.esriSystem.UID pPPUID = new ESRI.ArcGIS.esriSystem.UIDClass(); pComPropSheet.AddCategoryID(pPPUID); // General.... ESRI.ArcGIS.Framework.IPropertyPage pGenPage = new ESRI.ArcGIS.CartoUI.GeneralLayerPropPageClass(); pComPropSheet.AddPage(pGenPage); // Source ESRI.ArcGIS.Framework.IPropertyPage pSrcPage = new ESRI.ArcGIS.CartoUI.FeatureLayerSourcePropertyPageClass(); pComPropSheet.AddPage(pSrcPage); // Selection... ESRI.ArcGIS.Framework.IPropertyPage pSelectPage = new ESRI.ArcGIS.CartoUI.FeatureLayerSelectionPropertyPageClass(); pComPropSheet.AddPage(pSelectPage); // Display.... ESRI.ArcGIS.Framework.IPropertyPage pDispPage = new ESRI.ArcGIS.CartoUI.FeatureLayerDisplayPropertyPageClass(); pComPropSheet.AddPage(pDispPage); // Symbology.... ESRI.ArcGIS.Framework.IPropertyPage pDrawPage = new ESRI.ArcGIS.CartoUI.LayerDrawingPropertyPageClass(); pComPropSheet.AddPage(pDrawPage); // Fields... ESRI.ArcGIS.Framework.IPropertyPage pFieldsPage = new ESRI.ArcGIS.CartoUI.LayerFieldsPropertyPageClass(); pComPropSheet.AddPage(pFieldsPage); // Definition Query... ESRI.ArcGIS.Framework.IPropertyPage pQueryPage = new ESRI.ArcGIS.CartoUI.LayerDefinitionQueryPropertyPageClass(); pComPropSheet.AddPage(pQueryPage); // Labels.... ESRI.ArcGIS.Framework.IPropertyPage pSelPage = new ESRI.ArcGIS.CartoUI.LayerLabelsPropertyPageClass(); pComPropSheet.AddPage(pSelPage); // Joins & Relates.... ESRI.ArcGIS.Framework.IPropertyPage pJoinPage = new ESRI.ArcGIS.ArcMapUI.JoinRelatePageClass(); pComPropSheet.AddPage(pJoinPage); // Setup layer link ESRI.ArcGIS.esriSystem.ISet pMySet = new ESRI.ArcGIS.esriSystem.SetClass(); pMySet.Add(layer); pMySet.Reset(); // make the symbology tab active pComPropSheet.ActivePage = 4; // show the property sheet bool bOK = pComPropSheet.EditProperties(pMySet, 0); m_activeView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, m_activeView.Extent); return (bOK); }
这个是在网上找的代码, 假如要修改坐标系应该是相似的过程,并不需要得到用户选择了哪个,直接EditProperties就好