ThinkGeo.com    |     Documentation    |     Premium Support

Editing Multi-Line

Hi There,


I have a probem is that when i get to edit a Multi-Line (it looks like a curve on the map) it doesnt become editable as expcted, i.e. each joint point in the multi-line becomes editable (Since the multi-line contains X number of lines).. 


What I would like to achieve is to make the Multi-Line feature editable as whole feature from two only two points (start and end points) while keeping the curvy look of the feature!


Hope this makes sense and would appreacite if anyone can advise on how I can do this.


 


Many Thanks, Mos


 



Mostafa,


Thanks for your post and welcome you to ThinkGeo desktop discussion forum.
I think we may need to write our own logic to calculate the control points in the EditInterativeOverlay, I wrote a sample for you , hope it helps. Please take a try and let me know if any problems.

public class MyOwnEditInterativeOverlay : EditInteractiveOverlay
    {
        public MyOwnEditInterativeOverlay()
            : base()
        {
        }

        protected override System.Collections.Generic.IEnumerable<Feature> CalculateVertexControlPointsCore(Feature feature)
        {
            Collection<Feature> returnValues = new Collection<Feature>();

            if (feature.GetWellKnownType() == WellKnownType.Multiline)
            {
                MultilineShape multiLineShape = feature.GetShape() as MultilineShape;
                for (int j = 0; j < multiLineShape.Lines.Count; j++)
                {
                    LineShape lineShape = multiLineShape.Lines[j];

                    returnValues.Add(new Feature(lineShape.Vertices[0]));
                    returnValues.Add(new Feature(lineShape.Vertices[lineShape.Vertices.Count - 1]));

                }
            }
            else
            {
                return  base.CalculateVertexControlPointsCore(feature);
            }

            return returnValues;
        }
    }

Use the code like this:

winformsMap1.TrackOverlay.TrackMode = TrackMode.None;
winformsMap1.EditOverlay = new MyOwnEditInterativeOverlay();
 
winformsMap1.EditOverlay.CanAddVertex = false;
winformsMap1.EditOverlay.CanDrag = false;
winformsMap1.EditOverlay.CanRemoveVertex = false;
 
LineShape line1 = new LineShape();
line1.Vertices.Add(new Vertex(60, 60));
line1.Vertices.Add(new Vertex(70, 70));
 
LineShape line2 = new LineShape();
line2.Vertices.Add(new Vertex(80, 70));
line2.Vertices.Add(new Vertex(85, 60));
line2.Vertices.Add(new Vertex(95, 80));
 
MultilineShape multiLineShape = new MultilineShape();
multiLineShape.Lines.Add(line1);
multiLineShape.Lines.Add(line2);
 
Feature feature = new Feature(multiLineShape);
 
winformsMap1.EditOverlay.EditShapesLayer.InternalFeatures.Add(feature);
winformsMap1.EditOverlay.CalculateAllControlPoints();
 
winformsMap1.Refresh();

Any more questions please feel free to let me know.
Thanks.
Yale