Ejemplo n.º 1
0
 void ReadJSONField(Newtonsoft.Json.Linq.JToken properties, XLayer layer)
 {
     if (properties != null)
     {
         foreach (Newtonsoft.Json.Linq.JProperty fa in properties)
         {
             //Newtonsoft.Json.Linq.JProperty fieldname = (Newtonsoft.Json.Linq.JProperty)fa.ElementAt(0);
             //var fieldname = (string)fa.ElementAt(0);
             string name     = fa.Name;
             XField newfield = new XField(typeof(String), name);
             if (!(layer.Fields.Contains(newfield)))//图层若不存在该field则加入该field
             {
                 layer.Fields.Add(newfield);
             }
         }
     }
 }
Ejemplo n.º 2
0
        private void AddField_Click(object sender, EventArgs e)
        {
            string fieldname = textBox_add.Text;
            XField addfield  = new XField(Type.GetType("System.String"), fieldname);//默认为string类型

            layer.Fields.Add(addfield);
            //增加layer每个feature要素对应需要增加字段的值
            int atrlength = layer.Features[0].Attribute.Values.Count;

            foreach (XFeature feature in layer.Features)
            {
                if (feature.Attribute.Values.Count != atrlength)
                {
                    continue;                       //如果已经修改过feature的属性则继续下一个层循环
                }
                feature.Attribute.Values.Add(null); //增加对应字段的属性值 初始为null
            }
            FormAttribute form = new FormAttribute(layer);

            form.Show();
            MessageBox.Show(fieldname + " is successfully added into the layer's field");
        }
Ejemplo n.º 3
0
 public void AddField(XField field)
 {
 }