Time for action – scroll bars
In the Toolbox window, double-click on the VScrollBar control to add it to the form. Give it the following properties:
Name : vScrollBar1
Anchor : Top, Bottom, Right
LargeChange : 48
Location : 658, 27
Size : 17, 576
In the Toolbox window, double-click on the HScrollBar control to add it to the form. Give it the following properties:
Name : hScrollBar1
Anchor : Bottom, Left, Right
LargeChange : 48
Location : 184, 606
Size : 474, 17
Add the
FixScrollBarScales()
helper method to the MapEditor class:private void FixScrollBarScales() { Camera.ViewPortWidth = pctSurface.Width; Camera.ViewPortHeight = pctSurface.Height; Camera.Move(Vector2.Zero); vScrollBar1.Minimum = 0; vScrollBar1.Maximum = Camera.WorldRectangle.Height - Camera.ViewPortHeight; hScrollBar1.Minimum = 0; hScrollBar1.Maximum = Camera.WorldRectangle.Width - Camera.ViewPortWidth; }
Edit the
MapEditor_Load()
method to include a call toFixScrollBarScales...