<UserControl xmlns="https://github.com/avaloniaui"
             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:customControls="clr-namespace:Nebula.Launcher.Controls"
             xmlns:popup="clr-namespace:Nebula.Launcher.ViewModels.Popup"
             mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
             x:Class="Nebula.Launcher.Views.Popup.LoadingContextView"
             x:DataType="popup:LoadingContextViewModel">
    <Design.DataContext>
        <popup:LoadingContextViewModel />
    </Design.DataContext>
    <StackPanel Margin="25" Spacing="15" >
        <Panel Margin="5">
            <Border Padding="15" Background="{StaticResource DefaultGrad}" BoxShadow="0 1 1 0 #121212">
                <Label VerticalAlignment="Center">
                    <TextBlock Text="{Binding LoadingName}"/>
                </Label>
            </Border>
            <Button 
                HorizontalAlignment="Right" 
                VerticalAlignment="Center" 
                Command="{Binding Cancel}" 
                IsVisible="{Binding IsCancellable}">
                <Border Padding="15" Background="{StaticResource DefaultGrad}" BoxShadow="0 1 1 0 #121212">
                    <customControls:LocalizedLabel LocalId="task-cancel"/> 
                </Border>
            </Button>
        </Panel>
        <Grid ColumnDefinitions="*,*">
            <ScrollViewer Grid.Column="0" Grid.ColumnSpan="{Binding LoadingColumnSize}">
                <ItemsControl
                    Background="#00000000"
                    ItemsSource="{Binding LoadingContexts}"
                    Padding="0" >
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <StackPanel Orientation="Vertical" Spacing="5" Margin="5" />
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                
                    <ItemsControl.ItemTemplate>
                        <DataTemplate DataType="{x:Type popup:LoadingContext}">
                            <Border Background="{StaticResource DefaultGrad}" BoxShadow="0 1 1 0 #121212">
                                <StackPanel Margin="15">
                                    <ProgressBar Height="40" Maximum="{Binding CurrJobs}" Value="{Binding ResolvedJobs}" />
                                    <Panel Margin="5 15 5 5">
                                        <Label HorizontalAlignment="Left" VerticalAlignment="Center">
                                            <TextBlock Text="{Binding LoadingText}" />
                                        </Label>
                                        <Label HorizontalAlignment="Right" VerticalAlignment="Center">
                                            <TextBlock Text="{Binding Message}" />
                                        </Label>
                                    </Panel>
                                </StackPanel>
                            </Border>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </ScrollViewer>
            
            <StackPanel 
                Grid.Column="1" 
                Margin="10" Spacing="15"
                IsVisible="{Binding ShowSpeed}">
                <customControls:SimpleGraph Values="{Binding Values}" 
                                            Height="167" 
                                            GridBrush="{StaticResource DefaultForeground}"/>
                <Border Background="{StaticResource DefaultGrad}" BoxShadow="0 1 1 0 #121212">
                    <Panel Margin="10">
                        <Label>Speed</Label>
                        <Label HorizontalAlignment="Right">
                            <TextBlock Text="{Binding SpeedText}" />
                        </Label>
                    </Panel>
                </Border>
            </StackPanel>
        </Grid>
    </StackPanel>
</UserControl>