void QueryForm_CheckedChanged(object sender, EventArgs e) { ESRI.ArcGIS.Carto.ILayerFile layerFile = new ESRI.ArcGIS.Carto.LayerFileClass(); RadioButton btn = sender as RadioButton; listBox2.Items.Clear(); if (btn != null && btn.Checked) { try { selectedRadio = tags[(int)btn.Tag]; if (selectedRadio.Contains('+')) { //qhc = new QueryHelperLLWW_Modifier(); //listBox2.Items.AddRange(qhc.getQueryValueOptions("Landscape")); } else { listBox2.Items.AddRange(qhc.getQueryValueOptions(selectedRadio, "")); } } catch (Exception err) { } finally { layerFile.Close(); } } }
protected void DoClip(IActiveView activeView, IFeatureLayer ifl_active, IGeometry geometry) { try { ESRI.ArcGIS.Carto.IMap map = activeView.FocusMap; ESRI.ArcGIS.Carto.ILayerFile layerFile = new ESRI.ArcGIS.Carto.LayerFileClass(); ISpatialFilter isf = new SpatialFilterClass(); isf.Geometry = geometry; isf.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; gd.Title = "Save clipped feature class"; gd.ObjectFilter = new GxFilterFeatureClassesClass(); //new GxFilterFeatureClassesClass(); if (gd.DoModalSave(ArcMap.Application.hWnd) == false) { return; } while (System.IO.File.Exists(gd.FinalLocation.FullName + "\\" + gd.Name) || gd.ReplacingObject) { if (System.Windows.Forms.MessageBox.Show("You've selected a feature class that already exists. Select a different feature class name.", "Overwrite Feature Class", System.Windows.Forms.MessageBoxButtons.RetryCancel) == System.Windows.Forms.DialogResult.Cancel) { return; } if (gd.DoModalSave(ArcMap.Application.hWnd) == false) { return; } } // Create a new in-memory workspace. This returns a name object. InMemoryWorkspaceFactory wsf = new InMemoryWorkspaceFactoryClass(); IWorkspaceName workspaceName = wsf.Create(null, "MyWorkspace", null, 0); IName name = (IName)workspaceName; IFeatureWorkspace workspace; IWorkspaceEdit iwe; IFields flds; setFeatureSpatialReference(ifl_active, name, out workspace, out iwe, out flds); IFeatureClass ifc_new = workspace.CreateFeatureClass("AAA", flds, null, null, esriFeatureType.esriFTSimple, ifl_active.FeatureClass.ShapeFieldName, ""); IFeatureLayer fl = new FeatureLayerClass(); IGeoFeatureLayer gfl = (IGeoFeatureLayer)fl; IRgbColor rgbColor = new RgbColorClass(); rgbColor.Red = 255; rgbColor.Green = 0; rgbColor.Blue = 0; IColor color = rgbColor; // Implicit Cast fl.FeatureClass = ifc_new; fl.Name = "IntersectingShape"; ISimpleFillSymbol sfs = new SimpleFillSymbolClass(); ISimpleLineSymbol sls = new SimpleLineSymbolClass(); sls.Color = color; sls.Width = 4.0; sls.Style = esriSimpleLineStyle.esriSLSSolid; color.NullColor = true; sfs.Color = color; sfs.Outline = sls; ISimpleRenderer isr = new SimpleRendererClass(); isr.Symbol = (ISymbol)sfs; gfl.Renderer = (IFeatureRenderer)isr; IObjectCopy cpy = new ObjectCopyClass(); iwe.StartEditing(true); iwe.StartEditOperation(); IFeatureBuffer fb = ifc_new.CreateFeatureBuffer(); IFeatureCursor csri = ifc_new.Insert(false); fb.Shape = geometry; csri.InsertFeature(fb); csri.Flush(); iwe.StopEditOperation(); iwe.StopEditing(true); map.AddLayer(fl); ESRI.ArcGIS.AnalysisTools.Clip tool = new ESRI.ArcGIS.AnalysisTools.Clip(); tool.clip_features = fl; tool.in_features = ifl_active; tool.out_feature_class = gd.FinalLocation.FullName + "\\" + gd.Name; /*ws.PathName*/ //"In_memory" + "\\NWI_Clip_Result"; gp.AddOutputsToMap = true; gp.OverwriteOutput = true; gp.ToolExecuted += new EventHandler<ToolExecutedEventArgs>(gp_ToolExecuted); gp.ProgressChanged += new EventHandler<ProgressChangedEventArgs>(gp_ProgressChanged); gp.ExecuteAsync(tool); } catch (Exception err) { } finally { SelectArrowToolOnToolbar(); } }