private void AddQALayerToActiveView(IMap map, IFeatureClass SourceLineFeatureClass, IFeatureClass SourcePolygonFeatureClass, string layerPathFile, double metersPerUnit, bool bIsBefore1022, bool bFabricIsInGCS) { if (map == null || layerPathFile == null || !layerPathFile.EndsWith(".lyr")) { return; } // Create a new GxLayer IGxLayer gxLayer = new GxLayerClass(); IGxFile gxFile = (IGxFile)gxLayer; // Set the path for where the layerfile is located on disk gxFile.Path = layerPathFile; // Test if we have a valid layer and add it to the map if (!(gxLayer.Layer == null)) { if (!(gxLayer.Layer is ICompositeLayer)) return; ICompositeLayer pCompLyr = (ICompositeLayer)gxLayer.Layer; for (int i=0; i<pCompLyr.Count; i++) { ILayer pLyr = pCompLyr.get_Layer(i); // if (pLyr is IFeatureLayer) { IFeatureLayer pFlyr = (IFeatureLayer)pLyr; //now update the definition query IFeatureLayerDefinition pFeatLyrDef = (IFeatureLayerDefinition)pFlyr; string sLyrName = pFlyr.Name; bool bExc = false; if (sLyrName.Contains("Minus")) { pFlyr.FeatureClass = SourceLineFeatureClass; bExc = false; //ILayerFields pLayerFields = pFlyr as ILayerFields; //First turn off all layers //for (int kk = 0; kk < pLayerFields.FieldCount; kk++) //{ // IFieldInfo pFieldInfo = pLayerFields.get_FieldInfo(kk); // pFieldInfo.Visible = false; //} SetLabelExpressionOnFeatureLayer(pFlyr, out bExc); if (bExc || bFabricIsInGCS) { int jj=pFlyr.FeatureClass.FindField("ComputedMinusObserved"); if (jj>-1) { string sVal = (0.1 / metersPerUnit).ToString("0.00"); string sCminusO=pFlyr.FeatureClass.Fields.get_Field(jj).Name; pFeatLyrDef.DefinitionExpression = sCminusO + " > "+sVal+" AND " + sCminusO + " < "+sVal; //IFieldInfo pFieldInfo = pLayerFields.get_Field(jj) as IFieldInfo; //pFieldInfo.Visible = true; } continue; } string s = pFeatLyrDef.DefinitionExpression; int iField = SourceLineFeatureClass.FindField("ArcLength"); if (iField > -1) { //IFieldInfo pFieldInfo = pLayerFields.get_Field(iField) as IFieldInfo; //pFieldInfo.Visible = true; string s2 = SourceLineFeatureClass.Fields.get_Field(iField).Name; pFeatLyrDef.DefinitionExpression = s.Replace("\"ArcLength\"", s2); pFeatLyrDef.DefinitionExpression = pFeatLyrDef.DefinitionExpression.Replace("ArcLength", s2); } s = pFeatLyrDef.DefinitionExpression; iField = SourceLineFeatureClass.FindField("Distance"); if (iField > -1) { //IFieldInfo pFieldInfo = pLayerFields.get_Field(iField) as IFieldInfo; //pFieldInfo.Visible = true; string s2 = SourceLineFeatureClass.Fields.get_Field(iField).Name; pFeatLyrDef.DefinitionExpression = s.Replace("\"Distance\"", s2); pFeatLyrDef.DefinitionExpression = pFeatLyrDef.DefinitionExpression.Replace("Distance", s2); } s = pFeatLyrDef.DefinitionExpression; iField = SourceLineFeatureClass.FindField("DensifyType"); if (iField > -1) { string s2 = SourceLineFeatureClass.Fields.get_Field(iField).Name; pFeatLyrDef.DefinitionExpression = s.Replace("\"DensifyType\"", s2); pFeatLyrDef.DefinitionExpression = pFeatLyrDef.DefinitionExpression.Replace("DensifyType", s2); } s = pFeatLyrDef.DefinitionExpression; pFeatLyrDef.DefinitionExpression = s.Replace("\"Shape_Length\"", SourceLineFeatureClass.LengthField.Name); pFeatLyrDef.DefinitionExpression = pFeatLyrDef.DefinitionExpression.Replace("Shape_Length", SourceLineFeatureClass.LengthField.Name); } else if (sLyrName.Contains("Parcel")) { //In 10.1 start editing crashes if the definition query in these layers that use POWER function is present. //Can test if the release is 10.1 and knock out the def query, or else exclude the layers. string s = pFeatLyrDef.DefinitionExpression; int iField=SourcePolygonFeatureClass.FindField("MiscloseDistance"); string s2 = SourcePolygonFeatureClass.Fields.get_Field(iField).Name; pFeatLyrDef.DefinitionExpression = s.Replace("\"MiscloseDistance\"", s2); pFeatLyrDef.DefinitionExpression = pFeatLyrDef.DefinitionExpression.Replace("MiscloseDistance", s2); s = pFeatLyrDef.DefinitionExpression; iField = SourcePolygonFeatureClass.FindField("ShapeStdErrorE"); s2 = SourcePolygonFeatureClass.Fields.get_Field(iField).Name; pFeatLyrDef.DefinitionExpression = s.Replace("\"ShapeStdErrorE\"", s2); pFeatLyrDef.DefinitionExpression = pFeatLyrDef.DefinitionExpression.Replace("ShapeStdErrorE", s2); s = pFeatLyrDef.DefinitionExpression; iField = SourcePolygonFeatureClass.FindField("ShapeStdErrorN"); s2 = SourcePolygonFeatureClass.Fields.get_Field(iField).Name; pFeatLyrDef.DefinitionExpression = s.Replace("\"ShapeStdErrorN\"", s2); pFeatLyrDef.DefinitionExpression = pFeatLyrDef.DefinitionExpression.Replace("ShapeStdErrorN", s2); pFlyr.FeatureClass = SourcePolygonFeatureClass; SetLabelExpressionOnFeatureLayer(pFlyr, out bExc); if (s.ToLower().Contains("power") && bIsBefore1022) {//remove the def query CR278039 pFeatLyrDef.DefinitionExpression = ""; continue; } } } } gxLayer.Layer.Name = "QA Symbology"; IMxDocument pMXDoc = ArcMap.Document; IOperationStack pOpSt = pMXDoc.OperationStack; IAddLayersOperation pAddLyrOp = new AddLayersOperationClass(); pAddLyrOp.SetDestinationInfo(0,map,null); pAddLyrOp.Name = "Add Fabric QA Layer"; pAddLyrOp.AddLayer(gxLayer.Layer); IOperation pOp=(IOperation)pAddLyrOp; pOpSt.Do(pOp); } }
private void AddQALayerToActiveView(IMap map, IFeatureClass SourceLineFeatureClass, IFeatureClass SourcePolygonFeatureClass, string layerPathFile, double metersPerUnit, bool bIsBefore1022, bool bFabricIsInGCS) { if (map == null || layerPathFile == null || !layerPathFile.EndsWith(".lyr")) { return; } // Create a new GxLayer IGxLayer gxLayer = new GxLayerClass(); IGxFile gxFile = (IGxFile)gxLayer; // Set the path for where the layerfile is located on disk gxFile.Path = layerPathFile; // Test if we have a valid layer and add it to the map if (!(gxLayer.Layer == null)) { if (!(gxLayer.Layer is ICompositeLayer)) { return; } ICompositeLayer pCompLyr = (ICompositeLayer)gxLayer.Layer; for (int i = 0; i < pCompLyr.Count; i++) { ILayer pLyr = pCompLyr.get_Layer(i); // if (pLyr is IFeatureLayer) { IFeatureLayer pFlyr = (IFeatureLayer)pLyr; //now update the definition query IFeatureLayerDefinition pFeatLyrDef = (IFeatureLayerDefinition)pFlyr; string sLyrName = pFlyr.Name; bool bExc = false; if (sLyrName.Contains("Minus")) { pFlyr.FeatureClass = SourceLineFeatureClass; bExc = false; //ILayerFields pLayerFields = pFlyr as ILayerFields; //First turn off all layers //for (int kk = 0; kk < pLayerFields.FieldCount; kk++) //{ // IFieldInfo pFieldInfo = pLayerFields.get_FieldInfo(kk); // pFieldInfo.Visible = false; //} SetLabelExpressionOnFeatureLayer(pFlyr, out bExc); if (bExc || bFabricIsInGCS) { int jj = pFlyr.FeatureClass.FindField("ComputedMinusObserved"); if (jj > -1) { string sVal = (0.1 / metersPerUnit).ToString("0.00"); string sCminusO = pFlyr.FeatureClass.Fields.get_Field(jj).Name; pFeatLyrDef.DefinitionExpression = sCminusO + " > " + sVal + " AND " + sCminusO + " < " + sVal; //IFieldInfo pFieldInfo = pLayerFields.get_Field(jj) as IFieldInfo; //pFieldInfo.Visible = true; } continue; } string s = pFeatLyrDef.DefinitionExpression; int iField = SourceLineFeatureClass.FindField("ArcLength"); if (iField > -1) { //IFieldInfo pFieldInfo = pLayerFields.get_Field(iField) as IFieldInfo; //pFieldInfo.Visible = true; string s2 = SourceLineFeatureClass.Fields.get_Field(iField).Name; pFeatLyrDef.DefinitionExpression = s.Replace("\"ArcLength\"", s2); pFeatLyrDef.DefinitionExpression = s.Replace("ArcLength", s2); } s = pFeatLyrDef.DefinitionExpression; iField = SourceLineFeatureClass.FindField("Distance"); if (iField > -1) { //IFieldInfo pFieldInfo = pLayerFields.get_Field(iField) as IFieldInfo; //pFieldInfo.Visible = true; string s2 = SourceLineFeatureClass.Fields.get_Field(iField).Name; pFeatLyrDef.DefinitionExpression = s.Replace("\"Distance\"", s2); pFeatLyrDef.DefinitionExpression = s.Replace("Distance", s2); } s = pFeatLyrDef.DefinitionExpression; pFeatLyrDef.DefinitionExpression = s.Replace("Shape_Length", SourceLineFeatureClass.LengthField.Name); } else if (sLyrName.Contains("Parcel")) { //In 10.1 start editing crashes if the definition query in these layers that use POWER function is present. //Can test if the release is 10.1 and knock out the def query, or else exclude the layers. string s = pFeatLyrDef.DefinitionExpression; int iField = SourcePolygonFeatureClass.FindField("MiscloseDistance"); string s2 = SourcePolygonFeatureClass.Fields.get_Field(iField).Name; pFeatLyrDef.DefinitionExpression = s.Replace("\"MiscloseDistance\"", s2); pFeatLyrDef.DefinitionExpression = s.Replace("MiscloseDistance", s2); s = pFeatLyrDef.DefinitionExpression; iField = SourcePolygonFeatureClass.FindField("ShapeStdErrorE"); s2 = SourcePolygonFeatureClass.Fields.get_Field(iField).Name; pFeatLyrDef.DefinitionExpression = s.Replace("\"ShapeStdErrorE\"", s2); pFeatLyrDef.DefinitionExpression = s.Replace("ShapeStdErrorE", s2); s = pFeatLyrDef.DefinitionExpression; iField = SourcePolygonFeatureClass.FindField("ShapeStdErrorN"); s2 = SourcePolygonFeatureClass.Fields.get_Field(iField).Name; pFeatLyrDef.DefinitionExpression = s.Replace("\"ShapeStdErrorN\"", s2); pFeatLyrDef.DefinitionExpression = s.Replace("ShapeStdErrorN", s2); pFlyr.FeatureClass = SourcePolygonFeatureClass; SetLabelExpressionOnFeatureLayer(pFlyr, out bExc); if (s.ToLower().Contains("power") && bIsBefore1022) {//remove the def query CR278039 pFeatLyrDef.DefinitionExpression = ""; continue; } } } } gxLayer.Layer.Name = "QA Symbology"; IMxDocument pMXDoc = ArcMap.Document; IOperationStack pOpSt = pMXDoc.OperationStack; IAddLayersOperation pAddLyrOp = new AddLayersOperationClass(); pAddLyrOp.SetDestinationInfo(0, map, null); pAddLyrOp.Name = "Add Fabric QA Layer"; pAddLyrOp.AddLayer(gxLayer.Layer); IOperation pOp = (IOperation)pAddLyrOp; pOpSt.Do(pOp); } }
private void AddQALayerToActiveView(IMap map, IFeatureClass SourceLineFeatureClass, IFeatureClass SourcePolygonFeatureClass, string layerPathFile, double metersPerUnit, bool bIsBefore1022, bool bFabricIsInGCS) { if (map == null || layerPathFile == null || !layerPathFile.EndsWith(".lyr")) { return; } IWorkspace pWS = SourceLineFeatureClass.FeatureDataset.Workspace; bool bIsPostGres = false; if (pWS.Type != esriWorkspaceType.esriLocalDatabaseWorkspace) { IDatabaseConnectionInfo2 connectionInfo2 = (IDatabaseConnectionInfo2)(pWS); bIsPostGres = (connectionInfo2.ConnectionDBMS == esriConnectionDBMS.esriDBMS_PostgreSQL); } // Create a new GxLayer IGxLayer gxLayer = new GxLayerClass(); IGxFile gxFile = (IGxFile)gxLayer; // Set the path for where the layerfile is located on disk gxFile.Path = layerPathFile; // Test if we have a valid layer and add it to the map if (!(gxLayer.Layer == null)) { if (!(gxLayer.Layer is ICompositeLayer)) { return; } ICompositeLayer pCompLyr = (ICompositeLayer)gxLayer.Layer; for (int i = 0; i < pCompLyr.Count; i++) { ILayer pLyr = pCompLyr.get_Layer(i); // if (pLyr is IFeatureLayer) { IFeatureLayer pFlyr = (IFeatureLayer)pLyr; //now update the definition query IFeatureLayerDefinition pFeatLyrDef = (IFeatureLayerDefinition)pFlyr; string sLyrName = pFlyr.Name; bool bExc = false; if (sLyrName.Contains("Minus")) { pFlyr.FeatureClass = SourceLineFeatureClass; bExc = false; SetLabelExpressionOnFeatureLayer(pFlyr, out bExc); if (bExc || bFabricIsInGCS) { int jj = pFlyr.FeatureClass.FindField("ComputedMinusObserved"); if (jj > -1) { string sVal = (0.1 / metersPerUnit).ToString("0.00"); string sCminusO = pFlyr.FeatureClass.Fields.get_Field(jj).Name; pFeatLyrDef.DefinitionExpression = "(" + sCminusO + " > " + sVal + " OR " + sCminusO + " < -" + sVal + ") AND (" + sCminusO + " IS NOT NULL)"; if (bIsPostGres) { pFeatLyrDef.DefinitionExpression = "(((st_length(shape) - distance) > " + sVal + " OR (st_length(shape) - distance) < -" + sVal + " OR (distance - st_length(shape)) > " + sVal + " OR (distance - st_length(shape)) < -" + sVal + ") AND (radius IS NULL AND (densifytype IS NULL OR densifytype <> 3)) AND category <> 4) OR ( ( ((st_length(shape) - arclength) > " + sVal + " OR (st_length(shape) - arclength) < -" + sVal + ") OR (arclength - st_length(shape)) > " + sVal + " OR (arclength - st_length(shape)) < -" + sVal + ") AND ( NOT arclength IS NULL ) )"; //this is query for ST_Geometry as well as PG_Geometry } } continue; } string s = pFeatLyrDef.DefinitionExpression; int iField = SourceLineFeatureClass.FindField("ArcLength"); if (iField > -1) { string s2 = SourceLineFeatureClass.Fields.get_Field(iField).Name; pFeatLyrDef.DefinitionExpression = s.Replace("\"ArcLength\"", s2); pFeatLyrDef.DefinitionExpression = pFeatLyrDef.DefinitionExpression.Replace("ArcLength", s2); } s = pFeatLyrDef.DefinitionExpression; iField = SourceLineFeatureClass.FindField("Category"); if (iField > -1) { string s2 = SourceLineFeatureClass.Fields.get_Field(iField).Name; pFeatLyrDef.DefinitionExpression = s.Replace("\"Category\"", s2); pFeatLyrDef.DefinitionExpression = pFeatLyrDef.DefinitionExpression.Replace("Category", s2); } s = pFeatLyrDef.DefinitionExpression; iField = SourceLineFeatureClass.FindField("Radius"); if (iField > -1) { string s2 = SourceLineFeatureClass.Fields.get_Field(iField).Name; pFeatLyrDef.DefinitionExpression = s.Replace("\"Radius\"", s2); pFeatLyrDef.DefinitionExpression = pFeatLyrDef.DefinitionExpression.Replace("Radius", s2); } s = pFeatLyrDef.DefinitionExpression; iField = SourceLineFeatureClass.FindField("Distance"); if (iField > -1) { string s2 = SourceLineFeatureClass.Fields.get_Field(iField).Name; pFeatLyrDef.DefinitionExpression = s.Replace("\"Distance\"", s2); pFeatLyrDef.DefinitionExpression = pFeatLyrDef.DefinitionExpression.Replace("Distance", s2); } s = pFeatLyrDef.DefinitionExpression; iField = SourceLineFeatureClass.FindField("DensifyType"); if (iField > -1) { string s2 = SourceLineFeatureClass.Fields.get_Field(iField).Name; pFeatLyrDef.DefinitionExpression = s.Replace("\"DensifyType\"", s2); pFeatLyrDef.DefinitionExpression = pFeatLyrDef.DefinitionExpression.Replace("DensifyType", s2); } s = pFeatLyrDef.DefinitionExpression; pFeatLyrDef.DefinitionExpression = s.Replace("\"Shape_Length\"", SourceLineFeatureClass.LengthField.Name); pFeatLyrDef.DefinitionExpression = pFeatLyrDef.DefinitionExpression.Replace("Shape_Length", SourceLineFeatureClass.LengthField.Name); } else if (sLyrName.Contains("Parcel")) { //In 10.1 start editing crashes if the definition query in these layers that use POWER function is present. //Can test if the release is 10.1 and knock out the def query, or else exclude the layers. string s = pFeatLyrDef.DefinitionExpression; int iField = SourcePolygonFeatureClass.FindField("MiscloseDistance"); string s2 = SourcePolygonFeatureClass.Fields.get_Field(iField).Name; pFeatLyrDef.DefinitionExpression = s.Replace("\"MiscloseDistance\"", s2); pFeatLyrDef.DefinitionExpression = pFeatLyrDef.DefinitionExpression.Replace("MiscloseDistance", s2); s = pFeatLyrDef.DefinitionExpression; iField = SourcePolygonFeatureClass.FindField("ShapeStdErrorE"); s2 = SourcePolygonFeatureClass.Fields.get_Field(iField).Name; pFeatLyrDef.DefinitionExpression = s.Replace("\"ShapeStdErrorE\"", s2); pFeatLyrDef.DefinitionExpression = pFeatLyrDef.DefinitionExpression.Replace("ShapeStdErrorE", s2); s = pFeatLyrDef.DefinitionExpression; iField = SourcePolygonFeatureClass.FindField("ShapeStdErrorN"); s2 = SourcePolygonFeatureClass.Fields.get_Field(iField).Name; pFeatLyrDef.DefinitionExpression = s.Replace("\"ShapeStdErrorN\"", s2); pFeatLyrDef.DefinitionExpression = pFeatLyrDef.DefinitionExpression.Replace("ShapeStdErrorN", s2); pFlyr.FeatureClass = SourcePolygonFeatureClass; SetLabelExpressionOnFeatureLayer(pFlyr, out bExc); if (s.ToLower().Contains("power") && bIsBefore1022) {//remove the def query CR278039 pFeatLyrDef.DefinitionExpression = ""; continue; } } } } gxLayer.Layer.Name = "QA Symbology"; IMxDocument pMXDoc = ArcMap.Document; IOperationStack pOpSt = pMXDoc.OperationStack; IAddLayersOperation pAddLyrOp = new AddLayersOperationClass(); pAddLyrOp.SetDestinationInfo(0, map, null); pAddLyrOp.Name = "Add Fabric QA Layer"; pAddLyrOp.AddLayer(gxLayer.Layer); IOperation pOp = (IOperation)pAddLyrOp; pOpSt.Do(pOp); } }
private void CreateErrorLayer(string masterName, string secondName) { ISDUTExtension theExt = this.Extension; QAManager theQAMan = theExt.QAManager; IMap theMap = theExt.FocusMap; // Make a note of the FeatureClass which holds the errors this._errorFC = theQAMan.ErrorFeatureClass; // Get the template layer file string filename = theExt.get_SystemValue("qa.dataerrors.layerfile"); System.IO.FileInfo finfoLocation = new System.IO.FileInfo(this.GetType().Assembly.Location.ToString()); System.IO.FileInfo finfoLayer = new System.IO.FileInfo(finfoLocation.DirectoryName + System.IO.Path.DirectorySeparatorChar + filename); string theLayerFileName; // does it exist? if not, we're probably running this in the IDE so we should // look for it in the source tree if (finfoLayer.Exists) { theLayerFileName = finfoLayer.FullName; } else // first attempt failed so check the grandparent (source) folder { System.IO.FileInfo finfoLayer2 = new System.IO.FileInfo(finfoLocation.Directory.Parent.Parent.FullName + System.IO.Path.DirectorySeparatorChar + filename); if (finfoLayer2.Exists) { theLayerFileName = finfoLayer2.FullName; } else { throw new System.IO.FileNotFoundException("Could not locate the SUITT error layer file", finfoLayer.FullName); } } // Open the layer and give it its featureclass IGxLayer gxLayer = new GxLayerClass(); IGxFile gxFile = (IGxFile)gxLayer; gxFile.Path = theLayerFileName; IFeatureLayer theLayer = (IFeatureLayer)gxLayer.Layer; DateTime dtm = DateTime.Now; string createTime = "_" + dtm.Year.ToString() + dtm.Month.ToString() + dtm.Day.ToString() + dtm.Hour.ToString() + dtm.Minute.ToString() + dtm.Second.ToString(); theLayer.Name = ERROR_LAYER_NAME + createTime; theLayer.FeatureClass = this._errorFC; //theMap.AddLayer((ILayer)theLayer); IAdjustLayers adjustLayers = _App.FindExtensionByName("ESRI Adjustment Tools") as IAdjustLayers; adjustLayers.AdjustSelectedFeatures = false; UID pUID = new UIDClass(); pUID.Value = "{E156D7E5-22AF-11D3-9F99-00C04F6BC78E}"; IEnumLayer pEnumLayer = theMap.get_Layers(pUID, true); ILayer lyr = pEnumLayer.Next(); EnumLayer2 enumLayers = new EnumLayer2(); while (lyr != null) { /* while (lyr.Name.StartsWith(ERROR_LAYER_NAME)) { lyr = pEnumLayer.Next(); }*/ string _lyrName = lyr.Name; if (_lyrName.EndsWith(LAYER_TARGET)) { int _len = _lyrName.Length - (LAYER_TARGET.Length + 1); _lyrName = _lyrName.Substring(0, _len); if (_lyrName != masterName) { enumLayers.RemoveLayer(lyr); } } if (_lyrName.EndsWith(LAYER_SOURCE)) { int _len = _lyrName.Length - (LAYER_SOURCE.Length + 1); _lyrName = _lyrName.Substring(0, _len); if (_lyrName != secondName) { enumLayers.RemoveLayer(lyr); } } if (_lyrName == masterName) { lyr.Name = _lyrName + " " + LAYER_TARGET; enumLayers.AddLayer(lyr); enumLayers.RemoveLayer(lyr); } if (_lyrName == secondName) { lyr.Name = _lyrName + " " + LAYER_SOURCE; enumLayers.AddLayer(lyr); } lyr = pEnumLayer.Next(); } adjustLayers.CurrentLayers = enumLayers; theMap.AddLayer((ILayer)theLayer); // Refresh the map ((IActiveView)theMap).Refresh(); }
private void CreateErrorLayer() { ISDUTExtension theExt = this.Extension; QAManager theQAMan = theExt.QAManager; IMap theMap = theExt.FocusMap; // Make a note of the FeatureClass which holds the errors this._errorFC = theQAMan.ErrorFeatureClass; // Get the template layer file string filename = theExt.get_SystemValue("qa.dataerrors.layerfile"); System.IO.FileInfo finfoLocation = new System.IO.FileInfo(this.GetType().Assembly.Location.ToString()); System.IO.FileInfo finfoLayer = new System.IO.FileInfo(finfoLocation.DirectoryName + System.IO.Path.DirectorySeparatorChar + filename); string theLayerFileName; // does it exist? if not, we're probably running this in the IDE so we should // look for it in the source tree if (finfoLayer.Exists) { theLayerFileName = finfoLayer.FullName; } else // first attempt failed so check the grandparent (source) folder { System.IO.FileInfo finfoLayer2 = new System.IO.FileInfo(finfoLocation.Directory.Parent.Parent.FullName + System.IO.Path.DirectorySeparatorChar + filename); if (finfoLayer2.Exists) { theLayerFileName = finfoLayer2.FullName; } else { throw new System.IO.FileNotFoundException("Could not locate the SUITT error layer file", finfoLayer.FullName); } } // Open the layer and give it its featureclass IGxLayer gxLayer = new GxLayerClass(); IGxFile gxFile = (IGxFile)gxLayer; gxFile.Path = theLayerFileName; IFeatureLayer theLayer = (IFeatureLayer)gxLayer.Layer; theLayer.Name = ERROR_LAYER_NAME; theLayer.FeatureClass = this._errorFC; // Add it to the map theMap.AddLayer((ILayer)theLayer); // Refresh the map ((IActiveView)theMap).Refresh(); }