Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
87 lines (83 sloc) 4.64 KB
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ViewModels;assembly=FsSnowGlobe"
xmlns:events="clr-namespace:Events;assembly=FsSnowGlobe"
xmlns:fsxaml="clr-namespace:FsXaml;assembly=FsXaml.Wpf.Blend"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
Title="F# Advent 2015 - Snow Globe" Height="760" Width="1280" WindowStyle="SingleBorderWindow" ResizeMode="CanMinimize" Background="Black" >
<Window.DataContext>
<local:MainViewModel />
</Window.DataContext>
<Window.Resources>
<events:MouseConverter x:Key="mouseConverter" />
</Window.Resources>
<Grid Background="#AA344759" Height="720">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseMove">
<fsxaml:EventToCommand Command="{Binding MouseCommand}" EventArgsConverter="{StaticResource mouseConverter}" />
</i:EventTrigger>
</i:Interaction.Triggers>
<Grid.RowDefinitions>
<RowDefinition Height="720" />
</Grid.RowDefinitions>
<Image Source="{Binding BackgroundImageSource}" Width="1280" Height="720" RenderOptions.BitmapScalingMode="HighQuality" />
<!--<Border Background="#AA555555" Opacity="0.7" />-->
<ItemsControl ItemsSource="{Binding MistParticles}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas Grid.Row="0" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Name="Canvas2" Width="1280" Height="720" Canvas.Left="0" Canvas.Top="0" Margin="0,0,0,0" Background="Transparent" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate >
<Image Source="Mist.png" Width="256" Height="256" Opacity="0.3" >
<Image.RenderTransform>
<TransformGroup>
<RotateTransform Angle="{Binding Rotation}" />
<ScaleTransform ScaleX="{Binding Scale}" ScaleY="{Binding Scale}" />
</TransformGroup>
</Image.RenderTransform>
</Image>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemContainerStyle>
<Style>
<Setter Property="Canvas.Left" Value="{Binding Path=X}" />
<Setter Property="Canvas.Top" Value="{Binding Path=Y}" />
<Setter Property="Image.Opacity" Value="{Binding Alpha}" />
<Setter Property="Image.RenderTransformOrigin" Value="0.5,0.5" />
</Style>
</ItemsControl.ItemContainerStyle>
</ItemsControl>
<ItemsControl ItemsSource="{Binding Particles}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas Grid.Row="0" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Name="Canvas" Width="1280" Height="720" Canvas.Left="0" Canvas.Top="0" Margin="0,0,0,0" Background="Transparent" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Image Source="SnowFlake.png" Width="8" Height="8">
<Image.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleX="{Binding Scale}" ScaleY="{Binding Scale}" />
<RotateTransform Angle="{Binding Rotation}" />
</TransformGroup>
</Image.RenderTransform>
</Image>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemContainerStyle>
<Style>
<Setter Property="Canvas.Left" Value="{Binding Path=X}" />
<Setter Property="Canvas.Top" Value="{Binding Path=Y}" />
<Setter Property="Image.Opacity" Value="{Binding Alpha}" />
</Style>
</ItemsControl.ItemContainerStyle>
</ItemsControl>
<Button Grid.Row="0" Command="{Binding LoadImage}" HorizontalAlignment="Left" VerticalAlignment="Bottom" Background="Transparent" Foreground="#AA777777">Load Background Image</Button>
</Grid>
</Window>