// ArcGIS Snippet Title: // Loop Through Layers of Specific UID // // Long Description: // Stub code to loop through layers in a map where a specific UID is supplied. // // Add the following references to the project: // ESRI.ArcGIS.Carto // ESRI.ArcGIS.System // System // // Intended ArcGIS Products for this snippet: // ArcGIS Desktop (ArcEditor, ArcInfo, ArcView) // ArcGIS Engine // ArcGIS Server // // Applicable ArcGIS Product Versions: // 9.2 // 9.3 // 9.3.1 // 10.0 // // Required ArcGIS Extensions: // (NONE) // // Notes: // This snippet is intended to be inserted at the base level of a Class. // It is not intended to be nested within an existing Method. // ///<summary>Stub code to loop through layers in a map where a specific UID is supplied.</summary> /// ///<param name="map">An IMap interface in which the layers reside.</param> ///<param name="layerCLSID">A System.String that is the layer GUID type. For example: "{E156D7E5-22AF-11D3-9F99-00C04F6BC78E}" is the IGeoFeatureLayer.</param> /// ///<remarks>In order of the code to be useful the user needs to write their own code to use the layer in the TODO section. /// /// The different layer GUID's and Interface's are: /// "{AD88322D-533D-4E36-A5C9-1B109AF7A346}" = IACFeatureLayer /// "{74E45211-DFE6-11D3-9FF7-00C04F6BC6A5}" = IACLayer /// "{495C0E2C-D51D-4ED4-9FC1-FA04AB93568D}" = IACImageLayer /// "{65BD02AC-1CAD-462A-A524-3F17E9D85432}" = IACAcetateLayer /// "{4AEDC069-B599-424B-A374-49602ABAD308}" = IAnnotationLayer /// "{DBCA59AC-6771-4408-8F48-C7D53389440C}" = IAnnotationSublayer /// "{E299ADBC-A5C3-11D2-9B10-00C04FA33299}" = ICadLayer /// "{7F1AB670-5CA9-44D1-B42D-12AA868FC757}" = ICadastralFabricLayer /// "{BA119BC4-939A-11D2-A2F4-080009B6F22B}" = ICompositeLayer /// "{9646BB82-9512-11D2-A2F6-080009B6F22B}" = ICompositeGraphicsLayer /// "{0C22A4C7-DAFD-11D2-9F46-00C04F6BC78E}" = ICoverageAnnotationLayer /// "{6CA416B1-E160-11D2-9F4E-00C04F6BC78E}" = IDataLayer /// "{0737082E-958E-11D4-80ED-00C04F601565}" = IDimensionLayer /// "{48E56B3F-EC3A-11D2-9F5C-00C04F6BC6A5}" = IFDOGraphicsLayer /// "{40A9E885-5533-11D0-98BE-00805F7CED21}" = IFeatureLayer /// "{605BC37A-15E9-40A0-90FB-DE4CC376838C}" = IGdbRasterCatalogLayer /// "{E156D7E5-22AF-11D3-9F99-00C04F6BC78E}" = IGeoFeatureLayer /// "{34B2EF81-F4AC-11D1-A245-080009B6F22B}" = IGraphicsLayer /// "{EDAD6644-1810-11D1-86AE-0000F8751720}" = IGroupLayer /// "{D090AA89-C2F1-11D3-9FEF-00C04F6BC6A5}" = IIMSSubLayer /// "{DC8505FF-D521-11D3-9FF4-00C04F6BC6A5}" = IIMAMapLayer /// "{34C20002-4D3C-11D0-92D8-00805F7C28B0}" = ILayer /// "{E9B56157-7EB7-4DB3-9958-AFBF3B5E1470}" = IMapServerLayer /// "{B059B902-5C7A-4287-982E-EF0BC77C6AAB}" = IMapServerSublayer /// "{82870538-E09E-42C0-9228-CBCB244B91BA}" = INetworkLayer /// "{D02371C7-35F7-11D2-B1F2-00C04F8EDEFF}" = IRasterLayer /// "{AF9930F0-F61E-11D3-8D6C-00C04F5B87B2}" = IRasterCatalogLayer /// "{FCEFF094-8E6A-4972-9BB4-429C71B07289}" = ITemporaryLayer /// "{5A0F220D-614F-4C72-AFF2-7EA0BE2C8513}" = ITerrainLayer /// "{FE308F36-BDCA-11D1-A523-0000F8774F0F}" = ITinLayer /// "{FB6337E3-610A-4BC2-9142-760D954C22EB}" = ITopologyLayer /// "{005F592A-327B-44A4-AEEB-409D2F866F47}" = IWMSLayer /// "{D43D9A73-FF6C-4A19-B36A-D7ECBE61962A}" = IWMSGroupLayer /// "{8C19B114-1168-41A3-9E14-FC30CA5A4E9D}" = IWMSMapLayer ///</remarks> public void LoopThroughLayersOfSpecificUID(ESRI.ArcGIS.Carto.IMap map, System.String layerCLSID) { if (map == null || layerCLSID == null) { return; } ESRI.ArcGIS.esriSystem.IUID uid = new ESRI.ArcGIS.esriSystem.UIDClass(); uid.Value = layerCLSID; // Example: "{E156D7E5-22AF-11D3-9F99-00C04F6BC78E}" = IGeoFeatureLayer try { ESRI.ArcGIS.Carto.IEnumLayer enumLayer = map.get_Layers(((ESRI.ArcGIS.esriSystem.UID)(uid)), true); // Explicit Cast enumLayer.Reset(); ESRI.ArcGIS.Carto.ILayer layer = enumLayer.Next(); cboLayers.Items.Clear(); lstLayers.Clear(); while (!(layer == null)) { IFeatureLayer featureLayer = (IFeatureLayer)layer; if (featureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon) { cboLayers.Items.Add(layer.Name); lstLayers.Add(layer); } layer = enumLayer.Next(); } if (cboLayers.Items.Count > 0) { cboLayers.SelectedIndex = 0; } } catch (System.Exception ex) { //System.Windows.Forms.MessageBox.Show("No layers of type: " + uid.Value.ToString); } }
/// <summary> /// Method to set the map tool as the active tool for the map /// </summary> /// <param name="application"></param> /// <param name="toolName"></param> public void SetToolActiveInToolBar(string toolName) { if (ArcMap.Application == null) { return; } if (string.IsNullOrEmpty(toolName)) { if (ArcMap.Application.CurrentTool != null) // TRICKY: setting current tool to null at startup causes crash so extra check { ArcMap.Application.CurrentTool = null; } return; } if ((ArcMap.Application.CurrentTool != null) && (ArcMap.Application.CurrentTool.Name.Equals(toolName))) { // Tricky: Check if tool already active - because setting CurrentTool again will // cause Activate/Deactive to be called by ArcGIS framework return; } ESRI.ArcGIS.Framework.ICommandBars commandBars = ArcMap.Application.Document.CommandBars; ESRI.ArcGIS.esriSystem.UID commandID = new ESRI.ArcGIS.esriSystem.UIDClass(); commandID.Value = toolName; ESRI.ArcGIS.Framework.ICommandItem commandItem = commandBars.Find(commandID, false, false); if (commandItem != null) { ArcMap.Application.CurrentTool = commandItem; } }
// ArcGIS Snippet Title: // Create Context Menu // // Long Description: // Create a context or popup menu dynamically using some default command items. // // Add the following references to the project: // ESRI.ArcGIS.Framework // ESRI.ArcGIS.System // ESRI.ArcGIS.SystemUI // System // System.Drawing // System.Windows.Forms // // Intended ArcGIS Products for this snippet: // ArcGIS Desktop (ArcEditor, ArcInfo, ArcView) // // Applicable ArcGIS Product Versions: // 9.2 // 9.3 // 9.3.1 // 10.0 // // Required ArcGIS Extensions: // (NONE) // // Notes: // This snippet is intended to be inserted at the base level of a Class. // It is not intended to be nested within an existing Method. // ///<summary>Create a context or popup menu dynamically using some default command items.</summary> /// ///<param name="application">An IApplication Interface.</param> /// ///<remarks>Three default command items are added to the ContextMenu. Change the CLSID or ProgID as necessary for your specific command items.</remarks> public void CreateContextMenu(ESRI.ArcGIS.Framework.IApplication application) { ESRI.ArcGIS.Framework.ICommandBars commandBars = application.Document.CommandBars; ESRI.ArcGIS.Framework.ICommandBar commandBar = commandBars.Create("TemporaryContextMenu", ESRI.ArcGIS.SystemUI.esriCmdBarType.esriCmdBarTypeShortcutMenu); System.Object optionalIndex = System.Type.Missing; ESRI.ArcGIS.esriSystem.UID uid = new ESRI.ArcGIS.esriSystem.UIDClass(); uid.Value = "ROI.ContextMenuItems.ShowForm"; // Can use CLSID or ProgID uid.SubType = 0; commandBar.Add(uid, ref optionalIndex); uid.Value = "ROI.ContextMenuItems.ClearGraphics.ClearGraphics"; // Can use CLSID or ProgID uid.SubType = 0; commandBar.Add(uid, ref optionalIndex); //uid.Value = "{FBF8C3FB-0480-11D2-8D21-080009EE4E51}"; // Can use CLSID or ProgID //uid.SubType = 1; //commandBar.Add(uid, ref optionalIndex); //uid.Value = "{FBF8C3FB-0480-11D2-8D21-080009EE4E51}"; // Can use CLSID or ProgID //uid.SubType = 2; //commandBar.Add(uid, ref optionalIndex); //Show the context menu at the current mouse location System.Drawing.Point currentLocation = System.Windows.Forms.Form.MousePosition; commandBar.Popup(currentLocation.X, currentLocation.Y); }
public btnLaunchWindow() { ESRI.ArcGIS.esriSystem.UID dockWinID = new ESRI.ArcGIS.esriSystem.UIDClass(); dockWinID.Value = ThisAddIn.IDs.winTextToFeature; // Use GetDockableWindow directly as we want the client IDockableWindow not the internal class ESRI.ArcGIS.Framework.IDockableWindow dockWindow = ArcMap.DockableWindowManager.GetDockableWindow(dockWinID); dockWindow.Show(true); }
internal static ChampExtension GetExtension() { if (s_extension == null) { ESRI.ArcGIS.esriSystem.UID extID = new ESRI.ArcGIS.esriSystem.UIDClass(); extID.Value = ThisAddIn.IDs.ChampExtension; ArcMap.Application.FindExtensionByCLSID(extID); } return(s_extension); }
internal ESRI.ArcGIS.Framework.IDockableWindow GetApplyDockableWindow() { if (m_dockWindowApply == null) { ESRI.ArcGIS.esriSystem.UID dockUID = new ESRI.ArcGIS.esriSystem.UIDClass(); dockUID.Value = ThisAddIn.IDs.ChampApplyDockableWindow; m_dockWindowApply = ArcMap.DockableWindowManager.GetDockableWindow(dockUID); } return(m_dockWindowApply); }
public void SetToolActiveInToolBar(ESRI.ArcGIS.Framework.IApplication application, System.String toolName) { ESRI.ArcGIS.Framework.ICommandBars commandBars = application.Document.CommandBars; ESRI.ArcGIS.esriSystem.UID commandID = new ESRI.ArcGIS.esriSystem.UIDClass(); commandID.Value = toolName; // example: "esriArcMapUI.ZoomInTool"; ESRI.ArcGIS.Framework.ICommandItem commandItem = commandBars.Find(commandID, false, false); if (commandItem != null) { application.CurrentTool = commandItem; } }
private IEditor3 GetEditorFromArcMap(IMxApplication mxApplication) { if (mxApplication == null) { return(null); } ESRI.ArcGIS.esriSystem.UID uid = new ESRI.ArcGIS.esriSystem.UIDClass(); uid.Value = "{F8842F20-BB23-11D0-802B-0000F8037368}"; ESRI.ArcGIS.Framework.IApplication application = mxApplication as ESRI.ArcGIS.Framework.IApplication; // Dynamic Cast ESRI.ArcGIS.esriSystem.IExtension extension = application.FindExtensionByCLSID(uid); ESRI.ArcGIS.Editor.IEditor3 editor3 = extension as ESRI.ArcGIS.Editor.IEditor3; // Dynamic Cast return(editor3); }
internal static ESRI.ArcGIS.Carto.ILayer getLayerByName(string name) { ESRI.ArcGIS.Carto.IMap map = ArcMap.Document.FocusMap; ESRI.ArcGIS.esriSystem.UID uid = new ESRI.ArcGIS.esriSystem.UIDClass(); uid.Value = "{40A9E885-5533-11d0-98BE-00805F7CED21}"; ESRI.ArcGIS.Carto.IEnumLayer enumLayer = map.get_Layers(null, true); ESRI.ArcGIS.Carto.ILayer l = enumLayer.Next(); while (l != null) { if (l.Name.ToUpper() == name.ToUpper()) { break; } l = enumLayer.Next(); } return(l); }
internal static ESRI.ArcGIS.esriSystem.UID ToUID(this System.String id) { ESRI.ArcGIS.esriSystem.UID uid = new ESRI.ArcGIS.esriSystem.UIDClass(); uid.Value = id; return(uid); }
///<summary>Simple helper to create a featureclass in a geodatabase.</summary> /// ///<param name="workspace">An IWorkspace2 interface</param> ///<param name="featureDataset">An IFeatureDataset interface or Nothing</param> ///<param name="featureClassName">A System.String that contains the name of the feature class to open or create. Example: "states"</param> ///<param name="fields">An IFields interface</param> ///<param name="clsid">A UID value or Nothing. Example "esriGeoDatabase.Feature" or Nothing</param> ///<param name="clsext">A UID value or Nothing (this is the class extension if you want to reference a class extension when creating the feature class).</param> ///<param name="strConfigKeyword">An empty System.String or RDBMS table string for ArcSDE. Example: "myTable" or ""</param> /// ///<returns>An IFeatureClass interface or a Nothing</returns> /// ///<remarks> /// (1) If a 'featureClassName' already exists in the workspace a reference to that feature class /// object will be returned. /// (2) If an IFeatureDataset is passed in for the 'featureDataset' argument the feature class /// will be created in the dataset. If a Nothing is passed in for the 'featureDataset' /// argument the feature class will be created in the workspace. /// (3) When creating a feature class in a dataset the spatial reference is inherited /// from the dataset object. /// (4) If an IFields interface is supplied for the 'fields' collection it will be used to create the /// table. If a Nothing value is supplied for the 'fields' collection, a table will be created using /// default values in the method. /// (5) The 'strConfigurationKeyword' parameter allows the application to control the physical layout /// for this table in the underlying RDBMSfor example, in the case of an Oracle database, the /// configuration keyword controls the tablespace in which the table is created, the initial and /// next extents, and other properties. The 'strConfigurationKeywords' for an ArcSDE instance are /// set up by the ArcSDE data administrator, the list of available keywords supported by a workspace /// may be obtained using the IWorkspaceConfiguration interface. For more information on configuration /// keywords, refer to the ArcSDE documentation. When not using an ArcSDE table use an empty /// string (ex: ""). ///</remarks> internal IFeatureClass CreateFeatureClass(IWorkspace2 workspace, IFeatureDataset featureDataset, string featureClassName, IFields fields, ESRI.ArcGIS.esriSystem.UID clsid, ESRI.ArcGIS.esriSystem.UID clsext, string strConfigKeyword) { if (string.IsNullOrEmpty(featureClassName)) return null; IFeatureClass featureClass; var featureWorkspace = (IFeatureWorkspace)workspace; // Cast may throw exception if (workspace.NameExists[esriDatasetType.esriDTFeatureClass, featureClassName]) //feature class with that name already exists { featureClass = featureWorkspace.OpenFeatureClass(featureClassName); return featureClass; } // assign the class id value if not assigned if (clsid == null) { clsid = new ESRI.ArcGIS.esriSystem.UIDClass { Value = "esriGeoDatabase.Feature" }; //Works for shapefiles as well } IObjectClassDescription objectClassDescription = new FeatureClassDescriptionClass(); // if a fields collection is not passed in then supply our own if (fields == null) { // create the fields using the required fields method fields = objectClassDescription.RequiredFields; var fieldsEdit = (IFieldsEdit)fields; // Explicit Cast IField field = new FieldClass(); // create a user defined text field var fieldEdit = (IFieldEdit)field; // Explicit Cast // setup field properties fieldEdit.Name_2 = "SampleField"; fieldEdit.Type_2 = esriFieldType.esriFieldTypeString; fieldEdit.IsNullable_2 = true; fieldEdit.AliasName_2 = "Sample Field Column"; fieldEdit.DefaultValue_2 = "test"; fieldEdit.Editable_2 = true; fieldEdit.Length_2 = 100; // add field to field collection fieldsEdit.AddField(field); fields = fieldsEdit; } string strShapeField = ""; // locate the shape field for (int j = 0; j < fields.FieldCount; j++) { if (fields.Field[j].Type != esriFieldType.esriFieldTypeGeometry) continue; strShapeField = fields.Field[j].Name; break; } // Use IFieldChecker to create a validated fields collection. IFieldChecker fieldChecker = new FieldCheckerClass(); IEnumFieldError enumFieldError; IFields validatedFields; fieldChecker.ValidateWorkspace = (IWorkspace)workspace; fieldChecker.Validate(fields, out enumFieldError, out validatedFields); // The enumFieldError enumerator can be inspected at this point to determine // which fields were modified during validation. // finally create and return the feature class featureClass = featureDataset == null ? featureWorkspace.CreateFeatureClass(featureClassName, validatedFields, clsid, clsext, esriFeatureType.esriFTSimple, strShapeField, strConfigKeyword) : featureDataset.CreateFeatureClass(featureClassName, validatedFields, clsid, clsext, esriFeatureType.esriFTSimple, strShapeField, strConfigKeyword); return featureClass; }
/// <summary> /// get the global editor object for ArcMap /// </summary> private void InitEditor(ref string ErrorMessage) { ESRI.ArcGIS.esriSystem.UID pID; try { ////store editor object for use throughout extension pID = new ESRI.ArcGIS.esriSystem.UIDClass(); pID.Value = "esriEditor.Editor"; m_Editor = (ESRI.ArcGIS.Editor.IEditor)m_Application.FindExtensionByCLSID(pID); } catch (Exception ex) { ErrorMessage = "Could not locate Editor. " + ex.Message; } }
/// <summary> /// create polyline, point or polygon (simple) featureclass /// </summary> public static IFeatureClass CreateWorkspaceFeatureClass(string FCName, IWorkspace featWorkspace, esriGeometryType geomType, IFields pfields, ISpatialReference pSR, ref string ErrorMessage) { IField pField; ESRI.ArcGIS.esriSystem.UIDClass pCLSID; IGeometryDef pGeomDef; pCLSID = new ESRI.ArcGIS.esriSystem.UIDClass(); pCLSID.Value = "esricore.Feature"; //create geom def pGeomDef = new GeometryDefClass(); ((IGeometryDefEdit)pGeomDef).GeometryType_2 = geomType; ((IGeometryDefEdit)pGeomDef).SpatialReference_2 = pSR; //create the geometry field pField = new FieldClass(); ((IFieldEdit)pField).Name_2 = "SHAPE"; ((IFieldEdit)pField).AliasName_2 = "SHAPE"; ((IFieldEdit)pField).Type_2 = esriFieldType.esriFieldTypeGeometry; ((IFieldEdit)pField).GeometryDef_2 = pGeomDef; //add geometry to field collection ((IFieldsEdit)pfields).AddField(pField); // create the object id field pField = new FieldClass(); ((IFieldEdit)pField).Name_2 = "OBJECTID"; ((IFieldEdit)pField).AliasName_2 = "OBJECTID"; ((IFieldEdit)pField).Type_2 = esriFieldType.esriFieldTypeOID; ((IFieldsEdit)pfields).AddField(pField); try { //create the feature class return ((IFeatureWorkspace)featWorkspace).CreateFeatureClass(FCName, pfields, pCLSID, null, esriFeatureType.esriFTSimple, "SHAPE", ""); } catch (Exception ex) { ErrorMessage = "Error occured while create FeatureClass. " + ex.Message; return null; } }
private bool SetupFeaturePropertySheet(ILayer layer) { if (layer == null) { return(false); } ESRI.ArcGIS.Framework.IComPropertySheet pComPropSheet; pComPropSheet = new ESRI.ArcGIS.Framework.ComPropertySheetClass(); 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); ////更新图例 //IMapSurround pMapSurround = null; //ILegend pLegend = null; //for (int i = 0; i < m_map.MapSurroundCount; i++) //{ // pMapSurround = m_map.get_MapSurround(i); // if (pMapSurround is ILegend) // { // pLegend = pMapSurround as ILegend; // pLegend.AutoVisibility = true; // pLegend.Refresh(); // } //} return(bOK); }
internal void SetMap(string filePath) { // open the map document ESRI.ArcGIS.Carto.IMapDocument mapDocument = new ESRI.ArcGIS.Carto.MapDocumentClass(); mapDocument.Open(filePath, null); // get first map (data frame) ESRI.ArcGIS.Carto.IMap map = mapDocument.get_Map(0); // track whether we need to save properties string[] tTmp = new string[m_ExtractionLayerProperties.Keys.Count]; m_ExtractionLayerProperties.Keys.CopyTo(tTmp,0); // we will remove items from this previously configured list and anything left we know is no longer in map, so remove // from saved properties List<string> tPreviouslyConfiguredLayers = tTmp.ToList<string>(); // get raster layers ESRI.ArcGIS.esriSystem.UID rasterLayerId = new ESRI.ArcGIS.esriSystem.UIDClass(); // GUID for a raster layer rasterLayerId.Value = "{D02371C7-35F7-11D2-B1F2-00C04F8EDEFF}"; ESRI.ArcGIS.Carto.IEnumLayer rasterEnumLayer = map.get_Layers(rasterLayerId, true); int dirSelectedIndex = 0; int accSelectedIndex = 0; // set a default value of none // if either box is left at none then the SOE will know not to // expose the watershed operation ComboFlowDir.Items.Add("NONE"); ComboFlowAcc.Items.Add("NONE"); ESRI.ArcGIS.Carto.IRasterLayer rasterLayer = null; while ((rasterLayer = rasterEnumLayer.Next() as ESRI.ArcGIS.Carto.IRasterLayer) != null) { ESRI.ArcGIS.DataSourcesRaster.IRasterProps tRasterProps = rasterLayer.Raster as ESRI.ArcGIS.DataSourcesRaster.IRasterProps; ESRI.ArcGIS.Geodatabase.rstPixelType tPixelType = tRasterProps.PixelType; // flow dir can only be an integer raster of short or long types if (tPixelType == ESRI.ArcGIS.Geodatabase.rstPixelType.PT_UCHAR || tPixelType == ESRI.ArcGIS.Geodatabase.rstPixelType.PT_SHORT || tPixelType == ESRI.ArcGIS.Geodatabase.rstPixelType.PT_ULONG || tPixelType == ESRI.ArcGIS.Geodatabase.rstPixelType.PT_LONG) { ComboFlowDir.Items.Add(rasterLayer.Name); ComboFlowAcc.Items.Add(rasterLayer.Name); } // flow acc can theoretically be floating point as far as i can see // albeit it won't normally be else if (tPixelType == ESRI.ArcGIS.Geodatabase.rstPixelType.PT_FLOAT || tPixelType == ESRI.ArcGIS.Geodatabase.rstPixelType.PT_DOUBLE) { ComboFlowAcc.Items.Add(rasterLayer.Name); } if (rasterLayer.Name == m_FlowAccLayerName) { accSelectedIndex = ComboFlowAcc.Items.Count - 1; } else if (rasterLayer.Name == m_FlowDirLayerName) { dirSelectedIndex = ComboFlowDir.Items.Count - 1; } string tRasterType = "ContinuousRaster"; if (tRasterProps.IsInteger) { tRasterType = "CategoricalRaster"; } ExtractionLayerProperties tLayerInMap = new ExtractionLayerProperties(rasterLayer.Name, false, rasterLayer.Name.Substring(0, 6), tRasterType, "NONE", "NONE", "NONE",null,null,null); ExtractionLayerProperties tCurrentConfigForLayer; bool alreadyconfigured = m_ExtractionLayerProperties.TryGetValue(rasterLayer.Name,out tCurrentConfigForLayer); if (alreadyconfigured) { tLayerInMap.Enabled = tCurrentConfigForLayer.Enabled; tLayerInMap.ParamName = tCurrentConfigForLayer.ParamName; // that's all that needs doing for a raster raster } m_ExtractionLayerProperties[rasterLayer.Name] = tLayerInMap; tPreviouslyConfiguredLayers.Remove(rasterLayer.Name); } int extSelectedIndex = 0; ESRI.ArcGIS.esriSystem.UID featlyrId = new ESRI.ArcGIS.esriSystem.UIDClass(); featlyrId.Value = "{E156D7E5-22AF-11D3-9F99-00C04F6BC78E}"; ESRI.ArcGIS.Carto.IEnumLayer featureEnumLayer = map.get_Layers(featlyrId,true); ESRI.ArcGIS.Carto.IFeatureLayer featureLayer = null; while ((featureLayer = featureEnumLayer.Next() as ESRI.ArcGIS.Carto.IFeatureLayer) != null) { if (featureLayer.FeatureClass.ShapeType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon && featureLayer.FeatureClass.FeatureType == ESRI.ArcGIS.Geodatabase.esriFeatureType.esriFTSimple) { ComboExtentFeatures.Items.Add(featureLayer.Name); } if (featureLayer.Name == m_ExtentFeatureLayerName) { extSelectedIndex = ComboExtentFeatures.Items.Count - 1; } // now stuff for the extraction layer configuration List<string> catfields = new List<string>(); List<string> valfields = new List<string>(); List<string> measfields = new List<string>(); catfields.Add("NONE"); valfields.Add("NONE"); measfields.Add("NONE"); ESRI.ArcGIS.Geodatabase.IFields tFLFields = featureLayer.FeatureClass.Fields; for (int i = 0; i < tFLFields.FieldCount; i++) { ESRI.ArcGIS.Geodatabase.IField tField = featureLayer.FeatureClass.Fields.get_Field(i); ESRI.ArcGIS.Geodatabase.esriFieldType tFieldType = tField.Type; switch (tFieldType) { case ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeDouble: case ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeSingle: valfields.Add(tField.Name); measfields.Add(tField.Name); break; case ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeInteger: case ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeSmallInteger: valfields.Add(tField.Name); catfields.Add(tField.Name); measfields.Add(tField.Name); break; case ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeString: case ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeDate: catfields.Add(tField.Name); break; } } ExtractionLayerProperties tLayerInMap = new ExtractionLayerProperties(featureLayer.Name, false, featureLayer.Name.Substring(0, 6), "FeatureLayer", "NONE", "NONE", "NONE",catfields,valfields,measfields); ExtractionLayerProperties tCurrentConfigForLayer; bool alreadyconfigured = m_ExtractionLayerProperties.TryGetValue(featureLayer.Name, out tCurrentConfigForLayer); if (alreadyconfigured) { // it is already there - loaded from properties - we will make a new object anyway but will copy over the configured // parameter name, enabled, and selected fields. tLayerInMap.Enabled = tCurrentConfigForLayer.Enabled; tLayerInMap.ParamName = tCurrentConfigForLayer.ParamName; if (tCurrentConfigForLayer.CategoryFieldName != "NONE" && featureLayer.FeatureClass.FindField(tCurrentConfigForLayer.CategoryFieldName) != -1) { tLayerInMap.CategoryFieldName = tCurrentConfigForLayer.CategoryFieldName; } if (tCurrentConfigForLayer.ValueFieldName != "NONE" && featureLayer.FeatureClass.FindField(tCurrentConfigForLayer.ValueFieldName) != -1) { tLayerInMap.ValueFieldName = tCurrentConfigForLayer.ValueFieldName; } if (tCurrentConfigForLayer.MeasureFieldName != "NONE" && featureLayer.FeatureClass.FindField(tCurrentConfigForLayer.ValueFieldName) != -1) { tLayerInMap.MeasureFieldName = tCurrentConfigForLayer.MeasureFieldName; } } m_ExtractionLayerProperties[featureLayer.Name] = tLayerInMap; // now we need to delete from m_ExtractionLayerProperties any configs that haven't been found in the map tPreviouslyConfiguredLayers.Remove(featureLayer.Name); } foreach (string invalidLayerName in tPreviouslyConfiguredLayers) { m_ExtractionLayerProperties.Remove(invalidLayerName); } // now, m_extractionlayerproperties is a dictionary of extractionlayerproperties objects // where the objects contain the values from the previously saved lot if they were there foreach (ExtractionLayerProperties rowdetails in m_ExtractionLayerProperties.Values) { // string[] rowParams = new string[]{ // rowdetails.LayerName,rowdetails.Enabled.ToString(),rowdetails.ParamName,rowdetails.CategoryFieldName,rowdetails.ValueFieldName // }; dataGridView1.Rows.Add(); int newRowIdx = dataGridView1.Rows.Count - 1; DataGridViewRow tRow = dataGridView1.Rows[newRowIdx]; tRow.Cells["LayerName"].Value = rowdetails.LayerName; tRow.Cells["LayerAvail"].Value = rowdetails.Enabled.ToString(); tRow.Cells["LayerParam"].Value = rowdetails.ParamName; if (rowdetails.ExtractionType == "FeatureLayer") { DataGridViewComboBoxCell cfcell = (DataGridViewComboBoxCell)tRow.Cells["CatField"]; foreach (object itemToAdd in rowdetails.PossibleCategoryFields) { cfcell.Items.Add(itemToAdd); } cfcell.Value = rowdetails.CategoryFieldName; DataGridViewComboBoxCell valcell = (DataGridViewComboBoxCell)tRow.Cells["ValField"]; foreach (object itemToAdd in rowdetails.PossibleValueFields) { valcell.Items.Add(itemToAdd); } valcell.Value = rowdetails.ValueFieldName; DataGridViewComboBoxCell meascell = (DataGridViewComboBoxCell)tRow.Cells["MeasField"]; foreach (object itemToAdd in rowdetails.PossibleMeasureFields) { meascell.Items.Add(itemToAdd); } meascell.Value = rowdetails.MeasureFieldName; tRow.Cells["MeasField"].Value = rowdetails.MeasureFieldName; } else { tRow.Cells["CatField"].Value = rowdetails.CategoryFieldName; tRow.Cells["ValField"].Value = rowdetails.ValueFieldName; tRow.Cells["MeasField"].Value = rowdetails.MeasureFieldName; tRow.Cells["CatField"].ReadOnly = true; tRow.Cells["ValField"].ReadOnly = true; tRow.Cells["MeasField"].ReadOnly = true; } int rowIdx = dataGridView1.Rows.Add(tRow); } mapDocument.Close(); mapDocument = null; map = null; ComboFlowAcc.SelectedIndex = accSelectedIndex; ComboFlowDir.SelectedIndex = dirSelectedIndex; ComboExtentFeatures.SelectedIndex = extSelectedIndex; m_initAcc = true; m_initDir = true; m_initExt = true; m_GridIsInSyncWithProperties = true; radioReadMap.Checked = m_GetLayersFromMap; dataGridView1.Enabled = radioReadMap.Checked; }
public void SetToolActiveInToolBar(ESRI.ArcGIS.Framework.IApplication application, System.String toolName) { ESRI.ArcGIS.Framework.ICommandBars commandBars = application.Document.CommandBars; ESRI.ArcGIS.esriSystem.UID commandID = new ESRI.ArcGIS.esriSystem.UIDClass(); commandID.Value = toolName; // example: "esriArcMapUI.ZoomInTool"; ESRI.ArcGIS.Framework.ICommandItem commandItem = commandBars.Find(commandID, false, false); if (commandItem != null) application.CurrentTool = commandItem; }
public void AddScalebar(IPageLayout pageLayout, IMap map, double posX, double posY, double division, string strMapUnits, short srtDivisions) { try { if (pageLayout == null || map == null) { return; } IEnvelope envelope = new EnvelopeClass(); envelope.PutCoords(posX - (division * 2), posY, posX, posY + (division * 0.5)); // Specify the location and size of the scalebar ESRI.ArcGIS.esriSystem.IUID uid = new ESRI.ArcGIS.esriSystem.UIDClass(); uid.Value = "esriCarto.AlternatingScaleBar"; // Create a Surround. Set the geometry of the MapSurroundFrame to give it a location // Activate it and add it to the PageLayout's graphics container IGraphicsContainer graphicsContainer = pageLayout as IGraphicsContainer; // Dynamic Cast IActiveView activeView = pageLayout as IActiveView; // Dynamic Cast IFrameElement frameElement = graphicsContainer.FindFrame(map); IMapFrame mapFrame = frameElement as IMapFrame; // Dynamic Cast IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame(uid as ESRI.ArcGIS.esriSystem.UID, null); // Dynamic Cast IElement element = mapSurroundFrame as IElement; // Dynamic Cast element.Geometry = envelope; element.Activate(activeView.ScreenDisplay); graphicsContainer.AddElement(element, 0); IMapSurround mapSurround = mapSurroundFrame.MapSurround; IScaleBar markerScaleBar = ((IScaleBar)(mapSurround)); markerScaleBar.LabelPosition = esriVertPosEnum.esriBelow; markerScaleBar.UseMapSettings(); markerScaleBar.Divisions = srtDivisions; markerScaleBar.DivisionsBeforeZero = 0; markerScaleBar.Subdivisions = 0; markerScaleBar.LabelFrequency = esriScaleBarFrequency.esriScaleBarMajorDivisions; if (strMapUnits == "Feet") { markerScaleBar.Units = ESRI.ArcGIS.esriSystem.esriUnits.esriFeet; } //Default Settings else if (strMapUnits == "Miles") { markerScaleBar.Units = ESRI.ArcGIS.esriSystem.esriUnits.esriMiles; } else if (strMapUnits == "Meters") { markerScaleBar.Units = ESRI.ArcGIS.esriSystem.esriUnits.esriMeters; } else if (strMapUnits == "Kilometers") { markerScaleBar.Units = ESRI.ArcGIS.esriSystem.esriUnits.esriKilometers; } else { return; } } catch (Exception ex) { frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog(); return; } }
internal void SetMap(string filePath) { // open the map document ESRI.ArcGIS.Carto.IMapDocument mapDocument = new ESRI.ArcGIS.Carto.MapDocumentClass(); mapDocument.Open(filePath, null); // get first map (data frame) ESRI.ArcGIS.Carto.IMap map = mapDocument.get_Map(0); // track whether we need to save properties string[] tTmp = new string[m_ExtractionLayerProperties.Keys.Count]; m_ExtractionLayerProperties.Keys.CopyTo(tTmp, 0); // we will remove items from this previously configured list and anything left we know is no longer in map, so remove // from saved properties List <string> tPreviouslyConfiguredLayers = tTmp.ToList <string>(); // get raster layers ESRI.ArcGIS.esriSystem.UID rasterLayerId = new ESRI.ArcGIS.esriSystem.UIDClass(); // GUID for a raster layer rasterLayerId.Value = "{D02371C7-35F7-11D2-B1F2-00C04F8EDEFF}"; ESRI.ArcGIS.Carto.IEnumLayer rasterEnumLayer = map.get_Layers(rasterLayerId, true); int dirSelectedIndex = 0; int accSelectedIndex = 0; // set a default value of none // if either box is left at none then the SOE will know not to // expose the watershed operation ComboFlowDir.Items.Add("NONE"); ComboFlowAcc.Items.Add("NONE"); ESRI.ArcGIS.Carto.IRasterLayer rasterLayer = null; while ((rasterLayer = rasterEnumLayer.Next() as ESRI.ArcGIS.Carto.IRasterLayer) != null) { ESRI.ArcGIS.DataSourcesRaster.IRasterProps tRasterProps = rasterLayer.Raster as ESRI.ArcGIS.DataSourcesRaster.IRasterProps; ESRI.ArcGIS.Geodatabase.rstPixelType tPixelType = tRasterProps.PixelType; // flow dir can only be an integer raster of short or long types if (tPixelType == ESRI.ArcGIS.Geodatabase.rstPixelType.PT_UCHAR || tPixelType == ESRI.ArcGIS.Geodatabase.rstPixelType.PT_SHORT || tPixelType == ESRI.ArcGIS.Geodatabase.rstPixelType.PT_ULONG || tPixelType == ESRI.ArcGIS.Geodatabase.rstPixelType.PT_LONG) { ComboFlowDir.Items.Add(rasterLayer.Name); ComboFlowAcc.Items.Add(rasterLayer.Name); } // flow acc can theoretically be floating point as far as i can see // albeit it won't normally be else if (tPixelType == ESRI.ArcGIS.Geodatabase.rstPixelType.PT_FLOAT || tPixelType == ESRI.ArcGIS.Geodatabase.rstPixelType.PT_DOUBLE) { ComboFlowAcc.Items.Add(rasterLayer.Name); } if (rasterLayer.Name == m_FlowAccLayerName) { accSelectedIndex = ComboFlowAcc.Items.Count - 1; } else if (rasterLayer.Name == m_FlowDirLayerName) { dirSelectedIndex = ComboFlowDir.Items.Count - 1; } string tRasterType = "ContinuousRaster"; if (tRasterProps.IsInteger) { tRasterType = "CategoricalRaster"; } ExtractionLayerProperties tLayerInMap = new ExtractionLayerProperties(rasterLayer.Name, false, rasterLayer.Name.Substring(0, 6), tRasterType, "NONE", "NONE", "NONE", null, null, null); ExtractionLayerProperties tCurrentConfigForLayer; bool alreadyconfigured = m_ExtractionLayerProperties.TryGetValue(rasterLayer.Name, out tCurrentConfigForLayer); if (alreadyconfigured) { tLayerInMap.Enabled = tCurrentConfigForLayer.Enabled; tLayerInMap.ParamName = tCurrentConfigForLayer.ParamName; // that's all that needs doing for a raster raster } m_ExtractionLayerProperties[rasterLayer.Name] = tLayerInMap; tPreviouslyConfiguredLayers.Remove(rasterLayer.Name); } int extSelectedIndex = 0; ESRI.ArcGIS.esriSystem.UID featlyrId = new ESRI.ArcGIS.esriSystem.UIDClass(); featlyrId.Value = "{E156D7E5-22AF-11D3-9F99-00C04F6BC78E}"; ESRI.ArcGIS.Carto.IEnumLayer featureEnumLayer = map.get_Layers(featlyrId, true); ESRI.ArcGIS.Carto.IFeatureLayer featureLayer = null; while ((featureLayer = featureEnumLayer.Next() as ESRI.ArcGIS.Carto.IFeatureLayer) != null) { if (featureLayer.FeatureClass.ShapeType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon && featureLayer.FeatureClass.FeatureType == ESRI.ArcGIS.Geodatabase.esriFeatureType.esriFTSimple) { ComboExtentFeatures.Items.Add(featureLayer.Name); } if (featureLayer.Name == m_ExtentFeatureLayerName) { extSelectedIndex = ComboExtentFeatures.Items.Count - 1; } // now stuff for the extraction layer configuration List <string> catfields = new List <string>(); List <string> valfields = new List <string>(); List <string> measfields = new List <string>(); catfields.Add("NONE"); valfields.Add("NONE"); measfields.Add("NONE"); ESRI.ArcGIS.Geodatabase.IFields tFLFields = featureLayer.FeatureClass.Fields; for (int i = 0; i < tFLFields.FieldCount; i++) { ESRI.ArcGIS.Geodatabase.IField tField = featureLayer.FeatureClass.Fields.get_Field(i); ESRI.ArcGIS.Geodatabase.esriFieldType tFieldType = tField.Type; switch (tFieldType) { case ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeDouble: case ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeSingle: valfields.Add(tField.Name); measfields.Add(tField.Name); break; case ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeInteger: case ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeSmallInteger: valfields.Add(tField.Name); catfields.Add(tField.Name); measfields.Add(tField.Name); break; case ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeString: case ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeDate: catfields.Add(tField.Name); break; } } ExtractionLayerProperties tLayerInMap = new ExtractionLayerProperties(featureLayer.Name, false, featureLayer.Name.Substring(0, 6), "FeatureLayer", "NONE", "NONE", "NONE", catfields, valfields, measfields); ExtractionLayerProperties tCurrentConfigForLayer; bool alreadyconfigured = m_ExtractionLayerProperties.TryGetValue(featureLayer.Name, out tCurrentConfigForLayer); if (alreadyconfigured) { // it is already there - loaded from properties - we will make a new object anyway but will copy over the configured // parameter name, enabled, and selected fields. tLayerInMap.Enabled = tCurrentConfigForLayer.Enabled; tLayerInMap.ParamName = tCurrentConfigForLayer.ParamName; if (tCurrentConfigForLayer.CategoryFieldName != "NONE" && featureLayer.FeatureClass.FindField(tCurrentConfigForLayer.CategoryFieldName) != -1) { tLayerInMap.CategoryFieldName = tCurrentConfigForLayer.CategoryFieldName; } if (tCurrentConfigForLayer.ValueFieldName != "NONE" && featureLayer.FeatureClass.FindField(tCurrentConfigForLayer.ValueFieldName) != -1) { tLayerInMap.ValueFieldName = tCurrentConfigForLayer.ValueFieldName; } if (tCurrentConfigForLayer.MeasureFieldName != "NONE" && featureLayer.FeatureClass.FindField(tCurrentConfigForLayer.ValueFieldName) != -1) { tLayerInMap.MeasureFieldName = tCurrentConfigForLayer.MeasureFieldName; } } m_ExtractionLayerProperties[featureLayer.Name] = tLayerInMap; // now we need to delete from m_ExtractionLayerProperties any configs that haven't been found in the map tPreviouslyConfiguredLayers.Remove(featureLayer.Name); } foreach (string invalidLayerName in tPreviouslyConfiguredLayers) { m_ExtractionLayerProperties.Remove(invalidLayerName); } // now, m_extractionlayerproperties is a dictionary of extractionlayerproperties objects // where the objects contain the values from the previously saved lot if they were there foreach (ExtractionLayerProperties rowdetails in m_ExtractionLayerProperties.Values) { // string[] rowParams = new string[]{ // rowdetails.LayerName,rowdetails.Enabled.ToString(),rowdetails.ParamName,rowdetails.CategoryFieldName,rowdetails.ValueFieldName // }; dataGridView1.Rows.Add(); int newRowIdx = dataGridView1.Rows.Count - 1; DataGridViewRow tRow = dataGridView1.Rows[newRowIdx]; tRow.Cells["LayerName"].Value = rowdetails.LayerName; tRow.Cells["LayerAvail"].Value = rowdetails.Enabled.ToString(); tRow.Cells["LayerParam"].Value = rowdetails.ParamName; if (rowdetails.ExtractionType == "FeatureLayer") { DataGridViewComboBoxCell cfcell = (DataGridViewComboBoxCell)tRow.Cells["CatField"]; foreach (object itemToAdd in rowdetails.PossibleCategoryFields) { cfcell.Items.Add(itemToAdd); } cfcell.Value = rowdetails.CategoryFieldName; DataGridViewComboBoxCell valcell = (DataGridViewComboBoxCell)tRow.Cells["ValField"]; foreach (object itemToAdd in rowdetails.PossibleValueFields) { valcell.Items.Add(itemToAdd); } valcell.Value = rowdetails.ValueFieldName; DataGridViewComboBoxCell meascell = (DataGridViewComboBoxCell)tRow.Cells["MeasField"]; foreach (object itemToAdd in rowdetails.PossibleMeasureFields) { meascell.Items.Add(itemToAdd); } meascell.Value = rowdetails.MeasureFieldName; tRow.Cells["MeasField"].Value = rowdetails.MeasureFieldName; } else { tRow.Cells["CatField"].Value = rowdetails.CategoryFieldName; tRow.Cells["ValField"].Value = rowdetails.ValueFieldName; tRow.Cells["MeasField"].Value = rowdetails.MeasureFieldName; tRow.Cells["CatField"].ReadOnly = true; tRow.Cells["ValField"].ReadOnly = true; tRow.Cells["MeasField"].ReadOnly = true; } int rowIdx = dataGridView1.Rows.Add(tRow); } mapDocument.Close(); mapDocument = null; map = null; ComboFlowAcc.SelectedIndex = accSelectedIndex; ComboFlowDir.SelectedIndex = dirSelectedIndex; ComboExtentFeatures.SelectedIndex = extSelectedIndex; m_initAcc = true; m_initDir = true; m_initExt = true; m_GridIsInSyncWithProperties = true; radioReadMap.Checked = m_GetLayersFromMap; dataGridView1.Enabled = radioReadMap.Checked; }
//ÅжÏÓÒ¼ü²Ëµ¥ÏîÊÇ·ñ»ÒÉ«²»¿ÉÓà //public override bool Enabled //{ // get // { // //bool enabled = !(currentLayer is IRasterLayer); // return true; // } //} #endregion private void SetupFeaturePropertySheet(ILayer layer) { if (layer == null) { return; } ESRI.ArcGIS.Framework.IComPropertySheet pComPropSheet; pComPropSheet = new ESRI.ArcGIS.Framework.ComPropertySheet(); pComPropSheet.Title = layer.Name + " - properties"; 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); tocControl.Update(); //¸üÐÂĿ¼Ê÷ }