Exemple #1
0
 private void ClearFilterGeometry()
 {
     if (_filterGeometry != null)
     {
         _filterGeometry.Dispose();
     }
     lblSpatialFilterGeomSet.Visible = false;
 }
Exemple #2
0
        public override void Invoke()
        {
            var viewer    = this.Viewer;
            var sel       = viewer.GetSelection();
            var selLayers = sel.GetLayers();

            if (selLayers == null)
            {
                MessageBox.Show(Strings.TextNoSelection);
                return;
            }

            //This doesn't work :(
            //
            //var provider = viewer.GetProvider();
            //var featSvc = (MgFeatureService)provider.CreateService(MgServiceType.FeatureService);
            //var ext = sel.GetExtents(featSvc);
            //var ll = ext.LowerLeftCoordinate;
            //var ur = ext.UpperRightCoordinate;
            //viewer.ZoomToExtents(ll.X, ll.Y, ur.X, ur.Y);
            MgEnvelope env = new MgEnvelope();

            if (_agfRw == null)
            {
                _agfRw = new MgAgfReaderWriter();
            }
            for (var i = 0; i < selLayers.GetCount(); i++)
            {
                var layer = selLayers.GetItem(i);
                var fr    = sel.GetSelectedFeatures(layer, layer.FeatureClassName, false);
                try
                {
                    string geomName = layer.GetFeatureGeometryName();
                    while (fr.ReadNext())
                    {
                        if (!fr.IsNull(geomName))
                        {
                            MgByteReader agf  = null;
                            MgGeometry   geom = null;
                            try
                            {
                                agf  = fr.GetGeometry(geomName);
                                geom = _agfRw.Read(agf);
                                env.ExpandToInclude(geom.Envelope());
                            }
                            finally
                            {
                                if (agf != null)
                                {
                                    agf.Dispose();
                                    agf = null;
                                }
                                if (geom != null)
                                {
                                    geom.Dispose();
                                    geom = null;
                                }
                            }
                        }
                    }
                }
                finally
                {
                    fr.Close();
                }
            }
            var ll = env.LowerLeftCoordinate;
            var ur = env.UpperRightCoordinate;

            viewer.ZoomToExtents(ll.X, ll.Y, ur.X, ur.Y);
        }