<!--
	Copyright (c) Microsoft. All rights reserved.
-->

<UserControl x:Class="MOX.LanguagePicker"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:vsm='using:Windows.UI.Xaml'
	xmlns:mox="using:MOX"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">
	<UserControl.Resources>
		<Style x:Key="CommonStyle" TargetType="ListBoxItem">
			<Setter Property="TabNavigation" Value="Local" />
			<Setter Property="HorizontalContentAlignment" Value="Left" />
			<Setter Property="VerticalContentAlignment" Value="Center" />
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="ListBoxItem">
						<Border x:Name="LayoutRoot"
								AutomationProperties.Name="{TemplateBinding AutomationProperties.Name}"
								Background="{TemplateBinding Background}"
								BorderBrush="{TemplateBinding BorderBrush}"
								BorderThickness="{TemplateBinding BorderThickness}">
							<VisualStateManager.VisualStateGroups>
								<VisualStateGroup x:Name="CommonStates">
									<VisualState x:Name="Normal" />
									<VisualState x:Name="PointerOver">
										<Storyboard>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetName="LayoutRoot"
																		   Storyboard.TargetProperty="Background">
												<DiscreteObjectKeyFrame KeyTime="0" Value="{CustomResource :mso_brush:2427}" />
											</ObjectAnimationUsingKeyFrames>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"
																		   Storyboard.TargetProperty="Foreground">
												<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ListBoxItemPointerOverForegroundThemeBrush}" />
											</ObjectAnimationUsingKeyFrames>
										</Storyboard>
									</VisualState>
									<VisualState x:Name="Disabled">
										<Storyboard>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetName="LayoutRoot"
																		   Storyboard.TargetProperty="Background">
												<DiscreteObjectKeyFrame KeyTime="0" Value="Transparent" />
											</ObjectAnimationUsingKeyFrames>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"
																		   Storyboard.TargetProperty="Foreground">
												<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ListBoxItemDisabledForegroundThemeBrush}" />
											</ObjectAnimationUsingKeyFrames>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetName="LayoutRoot"
																		   Storyboard.TargetProperty="Visibility">
												<DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed" />
											</ObjectAnimationUsingKeyFrames>
										</Storyboard>
									</VisualState>
									<VisualState x:Name="Pressed">
										<Storyboard>
											<DoubleAnimation Storyboard.TargetName="PressedBackground"
															 Storyboard.TargetProperty="Opacity"
															 To="1"
															 Duration="0" />
											<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"
																		   Storyboard.TargetProperty="Foreground">
												<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ListBoxItemPressedForegroundThemeBrush}" />
											</ObjectAnimationUsingKeyFrames>
										</Storyboard>
									</VisualState>
								</VisualStateGroup>
								<VisualStateGroup x:Name="SelectionStates">
									<VisualState x:Name="Unselected" />
									<VisualState x:Name="Selected">
										<Storyboard>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetName="InnerGrid"
																		   Storyboard.TargetProperty="Background">
												<DiscreteObjectKeyFrame KeyTime="0" Value="{CustomResource :mso_brush:2555}" />
											</ObjectAnimationUsingKeyFrames>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"
																		   Storyboard.TargetProperty="Foreground">
												<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ListBoxItemSelectedForegroundThemeBrush}" />
											</ObjectAnimationUsingKeyFrames>
										</Storyboard>
									</VisualState>
									<VisualState x:Name="SelectedUnfocused">
										<Storyboard>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetName="InnerGrid"
																		   Storyboard.TargetProperty="Background">
												<DiscreteObjectKeyFrame KeyTime="0" Value="{CustomResource :mso_brush:2555}" />
											</ObjectAnimationUsingKeyFrames>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"
																		   Storyboard.TargetProperty="Foreground">
												<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ListBoxItemSelectedForegroundThemeBrush}" />
											</ObjectAnimationUsingKeyFrames>
										</Storyboard>
									</VisualState>
									<VisualState x:Name="SelectedDisabled">
										<Storyboard>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetName="InnerGrid"
																		   Storyboard.TargetProperty="Background">
												<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ListBoxItemSelectedDisabledBackgroundThemeBrush}" />
											</ObjectAnimationUsingKeyFrames>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"
																		   Storyboard.TargetProperty="Foreground">
												<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ListBoxItemSelectedDisabledForegroundThemeBrush}" />
											</ObjectAnimationUsingKeyFrames>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetName="LayoutRoot"
																		   Storyboard.TargetProperty="Visibility">
												<DiscreteObjectKeyFrame KeyTime="0" Value="Visible" />
											</ObjectAnimationUsingKeyFrames>
										</Storyboard>
									</VisualState>
									<VisualState x:Name="SelectedPointerOver">
										<Storyboard>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetName="InnerGrid"
																		   Storyboard.TargetProperty="Background">
												<DiscreteObjectKeyFrame KeyTime="0" Value="{CustomResource :mso_brush:2533}" />
											</ObjectAnimationUsingKeyFrames>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"
																		   Storyboard.TargetProperty="Foreground">
												<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ListBoxItemSelectedForegroundThemeBrush}" />
											</ObjectAnimationUsingKeyFrames>
										</Storyboard>
									</VisualState>
									<VisualState x:Name="SelectedPressed">
										<Storyboard>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetName="InnerGrid"
																		   Storyboard.TargetProperty="Background">
												<DiscreteObjectKeyFrame KeyTime="0" Value="{CustomResource :mso_brush:2555}" />
											</ObjectAnimationUsingKeyFrames>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"
																		   Storyboard.TargetProperty="Foreground">
												<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ListBoxItemSelectedForegroundThemeBrush}" />
											</ObjectAnimationUsingKeyFrames>
										</Storyboard>
									</VisualState>
								</VisualStateGroup>
								<VisualStateGroup x:Name="FocusStates">
									<VisualState x:Name="Focused">
										<Storyboard>
											<DoubleAnimation Storyboard.TargetName="FocusVisualWhite"
															 Storyboard.TargetProperty="Opacity"
															 To="1"
															 Duration="0" />
											<DoubleAnimation Storyboard.TargetName="FocusVisualBlack"
															 Storyboard.TargetProperty="Opacity"
															 To="1"
															 Duration="0" />
										</Storyboard>
									</VisualState>
									<VisualState x:Name="Unfocused" />
									<VisualState x:Name="PointerFocused" />
								</VisualStateGroup>
							</VisualStateManager.VisualStateGroups>
							<Grid x:Name="InnerGrid"
								 AutomationProperties.Name="{TemplateBinding AutomationProperties.Name}"
								 Background="Transparent"
								 Height="40">
								<Rectangle x:Name="PressedBackground"
										   Fill="{StaticResource ListBoxItemPressedBackgroundThemeBrush}"
										   Opacity="0" />
								<ContentPresenter x:Name="ContentPresenter"
												  Content="{TemplateBinding Content}"
												  ContentTransitions="{TemplateBinding ContentTransitions}"
												  ContentTemplate="{TemplateBinding ContentTemplate}"
												  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
												  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
												  AutomationProperties.Name="{TemplateBinding AutomationProperties.Name}"
												  Margin="30, 0, 0, 0" />
								<Rectangle x:Name="FocusVisualWhite"
										   Stroke="{StaticResource FocusVisualWhiteStrokeThemeBrush}"
										   StrokeEndLineCap="Square"
										   StrokeDashArray="1,1"
										   Opacity="0"
										   StrokeDashOffset=".5" />
								<Rectangle x:Name="FocusVisualBlack"
										   Stroke="{StaticResource FocusVisualBlackStrokeThemeBrush}"
										   StrokeEndLineCap="Square"
										   StrokeDashArray="1,1"
										   Opacity="0"
										   StrokeDashOffset="1.5" />
							</Grid>
						</Border>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
		<Style x:Key="NormalLanguageStyle" BasedOn="{StaticResource CommonStyle}" TargetType="ListBoxItem">
			<Setter Property="IsEnabled" Value="true"/>
		</Style>
		<Style x:Key="DisabledLanguageStyle" BasedOn="{StaticResource CommonStyle}" TargetType="ListBoxItem">
			<Setter Property="IsEnabled" Value="false"/>
		</Style>
		<mox:LanguagePickerItemStyleSelector x:Key="LanguagePickerItemStyleSelector" 
											NormalLanguageStyle="{StaticResource NormalLanguageStyle}" 
											DisabledLanguageStyle="{StaticResource DisabledLanguageStyle}" />
		<Storyboard x:Name="storyboardShowAllLanguages">
			<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="borderMRULanguages">
				<EasingDoubleKeyFrame KeyTime="0" Value="1"/>
				<EasingDoubleKeyFrame KeyTime="0:0:0.15" Value="0"/>
			</DoubleAnimationUsingKeyFrames>
			<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="borderAllLanguages" >
				<EasingDoubleKeyFrame KeyTime="0" Value="1"/>
				<EasingDoubleKeyFrame KeyTime="0:0:0.15" Value="1"/>
			</DoubleAnimationUsingKeyFrames>
		</Storyboard>
	</UserControl.Resources>
	<Grid>
		<Border x:Name="borderMRULanguages" BorderBrush="{StaticResource ListBoxForegroundThemeBrush}" BorderThickness="2" HorizontalAlignment="Center" VerticalAlignment="Center" Width="250" Visibility="Visible">
			<ListBox HorizontalAlignment="Stretch" VerticalAlignment="Center" SelectionMode="Single" IsTabStop="true" 
				x:Name="listboxMRULanguages" ItemsSource="{Binding MRUComboItems}" BorderThickness="0" ItemContainerStyle="{StaticResource CommonStyle}" >
				<ListBox.ItemTemplate>
					<DataTemplate>
						<TextBlock Text="{Binding Label}" FontStyle="{Binding FontStyle}" AutomationProperties.Name="{Binding Label}"/>
					</DataTemplate>
				</ListBox.ItemTemplate>
			</ListBox>
		</Border>
		<Border x:Name="borderAllLanguages" BorderBrush="{StaticResource ListBoxForegroundThemeBrush}" BorderThickness="2" HorizontalAlignment="Center" VerticalAlignment="Center" Width="250" Opacity="0" IsHitTestVisible="false" Visibility="Collapsed">
			<ListBox HorizontalAlignment="Stretch" VerticalAlignment="Center" SelectionMode="Single" IsTabStop="true" 
				x:Name="listboxAllLanguages" ItemsSource="{Binding ComboItems}" BorderThickness="0" Height="200" ItemContainerStyleSelector="{StaticResource LanguagePickerItemStyleSelector}" >
				<ListBox.ItemTemplate>
					<DataTemplate>
						<TextBlock Text="{Binding Label}" FontStyle="{Binding FontStyle}" />
					</DataTemplate>
				</ListBox.ItemTemplate>
			</ListBox>
		</Border>
	</Grid>
</UserControl>
