Microsoft® Surface® Live Stream Code Sample

ive Stream enables businesses to engage their customers face-to-face using the most recent and relevant Twitter™, Flickr®, and RSS newsfeeds.

C# (5.9 MB)
 
 
 
 
 
4.3 Star
(4)
6,627 times
Add to favorites
4/19/2011
E-mail Twitter del.icio.us Digg Facebook

Solution explorer

C#
<s:SurfaceUserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                      xmlns:s="http://schemas.microsoft.com/surface/2008"
                      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                      xmlns:controls="clr-namespace:LiveStream.Controls"
                      xmlns:props="clr-namespace:LiveStream.Properties"
                      mc:Ignorable="d"
                      x:Class="LiveStream.Controls.RiverContent.TagBack" d:DesignWidth="357.997" d:DesignHeight="336.22">
  <s:SurfaceUserControl.Resources>
    <ResourceDictionary>
      <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/LiveStream;component/Resources/Converters.xaml"/>
        <ResourceDictionary Source="/LiveStream;component/Resources/Resources.xaml"/>
      </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
  </s:SurfaceUserControl.Resources>
  <Grid>
    <VisualStateManager.VisualStateGroups>
      <VisualStateGroup x:Name="TagStates">
        <VisualStateGroup.Transitions>
          <VisualTransition GeneratedDuration="0:0:0.2"/>
        </VisualStateGroup.Transitions>
        <VisualState x:Name="TagLoadedVertical">
          <Storyboard>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="_loadingView">
              <SplineDoubleKeyFrame KeyTime="0" Value="0"/>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="_loadedVertical">
              <SplineDoubleKeyFrame KeyTime="0" Value="1"/>
            </DoubleAnimationUsingKeyFrames>
            <BooleanAnimationUsingKeyFrames Storyboard.TargetProperty="(controls:ImageLoader.IsImageLoading)" Storyboard.TargetName="imageLoader">
              <DiscreteBooleanKeyFrame KeyTime="0" Value="False"/>
            </BooleanAnimationUsingKeyFrames>
          </Storyboard>
        </VisualState>
        <VisualState x:Name="TagFailed">
          <Storyboard>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="_loadingView">
              <SplineDoubleKeyFrame KeyTime="0" Value="0"/>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="_failedView">
              <SplineDoubleKeyFrame KeyTime="0" Value="1"/>
            </DoubleAnimationUsingKeyFrames>
            <BooleanAnimationUsingKeyFrames Storyboard.TargetProperty="(controls:ImageLoader.IsImageLoading)" Storyboard.TargetName="imageLoader">
              <DiscreteBooleanKeyFrame KeyTime="0" Value="False"/>
            </BooleanAnimationUsingKeyFrames>
          </Storyboard>
        </VisualState>
        <VisualState x:Name="TagLoading"/>
        <VisualState x:Name="TagLoadedHorizontal">
          <Storyboard>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="_loadingView">
              <SplineDoubleKeyFrame KeyTime="0" Value="0"/>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="_loadedHorizontal">
              <SplineDoubleKeyFrame KeyTime="0" Value="1"/>
            </DoubleAnimationUsingKeyFrames>
            <BooleanAnimationUsingKeyFrames Storyboard.TargetProperty="(controls:ImageLoader.IsImageLoading)" Storyboard.TargetName="imageLoader">
              <DiscreteBooleanKeyFrame KeyTime="0" Value="False"/>
            </BooleanAnimationUsingKeyFrames>
          </Storyboard>
        </VisualState>
      </VisualStateGroup>
      <VisualStateGroup x:Name="LabelStates">
        <VisualState x:Name="NewsLabel">
          <Storyboard>
            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="_newsLabelVertical">
              <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
            </ObjectAnimationUsingKeyFrames>
            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="_newsLabelHorizontal">
              <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
            </ObjectAnimationUsingKeyFrames>
          </Storyboard>
        </VisualState>
        <VisualState x:Name="StatusLabel">
          <Storyboard>
            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="_statusLabelVertical">
              <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
            </ObjectAnimationUsingKeyFrames>
            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="_statusLabelHorizontal">
              <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
            </ObjectAnimationUsingKeyFrames>
          </Storyboard>
        </VisualState>
        <VisualState x:Name="ImageLabel">
          <Storyboard>
            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="_imageLabelVertical">
              <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
            </ObjectAnimationUsingKeyFrames>
            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="_imageLabelHorizontal">
              <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
            </ObjectAnimationUsingKeyFrames>
          </Storyboard>
        </VisualState>
        <VisualState x:Name="NoLabel"/>
      </VisualStateGroup>
      <VisualStateGroup x:Name="ContentTypeStates">
        <VisualState x:Name="IsStatus">
          <Storyboard>
            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="_statusBorder">
              <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
            </ObjectAnimationUsingKeyFrames>
            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="_newsImageBorder">
              <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Collapsed}"/>
            </ObjectAnimationUsingKeyFrames>
          </Storyboard>
        </VisualState>
        <VisualState x:Name="NotStatus"/>
      </VisualStateGroup>
    </VisualStateManager.VisualStateGroups>
    <Border Background="{DynamicResource ThemeBrush}" x:Name="_newsImageBorder" x:FieldModifier="private"/>
    <Border Background="Black" Opacity=".4" x:Name="_statusBorder" x:FieldModifier="private" Visibility="Collapsed" />
    <Grid Margin="5">
      <Border Background="{DynamicResource ForegroundBrush}" CornerRadius="35,0,0,0" />
      <s:SurfaceButton x:Name="_closeBtn" x:FieldModifier="private" ContactTapGesture="Close_ContactTapGesture" Style="{DynamicResource CloseButtonStyle}" VerticalAlignment="Top" HorizontalAlignment="Right" Background="{DynamicResource ThemeBrush}"/>
      <s:SurfaceButton x:Name="_flipBtn" x:FieldModifier="private" ContactTapGesture="Flip_ContactTapGesture" Grid.Column="1" Grid.Row="2" Padding="0" HorizontalAlignment="Right" VerticalAlignment="Bottom" Style="{DynamicResource BackFlipButtonStyle}" />
      <Grid x:Name="_loadedVertical" Margin="25,20,25,40" Opacity="0" MaxWidth="260" MinHeight="200" MinWidth="200">
        <Grid.RowDefinitions>
          <RowDefinition Height="Auto" />
          <RowDefinition Height="*" />
          <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <StackPanel>
          <TextBlock x:Name="_newsLabelVertical" Text="{x:Static props:Resources.News}" FontSize="36" Foreground="{DynamicResource ThemeBrush}" Visibility="Collapsed" FontFamily="{DynamicResource HeaderFont}" />
          <TextBlock x:Name="_statusLabelVertical" Text="{x:Static props:Resources.Tweet}" FontSize="36" Foreground="{DynamicResource ThemeBrush}" Visibility="Collapsed" FontFamily="{DynamicResource HeaderFont}" />
          <TextBlock x:Name="_imageLabelVertical" Text="{x:Static props:Resources.Image}" FontSize="36" Foreground="{DynamicResource ThemeBrush}" Visibility="Collapsed" FontFamily="{DynamicResource HeaderFont}" />
          <TextBlock Text="{x:Static props:Resources.TagPrompt}" FontSize="12" TextWrapping="Wrap" Margin="0,5,0,5" Foreground="{DynamicResource ThemeBrush}" />
        </StackPanel>
        <Image Grid.Row="1" x:Name="_tagImageVertical" />
        <StackPanel Grid.Row="2">
          <TextBlock Text="{x:Static props:Resources.GetTagPrompt}" FontSize="10" TextWrapping="Wrap" TextAlignment="Center" Foreground="{DynamicResource ThemeBrush}" />
          <TextBlock Text="http://gettag.mobi" FontSize="12" FontWeight="SemiBold" TextAlignment="Center" Foreground="{DynamicResource ThemeBrush}" />
        </StackPanel>
      </Grid>
      <Grid x:Name="_loadedHorizontal" Margin="25,20,25,40" Opacity="0">
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="165" />
          <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
          <RowDefinition Height="Auto" />
          <RowDefinition Height="*" />
        </Grid.RowDefinitions>
          <TextBlock x:Name="_newsLabelHorizontal" Grid.ColumnSpan="2" Text="{x:Static props:Resources.News}" FontSize="36" Foreground="{DynamicResource ThemeBrush}" Visibility="Collapsed" FontFamily="{DynamicResource HeaderFont}" />
          <TextBlock x:Name="_statusLabelHorizontal" Grid.ColumnSpan="2" Text="{x:Static props:Resources.Tweet}" FontSize="36" Foreground="{DynamicResource ThemeBrush}" Visibility="Collapsed" FontFamily="{DynamicResource HeaderFont}" />
          <TextBlock x:Name="_imageLabelHorizontal" Grid.ColumnSpan="2" Text="{x:Static props:Resources.Image}" FontSize="36" Foreground="{DynamicResource ThemeBrush}" Visibility="Collapsed" FontFamily="{DynamicResource HeaderFont}" />
        <StackPanel Grid.Row="1" VerticalAlignment="Center">
          <TextBlock Grid.Row="1" Text="{x:Static props:Resources.TagPrompt}" FontSize="12" TextWrapping="Wrap" Foreground="{DynamicResource ThemeBrush}" />
          <TextBlock Text="{x:Static props:Resources.GetTagPrompt}" FontSize="10" TextWrapping="Wrap" Foreground="{DynamicResource ThemeBrush}" Margin="0,15,0,0" />
          <TextBlock Text="http://gettag.mobi" FontSize="12" FontWeight="SemiBold" Foreground="{DynamicResource ThemeBrush}" />
        </StackPanel>
        <Image Grid.Row="1" Grid.Column="1" x:Name="_tagImageHorizontal" />
      </Grid>
      <Grid x:Name="_failedView" x:FieldModifier="private" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="25" Opacity="0">
        <TextBlock Text="{x:Static props:Resources.TagFailed}" FontSize="12" TextWrapping="Wrap" Foreground="{DynamicResource ThemeBrush}" />
      </Grid>
      <Grid x:Name="_loadingView" x:FieldModifier="private">
        <controls:ImageLoader x:Name="imageLoader" IsImageLoading="True" Label="{x:Static props:Resources.Tag}" Foreground="{DynamicResource ThemeBrush}" Style="{DynamicResource ImageLoaderStyle}" />
      </Grid>
    </Grid>
  </Grid>
</s:SurfaceUserControl>