Getting Started with .NET Gadgeteer by Simon Monk
Author:Simon Monk [Simon Monk]
Language: eng
Format: epub, pdf
Tags: COMPUTERS / Hardware / General
ISBN: 9781449328221
Publisher: Make
Published: 2012-05-06T16:00:00+00:00
Note
These numbers are not truly random, they are actually in a sequence and are an example of pseudorandom numbers. If you are interested, you can find more information on pseudorandom number generation here: http://en.wikipedia.org/wiki/Pseudorandom_number_generator.
Figure 3-3 shows the structure of the screen. You can see how the background, label, and two Rectangles make up the items to be displayed.
Figure 3-3. Screen Objects
The SetupUI method, which creates this structure, is quite similar to that of the previous project:
void SetupUI() { // initialize window mainWindow = display.WPFWindow; // setup the layout 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 tongue tongue = new Rectangle(tongueWidth, 40); tongue.Fill = new SolidColorBrush(Colors.Red); layout.Children.Add(tongue); //add the snowflake snowflake = new Rectangle(10, 10); snowflake.Fill = new SolidColorBrush(Colors.White); layout.Children.Add(snowflake); // add the text area label = new Text(); label.Height = 240; label.Width = 320; label.ForeColor = Colors.White; label.Font = Resources.GetFont(Resources.FontResources.NinaB); layout.Children.Add(label); Canvas.SetLeft(label, 0); Canvas.SetTop(label, 0); mainWindow.Child = layout; }
One difference between this and the previous project is that here, all parts of the display remain visible all of the time. There is no showing and hiding of controls.
SetupUI is called from the ProgramStarted method:
void ProgramStarted() { SetupUI(); Canvas.SetLeft(tongue, tongueLeftPosition); Canvas.SetTop(tongue, 200); Canvas.SetLeft(snowflake, snowflakeLeftPosition); Canvas.SetTop(snowflake, snowflakeTopPosition); joystickTimer.Tick += new GT.Timer.TickEventHandler(JoystickTimer_Tick); joystickTimer.Start(); snowFlakeTimer.Tick += new GT.Timer.TickEventHandler(SnowflakeTimer_Tick); snowFlakeTimer.Start(); }
The ProgramStarted then sets the positions of the tongue and snowflake rectangles on the layout Canvas using the methods SetLeft and SetTop. Later, we will use these same methods to change the positions of the tongue and snowflake. They will automatically handle any redrawing required, so we do not need to worry about erasing them from their old position before allowing them to be redrawn at their new one.
Finally, ProgramStarted creates the two timers and starts them.
Download
Getting Started with .NET Gadgeteer by Simon Monk.pdf
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Deep Learning with Python by François Chollet(16113)
The Mikado Method by Ola Ellnestam Daniel Brolund(13391)
Hello! Python by Anthony Briggs(13195)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(12354)
Dependency Injection in .NET by Mark Seemann(12212)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(10969)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(10818)
A Developer's Guide to Building Resilient Cloud Applications with Azure by Hamida Rebai Trabelsi(10540)
Grails in Action by Glen Smith Peter Ledbrook(10278)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(10216)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(9559)
Hit Refresh by Satya Nadella(9040)
Kotlin in Action by Dmitry Jemerov(8948)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(8686)
The Kubernetes Operator Framework Book by Michael Dame(8488)
Exploring Deepfakes by Bryan Lyon and Matt Tora(8308)
Robo-Advisor with Python by Aki Ranin(8261)
Practical Computer Architecture with Python and ARM by Alan Clements(8234)
Implementing Enterprise Observability for Success by Manisha Agrawal and Karun Krishnannair(8203)