Thursday, 27 February 2014

Winforms UI and the Double Buffered Panel

Session 2

The main task of this session was to link the new tile loader package to the WinForms user interface and display the new OS Terrain 50 data and existing Perlin noise terrain on the UI.  The first task was to remove the duplicated classes that were now in the tile loader package and to upgrade the UI so it can be used to display more than tile.  It also needs a bit of tidying up as it was developed fairly rapidly as a test bed for the A* algorithm.

The existing UI
Once the tile loading classes had been removed I reorganised the code behind to operate using the asynchronous tile loading package.  The main thing about user interfaces is that the main UI thread cannot be locked so the asynchronous calls to load tiles are crucial.

The other hurdle I faced was that the existing UI uses a basic panel to display the tile on.  When the UI scrolls the panel flickers so I had to create a new user control that is double buffered but inherits from the main .NET panel object.  This user control is then created dynamically on the UI loading so that it is tiled on the main pane. 

The second session overran slightly as I had underestimated how long it would take to change the UI over to using asynchronous calls. However, by the end of it I had the first sight of the terrain 50 data in the UI.  I had chosen the SU area tiles to begin the testing for two reasons, 1 it has a clear coast line which will help test the orientation is correct and 2 I am familiar with the area.

After session 2, the application only loads a single tile using the menu buttons so tomorrow I will be looking to load multiple tiles and change the UI slightly to load the data by double clicking the desired tile on the UI.  The background threads worked well and the performance is pretty good.  I will also be looking to improve the colour algorithm to give it more detail as the new data has a better fidelity which is not shown using the existing algorithm.
OS Terrain 50 in application


No comments:

Post a Comment