Hello All,
I???m trying to create a multipart polyline and I am having trouble with it adding connection lines when I add it to the feature layer. I start by adding the line graphic to a PointCollection.
ObservableCollection<PointCollection> lpc = new ObservableCollection<PointCollection>();
PointCollection PC = new PointCollection();
void LineDrawingSurface_DrawComplete(object sender, DrawEventArgs e)
{
GraphicsLayer linegraphicsLayer = MyMap.Layers["LineDrawGraphicsLayer"] as GraphicsLayer;
ESRI.ArcGIS.Client.Graphic graphic = new ESRI.ArcGIS.Client.Graphic()
{
Geometry = e.Geometry,
Symbol = MyLineSymbol
};
linegraphicsLayer.Graphics.Add(graphic);
Polyline PL = graphic.Geometry as Polyline;
for (int i = 0; i < PL.Paths.Count; i++)
{
foreach (var mp in PL.Paths)
{
PC.Add(mp);
}
}
lpc.Add(PC);
}
Next I draw two lines on the graphic layer. This shows two separate graphics like I want. Now when I???m done and press the save button I create a polyline and set it to the pointcollection. Then I create a graphic and set is geometry to the polyline. Finally I add the graphic to the featurelayer and save edits.
private void btnSave2_Click(object sender, RoutedEventArgs e)
{
GraphicsLayer linegraphicsLayer = MyMap.Layers["LineDrawGraphicsLayer"] as GraphicsLayer;
linegraphicsLayer.ClearGraphics();
Polyline pl = new Polyline();
pl.Paths = lpc;
pl.SpatialReference = MyMap.SpatialReference;
Graphic graph = new Graphic();
graph.Geometry = pl;
FeatureLayer fLayer = MyMap.Layers["FeatureLayer"] as FeatureLayer;
fLayer.Graphics.Add(graph);
fLayer.EndSaveEdits += Insert_EndSaveEdits;
fLayer.SaveEdits();
}
Now this all works fine but the problem is the polyline is one continuous line and not two separate lines as a multipart record as originally draw on the graphic layer. I have attached a image of what it is doing.
So how can get it to skip the line in the middle when I???m writing the record?
Thanks,
Craig