/// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add ZoomToSelectedFeatures.OnClick implementation
            ILayer            pLayer  = (ILayer)m_mapControl.CustomProperty;
            IFeatureLayer     pFLayer = (IFeatureLayer)pLayer;
            IFeatureSelection pFSel   = (IFeatureSelection)pFLayer;
            ISelectionSet     pSelSet = pFSel.SelectionSet;

            IEnumGeometry     pEnumGeom     = new EnumFeatureGeometry();
            IEnumGeometryBind pEnumGeomBind = (IEnumGeometryBind)pEnumGeom;

            pEnumGeomBind.BindGeometrySource(null, pSelSet);

            IGeometryFactory pGeomFactory = new GeometryEnvironmentClass();
            IGeometry        pGeom        = pGeomFactory.CreateGeometryFromEnumerator(pEnumGeom);
            double           dblXPer      = (pGeom.Envelope.XMax - pGeom.Envelope.XMin) / 10;
            double           dblYPer      = (pGeom.Envelope.YMax - pGeom.Envelope.YMin) / 10;
            IEnvelope        pEnvel       = new EnvelopeClass();

            pEnvel.PutCoords(pGeom.Envelope.XMin - dblXPer, pGeom.Envelope.YMin - dblYPer, pGeom.Envelope.XMax + dblXPer, pGeom.Envelope.YMax + dblYPer);
            //envelope1.PutCoords(pFLayer1.AreaOfInterest.Envelope.XMin - (pFLayer1.AreaOfInterest.Envelope.XMin * 0.0005), pFLayer1.AreaOfInterest.Envelope.YMin - (pFLayer1.AreaOfInterest.Envelope.YMin * 0.0005), pFLayer1.AreaOfInterest.Envelope.XMax * 1.0005, pFLayer1.AreaOfInterest.Envelope.YMax * 1.0005);

            m_mapControl.ActiveView.Extent = pEnvel;
            m_mapControl.ActiveView.Refresh();
        }
        void activeViewEvents_SelectionChanged()
        {
            ///loop through all feature layer and do a partial refresh if the layer is polygon
            ///This important as selection change only does a partial refresh at geoselection level and since we are drawing polygon at geography phase, this step is essential.
            IMap m_Map = m_MxDoc.FocusMap;

            ESRI.ArcGIS.esriSystem.UID m_UID = new ESRI.ArcGIS.esriSystem.UID();
            m_UID.Value = "{40A9E885-5533-11d0-98BE-00805F7CED21}";
            IEnumLayer m_EnumLayer = m_Map.Layers[m_UID];
            ILayer     m_Layer     = m_EnumLayer.Next();


            IActiveView m_activeview = (IActiveView)m_MxDoc.ActivatedView;

            do
            {
                if (m_Layer is IFeatureLayer)
                {
                    if (m_Layer != null)
                    {
                        if (m_Layer.Visible == true)
                        {
                            IFeatureSelection m_FeatureSelection = (IFeatureSelection)m_Layer;
                            ISelectionSet     m_SelSet           = m_FeatureSelection.SelectionSet;



                            if (m_SelSet.Count > 0)
                            {
                                IEnumGeometry     m_EnumGeo;
                                IEnumGeometryBind m_EnumGeoBind;

                                m_EnumGeo     = new EnumFeatureGeometry();
                                m_EnumGeoBind = (IEnumGeometryBind)m_EnumGeo;
                                m_EnumGeoBind.BindGeometrySource(null, m_SelSet);

                                IGeometryFactory m_GeoFactory = new GeometryEnvironmentClass();
                                IGeometry        m_GeoEnvelop = m_GeoFactory.CreateGeometryFromEnumerator(m_EnumGeo);
                                m_activeview.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, m_GeoEnvelop.Envelope);
                            }
                            else
                            {
                                m_activeview.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
                            }
                        }
                    }
                }
                m_Layer = m_EnumLayer.Next();
            } while (m_Layer != null);
        }
Exemple #3
0
        //高亮显示查询到的要素集合
        private void ZoomToSelectedFeature(IFeatureLayer pFeatureLyr, IQueryFilter pQueryFilter)
        {
            //符号边线颜色
            IRgbColor pLineColor = new RgbColor();

            pLineColor.Green = 130;
            ILineSymbol ilSymbl = new SimpleLineSymbolClass();

            ilSymbl.Color = pLineColor;
            ilSymbl.Width = 3;
            //定义选中要素的符号为红色
            ISimpleFillSymbol ipSimpleFillSymbol = new SimpleFillSymbol();

            ipSimpleFillSymbol.Outline = ilSymbl;
            RgbColor pFillColor = new RgbColor();

            pFillColor.Green         = 60;
            ipSimpleFillSymbol.Color = pFillColor;
            ipSimpleFillSymbol.Style = esriSimpleFillStyle.esriSFSDiagonalCross;
            //选取要素集
            IFeatureSelection pFtSelection = pFeatureLyr as IFeatureSelection;

            pFtSelection.SetSelectionSymbol = true;
            pFtSelection.SelectionSymbol    = (ISymbol)ipSimpleFillSymbol;
            pFtSelection.SelectFeatures(pQueryFilter, esriSelectionResultEnum.esriSelectionResultNew, false);

            ISelectionSet pSelectionSet = pFtSelection.SelectionSet;
            //居中显示选中要素
            IEnumGeometry     pEnumGeom     = new EnumFeatureGeometry();
            IEnumGeometryBind pEnumGeomBind = pEnumGeom as IEnumGeometryBind;

            pEnumGeomBind.BindGeometrySource(null, pSelectionSet);
            IGeometryFactory pGeomFactory = new GeometryEnvironmentClass();
            IGeometry        pGeom        = pGeomFactory.CreateGeometryFromEnumerator(pEnumGeom);

            MyMapControl.ActiveView.Extent = pGeom.Envelope;
            MyMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
        }
Exemple #4
0
        /// <summary>
        /// 选择一行,并在地图中显示
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void att_gridview_RowClick(object sender, RowClickEventArgs e)
        {
            GridView    att_gridview = (GridView)sender;
            GridHitInfo info         = att_gridview.CalcHitInfo(e.X, e.Y);

            //只有单击rowinditor时才执行选择行
            if (!info.InRowCell)
            {
                if (info.InRow)
                {
                    //存放selectedrow
                    ArrayList rows = new ArrayList();
                    for (int i = 0; i < att_gridview.SelectedRowsCount; i++)
                    {
                        if (att_gridview.GetSelectedRows()[i] >= 0)
                        {
                            rows.Add(att_gridview.GetDataRow(att_gridview.GetSelectedRows()[i]));
                        }
                    }
                    if (rows.Count > 0)
                    {
                        //遍历flayer_list寻找当前属性表对应的图层
                        for (int i = 0; i < flayer_list.Count; i++)
                        {
                            IDataLayer     datalayer = flayer_list[i] as IDataLayer;
                            IWorkspaceName w_name    = ((IDatasetName)(datalayer.DataSourceName)).WorkspaceName;
                            if (att_gridview.Tag.ToString() == w_name.PathName + "\\" + flayer_list[i].Name + "_" + flayer_list[i].DataSourceType)
                            {
                                IFeatureClass     m_featureclass = flayer_list[i].FeatureClass;
                                IFeatureSelection m_fselection   = flayer_list[i] as IFeatureSelection;

                                //构造查询条件
                                IQueryFilter m_queryfilter = new QueryFilterClass();
                                string       key           = flayer_list[i].FeatureClass.Fields.get_Field(0).Name;
                                string       m_whereclause = key + "=";
                                for (int j = 0; j < rows.Count; j++)
                                {
                                    DataRow m_dr = rows[j] as DataRow;
                                    if (j < 1)
                                    {
                                        m_whereclause += m_dr[0].ToString();
                                    }
                                    else
                                    {
                                        m_whereclause = m_whereclause + " or " + key + "=" + m_dr[0].ToString();
                                    }
                                }
                                m_queryfilter.WhereClause = m_whereclause;

                                //显示查询的要素
                                m_fselection.SelectFeatures(m_queryfilter, esriSelectionResultEnum.esriSelectionResultNew, false);
                                ISelectionSet     m_selectionset = m_fselection.SelectionSet;
                                IEnumGeometry     m_enumgeometry = new EnumFeatureGeometry();
                                IEnumGeometryBind m_enumgeobine  = m_enumgeometry as IEnumGeometryBind;
                                m_enumgeobine.BindGeometrySource(null, m_selectionset);
                                IGeometryFactory m_geofactory = new GeometryEnvironmentClass();
                                IGeometry        m_geometry   = m_geofactory.CreateGeometryFromEnumerator(m_enumgeometry);
                                m_mapControl.ActiveView.Extent = m_geometry.Envelope;
                                m_mapControl.Refresh();
                            }
                        }
                    }
                }
            }
        }
Exemple #5
0
        //空间信息查询确定按钮
        private void Btn_QueryOk_Click(object sender, EventArgs e)
        {
            //获得图层ID
            int iLyrID = -1;

            for (int i = 0; i < axMapControl_1.LayerCount; i++)
            {
                if (axMapControl_1.get_Layer(i).Name == Cbx_LyrName.Text)
                {
                    iLyrID = i;
                    break;
                }
            }

            //获取图层信息及要素集
            pFeaLyr = axMapControl_1.get_Layer(iLyrID) as IFeatureLayer;
            IFeatureClass pFC = pFeaLyr.FeatureClass;
            //获得字段的ID
            int iClmID = -1;

            for (int i = 0; i < pFC.Fields.FieldCount; i++)
            {
                if (pFC.Fields.get_Field(i).Name == "Name" || pFC.Fields.get_Field(i).Name == "name")
                {
                    iClmID = i;
                    break;
                }
            }
            //开始查询
            if (iClmID != -1)
            {
                //初始化一个条件过滤器
                IQueryFilter qfilter   = new QueryFilter();
                string       ColumName = pFC.Fields.get_Field(iClmID).Name;
                qfilter.WhereClause = ColumName + " like'%" + Txt_Query.Text + "%'";
                IFeatureCursor fCursor = pFC.Search(qfilter, false);
                //初始化数据表
                DataTable DT = new DataTable();
                //数据表字段填充
                for (int i = 0; i < fCursor.Fields.FieldCount; i++)
                {
                    DT.Columns.Add(fCursor.Fields.get_Field(i).Name, typeof(string));
                }

                //清除地图选择集
                axMapControl_1.Map.ClearSelection();
                //清除Gridview中的字段,解除gridcontrol数据源
                GridView_Info.Columns.Clear();
                GridControl_Info.DataSource = null;
                //数据填充
                for (int i = 0; i < pFC.FeatureCount(qfilter); i++)
                {
                    IFeature feature = fCursor.NextFeature();
                    axMapControl_1.Map.SelectFeature(axMapControl_1.get_Layer(iLyrID), feature);
                    DataRow dr = DT.NewRow();
                    for (int j = 0; j < feature.Fields.FieldCount; j++)
                    {
                        dr[j] = feature.get_Value(j).ToString();
                    }
                    DT.Rows.Add(dr);
                }
                //绑定结果是
                GridControl_Info.DataSource = DT;
                for (int i = 0; i < GridView_Info.Columns.Count; i++)
                {
                    if (GridView_Info.Columns[i].Name == "colshape" || GridView_Info.Columns[i].Name == "colShape")
                    {
                        GridView_Info.Columns[i].Visible = false;
                    }
                }


                //地图窗口缩放到选择位置
                IFeatureSelection featureSelection = pFeaLyr as IFeatureSelection;
                if (featureSelection.SelectionSet.Count == 0)
                {
                    return;
                }
                IEnumGeometryBind tEnumGeometryBind = new EnumFeatureGeometryClass();
                tEnumGeometryBind.BindGeometrySource(null, featureSelection.SelectionSet);
                IEnumGeometry    tEnumGeometry    = (IEnumGeometry)tEnumGeometryBind;
                IGeometryFactory tGeometryFactory = new GeometryEnvironmentClass();
                IGeometry        tGeometry        = tGeometryFactory.CreateGeometryFromEnumerator(tEnumGeometry);
                //缓冲处理,使处于边界的元素在视图中能够完全显示
                ITopologicalOperator mTopologicalOperator = (ITopologicalOperator)tGeometry;
                IGeometry            mPolygonBuffer       = mTopologicalOperator.Buffer(0.001) as IGeometry;
                axMapControl_1.Extent = mPolygonBuffer.Envelope;

                axMapControl_1.ActiveView.Refresh();
            }


            else
            {
                MessageBox.Show("该图层没有名称字段!!!");
            }
        }
        private void FlashFeature(IQueryFilter queryFilter)
        {
            if (_pipeData == null)
                _pipeData = new List<string>();
            else
                _pipeData.Clear();

            try
            {
                //---------------------------------------------------------------------
                // CHANGED: CR23 (Merged features)
                // Flash all the features relating to the selected incid at once.
                // This method may be triggered more than once if there are too
                // many to pass via the Named Pipes in one go.
                //
                IEnumGeometryBind enumGeometryBind = new EnumFeatureGeometryClass();
                enumGeometryBind.BindGeometrySource(null, _hluFeatureSelection.SelectionSet.Select(queryFilter, esriSelectionType.esriSelectionTypeHybrid, esriSelectionOption.esriSelectionOptionNormal, null));
                IGeometryFactory geometryFactory = new GeometryEnvironmentClass();
                IGeometry geom = geometryFactory.CreateGeometryFromEnumerator((IEnumGeometry)enumGeometryBind);

                IMxDocument mxDoc = (IMxDocument)_application.Document;
                IActiveView activeView = mxDoc.FocusMap as IActiveView;
                IScreenDisplay screenDisplay = activeView.ScreenDisplay;
                //---------------------------------------------------------------------
                //---------------------------------------------------------------------
                // FIX: 018 Bring ArcGIS and MapInfo into line by flashing all features twice
                FlashGeometry(geom, screenDisplay, 300, 2);
                //---------------------------------------------------------------------
            }
            catch { }
        }
Exemple #7
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            IEnvelope extent;

            if (this.rdoCurrentMapExtend.Checked)
            {
                extent            = (this.Map as IActiveView).Extent;
                this.ClipGeometry = extent;
            }
            else if (this.rdoCustomExtend.Checked)
            {
                double num;
                double num2;
                double num3;
                double num4;
                if (!double.TryParse(this.txtBottom.Text, out num))
                {
                    MessageBox.Show("底部值输入错误!");
                    return;
                }
                if (!double.TryParse(this.txtLeft.Text, out num2))
                {
                    MessageBox.Show("左边值输入错误!");
                    return;
                }
                if (!double.TryParse(this.txtTop.Text, out num3))
                {
                    MessageBox.Show("顶部值输入错误!");
                    return;
                }
                if (!double.TryParse(this.txtRight.Text, out num4))
                {
                    MessageBox.Show("右边值输入错误!");
                    return;
                }
                extent = new EnvelopeClass
                {
                    XMin = num2,
                    XMax = num4,
                    YMax = num3,
                    YMin = num
                };
                this.ClipGeometry = extent;
            }
            else if (this.rdoLayerExtend.Checked)
            {
                IEnumGeometry        geometry;
                ITopologicalOperator @operator;
                if (this.cboLayers.SelectedIndex == -1)
                {
                    MessageBox.Show("请选择图层!");
                    return;
                }
                extent = null;
                ILayer layer = (this.cboLayers.SelectedItem as LayerObject).Layer;
                if (this.cboFeatures.SelectedIndex == 0)
                {
                    geometry = new EnumFeatureGeometryClass();
                    (geometry as IEnumGeometryBind).BindGeometrySource(null, (layer as IGeoFeatureLayer).FeatureClass);
                    @operator = new PolygonClass();
                    @operator.ConstructUnion(geometry);
                    this.ClipGeometry = @operator as IGeometry;
                }
                else if (this.cboFeatures.SelectedIndex == 1)
                {
                    IQueryFilter outputFilter = new SpatialFilterClass();
                    (outputFilter as ISpatialFilter).Geometry   = this.Extend;
                    (outputFilter as ISpatialFilter).SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                    geometry = new EnumFeatureGeometryClass();
                    (geometry as IEnumGeometryBind).BindGeometrySource(outputFilter,
                                                                       (layer as IGeoFeatureLayer).FeatureClass);
                    IGeometryFactory3 factory   = new GeometryEnvironmentClass();
                    IGeometry         geometry2 = factory.CreateGeometryFromEnumerator(geometry);
                    int geometryCount           = (geometry2 as IGeometryCollection).GeometryCount;
                    @operator = new PolygonClass();
                    @operator.ConstructUnion(geometry2 as IEnumGeometry);
                    this.ClipGeometry = @operator as IGeometry;
                }
                else
                {
                    geometry = new EnumFeatureGeometryClass();
                    (geometry as IEnumGeometryBind).BindGeometrySource(null, (layer as IFeatureSelection).SelectionSet);
                    @operator = new PolygonClass();
                    @operator.ConstructUnion(geometry);
                    this.ClipGeometry = @operator as IGeometry;
                }
            }
            else
            {
                this.ClipGeometry = this.method_3(this.Map as IGraphicsContainerSelect);
            }
            base.DialogResult = DialogResult.OK;
        }
        private void ZoomSelected()
        {
            if ((_hluFeatureClass == null) || (_hluView == null)) return;

            if (_hluFeatureSelection == null)
                _hluFeatureSelection = (IFeatureSelection)_hluFeatureClass;

            if (_hluFeatureSelection.SelectionSet.Count == 0) return;

            IEnumGeometryBind enumGeometryBind = new EnumFeatureGeometryClass();
            enumGeometryBind.BindGeometrySource(null, _hluFeatureSelection.SelectionSet);
            IGeometryFactory geometryFactory = new GeometryEnvironmentClass();
            IGeometry geom = geometryFactory.CreateGeometryFromEnumerator((IEnumGeometry)enumGeometryBind);
            _hluView.Extent = geom.Envelope;
            _hluView.PartialRefresh(esriViewDrawPhase.esriViewGeography, _hluLayer, _hluView.Extent);
        }
 private void ZoomSelectedCursor(IQueryFilter queryFilter)
 {
     if ((queryFilter == null) || (_hluFeatureClass == null) || (_hluView == null)) return;
     IEnumGeometryBind enumGeometryBind = new EnumFeatureGeometryClass();
     enumGeometryBind.BindGeometrySource(queryFilter, _hluFeatureClass);
     IGeometryFactory geometryFactory = new GeometryEnvironmentClass();
     IGeometry geom = geometryFactory.CreateGeometryFromEnumerator((IEnumGeometry)enumGeometryBind);
     _hluView.Extent = geom.Envelope;
     _hluView.PartialRefresh(esriViewDrawPhase.esriViewGeography, _hluLayer, _hluView.Extent);
 }
        private void btnOKNextScale_Click(object sender, EventArgs e)
        {
            if (!CheckRequirements())
            {
                return;
            }

            IFeatureLayer buildingslayer = _utilitiesArcMap.FeatureLayer(this.cboBuildingLayer.Text);

            try
            {
                if (buildingslayer != null)
                {
                    int indexField           = _utilitiesArcMap.FindField(buildingslayer, "rsi_index");
                    int inspectionfieldindex = _utilitiesArcMap.FindField(buildingslayer, "rsi");

                    IFeatureClass     buildingsfeatureclass     = buildingslayer.FeatureClass;
                    IFeatureSelection buildingsfeatureselection = buildingslayer as IFeatureSelection;
                    if (buildingsfeatureselection.SelectionSet.Count > 0)
                    {
                        Update(1, buildingslayer);
                    }

                    IFeatureCursor featurecursor = null;
                    IQueryFilter   queryfilter   = new QueryFilterClass();
                    queryfilter.WhereClause = "\"rsi\" IS NULL";


                    if (indexField > -1)
                    {
                        queryfilter.SubFields = "rsi_index";
                        IQueryFilterDefinition queryFilterDef = (IQueryFilterDefinition)queryfilter;
                        queryFilterDef.PostfixClause = "ORDER BY rsi_index";
                    }

                    featurecursor = buildingsfeatureclass.Search(queryfilter, false);

                    IFeature feature = null;

                    while ((feature = featurecursor.NextFeature()) != null)
                    {
                        IPolygon  polygon  = feature.Shape as IPolygon;
                        IPolyline polyline = feature.Shape as IPolyline;

                        if ((polygon != null) || (polyline != null))
                        {
                            buildingsfeatureselection.Clear();
                            buildingsfeatureselection.Add(feature);
                            buildingsfeatureselection.SelectionChanged();
                            IEnumGeometry     enumgeometry     = new EnumFeatureGeometryClass();
                            IEnumGeometryBind enumgeometrybind = enumgeometry as IEnumGeometryBind;
                            enumgeometrybind.BindGeometrySource(null, buildingsfeatureselection.SelectionSet);
                            IGeometryFactory geometryfactory = new GeometryEnvironmentClass();
                            IGeometry        geometry        = geometryfactory.CreateGeometryFromEnumerator(enumgeometry);

                            double    scale    = _map.MapScale;
                            IEnvelope envelope = geometry.Envelope;
                            _activeView.Extent = envelope;
                            _map.MapScale      = scale;
                            _activeView.Refresh();

                            GetStatus();

                            return;
                        }

                        IPoint point = feature.Shape as IPoint;
                        if (point != null)
                        {
                            buildingsfeatureselection.Clear();
                            buildingsfeatureselection.Add(feature);
                            buildingsfeatureselection.SelectionChanged();
                            double    scale    = _map.MapScale;
                            IEnvelope envelope = _activeView.Extent;
                            envelope.CenterAt(point);
                            _activeView.Extent = envelope;
                            _map.MapScale      = scale;
                            _activeView.Refresh();

                            GetStatus();

                            return;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Building Inspector", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            finally
            {
                //_restartreport = false;
            }
        }
Exemple #11
0
        // zooms to features in the map that correspond to selected features in the list view
        private void btnZoomSelected_Click(object sender, System.EventArgs e)
        {
            try
            {
                IQueryFilter pQueryFilter = new QueryFilterClass();
                IFeatureClass pFeatureClass = m_pFeatureLayer.FeatureClass;

                // build array of selected OIDs
                string[] OID = new string[lvGPS.SelectedItems.Count];
                for(int x = 0; x < lvGPS.SelectedItems.Count; x++)
                {
                    OID[x] = lvGPS.SelectedItems[x].Text;
                }

                string OIDs = String.Join(",",OID);

                // build the whereclause
                string whereclause = pFeatureClass.OIDFieldName + " IN (" + OIDs + ")";

                Debug.WriteLine(whereclause);

                pQueryFilter.WhereClause = whereclause;

                // bind query filter resultant geometry into a geometry bag
                IEnumGeometryBind pEnumBind = new EnumFeatureGeometryClass();
                IGeometryFactory pGeomFactory = new GeometryEnvironmentClass();
                pEnumBind.BindGeometrySource(pQueryFilter,pFeatureClass);
                IGeometryBag pGeometryBag = (IGeometryBag)pGeomFactory.CreateGeometryFromEnumerator((IEnumGeometry)pEnumBind);
                IGeometryCollection pGeomCollection = (IGeometryCollection)pGeometryBag;

                // TODO:
                //IMxDocument pMxDoc = (IMxDocument)m_pApp.Document;
                IActiveView pActiveView = (IActiveView)m_pISDUTExt.FocusMap; //pMxDoc.FocusMap;
                //util.Utils.Release(pMxDoc);

                IEnvelope pEnv = pGeometryBag.Envelope;
                if(pGeomCollection.GeometryCount == 1)
                {
                    // if only one point the do a pan instead of a zoom

                    IPoint pPoint = new PointClass();
                    pPoint.PutCoords(pEnv.XMin,pEnv.YMin);

                    // get SR of featureclass
                    IGeoDataset pGeodataset = (IGeoDataset)m_pFeatureLayer.FeatureClass;

                    pPoint.SpatialReference = pGeodataset.SpatialReference;

                    // project point to match focus map SR

                    // TODO:
                    //pMxDoc = (IMxDocument)m_pApp.Document;
                    pPoint.Project(m_pISDUTExt.FocusMap.SpatialReference);// pMxDoc.FocusMap.SpatialReference);
                    //util.Utils.Release(pMxDoc);

                    IEnvelope pPanEnv = pActiveView.Extent;
                    pPanEnv.CenterAt(pPoint);
                    pActiveView.Extent = pPanEnv;
                }
                else
                {
                    pEnv.Expand(1.1,1.1,true);
                    pActiveView.Extent = pEnv;
                }

                pActiveView.Refresh();
            }
            catch(Exception ex)
            {
                util.Logger.Write(" Descrip  : Zooms to features on the map the correspond with items selected in the list view." +
                                "\n Message  : " + ex.Message +
                                "\n StackTrc : " + ex.StackTrace,util.Logger.LogLevel.Debug);

                MessageBox.Show(ex.Message + "\n" + ex.StackTrace);
                Debug.WriteLine(ex.Message + "\n" + ex.StackTrace);
            }

            //lvGPS.Focus();
        }
        void activeViewEvents_SelectionChanged()
        {

            ///loop through all feature layer and do a partial refresh if the layer is polygon
            ///This important as selection change only does a partial refresh at geoselection level and since we are drawing polygon at geography phase, this step is essential.
                IMap m_Map = m_MxDoc.FocusMap;
                ESRI.ArcGIS.esriSystem.UID m_UID = new ESRI.ArcGIS.esriSystem.UID();
                m_UID.Value = "{40A9E885-5533-11d0-98BE-00805F7CED21}";
                IEnumLayer m_EnumLayer = m_Map.Layers[m_UID];
                ILayer m_Layer = m_EnumLayer.Next();

           
                IActiveView m_activeview = (IActiveView)m_MxDoc.ActivatedView;  

                do
                {
                    if (m_Layer is IFeatureLayer)
                    {
                         if (m_Layer != null)
                         {
                             if (m_Layer.Visible == true)
                             {
                                 IFeatureSelection m_FeatureSelection = (IFeatureSelection)m_Layer;
                                 ISelectionSet m_SelSet = m_FeatureSelection.SelectionSet;



                                 if (m_SelSet.Count > 0)
                                 {
                                     IEnumGeometry m_EnumGeo;
                                     IEnumGeometryBind m_EnumGeoBind;

                                     m_EnumGeo = new EnumFeatureGeometry();
                                     m_EnumGeoBind = (IEnumGeometryBind)m_EnumGeo;
                                     m_EnumGeoBind.BindGeometrySource(null, m_SelSet);

                                     IGeometryFactory m_GeoFactory = new GeometryEnvironmentClass();
                                     IGeometry m_GeoEnvelop = m_GeoFactory.CreateGeometryFromEnumerator(m_EnumGeo);
                                     m_activeview.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, m_GeoEnvelop.Envelope);

                                 }
                                 else
                                 {
                                     m_activeview.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
                                 }

                             }
                    }
                    }
                   m_Layer = m_EnumLayer.Next();
                } while (m_Layer != null);


            
        }