﻿<Window x:Class="TwitchDownloaderWPF.WindowMassDownload"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:TwitchDownloaderWPF"
        xmlns:behave="clr-namespace:TwitchDownloaderWPF.Behaviors"
        xmlns:fa="http://schemas.fontawesome.com/icons/"
        xmlns:lex="http://wpflocalizeextension.codeplex.com"
        lex:LocalizeDictionary.DesignCulture=""
        lex:ResxLocalizationProvider.DefaultAssembly="TwitchDownloaderWPF"
        lex:ResxLocalizationProvider.DefaultDictionary="Strings"
        xmlns:emoji="clr-namespace:Emoji.Wpf;assembly=Emoji.Wpf"
        xmlns:gif="http://wpfanimatedgif.codeplex.com"
        mc:Ignorable="d"
        Title="Mass Downloader" MinHeight="250" Height="700" MinWidth="775" Width="1100" Loaded="Window_Loaded" SourceInitialized="Window_OnSourceInitialized">
    <Window.Resources>
        <Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}">
            <Setter Property="behave:TextBoxTripleClickBehavior.TripleClickSelectLine" Value="True" />
        </Style>
    </Window.Resources>

    <Grid Background="{DynamicResource AppBackground}">
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Top">
            <Label x:Name="LabelSort" Content="{lex:Loc Sort}" Margin="6,6,0,0" Background="{DynamicResource AppElementBackground}" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}"/>
            <ComboBox SelectedIndex="2" x:Name="ComboSortByDate" Margin="5,6,0,0" MinWidth="120" SelectionChanged="ComboSortByDate_SelectionChanged" Background="{DynamicResource AppElementBackground}" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}">
                <ComboBoxItem Content="{lex:Loc TopTwentyFourHours}" Tag="LAST_DAY"/>
                <ComboBoxItem Content="{lex:Loc TopSevenDays}" Tag="LAST_WEEK"/>
                <ComboBoxItem Content="{lex:Loc TopThirtyDays}" Tag="LAST_MONTH"/>
                <ComboBoxItem Content="{lex:Loc TopAllTime}" Tag="ALL_TIME"/>
            </ComboBox>
            <ComboBox SelectedIndex="0" x:Name="ComboSortByVideoType" Margin="5,6,0,0" MinWidth="120" SelectionChanged="ComboSortByVideoType_SelectionChanged" Background="{DynamicResource AppElementBackground}" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}">
                <ComboBoxItem Content="{lex:Loc VideoTypeAllVideos}" Tag=""/>
                <ComboBoxItem Content="{lex:Loc VideoTypePastBroadcasts}" Tag="ARCHIVE"/>
                <ComboBoxItem Content="{lex:Loc VideoTypeHighlights}" Tag="HIGHLIGHT"/>
                <ComboBoxItem Content="{lex:Loc VideoTypeUploads}" Tag="UPLOAD"/>
            </ComboBox>
        </StackPanel>
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Top">
            <Image x:Name="StatusImage" gif:ImageBehavior.AnimatedSource="Images/ppOverheat.gif" MaxWidth="50" Margin="0, 6, 6, 0" Visibility="Hidden" />
            <ComboBox x:Name="ComboChannel" IsEditable="True" Height="23" MinWidth="194" MaxWidth="300" Margin="0,6,0,0" KeyDown="ComboChannel_OnKeyDown" DropDownClosed="ComboChannel_OnDropDownClosed" Background="{DynamicResource AppElementBackground}" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
            <Button x:Name="btnChannel" Content="{lex:Loc SetChannel}" Margin="3,6,0,0" MinWidth="84" Height="30" Click="btnChannel_Click" Background="{DynamicResource ActionButtonBackground}" Foreground="{DynamicResource ActionButtonText}" BorderBrush="{DynamicResource ActionButtonBorder}"/>
        </StackPanel>
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Top">
            <Label x:Name="LabelVideoCount" Content="{lex:Loc LabelVideosPerPage}" Margin="6,6,0,0" Background="{DynamicResource AppElementBackground}" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}"/>
            <ComboBox SelectedIndex="1" x:Name="ComboVideoCount" Margin="5,6,6,0" MinWidth="70" SelectionChanged="ComboVideoCount_SelectionChanged" Background="{DynamicResource AppElementBackground}" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}">
                <ComboBoxItem Content="16" />
                <ComboBoxItem Content="30" />
                <ComboBoxItem Content="50" />
                <ComboBoxItem Content="100" />
            </ComboBox>
        </StackPanel>
        <ScrollViewer x:Name="scrollDownload" VerticalScrollBarVisibility="Auto" Margin="10,41,10,45">
            <ItemsControl x:Name="itemList" ItemsSource="{Binding videoList}" d:DataContext="{d:DesignInstance local:WindowMassDownload}">
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <WrapPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Top"/>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Border BorderThickness="1" CornerRadius="8" Margin="0,0,8,8" Padding="4" MouseLeftButtonUp="Border_OnMouseLeftButtonUp" Initialized="Border_Initialized" Background="{DynamicResource AppElementBackground}" BorderBrush="{DynamicResource AppElementBorder}">
                            <Border.ContextMenu>
                                <ContextMenu>
                                    <MenuItem Header="{lex:Loc CopyVideoIDToClipboard}" Click="MenuItemCopyVideoID_OnClick" Foreground="{DynamicResource AppText}">
                                        <MenuItem.Icon>
                                            <fa:SvgAwesome Icon="Solid_Copy" Foreground="{DynamicResource AppText}" />
                                        </MenuItem.Icon>
                                    </MenuItem>
                                    <MenuItem Header="{lex:Loc CopyVideoURLToClipboard}" Click="MenuItemCopyVideoUrl_OnClick" Foreground="{DynamicResource AppText}">
                                        <MenuItem.Icon>
                                            <fa:SvgAwesome Icon="Solid_Link" Foreground="{DynamicResource AppText}" />
                                        </MenuItem.Icon>
                                    </MenuItem>
                                    <MenuItem Header="{lex:Loc OpenVideoInBrowser}" Click="MenuItemOpenInBrowser_OnClick" Foreground="{DynamicResource AppText}">
                                        <MenuItem.Icon>
                                            <fa:SvgAwesome Icon="Solid_ExternalLinkAlt" Foreground="{DynamicResource AppText}" />
                                        </MenuItem.Icon>
                                    </MenuItem>
                                </ContextMenu>
                            </Border.ContextMenu>
                            <StackPanel Orientation="Vertical" Width="220" Background="{DynamicResource AppElementBackground}">
                                <Image Source="{Binding Thumbnail}" MaxHeight="90"></Image>
                                <emoji:TextBlock TextWrapping="Wrap" MaxHeight="40" TextTrimming="CharacterEllipsis" Foreground="{DynamicResource AppText}">
                                    <emoji:TextBlock.Text>
                                        <MultiBinding StringFormat="[{0:d}] - {1}">
                                            <Binding Path="Time" />
                                            <Binding Path="Title" />
                                        </MultiBinding>
                                    </emoji:TextBlock.Text>
                                </emoji:TextBlock>
                                <DockPanel>
                                    <TextBlock Text="{Binding LengthFormatted, StringFormat=Duration: {0}}" HorizontalAlignment="Left" Foreground="{DynamicResource AppText}"></TextBlock>
                                    <TextBlock Text="{Binding Views, StringFormat=Views: {0}}" HorizontalAlignment="Right" Foreground="{DynamicResource AppText}"></TextBlock>
                                </DockPanel>
                            </StackPanel>
                        </Border>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </ScrollViewer>
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Bottom" >
            <Label Margin="10,0,0,3" Background="{DynamicResource AppElementBackground}" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}">
                <TextBlock>
                <Run Text="{lex:Loc SelectedItems}"/>
                <Run x:Name="textCount" Text="0"/>
                </TextBlock>
            </Label>
            <Button x:Name="btnSelectAll" Content="{lex:Loc SelectAll}" Margin="5,0,0,3" MinWidth="80" Height="30" Click="btnSelectAll_Click" Background="{DynamicResource ActionButtonBackground}" Foreground="{DynamicResource ActionButtonText}" BorderBrush="{DynamicResource ActionButtonBorder}"/>
        </StackPanel>
        <Button x:Name="btnPrev" Content="&lt;-" HorizontalAlignment="Center" VerticalAlignment="Bottom" Width="34" Margin="0,0,80,4" Click="btnPrev_Click" Background="{DynamicResource ActionButtonBackground}" Foreground="{DynamicResource ActionButtonText}" BorderBrush="{DynamicResource ActionButtonBorder}"/>
        <Button x:Name="btnNext" Content="->" HorizontalAlignment="Center" VerticalAlignment="Bottom" Width="34" Margin="80,0,0,4" Click="btnNext_Click" Background="{DynamicResource ActionButtonBackground}" Foreground="{DynamicResource ActionButtonText}" BorderBrush="{DynamicResource ActionButtonBorder}"/>
        <Button x:Name="btnQueue" Content="{lex:Loc AddToQueue}" HorizontalAlignment="Right" Margin="0,0,10,4" VerticalAlignment="Bottom" MinWidth="102" Height="36" Click="btnQueue_Click" Background="{DynamicResource ActionButtonBackground}" Foreground="{DynamicResource ActionButtonText}" BorderBrush="{DynamicResource ActionButtonBorder}"/>
    </Grid>
</Window>
