/// <summary> /// 根据路径获得工作空间 /// </summary> /// <param name="strPath"></param> /// <returns></returns> //public abstract IWorkspace GetWorkspace(string strPath); /// <summary> /// 添加图层到地图上 /// </summary> /// <param name="workspace"></param> /// <param name="map"></param> public void AddLayerToMap(IWorkspace workspace, ESRI.ArcGIS.Carto.IMap map) { //IEnumDataset enumDataset = workspace.get_Datasets(esriDatasetType.esriDTAny); //IFeatureWorkspace featureWorkspace = workspace as IFeatureWorkspace; //IFeatureClassContainer featureClassContainer2 = featureWorkspace as IFeatureClassContainer; //IFeatureClass fea = featureClassContainer2.get_Class(0); //enumDataset.Reset(); //IDataset dataset = enumDataset.Next(); //while (dataset != null) //{ // IFeatureDataset featureDataset = dataset as IFeatureDataset; // if (featureDataset != null) // { // IFeatureClassContainer featureClassContainer = (IFeatureClassContainer)featureDataset; // IEnumFeatureClass enumFeatureClass = (IEnumFeatureClass)featureClassContainer.Classes; // IFeatureClass featureClass = enumFeatureClass.Next(); // while (featureClass != null) // { // map.AddLayer((ESRI.ArcGIS.Carto.ILayer)featureClass);//加载到地图上 // featureClass = enumFeatureClass.Next(); // } // } // dataset = enumDataset.Next(); //} //ESRI.ArcGIS.Carto.IActiveView activeView = map as ESRI.ArcGIS.Carto.IActiveView; //activeView.Refresh(); }
public override void OnClick() { if (_AppHk == null) { return; } if (this.WriteLog) { Plugin.LogTable.Writelog(base._Caption);//xisheng 日志记录 } ESRI.ArcGIS.Carto.IMap pMap = _AppHk.MapControl.ActiveView.FocusMap; //IArea pArea = pGon as IArea; //double area = pArea.Area; //GetArea(ref area, pMap); //double dArea = SysCommon.ModSysSetting.GetExportAreaOfUser(Plugin.ModuleCommon.TmpWorkSpace, m_pAppForm.ConnUser); //if (dArea >= 0 && area > dArea) //{ // MessageBox.Show("超过提取最大面积", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); // return; //} ///ZQ 20111027 add 判断数据字典是否初始化 if (SysCommon.ModField._DicFieldName.Count == 0) { SysCommon.ModField.InitNameDic(Plugin.ModuleCommon.TmpWorkSpace, SysCommon.ModField._DicFieldName, "属性对照表"); } GeoDataExport.frmExport frm = null; frm = new GeoDataExport.frmExport(pMap, null); frm.WriteLog = WriteLog;//ygc 2012-9-12 是否写日志 frm.WriteLog = this.WriteLog; frm.ShowDialog(); }
public FrmOverView() { InitializeComponent(); m_OverMap = this.axMapControl.Map; m_GraphContainer = (ESRI.ArcGIS.Carto.IGraphicsContainer)m_OverMap; m_ActiveView = (ESRI.ArcGIS.Carto.IActiveView)m_OverMap; }
public void Add(ESRI.ArcGIS.Carto.IMap map) { if (map == null) { NBGIS.PluginEngine.Applog.log.Error("Maps::Add\r\n加入的map对象为NUll"); } else { m_ArrayList.Add(map); } }
private void SetupActiveViewEvents(ESRI.ArcGIS.Carto.IMap map) { //parameter check if (map == null) { return; } ESRI.ArcGIS.Carto.IActiveViewEvents_Event activeViewEvents = map as ESRI.ArcGIS.Carto.IActiveViewEvents_Event; // Create an instance of the delegate, add it to AfterDraw event m_ActiveViewEventsAfterDraw = new ESRI.ArcGIS.Carto.IActiveViewEvents_AfterDrawEventHandler(OnActiveViewEventsAfterDraw); activeViewEvents.AfterDraw += m_ActiveViewEventsAfterDraw; // Create an instance of the delegate, add it to AfterItemDraw event m_ActiveViewEventsAfterItemDraw = new ESRI.ArcGIS.Carto.IActiveViewEvents_AfterItemDrawEventHandler(OnActiveViewEventsItemDraw); activeViewEvents.AfterItemDraw += m_ActiveViewEventsAfterItemDraw; // Create an instance of the delegate, add it to ContentsChanged event m_ActiveViewEventsContentsChanged = new ESRI.ArcGIS.Carto.IActiveViewEvents_ContentsChangedEventHandler(OnActiveViewEventsContentsChanged); activeViewEvents.ContentsChanged += m_ActiveViewEventsContentsChanged; // Create an instance of the delegate, add it to ContentsCleared event m_ActiveViewEventsContentsCleared = new ESRI.ArcGIS.Carto.IActiveViewEvents_ContentsClearedEventHandler(OnActiveViewEventsContentsCleared); activeViewEvents.ContentsCleared += m_ActiveViewEventsContentsCleared; // Create an instance of the delegate, add it to FocusMapChanged event m_ActiveViewEventsFocusMapChanged = new ESRI.ArcGIS.Carto.IActiveViewEvents_FocusMapChangedEventHandler(OnActiveViewEventsFocusMapChanged); activeViewEvents.FocusMapChanged += m_ActiveViewEventsFocusMapChanged; // Create an instance of the delegate, add it to ItemAdded event m_ActiveViewEventsItemAdded = new ESRI.ArcGIS.Carto.IActiveViewEvents_ItemAddedEventHandler(OnActiveViewEventsItemAdded); activeViewEvents.ItemAdded += m_ActiveViewEventsItemAdded; // Create an instance of the delegate, add it to ItemDeleted event m_ActiveViewEventsItemDeleted = new ESRI.ArcGIS.Carto.IActiveViewEvents_ItemDeletedEventHandler(OnActiveViewEventsItemDeleted); activeViewEvents.ItemDeleted += m_ActiveViewEventsItemDeleted; // Create an instance of the delegate, add it to ItemReordered event m_ActiveViewEventsItemReordered = new ESRI.ArcGIS.Carto.IActiveViewEvents_ItemReorderedEventHandler(OnActiveViewEventsItemReordered); activeViewEvents.ItemReordered += m_ActiveViewEventsItemReordered; // Create an instance of the delegate, add it to SelectionChanged event m_ActiveViewEventsSelectionChanged = new ESRI.ArcGIS.Carto.IActiveViewEvents_SelectionChangedEventHandler(OnActiveViewEventsSelectionChanged); activeViewEvents.SelectionChanged += m_ActiveViewEventsSelectionChanged; // Create an instance of the delegate, add it to SpatialReferenceChanged event m_ActiveViewEventsSpatialReferenceChanged = new ESRI.ArcGIS.Carto.IActiveViewEvents_SpatialReferenceChangedEventHandler(OnActiveViewEventsSpatialReferenceChanged); activeViewEvents.SpatialReferenceChanged += m_ActiveViewEventsSpatialReferenceChanged; // Create an instance of the delegate, add it to ViewRefreshed event m_ActiveViewEventsViewRefreshed = new ESRI.ArcGIS.Carto.IActiveViewEvents_ViewRefreshedEventHandler(OnActiveViewEventsViewRefreshed); activeViewEvents.ViewRefreshed += m_ActiveViewEventsViewRefreshed; }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { if (m_hookHelper.Hook == null) { return; } IMapControl2 pMapCtl = m_hookHelper.Hook as IMapControl2; ESRI.ArcGIS.Carto.IMap pMap = m_hookHelper.FocusMap; frmExport frm = new frmExport(pMap, null); frm.ShowDialog(); }
protected override void OnPopup(ItemCollection items) { ESRI.ArcGIS.Carto.IMap map = ArcMap.Document.FocusMap; for (int i = 0; i < map.LayerCount; i++) { ESRI.ArcGIS.Carto.ILayer layer = map.get_Layer(i); Item item = new Item(); item.Caption = layer.Name; item.Enabled = layer.Visible; item.Message = layer.Name; item.Tag = layer; items.Add(item); } }
public frmCalcGridMetricsFusion(ESRI.ArcGIS.Carto.IMap mp, rasterUtil rasterUtility = null) { InitializeComponent(); if (rasterUtility == null) { rsUtil = new rasterUtil(); } else { rsUtil = rasterUtility; } fsInt = new fusionIntegration(rsUtil); frmHlp = new frmHelper(mp, rsUtil); }
private ESRI.ArcGIS.Carto.ILayer GetBackgroundLayer(ESRI.ArcGIS.Carto.IMap map) { ESRI.ArcGIS.Carto.ILayer pLayer = map.get_Layer(0); ESRI.ArcGIS.Carto.ILayer pTempLayer = null; for (int i = 1; i < map.LayerCount; i++) { pTempLayer = map.get_Layer(i); if (pLayer.AreaOfInterest.Width < pTempLayer.AreaOfInterest.Width) { pLayer = pTempLayer; } } return(pLayer); }
public MapInfo(ESRI.ArcGIS.Carto.IMap map) { this.m_Map = map; this.m_Description = map.Description; this.m_Name = map.Name; this.m_Expanded = map.Expanded; this.m_IsFramed = map.IsFramed; this.m_LayerCount = map.LayerCount; this.m_MapsurroundCount = map.MapSurroundCount; this.m_MapUnits = map.MapUnits; this.m_ReferenceScale = map.ReferenceScale; this.m_DistanceUnits = map.DistanceUnits; this.m_SelectionCount = map.SelectionCount; this.m_UseSymbolLevels = map.UseSymbolLevels; }
///<summary>Draw a specified graphic on the map using the supplied colors.</summary> /// ///<param name="map">An IMap interface.</param> ///<param name="geometry">An IGeometry interface. It can be of the geometry type: esriGeometryPoint, esriGeometryPolyline, or esriGeometryPolygon.</param> ///<param name="rgbColor">An IRgbColor interface. The color to draw the geometry.</param> ///<param name="outlineRgbColor">An IRgbColor interface. For those geometry's with an outline it will be this color.</param> /// ///<remarks>Calling this function will not automatically make the graphics appear in the map area. Refresh the map area after after calling this function with Methods like IActiveView.Refresh or IActiveView.PartialRefresh.</remarks> public void AddGraphicToMap(ESRI.ArcGIS.Carto.IMap map, ESRI.ArcGIS.Geometry.IGeometry geometry, ESRI.ArcGIS.Display.IRgbColor rgbColor, ESRI.ArcGIS.Display.IRgbColor outlineRgbColor) { ESRI.ArcGIS.Carto.IGraphicsContainer graphicsContainer = (ESRI.ArcGIS.Carto.IGraphicsContainer)map; // Explicit Cast ESRI.ArcGIS.Carto.IElement element = null; if ((geometry.GeometryType) == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint) { // Marker symbols ESRI.ArcGIS.Display.ISimpleMarkerSymbol simpleMarkerSymbol = new ESRI.ArcGIS.Display.SimpleMarkerSymbol(); simpleMarkerSymbol.Color = rgbColor; simpleMarkerSymbol.Outline = true; simpleMarkerSymbol.OutlineColor = outlineRgbColor; simpleMarkerSymbol.Size = 15; simpleMarkerSymbol.Style = ESRI.ArcGIS.Display.esriSimpleMarkerStyle.esriSMSCircle; ESRI.ArcGIS.Carto.IMarkerElement markerElement = new ESRI.ArcGIS.Carto.MarkerElement() as ESRI.ArcGIS.Carto.IMarkerElement; markerElement.Symbol = simpleMarkerSymbol; element = (ESRI.ArcGIS.Carto.IElement)markerElement; // Explicit Cast } else if ((geometry.GeometryType) == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline) { // Line elements ESRI.ArcGIS.Display.ISimpleLineSymbol simpleLineSymbol = new ESRI.ArcGIS.Display.SimpleLineSymbol(); simpleLineSymbol.Color = rgbColor; simpleLineSymbol.Style = ESRI.ArcGIS.Display.esriSimpleLineStyle.esriSLSSolid; simpleLineSymbol.Width = 5; ESRI.ArcGIS.Carto.ILineElement lineElement = new ESRI.ArcGIS.Carto.LineElement() as ESRI.ArcGIS.Carto.ILineElement; lineElement.Symbol = simpleLineSymbol; element = (ESRI.ArcGIS.Carto.IElement)lineElement; // Explicit Cast } else if ((geometry.GeometryType) == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon) { // Polygon elements ESRI.ArcGIS.Display.ISimpleFillSymbol simpleFillSymbol = new ESRI.ArcGIS.Display.SimpleFillSymbol(); simpleFillSymbol.Color = rgbColor; simpleFillSymbol.Style = ESRI.ArcGIS.Display.esriSimpleFillStyle.esriSFSForwardDiagonal; ESRI.ArcGIS.Carto.IFillShapeElement fillShapeElement = new ESRI.ArcGIS.Carto.PolygonElement() as ESRI.ArcGIS.Carto.IFillShapeElement; fillShapeElement.Symbol = simpleFillSymbol; element = (ESRI.ArcGIS.Carto.IElement)fillShapeElement; // Explicit Cast } if (!(element == null)) { element.Geometry = geometry; graphicsContainer.AddElement(element, 0); } }
/// <summary> /// Occurs when this tool is clicked /// </summary> public override void OnClick() { if (m_hookHelper.Hook == null) { return; } IMapControl2 pMapCtl = m_hookHelper.Hook as IMapControl2; ESRI.ArcGIS.Geometry.IGeometry pGeometry = pMapCtl.Extent; if (pGeometry == null) { return; } ESRI.ArcGIS.Carto.IMap pMap = m_hookHelper.FocusMap; frmExport frm = new frmExport(pMap, pGeometry); frm.ShowDialog(); }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { if (m_hookHelper.Hook == null) { return; } IMapControl2 pMapCtl = m_hookHelper.Hook as IMapControl2; ESRI.ArcGIS.Geometry.IGeometry pGeometry = pMapCtl.TrackRectangle(); if (pGeometry == null) { return; } ESRI.ArcGIS.Carto.IMap pMap = m_hookHelper.FocusMap; frmExport frm = new frmExport(pMap, pGeometry); frm.ShowDialog(); }
private void RemoveActiveViewEvents(ESRI.ArcGIS.Carto.IMap map) { //parameter check if (map == null) { return; } ESRI.ArcGIS.Carto.IActiveViewEvents_Event activeViewEvents = map as ESRI.ArcGIS.Carto.IActiveViewEvents_Event; // Remove AfterDraw Event Handler activeViewEvents.AfterDraw -= m_ActiveViewEventsAfterDraw; // Remove AfterItemDraw Event Handler activeViewEvents.AfterItemDraw -= m_ActiveViewEventsAfterItemDraw; // Remove ContentsChanged Event Handler activeViewEvents.ContentsChanged -= m_ActiveViewEventsContentsChanged; // Remove ContentsCleared Event Handler activeViewEvents.ContentsCleared -= m_ActiveViewEventsContentsCleared; // Remove FocusMapChanged Event Handler activeViewEvents.FocusMapChanged -= m_ActiveViewEventsFocusMapChanged; // Remove ItemAdded Event Handler activeViewEvents.ItemAdded -= m_ActiveViewEventsItemAdded; // Remove ItemDeleted Event Handler activeViewEvents.ItemDeleted -= m_ActiveViewEventsItemDeleted; // Remove ItemReordered Event Handler activeViewEvents.ItemReordered -= m_ActiveViewEventsItemReordered; // Remove SelectionChanged Event Handler activeViewEvents.SelectionChanged -= m_ActiveViewEventsSelectionChanged; // Remove SpatialReferenceChanged Event Handler activeViewEvents.SpatialReferenceChanged -= m_ActiveViewEventsSpatialReferenceChanged; // Remove ViewRefreshed Event Handler activeViewEvents.ViewRefreshed -= m_ActiveViewEventsViewRefreshed; }
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); }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { if (m_hookHelper != null) { //TODO: Add Map/PageLayout related logic } else if (m_sceneHookHelper != null) { //TODO: Add Scene related logic } else if (m_globeHookHelper != null) { //TODO: Add Globe related logic } IGeometry pGeometry = null; ESRI.ArcGIS.Carto.IMap pMap = m_hookHelper.FocusMap; frmExport frm = new frmExport(pMap, pGeometry); frm.ShowDialog(); }
/// <summary> /// 重置mxd文档的数据源 /// </summary> /// <param name="pMapDoc"></param> /// <param name="pWs"></param> public static void ChangeMxdDataSource(ESRI.ArcGIS.Carto.IMapDocument pMapDoc, ESRI.ArcGIS.Geodatabase.IWorkspace pWs) { ESRI.ArcGIS.Geodatabase.IWorkspaceName pWsName = GetWorkspaceName(pWs); ESRI.ArcGIS.Carto.IMap pMap = pMapDoc.ActiveView.FocusMap; ESRI.ArcGIS.Carto.ILayer pLayer = null; ESRI.ArcGIS.Carto.IDataLayer pDataLayer = null; ESRI.ArcGIS.Geodatabase.IDatasetName pDataName = null; for (int i = 0; i < pMap.LayerCount; i++) { pLayer = pMap.get_Layer(i); if (pLayer.Valid == false) { if (pLayer is ESRI.ArcGIS.Carto.IDataLayer) { pDataLayer = pLayer as ESRI.ArcGIS.Carto.IDataLayer; try { pDataName = pDataLayer.DataSourceName as ESRI.ArcGIS.Geodatabase.IDatasetName; //获取DatasetName,必须是要替换的工作空间下的 ESRI.ArcGIS.Geodatabase.IDatasetName pDsName = GetDatasetName(pWs, pDataName.Name); if (pDsName == null) { continue; } pDataName = pDataLayer.DataSourceName as ESRI.ArcGIS.Geodatabase.IDatasetName; pDataName.WorkspaceName = pWsName; pDataLayer.Connect(pDsName as ESRI.ArcGIS.esriSystem.IName); System.Runtime.InteropServices.Marshal.ReleaseComObject(pDataName); System.Runtime.InteropServices.Marshal.ReleaseComObject(pDsName); //pDataName = pDataLayer.DataSourceName as ESRI.ArcGIS.Geodatabase.IDatasetName; } catch { } System.Runtime.InteropServices.Marshal.ReleaseComObject(pDataLayer); } } } System.Runtime.InteropServices.Marshal.ReleaseComObject(pWsName); System.Runtime.InteropServices.Marshal.ReleaseComObject(pMap); pMapDoc.Save(true, true); }
public void ReplaceMap(ESRI.ArcGIS.Carto.IMap newMap) { if (newMap == null) { throw new Exception("ControlsSynchronizer::ReplaceMap:/r/n New Map is not initialized"); } if (m_mapControl == null || m_pageLayoutControl == null) { throw new Exception("ControlsSynchronzier::ReplaceMap:\r\n MapControl or PageLayoutControl is not initialized"); } ESRI.ArcGIS.Carto.IMaps maps = new Maps(); maps.Add(newMap); bool IsMapActive = m_IsMapControlActive; this.ActivatePageLayout(); m_pageLayoutControl.PageLayout.ReplaceMaps(maps); m_mapControl.Map = newMap; m_mapActiveTool = null; m_pageLayoutActiveTool = null; if (IsMapActive) { this.ActivateMapControl(); m_mapControl.ActiveView.Refresh(); } else { this.ActivatePageLayout(); m_pageLayoutControl.ActiveView.Refresh(); } }
/// <summary> /// Get the index number for the specified layer name /// </summary> /// <param name="activeView">An IActiveView interface</param> /// <param name="layerName">A System.String that is the layer name in the active view. Example: "states"</param> /// <returns> /// A System.Int32 representing a layer number. /// Return values of 0 and greater are valid layers. A return value of -1 means the layer name was not found. /// </returns> public static Int32 GetIndexNumberFromLayerName(ESRI.ArcGIS.Carto.IActiveView activeView, System.String layerName) { if (activeView == null || layerName == null) { return(-1); } ESRI.ArcGIS.Carto.IMap map = activeView.FocusMap; // Get the number of layers int numberOfLayers = map.LayerCount; // Loop through the layers and get the correct layer index for (System.Int32 i = 0; i < numberOfLayers; i++) { if (layerName == map.get_Layer(i).Name) { // Layer was found return(i); } } // No layer was found return(-1); }
public static MapValidator Map(ESRI.ArcGIS.Carto.IMap map) { return(new MapValidator(map)); }
public void Remove(ESRI.ArcGIS.Carto.IMap map) { m_ArrayList.Remove(map); }
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; }