<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  x:Class="SDKSample.MyApp"
  xmlns:SampleControls="SampleControls"
  Startup="myAppStartup">
  <Application.Resources>

    <!-- Resources -->
    <DrawingBrush x:Key="MyGridBrushResource" 
      Viewport="0,0,10,10" ViewportUnits="Absolute" TileMode="Tile">
      <DrawingBrush.Drawing>
        <DrawingGroup>
          <DrawingGroup.Children>
            <GeometryDrawing Brush="#99FFFFFF">
              <GeometryDrawing.Geometry>
                <RectangleGeometry Rect="0,0,1,1" />
              </GeometryDrawing.Geometry>
            </GeometryDrawing>
            <GeometryDrawing Geometry="M0,0 L1,0 1,0.1, 0,0.1Z" Brush="#99CCCCFF" />
            <GeometryDrawing Geometry="M0,0 L0,1 0.1,1, 0.1,0Z" Brush="#99CCCCFF" />
          </DrawingGroup.Children>
        </DrawingGroup>
      </DrawingBrush.Drawing>
    </DrawingBrush>

    <GradientStopCollection x:Key="MyGlassGradientStopsResource">
      <GradientStop Color="White" Offset="0.2" />
      <GradientStop Color="Transparent" Offset="0.4" />
      <GradientStop Color="White" Offset="0.5" />
      <GradientStop Color="Transparent" Offset="0.75" />
      <GradientStop Color="White" Offset="0.9" />
      <GradientStop Color="Transparent" Offset="1.0" />
    </GradientStopCollection>

    <LinearGradientBrush x:Key="MyGlassBrushResource" StartPoint="0,0" EndPoint="1,1" Opacity="1" GradientStops="{StaticResource MyGlassGradientStopsResource}" />


    <!-- Styles & Templates -->
    <Style TargetType="{x:Type TextBlock}">
      <Setter Property="TextBlock.FontFamily" Value="Verdana" />
      <Setter Property="TextBlock.HorizontalAlignment" Value="Left" />
      <Setter Property="TextBlock.TextWrapping" Value="Wrap" />
      <Setter Property="TextBlock.FontWeight" Value="Normal" />
      <Setter Property="TextBlock.MaxWidth" Value="500" />
    </Style>

    <Style TargetType="{x:Type TextBlock}" x:Key="CodeTextBlockStyle">
      <Setter Property="TextBlock.FontFamily" Value="Courier New" />
      <Setter Property="TextBlock.HorizontalAlignment" Value="Left" />
      <Setter Property="TextBlock.TextWrapping" Value="Wrap" />
      <Setter Property="TextBlock.FontWeight" Value="Normal" />
      <Setter Property="TextBlock.MaxWidth" Value="500" />
    </Style>

    <Style x:Key="myIntroTextBorderStyle" TargetType="{x:Type Border}">
      <Setter Property="Border.Background">
        <Setter.Value>
          <LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
            <LinearGradientBrush.GradientStops>
              <GradientStop Offset="0.0" Color="#CCCCFF" />
              <GradientStop Offset="1.0" Color="White" />
            </LinearGradientBrush.GradientStops>
          </LinearGradientBrush>
        </Setter.Value>
      </Setter>
      <Setter Property="Border.HorizontalAlignment" Value="Stretch" />
      <Setter Property="Border.BorderBrush" Value="Gray" />
      <Setter Property="Border.BorderThickness" Value="1" />
      <Setter Property="Border.Margin" Value="0,0,0,40" />
      <Setter Property="Border.VerticalAlignment" Value="Top" />
    </Style>

    <Style TargetType="{x:Type Button}">


      <Setter Property="Button.MinWidth" Value="120" />
      <Setter Property="Button.Background" Value="#330033FF" />


      <Setter Property="Template">
        <Setter.Value>
          <ControlTemplate TargetType="{x:Type Button}">

            <StackPanel Background="Transparent">
              <Grid x:Name="mainPanel" RenderTransformOrigin="0.5,0.5">
                <Grid x:Name="decorativeGrid" Background="Transparent" VerticalAlignment="Stretch"
                  RenderTransformOrigin="0.5,0.5">
                  <ColumnDefinition Width="Auto"/>
                  <ColumnDefinition Width="*" />
                  <ColumnDefinition Width="Auto" />
                  <RowDefinition Height="5" />
                  <RowDefinition Height="*" />
                  <RowDefinition Height="5" />

                  <Rectangle x:Name="backgroundRectangle"
                   Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" Grid.RowSpan="3"
                   RadiusX="5" RadiusY="5"
                   HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                   Fill="White" />

                  <Rectangle x:Name="userBackgroundRectangle"
                    Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" Grid.RowSpan="3"
                    RadiusX="5" RadiusY="5"
                    HorizontalAlignment="Stretch" 
                    VerticalAlignment="Stretch"
                    Fill="{TemplateBinding Background}" />

                  <Rectangle Grid.Row="0" Grid.Column="0" Grid.RowSpan="3"
                    RadiusX="5" RadiusY="5"
                    Width="5" HorizontalAlignment="Left">
                    <Rectangle.Fill>
                      <LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
                        <LinearGradientBrush.GradientStops>
                          <GradientStop Offset="0.0" Color="Gray" />
                          <GradientStop Offset="1.0" Color="Transparent" />
                        </LinearGradientBrush.GradientStops>
                      </LinearGradientBrush>
                    </Rectangle.Fill>
                  </Rectangle>

                  <Rectangle Grid.Row="0" Grid.Column="2" Grid.RowSpan="3"
                    RadiusX="5" RadiusY="5"
                    Width="5" HorizontalAlignment="Right">
                    <Rectangle.Fill>
                      <LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
                        <LinearGradientBrush.GradientStops>
                          <GradientStop Offset="0.0" Color="Transparent" />
                          <GradientStop Offset="1.0" Color="Gray" />
                        </LinearGradientBrush.GradientStops>
                      </LinearGradientBrush>
                    </Rectangle.Fill>
                  </Rectangle>

                  <Rectangle x:Name="glassRectangle"
                    Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" Grid.RowSpan="3"
                    RadiusX="5" RadiusY="5"
                    Stroke="Gray" StrokeThickness="1"
                    HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                    <Rectangle.Fill>
                      <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1" Opacity="0.5">
                        <LinearGradientBrush.GradientStops>
                          <GradientStop Offset="0.0" Color="White" />
                          <GradientStop Offset="0.45" Color="Transparent" />
                          <GradientStop Offset="0.51" Color="#99000000" />
                          <GradientStop Offset="0.9" Color="#99FFFFFF" />
                          <GradientStop Offset="1" Color="#FFFFFFFF" />
                        </LinearGradientBrush.GradientStops>
                      </LinearGradientBrush>
                    </Rectangle.Fill>
                    <Rectangle.OpacityMask>
                      <RadialGradientBrush>
                        <RadialGradientBrush.GradientStops>
                          <GradientStop Offset="0.0" Color="Transparent" />
                          <GradientStop Offset="1.0" Color="Black" />
                        </RadialGradientBrush.GradientStops>
                      </RadialGradientBrush>
                    </Rectangle.OpacityMask>
                  </Rectangle>

                  <Rectangle Height="10" Margin="3" 
                    Grid.Column="1" Grid.Row="0" Grid.RowSpan="3" 
                    VerticalAlignment="Top" HorizontalAlignment="Stretch"
                    RadiusX="5" RadiusY="5">
                    <Rectangle.Fill>
                      <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                        <LinearGradientBrush.GradientStops>
                          <GradientStop Offset="0.0" Color="#99FFFFFF" />
                          <GradientStop Offset="1.0" Color="Transparent" />
                        </LinearGradientBrush.GradientStops>
                      </LinearGradientBrush>
                    </Rectangle.Fill>
                  </Rectangle>



                  <Grid.RenderTransform>
                    <TransformGroup>
                      <ScaleTransform />
                      <RotateTransform />
                    </TransformGroup>
                  </Grid.RenderTransform>
                </Grid>
                <ContentPresenter x:Name="myContentPresenter" 
                  Grid.Row="1" Grid.Column="1"
                  VerticalAlignment="Center" HorizontalAlignment="Center" 
          Margin="10" Content="{TemplateBinding Content}" />

                <Grid.RenderTransform>
                  <TransformGroup>
                    <ScaleTransform />
                    <RotateTransform />
                  </TransformGroup>
                </Grid.RenderTransform>
              </Grid>
            </StackPanel>

            <ControlTemplate.Triggers>
              <EventTrigger RoutedEvent="Mouse.MouseEnter">
                <EventTrigger.Actions>
                  <BeginStoryboard Name="mouseEnterBeginStoryboard" HandoffBehavior="Compose">
                    <Storyboard FillBehavior="Stop">
                      <DoubleAnimation Storyboard.TargetName="userBackgroundRectangle" 
                        Storyboard.TargetProperty="(Rectangle.Fill).(Brush.Opacity)"
                        To="0" Duration="0:0:0.1" FillBehavior="HoldEnd" />
                      <DoubleAnimation Storyboard.TargetName="userBackgroundRectangle" 
                        Storyboard.TargetProperty="(Rectangle.Fill).(Brush.Opacity)"
                        BeginTime="0:0:0.1" To="0.5" Duration="0:0:1" AutoReverse="True" 
                        RepeatBehavior="Forever" />
                      <DoubleAnimation Storyboard.TargetName="decorativeGrid" 
                        Storyboard.TargetProperty="(Grid.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"
                         By="-0.05" Duration="0:0:0.5" AutoReverse="True" 
                        RepeatBehavior="Forever" />
                      <DoubleAnimation Storyboard.TargetName="decorativeGrid" 
                        Storyboard.TargetProperty="(Grid.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"
                          By="-0.05" Duration="0:0:0.5" AutoReverse="True" 
                        RepeatBehavior="Forever" />
                    </Storyboard>
                  </BeginStoryboard>
                </EventTrigger.Actions>
              </EventTrigger>

              <EventTrigger RoutedEvent="Mouse.MouseLeave">
                <EventTrigger.Actions>
                  <StopStoryboard BeginStoryboardName="mouseEnterBeginStoryboard" />
                </EventTrigger.Actions>
              </EventTrigger>

              <EventTrigger RoutedEvent="ButtonBase.Click">
                <EventTrigger.Actions>
                  <BeginStoryboard>
                    <Storyboard>
                      <ColorAnimation 
                        Storyboard.TargetName="backgroundRectangle" 
                        Storyboard.TargetProperty="(Rectangle.Fill).(SolidColorBrush.Color)"
                        To="Lime" Duration="0:0:0.05" AutoReverse="True"  RepeatBehavior="3x" />
                      <DoubleAnimation 
                        Storyboard.TargetName="mainPanel" 
                        Storyboard.TargetProperty="(Grid.RenderTransform).(TransformGroup.Children)[1].(RotateTransform.Angle)"
                         From="0" To="360" Duration="0:0:0.5" />
                      <DoubleAnimation 
                        Storyboard.TargetName="mainPanel" 
                        Storyboard.TargetProperty="(Grid.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"
                         From="1" To="0.25" Duration="0:0:0.25" AutoReverse="True"  />
                      <DoubleAnimation 
                        Storyboard.TargetName="mainPanel" 
                        Storyboard.TargetProperty="(Grid.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"
                         From="1" To="0.25" Duration="0:0:0.25" AutoReverse="True"  />
                    </Storyboard>
                  </BeginStoryboard>
                </EventTrigger.Actions>
              </EventTrigger>
            </ControlTemplate.Triggers>

          </ControlTemplate>
        </Setter.Value>
      </Setter>
    </Style>

    <Style x:Key="CodeSnippetParagraph">
        <Setter Property="TextBlock.FontFamily" Value="Courier New" />
        <Setter Property="TextBlock.FontSize" Value="10" />
        <Setter Property="TextBlock.TextWrapping" Value="Wrap" />
        <Setter Property="TextBlock.Margin" Value="5,0,5,5" />
        <Setter Property="TextBlock.Background" Value="LightGray" />
      <Setter Property="TextBlock.TextAlignment" Value="Left" />
    </Style>

  </Application.Resources>
</Application>