<UserControl x:Class="Hearthstone_Deck_Tracker.FlyoutControls.Options.Streaming.StreamingTwitchExtension"
             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:lex="http://wpflocalizeextension.codeplex.com"
             xmlns:controls="clr-namespace:Hearthstone_Deck_Tracker.Controls"
             xmlns:oAuth="clr-namespace:HSReplay.OAuth;assembly=HSReplay"
             lex:LocalizeDictionary.DesignCulture="en"
             lex:ResxLocalizationProvider.DefaultAssembly="HearthstoneDeckTracker"
             lex:ResxLocalizationProvider.DefaultDictionary="Strings"
             DataContext="{Binding RelativeSource={RelativeSource Self}}"
             mc:Ignorable="d" 
             d:DesignHeight="600" d:DesignWidth="300">
    <StackPanel Margin="20">
        <StackPanel Visibility="{Binding IsAuthenticated, Converter={StaticResource InverseBoolToVisibility}}">
            <TextBlock FontWeight="SemiBold" FontSize="16" TextAlignment="Center">
                <Run Text="{lex:Loc Options_Streaming_TwitchExt_Intro_Header}"/>
                <LineBreak/>
                <Run Text="{lex:Loc Options_Streaming_TwitchExt_Intro_Subtitle}" FontWeight="Normal" FontSize="15"/>
                <LineBreak/><LineBreak/><LineBreak/>
                <Run Text="{lex:Loc Options_Streaming_TwitchExt_Label_Login}" FontWeight="Normal" FontSize="15"/>
            </TextBlock>
            <controls:OAuthLogin ScopeConsideredLoggedIn="{Binding Source={x:Static oAuth:Scope.ReadSocialAccounts}}"
                                 Margin="15"/>
        </StackPanel>
        <StackPanel Visibility="{Binding IsAuthenticated, Converter={StaticResource BoolToVisibility}}">
            <StackPanel Visibility="{Binding TwitchAccountLinked, Converter={StaticResource InverseBoolToVisibility}}">
                <TextBlock FontWeight="SemiBold" FontSize="16" TextAlignment="Center" TextWrapping="Wrap">
                    <Run Text="{lex:Loc Options_Streaming_TwitchExt_Label_TwitchAccount}" FontWeight="Normal" FontSize="15"/>
                </TextBlock>
                <Button Style="{DynamicResource AccentedSquareButtonStyle}" Width="300"
                        Margin="15" Command="{Binding LinkTwitchAccountCommand}">
                    <TextBlock Text="{lex:Loc Options_Streaming_TwitchExt_Step2_Link}"/>
                </Button>
            </StackPanel>
            <CheckBox Margin="0,10,0,0" Visibility="{Binding SetupComplete, Converter={StaticResource BoolToVisibility}}"
                      IsChecked="{Binding TwitchExtensionEnabled}" Content="{lex:Loc Options_Streaming_TwitchExt_CheckBox_Enable}"
                      HorizontalAlignment="Center"/>
            <StackPanel
                HorizontalAlignment="Center" Margin="0,10,0,0">
                <StackPanel.Visibility>
                    <MultiBinding Converter="{StaticResource BoolToVisibility}">
                        <Binding Path="TwitchAccountLinked"/>
                        <Binding Path="TwitchExtensionEnabled"/>
                    </MultiBinding>
                </StackPanel.Visibility>
                <StackPanel Margin="0,0,0,10" Orientation="Horizontal" HorizontalAlignment="Center">
                    <TextBlock Margin="5,0,0,0" VerticalAlignment="Center"
                               Text="{lex:Loc Options_Streaming_TwitchExt_TwitchAccount}" FontSize="15" FontWeight="SemiBold"/>
                    <TextBlock Text="{Binding SelectedTwitchUser.Username}" VerticalAlignment="Center" Margin="3,0,0,0"
                               FontSize="15" FontWeight="SemiBold"
                               Visibility="{Binding MultipleTwitchAccounts, Converter={StaticResource InverseBoolToVisibility}}"/>
                    <ComboBox Margin="5,0,0,0" SelectionChanged="TwitchAccountComboBox_OnSelectionChanged"
                              SelectedItem="{Binding SelectedTwitchUser}" ItemsSource="{Binding AvailableTwitchAccounts}"
                              Visibility="{Binding MultipleTwitchAccounts, Converter={StaticResource BoolToVisibility}}">
                        <ComboBox.ItemTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Username}"></TextBlock>
                            </DataTemplate>
                        </ComboBox.ItemTemplate>
                    </ComboBox>
                    <Button Style="{DynamicResource MetroCircleButtonStyle}" Width="26" Height="26" Margin="0,-5,-5,-5" Command="{Binding RefreshTwitchAccountsCommand}">
                        <Rectangle Width="10" Height="12">
                            <Rectangle.Fill>
                                <VisualBrush Visual="{DynamicResource appbar_refresh}" />
                            </Rectangle.Fill>
                        </Rectangle>
                    </Button>
                </StackPanel>
                <TextBlock Margin="5,0,0,0" Visibility="{Binding TwitchStreamLive, Converter={StaticResource BoolToVisibility}}"
                           HorizontalAlignment="Center">
                    <Run Text="{lex:Loc Options_Streaming_TwitchExt_Status_Label_Stream}"/>
                    <Run Foreground="Green" Text="✔️"/>
                    <Run Text="{lex:Loc Options_Streaming_TwitchExt_Status_Stream_Success}"/>
                </TextBlock>
                <TextBlock Margin="5,0,0,0" Visibility="{Binding TwitchStreamLive, Converter={StaticResource InverseBoolToVisibility}}"
                           HorizontalAlignment="Center">
                    <Run Text="{lex:Loc Options_Streaming_TwitchExt_Status_Label_Stream}"/>
                    <Run Foreground="Red" Text="✖"/>
                    <Run Text="{lex:Loc Options_Streaming_TwitchExt_Status_Stream_Error}"/>
                </TextBlock>
                <Button Margin="0,35,0,15" Style="{DynamicResource AccentedSquareButtonStyle}"
                        Width="300" Command="{Binding InstallTwitchExtensionCommand}">
                    <TextBlock Text="{lex:Loc Options_Streaming_TwitchExt_Step3_Link}"/>
                </Button>
            </StackPanel>
        </StackPanel>
        <TextBlock Margin="0,10,0,0" HorizontalAlignment="Center">
            <Hyperlink Command="{Binding SetupGuideCommand}">
                <Run Text="{lex:Loc Options_Streaming_TwitchExt_SetupGuide_Link}"/>
            </Hyperlink>
        </TextBlock>
    </StackPanel>
</UserControl>
