Esempio n. 1
0
        public FeatureClassIndexDlg(IFeatureClass pFc)
        {
            InitializeComponent();
            featureCls          = pFc;
            fcFields            = pFc.GetFields();
            featureCls.LockType = gviLockType.gviLockExclusiveSchema;

            List <string> geoFields = new List <string>();

            for (int l = 0; l < fcFields.Count; l++)
            {
                IFieldInfo myField = fcFields.Get(l);
                if (myField != null && myField.FieldType == gviFieldType.gviFieldGeometry)
                {
                    geoFields.Add(myField.Name);
                }
            }

            //读取FC的索引信息
            //属性索引
            IDbIndexInfoCollection DbIndexInfos = featureCls.GetDbIndexInfos();

            if (DbIndexInfos != null)
            {
                for (int k = 0; k < DbIndexInfos.Count; k++)
                {
                    IDbIndexInfo DbIndex = DbIndexInfos.Get(k);
                    if (DbIndex.FieldCount == 1)
                    {
                        string getName = DbIndex.GetFieldName(0);
                        int    ind     = fcFields.IndexOf(getName);
                        if (ind >= 0)
                        {
                            IFieldInfo unVaildField = fcFields.Get(ind);
                            if (unVaildField.FieldType == gviFieldType.gviFieldFID || unVaildField.FieldType == gviFieldType.gviFieldGeometry || unVaildField.FieldType == gviFieldType.gviFieldBlob)
                            {
                                continue;
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }
                    AttrIndexList.Add(DbIndex.Name);
                    this.lb_AttrIndex.Items.Add(new myAttrIndex(DbIndex, false));
                }
            }

            //空间索引
            IIndexInfoCollection GridIndexInfos = featureCls.GetSpatialIndexInfos();

            if (GridIndexInfos != null)
            {
                GridIndexHash = new Hashtable(GridIndexInfos.Count);
                for (int k = 0; k < GridIndexInfos.Count; k++)
                {
                    IGridIndexInfo GridIndex = GridIndexInfos.Get(k) as IGridIndexInfo;
                    if (GridIndex != null)
                    {
                        GridIndexHash.Add(GridIndex.GeoColumnName, GridIndex);
                        CheckIndexEdit GridIndexItem = new CheckIndexEdit(GridIndex.GeoColumnName);
                        GridIndexItem.ExistIndex = new IndexAboutGeometry(GridIndex.L1, GridIndex.L2, GridIndex.L3, true);
                        GridIndexItem.NewIndex   = new IndexAboutGeometry(GridIndex.L1, GridIndex.L2, GridIndex.L3, true);
                        this.lb_SpatialIndexGeo.Items.Add(GridIndexItem);
                    }
                }

                foreach (string sGeoColumn in geoFields)
                {
                    if (GridIndexHash.ContainsKey(sGeoColumn))
                    {
                        continue;
                    }
                    CheckIndexEdit GridIndexItem = new CheckIndexEdit(sGeoColumn);
                    GridIndexItem.ExistIndex = null;
                    GridIndexItem.NewIndex   = new IndexAboutGeometry(0, 0, 0, false);
                    this.lb_SpatialIndexGeo.Items.Add(GridIndexItem);
                }
            }

            //渲染索引
            IIndexInfoCollection RenderIndexInfos = featureCls.GetRenderIndexInfos();

            if (RenderIndexInfos != null)
            {
                RenderIndexHash = new Hashtable(RenderIndexInfos.Count);
                for (int k = 0; k < RenderIndexInfos.Count; k++)
                {
                    IRenderIndexInfo RenderIndex = RenderIndexInfos.Get(k) as IRenderIndexInfo;
                    if (RenderIndex != null)
                    {
                        RenderIndexHash.Add(RenderIndex.GeoColumnName, RenderIndex);
                        CheckIndexEdit RenderIndexItem = new CheckIndexEdit(RenderIndex.GeoColumnName);
                        RenderIndexItem.ExistIndex = new IndexAboutGeometry(RenderIndex.L1, 0, 0, true);
                        RenderIndexItem.NewIndex   = new IndexAboutGeometry(RenderIndex.L1, 0, 0, true);
                        this.lb_RenderIndexGeo.Items.Add(RenderIndexItem);
                    }
                }

                foreach (string sGeoColumn in geoFields)
                {
                    if (RenderIndexHash.ContainsKey(sGeoColumn))
                    {
                        continue;
                    }
                    CheckIndexEdit RenderIndexItem = new CheckIndexEdit(sGeoColumn);
                    RenderIndexItem.ExistIndex = null;
                    RenderIndexItem.NewIndex   = new IndexAboutGeometry(0, 0, 0, false);
                    this.lb_RenderIndexGeo.Items.Add(RenderIndexItem);
                }

                //填充渲染索引的ListBoxControl控件,一个是lbc_FieldsAvailable,另一个是lbc_FieldsSelected
                for (int k = 0; k < fcFields.Count; k++)
                {
                    IFieldInfo fcField = fcFields.Get(k);
                    if (fcField.FieldType == gviFieldType.gviFieldFID || fcField.FieldType == gviFieldType.gviFieldGeometry || fcField.FieldType == gviFieldType.gviFieldBlob)
                    {
                        continue;
                    }
                    if (fcField.RegisteredRenderIndex)
                    {
                        this.lb_RenderField.Items.Add(new myFieldInfo(fcField));
                        RegRenderIndexFields.Add(fcField.Name);
                        RegRenderIndexHash.Add(fcField.Name, fcField);
                    }
                    else
                    {
                        this.lb_RenderAllField.Items.Add(new myFieldInfo(fcField));
                    }
                }
            }
        }