Graphics Reference
In-Depth Information
Revision V.07 of the laboratory shows this animated clock, but its XAML has
been modified to make the hour hand move unnaturally fast to make it easier to
notice and test the animation's movement. We recommend the following exercises
to those who want to test their understanding of this section.
Inline Exercise 2.8: Study the XAML code of revision V.07, and then do the
following.
a. The minute hand is currently instantiated into the scene with no modeling
transformation. Add the necessary tagging to attach a transform group to it
and install the two rotation transforms (one to place it in the default 12:00
position, the other to facilitate animation). Add the necessary tagging to
the storyboard to animate it to rotate once per minute.
b. Set up animation of the second hand similarly.
c. Repair the animation of the hour hand so that it is accurate.
d. If you'd like to demo the clock to a friend, manually change the “default
position” rotate transformations to initialize the hands to better approxi-
mate the actual time at your location, and then commence execution and
watch the clock keep accurate time.
e. The ultimate solution for the clock-initialization problem is to use pro-
cedural code to initialize the clock. If you have access to Visual Studio
software and tutorials, take this XAML prototype and “productize” it by
adding initialization logic to create a fully functional WPF clock applica-
tion that shows the correct local time.
Inline Exercise 2.9: For a more thorough exercise in template-based model-
ing and animation, visit the online resources to download instructions for the
“Covered Wagon” programming exercise.
2.5.2 Dynamics via Procedural Code
Obviously, there is a limit to the richness of an application built using XAML
alone. Procedural code is necessary for the performance of processing, logic,
database access, and sophisticated interactivity. WPF developers use XAML for
what it's best suited (scene initialization, resource repository, simple animations,
etc.), and use procedural code to complete the specification of the application's
behavior. For example, in a real clock application, procedural code would be used
to determine the correct local time, to support alarm features, to respond to user
interaction, etc.
2.6 Supporting a Variety of Form Factors
The wide variety of raster display devices—ranging from small smartphone
screens to wall-size LCD monitors—poses a challenge to applications. These
problems are similar to the ones faced by a desktop application when its window's
 
 
 
 
Search WWH ::




Custom Search