示例#1
0
        //OK Loop
        public ZhFeatureClass GetZhFeatureClass(string featureClassName)
        {
            ZhFeatureClass ZHfeatcls = null;
            IFeatureClass  fc        = GetFeatureClass(featureClassName);

            if (fc != null)
            {
                switch (fc.ShapeType)
                {
                case esriGeometryType.esriGeometryPolygon:
                    ZHfeatcls = new ZhPolygonFeatureClass(fc);
                    break;

                case esriGeometryType.esriGeometryPolyline:
                case esriGeometryType.esriGeometryLine:
                    ZHfeatcls = new ZhPolylineFeatureClass(fc);
                    break;

                case esriGeometryType.esriGeometryPoint:
                case esriGeometryType.esriGeometryMultipoint:
                    ZHfeatcls = new ZhPointFeatureClass(fc);
                    break;
                }
            }
            return(ZHfeatcls);
        }
        private void GetFields(IFeatureClass fc)
        {
            ZhFeatureClass zhfeatclass = new ZhPolylineFeatureClass(fc);

            //获取分组字段集合
            List <string> fieldNameArray = zhfeatclass.GetFieldNames();

            if (fieldNameArray != null && fieldNameArray.Count > 0)
            {
                this.CB_Fields2.Items.Clear();
                foreach (string fd in fieldNameArray)
                {
                    this.CB_Fields2.Items.Add(fd);
                }
                this.CB_Fields2.Sorted = true;
            }
        }
        //选择源图层已改变 事件
        private void CB_LayerList2_SelectedIndexChanged(object sender, EventArgs e)
        {
            //初始化当前图层的列字段名称
            object obj = this.CB_LayerList2.SelectedItem;

            if (obj != null && obj is CommonComboBoxItem)
            {
                CommonComboBoxItem item        = obj as CommonComboBoxItem;
                IFeatureClass      fc          = item.Tag as IFeatureClass;
                ZhFeatureClass     zhfeatclass = new ZhPolylineFeatureClass(fc);
                //获取字段集合
                List <string> fieldNameArray = zhfeatclass.GetFieldNames();
                if (fieldNameArray != null && fieldNameArray.Count > 0)
                {
                    this.CB_Fields2.Items.Clear();
                    foreach (string fd in fieldNameArray)
                    {
                        this.CB_Fields2.Items.Add(fd);
                    }
                }
            }
        }
        //选择图层已改变 事件
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            //初始化当前图层的列字段名称
            object obj = this.comboBox1.SelectedItem;

            if (obj != null && obj is CommonComboBoxItem)
            {
                CommonComboBoxItem item           = obj as CommonComboBoxItem;
                IFeatureClass      fc             = item.Tag as IFeatureClass;
                ZhFeatureClass     zhfeatclass    = new ZhPolylineFeatureClass(fc);
                List <string>      fieldNameArray = zhfeatclass.GetFieldNames();
                if (fieldNameArray != null && fieldNameArray.Count > 0)
                {
                    this.CB_Fields.Items.Clear();
                    foreach (string fd in fieldNameArray)
                    {
                        this.CB_Fields.Items.Add(fd);
                    }
                }
                this.RefreshSpatialReferenceText(fc);
            }
            //---
        }