コード例 #1
0
        /// <summary>
        /// Removes categories without any features.
        /// </summary>
        public static void RemoveUnusedCategories(this IFeatureSet fs)
        {
            var dct = fs.GetCategoryCounts();

            var list = new List <IFeatureCategory>();

            foreach (var ct in fs.Categories)
            {
                if (!dct.ContainsKey(ct.Index))
                {
                    list.Add(ct);
                }
            }

            if (list.Any())
            {
                foreach (var ct in list)
                {
                    fs.Categories.Remove(ct);
                }

                // need to reapply since it's likely that indices have changed
                fs.Categories.ApplyExpressions();
            }
        }
コード例 #2
0
        /// <summary>
        /// Calculates the number of shapes in each category
        /// </summary>
        private void RefreshCategoriesCount()
        {
            _shapefile.Categories.ApplyExpressions();

            var values = _shapefile.GetCategoryCounts(); // id of category, count

            int count = _shapefile.Categories.Count;

            for (int i = 0; i < count; i++)
            {
                dgvCategories[CMN_COUNT, i].Value = values.ContainsKey(i) ? values[i] : 0;
            }
        }