Example #1
0
 private void btn_Remove_Click(object sender, EventArgs e)
 {
     if (this.lb_SelectFields.SelectedItems.Count > 0)
     {
         myFieldInfo selectField = this.lb_SelectFields.SelectedItems[0] as myFieldInfo;
         this.lb_SelectFields.Items.RemoveAt(this.lb_SelectFields.SelectedIndices[0]);
         this.lb_Fields.Items.Add(selectField);
     }
 }
Example #2
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();
            }
        }