private void AddCustomVertex(Vertex trackVertex) { Feature currentFeature = GetCurrentFeature(); VertexAddingTrackInteractiveOverlayEventArgs vertexAddingTrackInteractiveOverlayEventArgs = new VertexAddingTrackInteractiveOverlayEventArgs(trackVertex, currentFeature, false); OnVertexAdding(vertexAddingTrackInteractiveOverlayEventArgs); if (vertexAddingTrackInteractiveOverlayEventArgs.Cancel) { return; } Vertices.Add(vertexAddingTrackInteractiveOverlayEventArgs.AddingVertex); currentFeature = GetCurrentFeature(); OnVertexAdded(new VertexAddedTrackInteractiveOverlayEventArgs(vertexAddingTrackInteractiveOverlayEventArgs.AddingVertex, currentFeature)); if (boundaryVertices.Count > 0) { if (Vertices.Count == 1) { Vertices.Add(boundaryVertices.First()); Vertices.Add(trackVertex); Vertices.Add(boundaryVertices.Last()); OnTrackStarted(new TrackStartedTrackInteractiveOverlayEventArgs(trackVertex)); } else { Vertices.RemoveAt(Vertices.Count - 2); Vertices.Add(trackVertex); Vertices.Add(boundaryVertices.Last()); } } }
//protected override void OnTrackStarted(TrackStartedTrackInteractiveOverlayEventArgs e) //{ // base.OnTrackStarted(e); // if (!isShiftKeyDown) // { // PointShape snappedPoint = GetSnappingPoint(e.StartedVertex, new Feature()); // if (snappedPoint != null) e.StartedVertex = new Vertex(snappedPoint); // } //} protected override void OnVertexAdding(VertexAddingTrackInteractiveOverlayEventArgs e) { base.OnVertexAdding(e); if (MouseDownCount == 1) { if (firstPoint == null) { firstPoint = GetSnappingPoint(e.AddingVertex, e.AffectedFeature, false); } //if (firstPoint != null) e.AddingVertex = new Vertex(firstPoint); } else { PointShape snappedPoint = GetSnappingPoint(e.AddingVertex, e.AffectedFeature, false); if (snappedPoint != null) { e.AddingVertex = new Vertex(snappedPoint); } firstPoint = null; } }