Exemplo n.º 1
0
        /// <summary>
        /// 保存字段更改
        /// </summary>
        public void SaveFieldChange()
        {
            ILayerFields pLayerFields = (ILayerFields)m_pCurrentLayer;

            if (cboFields == null)
            {
                return;
            }
            cboFields.Items.Clear();
            cboFields.Text = null;
            //遍历所有的Item,并根据其Checked属性设置字段的显示与否
            for (int i = 0; i < lstFieldsView.Items.Count; i++)
            {
                IField pField;
                pField = lstFieldsView.Items[i].Tag as IField;
                IFieldInfo   pFieldInfo = pLayerFields.get_FieldInfo(i);
                ListViewItem fieldItem  = lstFieldsView.Items[i];
                pFieldInfo.Visible = fieldItem.Checked;
                if (fieldItem.Checked)
                {
                    cboFields.Items.Add(fieldItem.Name);
                }
            }
            if (cboFields.Items.Count > 0)
            {
                cboFields.SelectedIndex = 0;
            }
        }
Exemplo n.º 2
0
        private void LayerDisplaySetCtrl_Load(object sender, EventArgs e)
        {
            this.chkShowMapTip.Checked = this.ilayer_0.ShowTips;
            if (this.ilayer_0 is ILayerEffects)
            {
                this.txtPercent.Text = (this.ilayer_0 as ILayerEffects).Transparency.ToString();
            }
            else
            {
                this.txtPercent.Enabled = false;
            }
            if (this.ilayer_0 is IFeatureLayer)
            {
                this.chkScaleSymbols.Checked = (this.ilayer_0 as IFeatureLayer2).ScaleSymbols;
                this.chkScaleSymbols.Enabled = true;
                this.chkShowMapTip.Enabled   = true;
            }
            else
            {
                this.chkScaleSymbols.Enabled = false;
                this.chkShowMapTip.Enabled   = true;
            }
            ILayerFields fields = this.ilayer_0 as ILayerFields;

            this.cboFields.Properties.Items.Clear();
            this.cboFields.Properties.Items.Add("<无>");
            if (this.ilayer_0 is IHotlinkContainer)
            {
                int    num2         = 0;
                string hotlinkField = (this.ilayer_0 as IHotlinkContainer).HotlinkField;
                this.HyperLinkGroup.Visible = true;
                for (int i = 0; i < fields.FieldCount; i++)
                {
                    IField     field = fields.get_Field(i);
                    IFieldInfo info  = fields.get_FieldInfo(i);
                    if ((field.Type == esriFieldType.esriFieldTypeString) && info.Visible)
                    {
                        this.cboFields.Properties.Items.Add(new FieldWrapEx(field, info));
                        if (field.Name == hotlinkField)
                        {
                            num2 = this.cboFields.Properties.Items.Count - 1;
                        }
                    }
                }
                this.cboFields.SelectedIndex         = num2;
                this.rdoHyperLinkeType.SelectedIndex = (int)(this.ilayer_0 as IHotlinkContainer).HotlinkType;
            }
            else
            {
                this.HyperLinkGroup.Visible = false;
            }
            this.bool_0 = true;
        }
        private bool getElevationTableAndField(ref Dictionary <int, string> FeatureLayerIDAndFieldNamesList, ref List <string> ElevationLayerNames)
        {
            IMap map = ArcMap.Document.FocusMap;
            // get the elevation layers in the focus map
            int        iLayerPos  = 0; //relying on layer index
            IEnumLayer enumLayers = map.get_Layers(null, true);
            ILayer     pLayer     = enumLayers.Next();

            while (pLayer != null)
            {
                iLayerPos++;//use the TOC index
                if (pLayer is ICadastralFabricSubLayer2)
                {
                    pLayer = enumLayers.Next();
                    continue;
                }
                if (!(pLayer is IFeatureLayer))
                {//filter for feature layers only
                    pLayer = enumLayers.Next();
                    continue;
                }

                ILayerFields pLyrFlds = pLayer as ILayerFields;
                for (int i = 0; i < pLyrFlds.FieldCount; i++)
                {
                    if (pLyrFlds.get_Field(i).Type == esriFieldType.esriFieldTypeDouble)
                    {
                        IFieldInfo pFldInfo = pLyrFlds.get_FieldInfo(i);
                        if (!pFldInfo.Visible)
                        {
                            continue;
                        }

                        string sFieldName = pLyrFlds.get_Field(i).Name;
                        if (sFieldName.ToLower().Contains("elevation") || sFieldName.ToLower() == ("z") || sFieldName.ToLower().Contains("height"))
                        {
                            if (!FeatureLayerIDAndFieldNamesList.ContainsKey(iLayerPos))
                            {
                                FeatureLayerIDAndFieldNamesList.Add(iLayerPos, sFieldName);
                                ElevationLayerNames.Add(pLayer.Name);
                            }
                            else
                            {
                                FeatureLayerIDAndFieldNamesList[iLayerPos] += "," + sFieldName;
                            }
                        }
                    }
                }
                pLayer = enumLayers.Next();
            }
            return(false);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 初始化字段内容
        /// </summary>
        private void InitLayerFields()
        {
            IFields      pFields;
            ListViewItem fieldItem;

            pFields = m_pCurrentLayer.FeatureClass.Fields; //获取当前图层的所有字段
            ILayerFields pLayerFields = (ILayerFields)m_pCurrentLayer;

            //遍历并获取每个字段
            for (int i = 0; i < pFields.FieldCount; i++)
            {
                //根据字段属性设置Item
                fieldItem = new ListViewItem();
                IField     pField     = pFields.get_Field(i);
                IFieldInfo pFieldInfo = pLayerFields.get_FieldInfo(i);
                fieldItem.Name    = pField.Name;
                fieldItem.Text    = pField.Name;
                fieldItem.Tag     = pField;
                fieldItem.Checked = pFieldInfo.Visible;
                //设置Item的SubItems
                string[] subItems = new string[5];
                subItems[0] = pField.AliasName;
                subItems[1] = GetFieldType(pField.Type);
                subItems[2] = pField.Length.ToString();
                subItems[3] = pField.Precision.ToString();
                subItems[4] = pField.Scale.ToString();
                fieldItem.SubItems.AddRange(subItems);
                //添加Item到ListView
                lstFieldsView.Items.Add(fieldItem);
                if (fieldItem.Checked)
                {
                    cboFields.Items.Add(fieldItem.Name);
                }
            }
            if (cboFields.Items.Count > 0)
            {
                cboFields.SelectedIndex = 0;
            }
        }
Exemplo n.º 5
0
        private void ReadFieldInfo()
        {
            IDomain           domain       = null;
            ICodedValueDomain domain2      = null;
            ILayerFields      featureLayer = this.FeatureLayer as ILayerFields;

            for (int i = 0; i < featureLayer.FieldCount; i++)
            {
                string     str;
                IFieldInfo info;
                FieldInfo  info2;
                IField     field = featureLayer.get_Field(i);
                if (field.Required)
                {
                    if ((featureLayer is IFDOGraphicsLayer) && (string.Compare(field.Name, "SymbolID", true) == 0))
                    {
                        str = (field.Type == esriFieldType.esriFieldTypeString)
                            ? string.Format("(长度={0})", field.Length)
                            : "";
                        info  = featureLayer.get_FieldInfo(i);
                        info2 = new FieldInfo
                        {
                            FieldName       = "SymbolID",
                            TypeDescription = RowOperator.GetFieldTypeString(field.Type) + str,
                            IsNull          = field.IsNullable,
                            IsVisible       = info.Visible,
                            LayerFieldAlias = info.Alias
                        };
                        this.m_listInfo.Add(info2);
                        this.m_sortAliaslistInfo.Add(info2.LayerFieldAlias, info2);
                        this.m_sortnamelistInfo.Add(info2.FieldName, info2);
                    }
                }
                else if (field.Editable &&
                         ((((field.Type != esriFieldType.esriFieldTypeGeometry) &&
                            (field.Type != esriFieldType.esriFieldTypeBlob)) &&
                           (field.Type != esriFieldType.esriFieldTypeRaster)) &&
                          (field.Type != esriFieldType.esriFieldTypeOID)))
                {
                    str = (field.Type == esriFieldType.esriFieldTypeString)
                        ? string.Format("(长度={0})", field.Length)
                        : "";
                    info  = featureLayer.get_FieldInfo(i);
                    info2 = new FieldInfo
                    {
                        FieldName       = field.Name,
                        TypeDescription = RowOperator.GetFieldTypeString(field.Type) + str,
                        IsNull          = field.IsNullable,
                        IsVisible       = info.Visible,
                        LayerFieldAlias = info.Alias
                    };
                    domain = field.Domain;
                    if ((domain != null) && (domain is ICodedValueDomain))
                    {
                        domain2 = domain as ICodedValueDomain;
                        List <string> list = new List <string>();
                        if (field.IsNullable)
                        {
                            list.Add("<空>");
                        }
                        for (int j = 0; j < domain2.CodeCount; j++)
                        {
                            list.Add(domain2.get_Name(j));
                        }
                        info2.CodeDomainList = list;
                    }
                    this.m_listInfo.Add(info2);
                    this.m_sortAliaslistInfo.Add(info2.LayerFieldAlias, info2);
                    this.m_sortnamelistInfo.Add(info2.FieldName, info2);
                }
            }
        }