<Page
    x:Class="MapsSamples.Flicker"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:MapsSamples"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:c1="using:C1.Xaml.Maps"
    mc:Ignorable="d"
    d:DesignHeight="300"
    d:DesignWidth="400">

    <UserControl.Resources>
        <c1:XElementConverter x:Key="xcnv" />
        <local:ImageConverter x:Key="icnv" />
        <Style x:Key="style" TargetType="c1:C1VectorPlacemark">
            <Setter Property="Stroke" Value="#FF8FB4CC" />
            <Setter Property="StrokeThickness" Value="2" />
            <Setter Property="LabelTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <Border Tapped="Border_Tapped" Background="#70ffffff" BorderBrush="BurlyWood" BorderThickness="1" CornerRadius="3">
                            <StackPanel Orientation="Vertical">
                                <TextBlock x:Name="txt" Visibility="Collapsed" FontSize="8" MaxWidth="100" TextWrapping="Wrap" Text="{Binding Converter={StaticResource xcnv}, ConverterParameter=title}" />
                                <Image x:Name="img" MaxWidth="50" MaxHeight="50" Opacity="0.8" Source="{Binding Converter={StaticResource icnv}}" />
                            </StackPanel>
                        </Border>
                    </DataTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="Geometry" Value="M3,0 A 3,3 180 1 0 -3,0 A 3,3 180 1 0 3,0 Z" />
        </Style>

    </UserControl.Resources>
    <Grid>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition />
            </Grid.RowDefinitions>
            <Border Grid.Row="1">
                <Grid>
                    <c1:C1Maps x:Name="maps" Opacity="0.5">
                        <c1:C1VectorLayer x:Name="vl" LabelVisibility="Visible" ItemStyle="{StaticResource style}" UriSourceLoaded="vl_UriSourceLoaded" UriSource="http://api.flickr.com/services/feeds/geo/Uruguay/Montevideo"/>
                    </c1:C1Maps>
                    <local:MapTool Maps="{Binding ElementName=maps}" x:Name="mapTool"></local:MapTool>
                </Grid>
            </Border>
            <TextBlock x:Name="txt" FontSize="24" HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Binding LoadingData_Text, Source={StaticResource MapsSamplesLocalization}}" Grid.Row="1" />

            <Border>
                <StackPanel Orientation="Horizontal" x:Name="stackPanel">
                    <TextBlock VerticalAlignment="Center" Text="{Binding  EnterPlace_Text, Source={StaticResource MapsSamplesLocalization}}" x:Name="centerTxt"/>
                    <StackPanel Orientation="Horizontal" Margin="0,0,0,10">
                        <TextBox x:Name="tb" IsEnabled="False" Text="{Binding Uruguay_Text, Source={StaticResource MapsSamplesLocalization}}" MinWidth="200" KeyDown="tb_KeyDown" Margin="10,0" />
                        <Button x:Name="btnLoad" IsEnabled="False" Content="{Binding LoadData_Content, Source={StaticResource MapsSamplesLocalization}}" Width="80" Click="Button_Click" />
                    </StackPanel>
                </StackPanel>
            </Border>
        </Grid>
        <Rectangle x:Name="mask" Fill="#FF1D1D1D" IsHitTestVisible="False" HorizontalAlignment="Left" Stroke="Black" VerticalAlignment="Top" Visibility="Collapsed" Opacity="0.7"/>
        <Popup  x:Name="popup" Width="Auto" Height="Auto">
            <Border BorderThickness="2" BorderBrush="{ThemeResource AppBarBorderThemeBrush}">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="38"></RowDefinition>
                        <RowDefinition></RowDefinition>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition></ColumnDefinition>
                        <ColumnDefinition Width="38"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <TextBlock x:Name="tbHeader"></TextBlock>
                    <Button x:Name="btnClose" Content="&#xE10A;" BorderThickness="0" FontFamily ="{ThemeResource SymbolThemeFontFamily}" FontSize ="{ThemeResource ComboBoxArrowThemeFontSize}" Padding="0 2 0 0" Width="38" HorizontalAlignment="Right" Grid.Column="1" Tapped="btnClose_Tapped"></Button>
                    <Image x:Name="contImg" MaxHeight="400" MaxWidth="400" Stretch="None" Grid.Row="1" Grid.ColumnSpan="2"></Image>
                </Grid>
            </Border>
        </Popup>
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup>
                <VisualState x:Name="NarrowLayout">
                    <VisualState.StateTriggers>
                        <AdaptiveTrigger MinWindowWidth="0"></AdaptiveTrigger>
                    </VisualState.StateTriggers>
                    <VisualState.Setters>
                        <Setter Target="mapTool.Visibility" Value="Collapsed"></Setter>
                        <Setter Target="centerTxt.FontSize" Value="12"></Setter>
                        <Setter Target="tb.MinWidth" Value="100"></Setter>
                        <Setter Target="tb.Width" Value="100"></Setter>
                        <Setter Target="stackPanel.Orientation" Value="Vertical"></Setter>
                        <Setter Target="centerTxt.Margin" Value="20, 0"></Setter>
                        <Setter Target="tb.Width" Value="200"></Setter>
                        <Setter Target="tb.Margin" Value="20, 0"></Setter>
                        <Setter Target="btnLoad.Width" Value="75"></Setter>
                    </VisualState.Setters>
                </VisualState>
                <VisualState x:Name="WideLayout">
                    <VisualState.StateTriggers>
                        <AdaptiveTrigger MinWindowWidth="540"></AdaptiveTrigger>
                    </VisualState.StateTriggers>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>
</Page>
