Ejemplo n.º 1
0
        /// <summary>
        /// This calculates the extent for the category and caches it in the extents collection
        /// </summary>
        /// <param name="category"></param>
        protected virtual Extent CalculateCategoryExtent(IFeatureCategory category)
        {
            Extent ext = new Extent(new[]{double.MaxValue, double.MaxValue, double.MinValue, double.MinValue});
            if(_editMode)
            {
                IDictionary<IFeature, IDrawnState> features = _drawingFilter.DrawnStates;

                foreach (IFeature f in DataSet.Features)
                {
                    if (category == features[f].SchemeCategory)
                    {
                        ext.ExpandToInclude(new Extent(f.Envelope));
                    }
                }
                if (_categoryExtents.Keys.Contains(category))
                {
                    _categoryExtents[category] = ext.Copy();
                }
                else
                {
                    _categoryExtents.Add(category, ext.Copy());
                }
            }
            else
            {
                FastDrawnState[] states = DrawnStates;
                List<ShapeRange> ranges = DataSet.ShapeIndices;
                for(int shp = 0; shp < DrawnStates.Length; shp++)
                {
                    if(!_categoryExtents.ContainsKey(states[shp].Category))
                    {
                        _categoryExtents.Add(states[shp].Category, ranges[shp].Extent.Copy());
                    }
                    else
                    {
                        _categoryExtents[states[shp].Category].ExpandToInclude(ranges[shp].Extent);
                    }
                }
            }
            
            return ext;
        }