Ejemplo n.º 1
0
        private void dgvAttTable_MouseUp(object sender, MouseEventArgs e)
        {
            try
            {
                int           intSelCounts = dgvAttTable.SelectedRows.Count;
                IFeatureLayer pFLayer      = m_pLayer as IFeatureLayer;
                if (intSelCounts == 0)
                {
                    m_pSnippet.ClearSelectedMapFeatures(m_pActiveView, pFLayer);
                }
                else//Brushing on Map
                {
                    for (int i = 0; i < intSelCounts; i++)
                    {
                        string value1 = dgvAttTable.SelectedRows[i].Cells[0].Value.ToString();


                        string whereClause = "FID =" + value1;

                        if (m_pActiveView == null || pFLayer == null || whereClause == null || value1 == "")
                        {
                            return;
                        }
                        ESRI.ArcGIS.Carto.IFeatureSelection featureSelection = pFLayer as ESRI.ArcGIS.Carto.IFeatureSelection; // Dynamic Cast

                        // Set up the query
                        ESRI.ArcGIS.Geodatabase.IQueryFilter queryFilter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass();
                        queryFilter.WhereClause = whereClause;

                        // Invalidate only the selection cache. Flag the original selection
                        m_pActiveView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeoSelection, null, null);

                        // Perform the selection
                        if (i == 0)
                        {
                            featureSelection.SelectFeatures(queryFilter, ESRI.ArcGIS.Carto.esriSelectionResultEnum.esriSelectionResultNew, false);
                        }
                        else
                        {
                            featureSelection.SelectFeatures(queryFilter, ESRI.ArcGIS.Carto.esriSelectionResultEnum.esriSelectionResultAdd, false);
                        }
                    }
                    // Flag the new selection
                    m_pActiveView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeoSelection, null, null);

                    //Brushing to other graphs
                    m_pBL.BrushingToOthers(pFLayer, this.Handle);
                }
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return;
            }
        }
Ejemplo n.º 2
0
        private void FeatureSelectionOnActiveView(string whereClause, IActiveView pActiveView, IFeatureLayer pFLayer)
        {
            try
            {
                ESRI.ArcGIS.Carto.IFeatureSelection featureSelection = pFLayer as ESRI.ArcGIS.Carto.IFeatureSelection; // Dynamic Cast

                // Set up the query
                ESRI.ArcGIS.Geodatabase.IQueryFilter queryFilter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass();
                queryFilter.WhereClause = whereClause;

                // Invalidate only the selection cache. Flag the original selection
                pActiveView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeoSelection, null, null);

                // Perform the selection
                featureSelection.SelectFeatures(queryFilter, ESRI.ArcGIS.Carto.esriSelectionResultEnum.esriSelectionResultNew, false);

                // Flag the new selection
                pActiveView.Refresh();
                //pActiveView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeoSelection, null, null);
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return;
            }
        }
Ejemplo n.º 3
0
        public void FeatureSelectionOnActiveView(string whereClause, IActiveView pActiveView, IFeatureLayer pFLayer)
        {
            try
            {
                //pActiveView.GraphicsContainer.DeleteAllElements();
                ESRI.ArcGIS.Carto.IFeatureSelection featureSelection = pFLayer as ESRI.ArcGIS.Carto.IFeatureSelection; // Dynamic Cast

                // Set up the query
                ESRI.ArcGIS.Geodatabase.IQueryFilter queryFilter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass();
                queryFilter.WhereClause = whereClause;

                // Invalidate only the selection cache. Flag the original selection
                pActiveView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeoSelection, null, null);

                // Perform the selection
                featureSelection.SelectFeatures(queryFilter, ESRI.ArcGIS.Carto.esriSelectionResultEnum.esriSelectionResultNew, false);

                // Flag the new selection
                //pActiveView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeoSelection, null, null);
                pActiveView.Refresh();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception:" + ex.Message);
                return;
            }
        }
Ejemplo n.º 4
0
        private void BrushingOnMapControl(ISpatialFilter pSpatialFilter, IActiveView pActiveView, IFeatureLayer pFLayer)
        {
            ESRI.ArcGIS.Carto.IFeatureSelection featureSelection = pFLayer as ESRI.ArcGIS.Carto.IFeatureSelection; // Dynamic Cast

            // Invalidate only the selection cache. Flag the original selection
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);

            // Perform the selection
            featureSelection.SelectFeatures(pSpatialFilter, esriSelectionResultEnum.esriSelectionResultNew, false);

            // Flag the new selection
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
        }
Ejemplo n.º 5
0
        internal void addFeatureClassToMapAsLayer(ref IFeatureClass fc, string LayerName, string whereClause)
        {
            try
            {
                // define a new layer for the asset catalog
                IFeatureLayer player = new FeatureLayer();
                player.FeatureClass = fc;
                player.Name         = LayerName;

                // TODO: Specifically set the spatial reference

                // Set up the query
                ESRI.ArcGIS.Geodatabase.IQueryFilter queryFilter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass();
                queryFilter.WhereClause = whereClause;

                // create a feature selection object
                ESRI.ArcGIS.Carto.IFeatureSelection featureSelection
                    = player as ESRI.ArcGIS.Carto.IFeatureSelection; // Dynamic Cast

                // Perform the selection
                featureSelection.SelectFeatures(queryFilter, ESRI.ArcGIS.Carto.esriSelectionResultEnum.esriSelectionResultNew, false);

                //Create a GxLayer to stylize the layer.
                ESRI.ArcGIS.Catalog.IGxLayer gxLayerCls = new ESRI.ArcGIS.Catalog.GxLayer();
                ESRI.ArcGIS.Catalog.IGxFile  gxFile     = (ESRI.ArcGIS.Catalog.IGxFile)gxLayerCls;
                //Explicit Cast.

                // create an assembly file object to determine where on the system this is running
                log.Debug("Attempting to locate the executing extension assembly.");
                Uri assemblyUri = new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase);
                System.IO.FileInfo assemblyFileInfo
                    = new System.IO.FileInfo(Path.GetDirectoryName(assemblyUri.LocalPath));
                log.Debug("Executing from: " + assemblyFileInfo.FullName);

                //Set the path for where the layer file is located on disk.
                gxFile.Path = assemblyFileInfo.FullName + "\\GME_Catalog_Style.lyr";
                log.Debug("lyr Path: " + gxFile.Path);

                // validate the symbology layers exist
                if (!(gxLayerCls.Layer == null))
                {
                    // create a geo feature layer for the master symbology
                    IGeoFeatureLayer symbologyGeoFeatureLayer = gxLayerCls.Layer as IGeoFeatureLayer;

                    // create a geo feature layer for the new features
                    IGeoFeatureLayer pGeoFeatureLayer = player as IGeoFeatureLayer;

                    // apply the renderer from the template to the new feature layer
                    pGeoFeatureLayer.Renderer = symbologyGeoFeatureLayer.Renderer;
                }

                // add the layer to the map
                m_map.AddLayer(player);

                // Flag the new selection
                ArcMap.Document.ActiveView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeoSelection, null, null);

                // manually trigger the selection has changed event to determine if the buttons should re-enable
                ArcMap_SelectionChanged();
            }
            catch (System.Exception ex)
            {
                // an error occured
                log.Error(ex);
                System.Windows.Forms.MessageBox.Show("Unable to add feature class to the map.");
            }
        }