Let It* Snow
December 24, 2014*) It – meaning your app
Today is the 24th of December. It’s Christmas. But no snow to be seen anywhere, which is really rare for Austria.
In fact, that’s what my weather app looked like today.
9° Celsius (48° Fahrenheit) … that’s just not OK for the 24th of December.
So, I decided to fix that weather issue … to the extent possible.
Newport’s ParticleControl
My Windows and Windows Phone Framework Newport offers an easy to use ParticleControl, which I decided to use as a snow cannon.
Even though, temperatures are still to high. The app (well yes - another app, but still …) displays a nice snow animation.
Here’s the XAML for the page hosting the ParticleControl using the above screenshot from the weather app.
<Grid> <Grid.Background> <ImageBrush ImageSource="Assets/Weather.jpg"/> </Grid.Background> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <Grid Grid.Row="0" Background="Blue"> <n:ParticleControl OnNewParticleCommand="{Binding Path=InitParticleCommand}" MaxParticleCount="70" Speed="2" Life="150" LifeVariance="200" StartColor="White" EndColor="White" IsRunning="True"/> </Grid> </Grid>
And this is the code used in the ViewModel’s InitParticleCommand to steer the snow flakes.
public ParticlesViewModel() { InitParticleCommand = new GenericActionCommand<Particle>(p => { p.Position.X = RandomData.GetDouble(500); p.Position.Y = 0; p.Velocity.Y = Math.Abs(p.Velocity.Y); }); }
If you liked this little demo, please check out the Newport Development framework for Windows Phone and Windows Store Apps.
Merry Christmas!