<UserControl
    d:DesignHeight="500"
    d:DesignWidth="800"
    mc:Ignorable="d"
    x:Class="Nebula.Launcher.Views.ServerEntryView"
    x:DataType="viewModels:ServerEntryModelView"
    xmlns="https://github.com/avaloniaui"
    xmlns:converters="clr-namespace:Nebula.Launcher.Converters"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:models="clr-namespace:Nebula.Shared.Models;assembly=Nebula.Shared"
    xmlns:system="clr-namespace:System;assembly=System.Runtime"
    xmlns:viewModels="clr-namespace:Nebula.Launcher.ViewModels"
    xmlns:views="clr-namespace:Nebula.Launcher.Views"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    IsVisible="{Binding IsVisible}">
    <Design.DataContext>
        <viewModels:ServerEntryModelView />
    </Design.DataContext>

    <Border
        Background="{StaticResource DefaultGrad}"
        BoxShadow="-2 0 5 -1 #121212"
        CornerRadius="10"
        Margin="5">

        <Grid ColumnDefinitions="*,80,50,50" RowDefinitions="35,*,*">
            <Border
                Background="Transparent"
                BoxShadow="0 3 3 -2 #121212"
                CornerRadius="10"
                Grid.Column="0"
                Grid.ColumnSpan="2"
                Grid.Row="0"
                IsVisible="{Binding ExpandInfo}" />

            <Button
                Background="Transparent"
                Command="{Binding ExpandInfoRequired}"
                Grid.Column="0"
                Grid.Row="0"
                HorizontalAlignment="Stretch"
                VerticalAlignment="Stretch">
                <ScrollViewer
                    HorizontalScrollBarVisibility="Hidden"
                    Margin="10,0,0,0"
                    VerticalScrollBarVisibility="Disabled"
                    x:Name="AutoScrollViewer">
                    <Label VerticalAlignment="Center">
                        <TextBlock Text="{Binding Status.Name}" />
                    </Label>
                </ScrollViewer>
            </Button>

            <StackPanel
                Grid.Column="1"
                Grid.Row="0"
                HorizontalAlignment="Center"
                Orientation="Horizontal"
                VerticalAlignment="Center">
                <Label>
                    <TextBlock Text="{Binding Status.Players}" />
                </Label>
                <Label>/</Label>
                <Label>
                    <TextBlock Text="{Binding Status.SoftMaxPlayers}" />
                </Label>
            </StackPanel>

            <Panel
                Grid.Column="2"
                Grid.Row="0"
                Margin="5,0,0,0">
                <Button
                    Command="{Binding ToggleFavorites}"
                    CornerRadius="10,10,10,10"
                    HorizontalAlignment="Stretch"
                    IsVisible="{Binding !IsFavorite}"
                    VerticalAlignment="Stretch">
                    <Svg Margin="4" Path="/Assets/svg/star.svg" />
                </Button>
                <Button
                    Command="{Binding ToggleFavorites}"
                    CornerRadius="10,10,10,10"
                    HorizontalAlignment="Stretch"
                    IsVisible="{Binding IsFavorite}"
                    VerticalAlignment="Stretch">
                    <Svg Margin="4" Path="/Assets/svg/starfull.svg" />
                </Button>
            </Panel>

            <Panel
                Grid.Column="3"
                Grid.Row="0"
                Margin="5,0,0,0">
                <Button
                    Command="{Binding RunInstance}"
                    CornerRadius="10,10,10,10"
                    HorizontalAlignment="Stretch"
                    IsVisible="{Binding RunVisible}"
                    VerticalAlignment="Stretch">
                    <Svg Margin="4" Path="/Assets/svg/play.svg" />
                </Button>
                <Grid ColumnDefinitions="*" IsVisible="{Binding !RunVisible}">
                    <Button
                        Command="{Binding ReadLog}"
                        CornerRadius="10"
                        HorizontalAlignment="Stretch"
                        VerticalAlignment="Stretch">
                        <Svg Margin="4" Path="/Assets/svg/newspaper.svg" />
                    </Button>
                </Grid>
            </Panel>

            <Label
                FontSize="12"
                Grid.Column="0"
                Grid.ColumnSpan="2"
                Grid.Row="1"
                HorizontalAlignment="Left"
                IsVisible="{Binding ExpandInfo}"
                Margin="15">
                <TextBlock Text="{Binding Description}" TextWrapping="Wrap" />
            </Label>

            <Border
                Background="Transparent"
                BoxShadow="0 -3 3 -2 #121212"
                CornerRadius="10"
                Grid.Column="0"
                Grid.ColumnSpan="3"
                Grid.Row="2"
                IsVisible="{Binding ExpandInfo}"
                Margin="5">
                <StackPanel Margin="5" Spacing="5">
                    <StackPanel Orientation="Horizontal">
                        <Label FontSize="10" VerticalAlignment="Center">Tags:</Label>
                        <ItemsControl ItemsSource="{Binding Tags}">
                            <ItemsControl.ItemTemplate>
                                <DataTemplate DataType="{x:Type system:String}">
                                    <Border
                                        Background="{StaticResource DefaultForeground}"
                                        BorderThickness="0"
                                        CornerRadius="8"
                                        HorizontalAlignment="Center"
                                        Margin="1,1,1,1"
                                        VerticalAlignment="Center">
                                        <Label FontSize="10" Margin="5,0,5,0">
                                            <TextBlock Text="{Binding}" />
                                        </Label>
                                    </Border>
                                </DataTemplate>
                            </ItemsControl.ItemTemplate>
                            <ItemsControl.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <StackPanel
                                        HorizontalAlignment="Left"
                                        Margin="5"
                                        Orientation="Horizontal"
                                        Spacing="8"
                                        VerticalAlignment="Center" />
                                </ItemsPanelTemplate>
                            </ItemsControl.ItemsPanel>
                        </ItemsControl>
                    </StackPanel>

                    <StackPanel Orientation="Horizontal">
                        <Label FontSize="10" VerticalAlignment="Center">Map:</Label>
                        <Border
                            Background="{StaticResource DefaultForeground}"
                            BorderThickness="0"
                            CornerRadius="8"
                            HorizontalAlignment="Center"
                            Margin="5"
                            VerticalAlignment="Center">
                            <Label FontSize="10" Margin="5,0,5,0">
                                <TextBlock Text="{Binding Status.Map}" />
                            </Label>
                        </Border>
                    </StackPanel>

                    <StackPanel Orientation="Horizontal">
                        <Label FontSize="10" VerticalAlignment="Center">Preset:</Label>
                        <Border
                            Background="{StaticResource DefaultForeground}"
                            BorderThickness="0"
                            CornerRadius="8"
                            HorizontalAlignment="Center"
                            Margin="5"
                            VerticalAlignment="Center">
                            <Label FontSize="10" Margin="5,0,5,0">
                                <TextBlock Text="{Binding Status.Preset}" />
                            </Label>
                        </Border>
                    </StackPanel>

                    <ItemsControl ItemsSource="{Binding Links}">
                        <ItemsControl.ItemTemplate>
                            <DataTemplate DataType="{x:Type models:ServerLink}">
                                <Border
                                    Background="Transparent"
                                    BoxShadow="0 0 13 -1 #121212"
                                    CornerRadius="10">
                                    <Button
                                        Command="{Binding $parent[views:ServerEntryView].((viewModels:ServerEntryModelView)DataContext).OnLinkGo}"
                                        CommandParameter="{Binding Url}"
                                        Margin="3">
                                        <StackPanel Orientation="Horizontal" Spacing="5">
                                            <Svg Height="20" Path="{Binding Icon, Converter={x:Static converters:TypeConverters.IconConverter}}" />
                                            <Label FontSize="10">
                                                <TextBlock Text="{Binding Name}" />
                                            </Label>
                                        </StackPanel>
                                    </Button>
                                </Border>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                        <ItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                                <StackPanel
                                    HorizontalAlignment="Left"
                                    Margin="5"
                                    Orientation="Horizontal"
                                    Spacing="8"
                                    VerticalAlignment="Center" />
                            </ItemsPanelTemplate>
                        </ItemsControl.ItemsPanel>
                    </ItemsControl>
                </StackPanel>
            </Border>
            <StackPanel
                Grid.Column="3"
                Grid.Row="1"
                IsVisible="{Binding ExpandInfo}"
                Margin="5,5,0,0"
                Spacing="5">
                <Button
                    Command="{Binding OpenContentViewer}">
                    <Svg Margin="4" Path="/Assets/svg/folder.svg" />
                </Button>
                <Button
                    Command="{Binding StopInstance}"
                    CornerRadius="10"
                    Height="35"
                    HorizontalAlignment="Stretch"
                    IsVisible="{Binding !RunVisible}"
                    VerticalAlignment="Stretch">
                    <Svg Margin="4" Path="/Assets/svg/stop.svg" />
                </Button>
            </StackPanel>
        </Grid>
    </Border>
</UserControl>
