Geography Reference
In-Depth Information
We hook this event in our code and add some code to it to change the label. However, we
also need to use our Boolean variable to control it as we don't want it called every time our
map is refreshed (which will happen quite often).
Hook the event with the following code:
private void MapBox1MapRefreshed( object sender, EventArgs e)
{
if (_mapInitializing)
{
_mapInitializing = false ;
lblStatusText.Text = "MAP Initialized" ;
}
}
If you run it now, the status bar should update when the map has finished rendering.
Wiring up the Tool Buttons
Now we'll add the code for the two buttons that allow you to switch tools.
SharpMap has a number of different tool modes, from zooming and panning to drawing lines
and polygons over the top of your loaded map.
The two tools we'll use in this app are the zoom and pan tool, which is the default, and the
query tool.
Changing the tool is as simple as assigning a new value to the ActiveTool property of the
MapBox control on your form. The value to assign is any of the values from the
MapBox.Tools type enumeration.
Double-click on each button in turn and add the following code in each of their click handlers
as follows:
private void BtnZoomAndPanClick( object sender, System. EventArgs e)
{
mpbMapView.ActiveTool = MapBox . Tools .Pan;
}
private void BtnQueryCountyClick( object sender, System. EventArgs e)
 
Search WWH ::




Custom Search