Ejemplo n.º 1
0
 private void lb_RenderIndexGeo_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (this.lb_RenderIndexGeo.SelectedItems.Count > 0)
     {
         CheckIndexEdit mySelectIndex = this.lb_RenderIndexGeo.SelectedItems[0] as CheckIndexEdit;
         if (mySelectIndex != null)
         {
             if (mySelectIndex.ExistIndex != null)
             {
                 this.btn_RenderAdd.Enabled    = false;
                 this.btn_RenderDelete.Enabled = true;
             }
             else
             {
                 this.btn_RenderAdd.Enabled    = true;
                 this.btn_RenderDelete.Enabled = false;
             }
             if (mySelectIndex.NewIndex != null && mySelectIndex.NewIndex.IsInitail)
             {
                 this.SetRenderIndexControl(mySelectIndex.GeoFieldName, mySelectIndex.NewIndex);
                 this.btn_RenderCal.Enabled = true;
             }
             else
             {
                 this.btn_RenderCal.Enabled = false;
             }
         }
     }
     else
     {
         this.btn_RenderCal.Enabled = false;
     }
 }
Ejemplo n.º 2
0
 private void btn_RenderCal_Click(object sender, EventArgs e)
 {
     if (this.lb_RenderIndexGeo.SelectedItems.Count > 0 && (this.lb_RenderIndexGeo.SelectedItems[0] as CheckIndexEdit).NewIndex.IsInitail)
     {
         CheckIndexEdit   SelectIndexItem = this.lb_RenderIndexGeo.SelectedItems[0] as CheckIndexEdit;
         IRenderIndexInfo tempIndexInfo   = featureCls.CalculateDefaultRenderIndex(SelectIndexItem.GeoFieldName);
         SelectIndexItem.NewIndex.L1 = tempIndexInfo.L1;
         this.SetRenderIndexControl(SelectIndexItem.GeoFieldName, SelectIndexItem.NewIndex);
     }
 }
Ejemplo n.º 3
0
 private void btn_RenderAdd_Click(object sender, EventArgs e)
 {
     if (this.lb_RenderIndexGeo.SelectedItems.Count > 0)
     {
         CheckIndexEdit SelectIndexItem = this.lb_RenderIndexGeo.SelectedItems[0] as CheckIndexEdit;
         SelectIndexItem.NewIndex.IsInitail = true;
         this.SetRenderIndexControl(SelectIndexItem.GeoFieldName, SelectIndexItem.NewIndex);
         this.btn_RenderAdd.Enabled    = false;
         this.btn_RenderDelete.Enabled = true;
         this.btn_RenderCal.Enabled    = true;
     }
 }
Ejemplo n.º 4
0
 private void btn_RenderDelete_Click(object sender, EventArgs e)
 {
     if (this.lb_RenderIndexGeo.SelectedItems.Count > 0)
     {
         CheckIndexEdit SelectIndexItem = this.lb_RenderIndexGeo.SelectedItems[0] as CheckIndexEdit;
         SelectIndexItem.ExistIndex         = null;
         SelectIndexItem.NewIndex.IsInitail = false;
         SelectIndexItem.NewIndex.L1        = 0;
         this.tb_RenderGeoField.Text        = "";
         this.tb_RenderL1.Text         = "";
         this.btn_RenderAdd.Enabled    = true;
         this.btn_RenderDelete.Enabled = false;
         this.btn_RenderCal.Enabled    = false;
     }
 }
Ejemplo n.º 5
0
 private void btn_SpatialDelete_Click(object sender, EventArgs e)
 {
     if (this.lb_SpatialIndexGeo.SelectedItems.Count > 0 && (this.lb_SpatialIndexGeo.SelectedItems[0] as CheckIndexEdit).NewIndex.IsInitail)
     {
         CheckIndexEdit SelectGridIndexItem = this.lb_SpatialIndexGeo.SelectedItems[0] as CheckIndexEdit;
         SelectGridIndexItem.ExistIndex         = null;
         SelectGridIndexItem.NewIndex.IsInitail = false;
         SelectGridIndexItem.NewIndex.L1        = 0;
         SelectGridIndexItem.NewIndex.L2        = 0;
         SelectGridIndexItem.NewIndex.L3        = 0;
         this.ClearGridIndexControl();
         this.btn_SpatialAdd.Enabled    = true;
         this.btn_SpatialCal.Enabled    = false;
         this.btn_SpatialDelete.Enabled = false;
     }
 }
Ejemplo n.º 6
0
        private void btn_OK_Click(object sender, EventArgs e)
        {
            try
            {
                //属性索引
                foreach (string sDbIndexName in DelAttrIndexList)
                {
                    featureCls.DeleteDbIndex(sDbIndexName);
                    AttrIndexList.Remove(sDbIndexName);
                }
                for (int i = 0; i < this.lb_AttrIndex.Items.Count; i++)
                {
                    myAttrIndex oneIndexItem = this.lb_AttrIndex.Items[i] as myAttrIndex;
                    if (AttrIndexList.Contains(oneIndexItem.ToString()))
                    {
                        continue;
                    }
                    featureCls.AddDbIndex(oneIndexItem.dbIndex);
                }

                //空间索引
                for (int j = 0; j < this.lb_SpatialIndexGeo.Items.Count; j++)
                {
                    CheckIndexEdit oneIndexItem = this.lb_SpatialIndexGeo.Items[j] as CheckIndexEdit;
                    string         sGeoCol      = oneIndexItem.GeoFieldName;
                    if (oneIndexItem.ExistIndex == null && GridIndexHash.ContainsKey(sGeoCol))
                    {
                        featureCls.DeleteSpatialIndex(sGeoCol);
                    }
                    if (oneIndexItem.ExistIndex == null && oneIndexItem.NewIndex.IsInitail)
                    {
                        IGridIndexInfo NewIndexInfo = new GridIndexInfo();
                        NewIndexInfo.GeoColumnName = sGeoCol;
                        NewIndexInfo.L1            = oneIndexItem.NewIndex.L1;
                        NewIndexInfo.L2            = oneIndexItem.NewIndex.L2;
                        NewIndexInfo.L3            = oneIndexItem.NewIndex.L3;
                        featureCls.AddSpatialIndex(NewIndexInfo as IIndexInfo);
                    }
                    if (oneIndexItem.ExistIndex != null && !oneIndexItem.IsSameIndex())
                    {
                        featureCls.DeleteSpatialIndex(sGeoCol);
                        IGridIndexInfo NewIndexInfo = new GridIndexInfo();
                        NewIndexInfo.GeoColumnName = sGeoCol;
                        NewIndexInfo.L1            = oneIndexItem.NewIndex.L1;
                        NewIndexInfo.L2            = oneIndexItem.NewIndex.L2;
                        NewIndexInfo.L3            = oneIndexItem.NewIndex.L3;
                        featureCls.AddSpatialIndex(NewIndexInfo as IIndexInfo);
                    }
                }

                //渲染索引
                for (int k = 0; k < this.lb_RenderIndexGeo.Items.Count; k++)
                {
                    CheckIndexEdit oneIndexItem = this.lb_RenderIndexGeo.Items[k] as CheckIndexEdit;
                    string         sGeoCol      = oneIndexItem.GeoFieldName;
                    if (oneIndexItem.ExistIndex == null && RenderIndexHash.ContainsKey(sGeoCol))
                    {
                        featureCls.DeleteRenderIndex(sGeoCol);
                    }
                    if (oneIndexItem.ExistIndex == null && oneIndexItem.NewIndex.IsInitail)
                    {
                        IRenderIndexInfo NewIndexInfo = new RenderIndexInfo();
                        NewIndexInfo.GeoColumnName = sGeoCol;
                        NewIndexInfo.L1            = oneIndexItem.NewIndex.L1;
                        featureCls.AddRenderIndex(NewIndexInfo);
                    }
                    if (oneIndexItem.ExistIndex != null && !oneIndexItem.IsSameIndex())
                    {
                        featureCls.DeleteRenderIndex(sGeoCol);
                        IRenderIndexInfo NewIndexInfo = new RenderIndexInfo();
                        NewIndexInfo.GeoColumnName = sGeoCol;
                        NewIndexInfo.L1            = oneIndexItem.NewIndex.L1;
                        featureCls.AddRenderIndex(NewIndexInfo);
                    }
                }
                for (int l = 0; l < this.lb_RenderField.Items.Count; l++)
                {
                    myFieldInfo oneField = this.lb_RenderField.Items[l] as myFieldInfo;
                    if (RegRenderIndexFields.Contains(oneField.ToString()))
                    {
                        RegRenderIndexFields.Remove(oneField.ToString());
                        continue;
                    }
                    else
                    {
                        oneField.fieldinfo.RegisteredRenderIndex = true;
                        featureCls.ModifyField(oneField.fieldinfo);
                    }
                }
                if (RegRenderIndexFields.Count > 0)
                {
                    foreach (string sFieldName in RegRenderIndexFields)
                    {
                        IFieldInfo delField = RegRenderIndexHash[sFieldName] as IFieldInfo;
                        delField.RegisteredRenderIndex = false;
                        featureCls.ModifyField(delField);
                    }
                }
                MessageBox.Show("保存成功!");
            }
            catch (Exception ex)
            {
                MessageBox.Show("保存失败!" + ex.ToString());
            }
            finally
            {
                featureCls.LockType = gviLockType.gviLockSharedSchema;
                this.Close();
            }
        }
Ejemplo n.º 7
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));
                    }
                }
            }
        }