WPFWindow
This example is fine, but we need to be able to display a little more than just the last image captured by the camera. We need to be able to display messages, such as what the interval is set to, and a message if there is an error writing to the SD card.
To accommodate this message area, we need to abandon our SimpleGraphics
interface to the display and use
something called WPFWindow
.
WPFWindow
is a class that allows
us to structure the screen into various different areas. In this case, the
whole screen as one area to display the image, and a small area near the
top of the screen, where sometimes a message will appear.
We are going to modify the “Spy Camera Test” project to display a little notification at the top of the screen whenever a photo is taken.
This program is now over 100 lines long, so you will probably want to open the “Spy Camera Test” project now.
Creating a UI Structure
The biggest change to the project is the way the display is used.
This is all contained in a new method called SetupUI
(UI for User Interface). This method
would normally appear in the code just after ProgramStarted
:
void SetupUI() { mainWindow = display.WPFWindow; // setup the layout Canvas layout = new Canvas(); Border background = new Border(); background.Background = new SolidColorBrush(Colors.Black); background.Height = 240; background.Width = 320; layout.Children.Add(background); Canvas.SetLeft(background, 0); Canvas.SetTop(background, 0); // add the image display imageDisplay = new Border(); ...
Get Getting Started with .NET Gadgeteer now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.