<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:local="clr-namespace:ForzaUI"
    mc:Ignorable="d"
    x:Class="ForzaUI.HUDNetworkStatusControl"
    Margin="0,0,0,0"
    VerticalAlignment="Top"
    HorizontalAlignment="Center">

    <UserControl.Resources>
        <ResourceDictionary>
            <Style x:Key="A_Style_FZTextBlock_NetworkStatus" TargetType="{x:Type local:FZTextBlock}" BasedOn="{StaticResource A_Style_FZTextBlock_HudMedium}">
                <Setter Property="HorizontalAlignment" Value="Center"/>
                <Setter Property="TextAlignment" Value="Center"/>
                <Setter Property="VerticalAlignment" Value="Center"/>
                <Setter Property="TextWrapping" Value="NoWrap"/>
				
				<Setter Property="local:ScreenReader.LineType" Value="NotificationPrompt"/>
				<Setter Property="local:ScreenReader.Event" Value="OnChange"/>
				<Setter Property="local:ScreenReader.Line" Value="{Binding (local:TextBlockInlineMarkup.Markup), RelativeSource={RelativeSource Self}, Converter={StaticResource A_Converter_TrimInlineMarkup}}"/> 			

                <Style.Triggers>
                    <DataTrigger Binding="{Binding Tag, RelativeSource={RelativeSource Self}}" Value="{x:Static Visibility.Collapsed}">
                        <Setter Property="TextWrapping" Value="Wrap" />
                        <Setter Property="MaxWidth" Value="540" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
            
            <Style x:Key="A_Style_FZRun_NetworkStatusMarkup_HIGHLIGHT" TargetType="{x:Type local:FZRun}">
                <Setter Property="Color" Value="{StaticResource A_Color_HUD_Text}"/>
            </Style>
        </ResourceDictionary>
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot">
        <Grid.Resources>
            <QuadraticEase x:Key="A_EasingFunction_EaseIn" EasingMode="EaseIn"/>
            <QuadraticEase x:Key="A_EasingFunction_EaseOut" EasingMode="EaseOut"/>

            <Storyboard x:Key="A_Storyboard_Show_Indefinite">
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="TextBlock">
                    <DiscreteDoubleKeyFrame KeyTime="0:0:0.0" Value="1"/>
                </DoubleAnimationUsingKeyFrames>
            </Storyboard>

            <Storyboard x:Key="A_Storyboard_Hidden">
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="TextBlock">
                    <DiscreteDoubleKeyFrame KeyTime="0:0:0.0" Value="0"/>
                </DoubleAnimationUsingKeyFrames>
            </Storyboard>

            <Storyboard x:Key="A_Storyboard_Show_3Seconds">
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="TextBlock">
                    <DiscreteDoubleKeyFrame KeyTime="0:0:0.0" Value="1"/>
                </DoubleAnimationUsingKeyFrames>
                <StringAnimationUsingKeyFrames Storyboard.TargetProperty="(local:EventFire.EventName)" Storyboard.TargetName="EventFire">
                    <DiscreteStringKeyFrame KeyTime="0:0:0.0" Value=""/>
                    <DiscreteStringKeyFrame KeyTime="0:0:3.0" Value="Expired"/>
                    <DiscreteStringKeyFrame KeyTime="0:0:3.2" Value=""/>
                </StringAnimationUsingKeyFrames>
            </Storyboard>

            <Storyboard x:Key="A_Storyboard_Show_5Seconds">
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="TextBlock">
                    <DiscreteDoubleKeyFrame KeyTime="0:0:0.0" Value="1"/>
                </DoubleAnimationUsingKeyFrames>
                <StringAnimationUsingKeyFrames Storyboard.TargetProperty="(local:EventFire.EventName)" Storyboard.TargetName="EventFire">
                    <DiscreteStringKeyFrame KeyTime="0:0:0.0" Value=""/>
                    <DiscreteStringKeyFrame KeyTime="0:0:5.0" Value="Expired"/>
                    <DiscreteStringKeyFrame KeyTime="0:0:5.2" Value=""/>
                </StringAnimationUsingKeyFrames>
            </Storyboard>

            <Storyboard x:Key="A_Storyboard_Hidden_To_Any">
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="TextBlock">
                    <EasingDoubleKeyFrame KeyTime="0:0:0.25" Value="1" EasingFunction="{StaticResource A_EasingFunction_EaseOut}"/>
                </DoubleAnimationUsingKeyFrames>
            </Storyboard>

            <Storyboard x:Key="A_Storyboard_Any_To_Hidden">
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="TextBlock">
                    <EasingDoubleKeyFrame KeyTime="0:0:0.25" Value="0" EasingFunction="{StaticResource A_EasingFunction_EaseIn}"/>
                </DoubleAnimationUsingKeyFrames>
                <StringAnimationUsingKeyFrames Storyboard.TargetProperty="(local:EventFire.EventName)" Storyboard.TargetName="EventFire">
                    <DiscreteStringKeyFrame KeyTime="0:0:0.0" Value=""/>
                    <DiscreteStringKeyFrame KeyTime="0:0:0.25" Value="Finished"/>
                    <DiscreteStringKeyFrame KeyTime="0:0:0.27" Value=""/>
                </StringAnimationUsingKeyFrames>
            </Storyboard>

        </Grid.Resources>

        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup>
                <VisualState x:Name="Hidden" Storyboard="{StaticResource A_Storyboard_Hidden}"/>
                <VisualState x:Name="RaceStarting" Storyboard="{StaticResource A_Storyboard_Show_Indefinite}"/>
                <VisualState x:Name="ActionForbidden" Storyboard="{StaticResource A_Storyboard_Show_3Seconds}"/>
                <VisualState x:Name="LeaderChange" Storyboard="{StaticResource A_Storyboard_Show_3Seconds}"/>
                <VisualState x:Name="PlayerLeft" Storyboard="{StaticResource A_Storyboard_Show_3Seconds}"/>
                <VisualState x:Name="PlayerJoined" Storyboard="{StaticResource A_Storyboard_Show_3Seconds}"/>
                <VisualState x:Name="PlayerJoining" Storyboard="{StaticResource A_Storyboard_Show_3Seconds}"/>
                <VisualState x:Name="OnlyPlayerPrompt" Storyboard="{StaticResource A_Storyboard_Show_Indefinite}"/>
                <VisualState x:Name="MatchMakingComplete" Storyboard="{StaticResource A_Storyboard_Show_5Seconds}"/>
                <VisualState x:Name="MatchMakingProgress" Storyboard="{StaticResource A_Storyboard_Show_Indefinite}"/>
                <VisualState x:Name="EventProgress" Storyboard="{StaticResource A_Storyboard_Show_Indefinite}"/>
                <VisualState x:Name="BucketListWaitPlayer" Storyboard="{StaticResource A_Storyboard_Show_5Seconds}"/>
                <VisualState x:Name="BucketListStarted" Storyboard="{StaticResource A_Storyboard_Show_5Seconds}"/>
                <VisualState x:Name="BucketListEnded" Storyboard="{StaticResource A_Storyboard_Show_5Seconds}"/>
                <VisualState x:Name="LatencyWarning" Storyboard="{StaticResource A_Storyboard_Show_5Seconds}"/>
                <VisualState x:Name="PartyStatus" Storyboard="{StaticResource A_Storyboard_Show_Indefinite}"/>
                <VisualState x:Name="ScheduledEventSignup" Storyboard="{StaticResource A_Storyboard_Show_5Seconds}"/>
                <VisualState x:Name="ScheduledEventCountdown" Storyboard="{StaticResource A_Storyboard_Show_Indefinite}"/>
                <VisualState x:Name="EliminatorPlayerEliminated" Storyboard="{StaticResource A_Storyboard_Show_3Seconds}"/>
                <VisualState x:Name="EliminatorActivityNotice" Storyboard="{StaticResource A_Storyboard_Show_3Seconds}"/>
                <VisualStateGroup.Transitions>
                    <VisualTransition From="Hidden" GeneratedDuration="0:0:0.25" Storyboard="{StaticResource A_Storyboard_Hidden_To_Any}"/>
                    <VisualTransition To="Hidden" GeneratedDuration="0:0:0.25" Storyboard="{StaticResource A_Storyboard_Any_To_Hidden}"/>
                </VisualStateGroup.Transitions>
            </VisualStateGroup>

        </VisualStateManager.VisualStateGroups>

        <Decorator x:Name="TextBlock" Opacity="0">
            <local:FZMaterial Preset="{StaticResource A_FZMaterialPresetGlass_HudItem}" Color="{StaticResource A_Color_HUD_ItemBackground}">
                <Viewbox MaxHeight="70" MaxWidth="564" StretchDirection="DownOnly" Stretch="Uniform">
                    <Decorator  MinHeight="40">
                        <StackPanel Orientation="Vertical" Margin="12,14" VerticalAlignment="Center">
                            <local:FZTextBlock x:Name="Text"  local:TextBlockInlineMarkup.Markup="{Binding Text}" local:TextBlockInlineMarkup.ResourceBaseName="A_Style_FZRun_NetworkStatusMarkup_" Style="{StaticResource A_Style_FZTextBlock_NetworkStatus}" Tag="{Binding SubText, Converter={StaticResource A_StringVisConverter}}"/>
                            <local:FZTextBlock x:Name="SubText" Margin="0,13,0,0" local:TextBlockInlineMarkup.Markup="{Binding SubText}" local:TextBlockInlineMarkup.ResourceBaseName="A_Style_FZRun_NetworkStatusMarkup_" Style="{StaticResource A_Style_FZTextBlock_NetworkStatus}" Visibility="{Binding SubText, Converter={StaticResource A_StringVisConverter}}" Color="{StaticResource A_Color_HUD_AlternateText}"/>
                        </StackPanel>
                    </Decorator>
                </Viewbox>
            </local:FZMaterial>
        </Decorator>
        <local:EventFire x:Name="EventFire" />
    </Grid>
</UserControl>