Example #1
0
        public override void GisForward(mapcontent map)
        {
            base.GisForward(map);
            Layer layer = map.GetLayerByName(this.layername);

            if (layer == null)
            {
                return;
            }
            FeatureCollection collection = layer.featuresource.features;

            collection.GetFeatureByID(createdfeatureid).visible = true;
        }
Example #2
0
        public override void GisRecover(mapcontent map)
        {
            base.GisRecover(map);
            Layer layer = map.GetLayerByName(this.layername);

            if (layer == null)
            {
                return;
            }
            FeatureCollection collection = layer.featuresource.features;

            foreach (int featureid in this.CopyFeatureIDs)
            {
                collection.GetFeatureByID(featureid).visible = false;
            }
        }
        private void treeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            var                 item          = (TreeViewItem)treeView.SelectedItem;
            int                 id            = Convert.ToInt32(item.Header);
            Feature             feature       = source.GetFeatureByID(id);
            Schema              schema        = feature.schema;
            List <DataRowModel> models        = new List <DataRowModel>();
            DataRowModel        geometrymodel = new DataRowModel();

            geometrymodel.字段名 = "地理要素类型";
            switch (feature.geometry.geometryType)
            {
            case OSGeo.OGR.wkbGeometryType.wkbPoint:
                geometrymodel.值 = "点";
                break;

            case OSGeo.OGR.wkbGeometryType.wkbLineString:
                geometrymodel.值 = "线";
                break;

            case OSGeo.OGR.wkbGeometryType.wkbMultiLineString:
                geometrymodel.值 = "多线";
                break;

            case OSGeo.OGR.wkbGeometryType.wkbPolygon:
                geometrymodel.值 = "面";
                break;

            case OSGeo.OGR.wkbGeometryType.wkbMultiPolygon:
                geometrymodel.值 = "多面";
                break;
            }
            //geometrymodel.数据类型 = layer.dataset.table.Columns[i].DataType.ToString();
            models.Add(geometrymodel);
            foreach (string attributename in feature.attributes.Keys)
            {
                DataRowModel model = new DataRowModel();
                model.字段名 = attributename;
                model.值   = feature.GetArrtributeByName(attributename).ToString();
                //OSGeo.OGR.FieldDefn fdn = null;
                //schema.fields.TryGetValue(attributename, out fdn);
                model.数据类型 = schema.GetArrtributeTypeByName(attributename);
                models.Add(model);
            }

            dataGrid.ItemsSource = models;

            try
            {
                //int id = Convert.ToInt32(item.Header);
                //MercuryGISData.Layer layer = ((TreeViewItem)item.Parent).DataContext as MercuryGISData.Layer;
                //System.Data.DataRow row = layer.GetDataRow(id);
                //List<string> fields = layer.GetFields();
                //List<DataRowModel> models = new List<DataRowModel>();
                //for (int i = 0; i < fields.Count; i++)
                //{
                //    DataRowModel model = new DataRowModel();
                //    model.字段名 = fields[i];
                //    model.值 = row[i].ToString();
                //    model.数据类型 = layer.dataset.table.Columns[i].DataType.ToString();
                //    models.Add(model);
                //}
                //dataGrid.ItemsSource = models;
            }
            catch (Exception)
            {
            }
        }