Exemple #1
0
        protected override InteractiveResult MouseUpCore(InteractionArguments interactionArguments)
        {
            if (IsShiftKeyDown == true)
            {
                PolygonShape newPolygonShape = (PolygonShape)EditShapesLayer.InternalFeatures[0].GetShape();
                RingShape    ringShape       = new RingShape();

                foreach (Feature feature in controlPoints)
                {
                    PointShape controlPointShape = (PointShape)feature.GetShape();
                    if (feature.ColumnValues["nodetype"] == "special")
                    {
                        BaseShape  baseShape  = snappingFeature.GetShape();
                        PointShape pointShape = baseShape.GetClosestPointTo(controlPointShape, GeographyUnit.DecimalDegree);
                        ringShape.Vertices.Add(new Vertex(pointShape.X, pointShape.Y));
                    }
                    else
                    {
                        ringShape.Vertices.Add(new Vertex(controlPointShape.X, controlPointShape.Y));
                    }
                }

                newPolygonShape.OuterRing = ringShape;

                Feature newFeature = new Feature(newPolygonShape, EditShapesLayer.InternalFeatures[0].ColumnValues);

                EditShapesLayer.Open();
                EditShapesLayer.EditTools.BeginTransaction();
                EditShapesLayer.InternalFeatures.Clear();
                EditShapesLayer.InternalFeatures.Add(newFeature);
                EditShapesLayer.EditTools.CommitTransaction();
                EditShapesLayer.Close();
            }
            return(base.MouseUpCore(interactionArguments));
        }
        public Collection <Feature> GetEditingFeaturesInterseting(BaseShape baseShape)
        {
            BaseShape searchArea = baseShape;

            if (baseShape.GetWellKnownType() == WellKnownType.Point)
            {
                PointShape worldCoordinate  = (PointShape)baseShape;
                double     searchTorlerence = 15 * MapArguments.CurrentResolution;
                searchArea = new RectangleShape(worldCoordinate.X - searchTorlerence,
                                                worldCoordinate.Y + searchTorlerence, worldCoordinate.X + searchTorlerence,
                                                worldCoordinate.Y - searchTorlerence);
            }

            Collection <Feature> features = new Collection <Feature>();

            lock (EditShapesLayer)
            {
                if (!EditShapesLayer.IsOpen)
                {
                    EditShapesLayer.Open();
                }
                var intersectingFeatures = EditShapesLayer.QueryTools.GetFeaturesIntersecting(searchArea, EditShapesLayer.GetDistinctColumnNames());
                foreach (var feature in intersectingFeatures)
                {
                    features.Add(feature);
                }
            }

            return(features);
        }
Exemple #3
0
        //Overrides the DrawCore function.
        protected override void DrawCore(GeoCanvas canvas)
        {
            //Draws the Edit Shapes as default.
            Collection <SimpleCandidate> labelsInAllLayers = new Collection <SimpleCandidate>();

            EditShapesLayer.Open();
            EditShapesLayer.Draw(canvas, labelsInAllLayers);
            canvas.Flush();

            //Draws the control points.
            ExistingControlPointsLayer.Open();
            Collection <Feature> controlPoints = ExistingControlPointsLayer.FeatureSource.GetAllFeatures(ReturningColumnsType.AllColumns);

            //Loops thru the control points.
            foreach (Feature feature in controlPoints)
            {
                //Looks at the value of "state" to draw the control point as dragged or not.
                if (feature.ColumnValues["state"] != "selected")
                {
                    Feature[] features = new Feature[1] {
                        feature
                    };
                    controlPointStyle.Draw(features, canvas, labelsInAllLayers, labelsInAllLayers);
                }
                else
                {
                    Feature[] features = new Feature[1] {
                        feature
                    };
                    draggedControlPointStyle.Draw(features, canvas, labelsInAllLayers, labelsInAllLayers);
                }
            }
        }
        public bool CheckIsInHitArea(Vertex hitPoint)
        {
            double         resolution         = MapArguments.CurrentResolution;
            double         searchingTolerance = resolution * 14 * searchingToleranceRatio;
            RectangleShape searchingArea      = new RectangleShape(hitPoint.X - searchingTolerance, hitPoint.Y + searchingTolerance, hitPoint.X + searchingTolerance, hitPoint.Y - searchingTolerance);

            if (!EditShapesLayer.IsOpen)
            {
                EditShapesLayer.Open();
            }
            var features = EditShapesLayer.QueryTools.GetFeaturesIntersecting(searchingArea, EditShapesLayer.GetDistinctColumnNames());

            return(features.Count != 0);
        }
Exemple #5
0
        //Overrides the DrawCore function.
        protected override void DrawCore(GeoCanvas canvas)
        {
            //Draws the Edit Shapes as default.
            Collection <SimpleCandidate> labelsInAllLayers = new Collection <SimpleCandidate>();

            EditShapesLayer.Open();
            EditShapesLayer.Draw(canvas, labelsInAllLayers);
            canvas.Flush();

            //Draws the control points.
            ExistingControlPointsLayer.Open();
            Collection <Feature> controlPoints = ExistingControlPointsLayer.FeatureSource.GetAllFeatures(ReturningColumnsType.AllColumns);

            //Loops thru the control points.
            foreach (Feature feature in controlPoints)
            {
                //Looks at the value of "state" to draw the control point as dragged or not.
                if (feature.ColumnValues["state"] != "selected")
                {
                    Feature[] features = new Feature[1] {
                        feature
                    };
                    controlPointStyle.Draw(features, canvas, labelsInAllLayers, labelsInAllLayers);
                }
                else
                {
                    Feature[] features = new Feature[1] {
                        feature
                    };
                    draggedControlPointStyle.Draw(features, canvas, labelsInAllLayers, labelsInAllLayers);

                    PointShape pointShape        = feature.GetShape() as PointShape;
                    PointShape closestPointShape = referenceShape.GetClosestPointTo(pointShape, GeographyUnit.DecimalDegree);
                    //Draws the closest point on the reference shape and the distance to it from the dragged control point.
                    if (closestPointShape != null)
                    {
                        double       Dist         = System.Math.Round(closestPointShape.GetDistanceTo(pointShape, GeographyUnit.DecimalDegree, DistanceUnit.Meter));
                        ScreenPointF ScreenPointF = ExtentHelper.ToScreenCoordinate(canvas.CurrentWorldExtent, pointShape, canvas.Width, canvas.Height);
                        canvas.DrawTextWithScreenCoordinate(System.Convert.ToString(Dist) + " m", new GeoFont("Arial", 12, DrawingFontStyles.Bold), new GeoSolidBrush(GeoColor.StandardColors.Black),
                                                            ScreenPointF.X + 35, ScreenPointF.Y, DrawingLevel.LabelLevel);
                        canvas.DrawEllipse(closestPointShape, 12, 12, new GeoSolidBrush(GeoColor.StandardColors.Purple), DrawingLevel.LevelFour);
                    }
                }
            }
        }
Exemple #6
0
        //Overrides the DrawCore function.
        protected override void DrawCore(GeoCanvas canvas)
        {
            if (EditShapesLayer.InternalFeatures.Count > 1)
            {
                throw new NotImplementedException("Only allow one shape to be editing.");
            }

            //Draws the Edit Shapes as default.
            Collection <SimpleCandidate> labelsInAllLayers = new Collection <SimpleCandidate>();

            EditShapesLayer.Open();
            EditShapesLayer.Draw(canvas, labelsInAllLayers);
            canvas.Flush();

            ExistingControlPointsLayer.Open();
            Collection <Feature> ExistingControlPoints = ExistingControlPointsLayer.QueryTools.GetAllFeatures(new string[1] {
                "IsSelected"
            });

            ExistingControlPointsLayer.Close();

            //Loops thru the control points.
            for (int i = ExistingControlPoints.Count - 1; i >= 0; i--)
            {
                Feature feature = ExistingControlPoints[i];
                if (feature.ColumnValues.ContainsKey("IsSelected") && feature.ColumnValues["IsSelected"] == "true")
                {
                    Feature[] features = new Feature[1] {
                        feature
                    };
                    selectedControlPointStyle.Draw(features, canvas, labelsInAllLayers, labelsInAllLayers);
                }
                else
                {
                    Feature[] features = new Feature[1] {
                        feature
                    };
                    controlPointStyle.Draw(features, canvas, labelsInAllLayers, labelsInAllLayers);
                }
            }
        }
Exemple #7
0
        //Overrides the DrawCore function.
        protected override void DrawCore(GeoCanvas canvas)
        {
            //Draws the Edit Shapes as default.
            Collection <SimpleCandidate> labelsInAllLayers = new Collection <SimpleCandidate>();

            EditShapesLayer.Open();
            EditShapesLayer.Draw(canvas, labelsInAllLayers);
            canvas.Flush();

            //Gets the control points and draw its features according to the value of "IsSelected" column.
            this.ExistingControlPointsLayer.Open();
            Collection <Feature> ExistingControlPoints = this.ExistingControlPointsLayer.QueryTools.GetAllFeatures(new string[1] {
                "IsSelected"
            });

            ExistingControlPointsLayer.Close();

            //Loops thru the control points features and check for the value of "IsSelected" collumn.
            foreach (Feature feature in ExistingControlPoints)
            {
                if (feature.ColumnValues.ContainsKey("IsSelected") && feature.ColumnValues["IsSelected"] == "true")
                {
                    Feature[] features = new Feature[1] {
                        feature
                    };
                    selectedControlPointStyle.Draw(features, canvas, labelsInAllLayers, labelsInAllLayers);
                }
                else
                {
                    Feature[] features = new Feature[1] {
                        feature
                    };
                    controlPointStyle.Draw(features, canvas, labelsInAllLayers, labelsInAllLayers);
                }
            }
        }
Exemple #8
0
        //Overrides the DrawCore function to draw the Edit Layers, the vertices and tolerance ellipses of layer to snap to,
        //and the control points.
        protected override void DrawCore(GeoCanvas canvas)
        {
            //Sets the geography Unit used in FindNearestSnappingPoint function
            geographyUnit      = canvas.MapUnit;
            currentWorldExtent = canvas.CurrentWorldExtent;
            mapWidth           = canvas.Width;
            mapHeight          = canvas.Height;

            //Draws the Edit Shapes as default.
            Collection <SimpleCandidate> labelsInAllLayers = new Collection <SimpleCandidate>();

            EditShapesLayer.Open();
            EditShapesLayer.Draw(canvas, labelsInAllLayers);
            canvas.Flush();

            //Draw the vertices and tolerance ellipses of layer to snap to.
            toSnapInMemoryFeatureLayer.Open();
            Collection <Feature> toSnapPoints = toSnapInMemoryFeatureLayer.FeatureSource.GetAllFeatures(ReturningColumnsType.AllColumns);

            toSnapInMemoryFeatureLayer.Close();
            foreach (Feature feature in toSnapPoints)
            {
                PolygonShape polygonShape = (PolygonShape)feature.GetShape();

                foreach (Vertex vertex in polygonShape.OuterRing.Vertices)
                {
                    //Draws the vertex.
                    PointShape pointShape = new PointShape(vertex);
                    canvas.DrawEllipse(pointShape, 5, 5, new GeoSolidBrush(GeoColor.StandardColors.Black), DrawingLevel.LevelOne);

                    //Draws the tolerance ellipse.
                    if (toleranceType == ToleranceCoordinates.Screen)
                    {
                        ScreenPointF screenPointF = ExtentHelper.ToScreenCoordinate(canvas.CurrentWorldExtent, pointShape, canvas.Width, canvas.Height);
                        canvas.DrawEllipse(screenPointF, tolerance * 2, tolerance * 2, new GeoPen(GeoColor.StandardColors.Black), new GeoSolidBrush(), DrawingLevel.LevelFour, 0, 0, PenBrushDrawingOrder.PenFirst);
                    }
                    else
                    {
                        EllipseShape ellipseShape = new EllipseShape(pointShape, tolerance, canvas.MapUnit, toleranceUnit);
                        canvas.DrawArea(ellipseShape, new GeoPen(GeoColor.StandardColors.Black), DrawingLevel.LevelOne);
                    }
                }
            }

            //Draws the control points.
            ExistingControlPointsLayer.Open();
            Collection <Feature> controlPoints = ExistingControlPointsLayer.FeatureSource.GetAllFeatures(ReturningColumnsType.AllColumns);

            ////Loops thru the control points.
            foreach (Feature feature in controlPoints)
            {
                //Looks at the value of "state" to draw the control point as dragged or not.
                Feature[] features = new Feature[1] {
                    feature
                };
                controlPointStyle.Draw(features, canvas, labelsInAllLayers, labelsInAllLayers);
            }

            foreach (Feature feature in SelectedControlPointLayer.InternalFeatures)
            {
                Feature[] features = new Feature[1] {
                    feature
                };
                draggedControlPointStyle.Draw(features, canvas, labelsInAllLayers, labelsInAllLayers);
            }
        }