No problem, before I saw your last reply, I realized the subject and
replaced frm by mapViewControl1 but the error:
mapViewControl1.Map Cannot be used in this context, because it lacks the get accessor
I viewed the source code of the MapViewControl.cs and modified the Map property from (private get) to (get)
and everything is well with building.
but when I run the program, I just see the white background of the MapViewControl (BackColor = white).
I traced (by debugging) the cursor and (the issue) was in the OnPaint event of the MapViewControl:
void OnPaint(PaintEventArgs e)
Graphics g = e.Graphics;
Graphics screenGraphics = e.Graphics;
g.SmoothingMode = SmoothingMode.AntiAlias;
if (DesignMode || _presenter ==
the _presenter is a MapPresenter object and it was null.
I then knew the initializing mapViewControl1.Map this way is better:
SharpMap.Data.Providers.ShapeFile.ShapeFileProvider prov =
SharpMap.Layers.GeometryLayer gl =
SharpMap.Map myMap =
myMap.Title = "Map1";
//Add layer to map
mapViewControl1.Map = myMap;
// Refresh the view
this way the _presenter object is not null and the execution continues...(we are in the OnPaint event of the MapViewControl)
while (_renderObjectQueue.Count > 0)
GdiRenderObject ro = _renderObjectQueue.Dequeue();
if (ro.State == RenderState.Unknown)
the _presenter.IsRenderingSelection is false so the if execution enters the if loop body and executes g.Clear(BackColor)
and then the while loop condition:
_renderObjectQueue.Count is zero in my case so the while loop ends with no one loop
and finally, the painting is not done
consequently I see that white background image
I have no building errors but also the ShapeFile is not rendered.
Does any one of you has a working shapefile example to give the source code of?
I need that please, else, I have to go back to V0.9 which I don't want to.