示例#1
0
        /// <summary>
        /// Get the dimension of the geometry
        /// </summary>
        /// <param name="geom">the geom to get the dimension for</param>
        /// <returns>dimension of the geometry</returns>
        private int GeometryOrder(FeatureGeometryFieldDescriptor geom)
        {
            var physicalType = geom.FieldType.PhysicalType;

            switch (physicalType)
            {
            case FeaturePhysicalFieldType.Annotation:
            case FeaturePhysicalFieldType.MultiAnnotation:
                return(0);

            case FeaturePhysicalFieldType.Point:
            case FeaturePhysicalFieldType.MultiPoint:
                return(1);

            case FeaturePhysicalFieldType.Curve:
            case FeaturePhysicalFieldType.MultiCurve:
                return(2);

            case FeaturePhysicalFieldType.Polygon:
            case FeaturePhysicalFieldType.MultiPolygon:
                return(3);

            default:
                return(10);
            }
        }
 /// <summary>
 /// Constructs the request
 /// </summary>
 /// <param name="sender">The originator of the request</param>
 /// <param name="feature">The feature (recipe-holder) to show details for</param>
 public LiteDisplayFeatureDetailsRequestMessage(Object sender, IFeatureRecipeHolder feature, FeatureGeometryFieldDescriptor geometryField = null, bool makeViewActive = false, bool startEditing = false)
     : base(sender)
 {
     RecipeHolders = new List <IFeatureRecipeHolder> {
         feature
     };
     SelectedGeometryFieldDescriptor = geometryField;
     StartEditing   = geometryField != null && startEditing;
     MakeViewActive = makeViewActive;
 }
        /// <summary>
        /// Returns an edit element for the specified fieldDescriptor
        /// </summary>
        private RedliningElement ElementFor(FeatureGeometryFieldDescriptor fieldDescriptor, IFeatureGeometry geometry)
        {
            RedliningElement redliningElement = null;
            var model     = this.DrawingModel;
            var selection = this.DrawingSelection;

            if (model != null && selection != null)
            {
                foreach (var element in model)
                {
                    if ((element.Tag as FeatureGeometryFieldDescriptor) == fieldDescriptor)
                    {
                        redliningElement = element;
                        break;
                    }
                }

                if (redliningElement != null)
                {
                    selection.Set(redliningElement);
                }
                else
                {
                    if (geometry != null)
                    {
                        // Set the geometry to the correct coordinate system
                        geometry = geometry.InCoordinateSystem(this.CoordinateSystem);

                        // Get the redlining element
                        redliningElement = RedliningElement.ElementFor(geometry);

                        // Make sure the element is decorated
                        MapView.EditGeometryLayer.DecorateElement(redliningElement);

                        model.Add(redliningElement);
                        selection.Set(redliningElement);
                    }
                    else
                    {
                        redliningElement = RedliningElement.Create(fieldDescriptor.FieldType.PhysicalType, CoordinateSystem);
                        MapView.EditGeometryLayer.NewElement(redliningElement);
                    }

                    // Make sure we are using the cache properly
                    redliningElement.Tag = fieldDescriptor;
                }
            }

            return(redliningElement);
        }
        /// <summary>
        /// Handles the stopping of editing geometry
        /// </summary>
        private void StopEditingGeometry(FeatureGeometryFieldDescriptor fieldDescriptor = null)
        {
            // Get the mapView to interact upon
            var mapView   = MapView;
            var editLayer = EditGeometryLayer;
            var model     = this.DrawingModel;
            var selection = this.DrawingSelection;

            IsEditing = false;

            if (model != null && selection != null)
            {
                selection.Clear();

                if (fieldDescriptor != null)
                {
                    RedliningElement elementToRemove = null;

                    foreach (var element in model.Elements())
                    {
                        if (element.Tag == fieldDescriptor)
                        {
                            elementToRemove = element;
                            break;
                        }
                    }

                    if (elementToRemove != null)
                    {
                        model.Remove(elementToRemove);
                    }
                }
                else
                {
                    // No specific geometry; just clear the model
                    ClearModel();
                }
            }

            if (editLayer != null)
            {
                // Make sure we explicitly cancel all interaction in case the last interaction
                // mode was activated by a New-Geometry action
                editLayer.StopInteraction();
            }
        }
        /// <summary>
        /// Handles the starting of editing geometry
        /// </summary>
        private void StartEditingGeometry(EditableFeature feature, FeatureGeometryFieldDescriptor fieldDescriptor)
        {
            // Get the mapView to interact upon
            var mapView = MapView;

            // Make sure we stop editing geometry first
            StopEditingGeometry();

            if (mapView != null)
            {
                mapView.ClearSelection();

                if (EditFeature != feature)
                {
                    // A new feature; clear the model completely
                    ClearModel();
                }

                IsEditing        = false;
                this.EditFeature = null;

                if (feature != null && MapView != null)
                {
                    var geometry = feature[fieldDescriptor] as IFeatureGeometry;

                    // Set the edit properties
                    EditFeature = feature;
                    IsEditing   = true;

                    // Now do the thing, dependent on availability of a geometry
                    try
                    {
                        SettingUp = true;
                        var redliningElement = ElementFor(fieldDescriptor, geometry);
                    }
                    finally
                    {
                        SettingUp = false;
                    }
                }
            }
        }
示例#6
0
        /// <summary>
        /// Determines the geometry to start with
        /// </summary>
        private void DetermineStartWithFieldDescriptor()
        {
            FeatureGeometryFieldDescriptor startWith = null;
            FeatureGeometryFieldDescriptor backstop  = null;
            var startDim = -1;
            var backDim  = -1;

            foreach (FeatureGeometryFieldDescriptor geometryField in TableDescriptor.FieldDescriptors.Descriptors(FeatureFieldDescriptorType.Geometry))
            {
                var editabilityProperties = geometryField.EditabilityProperties;
                if (geometryField.FieldType.IsStructured && editabilityProperties.AllowUpdate)
                {
                    if (editabilityProperties.IsPrimary)
                    {
                        startWith = geometryField;
                        break;
                    }

                    var newOrder = GeometryOrder(geometryField);
                    if (editabilityProperties.IsMandatory)
                    {
                        // A mandatory field
                        if (startWith == null || startDim < newOrder)
                        {
                            startWith = geometryField;
                            startDim  = newOrder;
                        }
                    }
                    else if (backstop == null || backDim < newOrder)
                    {
                        backstop = geometryField;
                        backDim  = newOrder;
                    }
                }
            }

            PrimaryGeometryDescriptor = startWith ?? backstop;
        }
 /// <summary>
 /// Default constructor
 /// </summary>
 public LiteStopEditGeometryRequestMessage(object sender, FeatureGeometryFieldDescriptor fieldDescriptor = null)
     : base(sender)
 {
     FieldDescriptor = fieldDescriptor;
 }
示例#8
0
        /// <summary>
        /// Constructs the request
        /// </summary>
        /// <param name="sender">The originator of the request</param>
        /// <param name="feature">The feature (recipe-holder) to show details for</param>
        public LiteNewFeatureRequestMessage(Object sender, FeatureTableDescriptor tableDescriptor, FeatureGeometryFieldDescriptor geomDescriptor, IFeatureGeometry startWithGeometry = null, Feature attachToFeature = null)
            : base(sender)
        {
            this.TableDescriptor    = tableDescriptor;
            this.GeometryDescriptor = geomDescriptor;

            if (tableDescriptor.EditabilityProperties.AllowInsert)
            {
                var newFeature = tableDescriptor.NewTemplateFeature();

                if (geomDescriptor != null && startWithGeometry != null)
                {
                    StartedWithTrail = true;
                    newFeature[geomDescriptor.Name] = startWithGeometry;
                }

                Feature = new EditableFeature(newFeature, false, attachToFeature);
            }
        }
 /// <summary>
 /// Request editing the geometry
 /// </summary>
 public LiteStartEditGeometryRequestMessage(object sender, EditableFeature feature, FeatureGeometryFieldDescriptor field)
     : base(sender)
 {
     this.Feature         = feature;
     this.FieldDescriptor = field;
 }
 /// <summary>
 /// Constructs the request
 /// </summary>
 /// <param name="sender">The originator of the request</param>
 /// <param name="feature">The features to show details for</param>
 public LiteDisplayFeatureDetailsRequestMessage(Object sender, IList <IFeatureRecipeHolder> features, FeatureGeometryFieldDescriptor geometryField = null)
     : base(sender)
 {
     RecipeHolders = new List <IFeatureRecipeHolder>(features);
     SelectedGeometryFieldDescriptor = geometryField;
 }