<Window x:Class="ServerManagerTool.GameDataWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:com="clr-namespace:ServerManagerTool.Common;assembly=ServerManager.Common"
        MinWidth="640" MinHeight="480" Width="800" Height="480" ResizeMode="CanResize" WindowStyle="ToolWindow" WindowStartupLocation="CenterOwner" ShowInTaskbar="False"
        Loaded="Window_Loaded"
        Icon="../Art/favicon.ico" Title="{DynamicResource GameDataWindow_Title}">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="..\Globalization\en-US\en-US.xaml"/>
                <ResourceDictionary Source="..\Styles\Default.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>
    
    <Grid Background="{StaticResource BeigeGradient}">
        <Grid.RowDefinitions>
            <RowDefinition/>
        </Grid.RowDefinitions>

        <GroupBox Grid.Row="0" HorizontalAlignment="Stretch" Style="{StaticResource GroupBoxStyle}">
            <GroupBox.Header>
                <StackPanel Orientation="Horizontal" Margin="0,5,0,5">
                    <Button Width="22" Height="22" Click="AddGameData_Click" ToolTip="{DynamicResource GameDataWindow_AddGameDataTooltip}">
                        <Image Source="{com:Icon Path=/Ark Server Manager;component/Art/Add.ico,Size=32}"/>
                    </Button>
                    <Button Width="22" Height="22" Click="ClearGameData_Click" Margin="10,0,0,0" ToolTip="{DynamicResource GameDataWindow_ClearGameDataTooltip}">
                        <Image Source="{com:Icon Path=/Ark Server Manager;component/Art/Delete.ico,Size=32}"/>
                    </Button>
                    <Button Width="22" Height="22" Click="ReloadGameData_Click" Margin="10,0,0,0" ToolTip="{DynamicResource GameDataWindow_ReloadGameDataTooltip}">
                        <Image Source="{com:Icon Path=/Ark Server Manager;component/Art/Reload.ico,Size=32}"/>
                    </Button>
                    <Button Width="22" Height="22" Click="ValidateGameData_Click" Margin="10,0,0,0" ToolTip="{DynamicResource GameDataWindow_ValidateGameDataTooltip}">
                        <Image Source="{com:Icon Path=/Ark Server Manager;component/Art/Validate.ico,Size=32}"/>
                    </Button>
                    <Button Width="22" Height="22" Click="OpenGameDataFolder_Click" Margin="10,0,0,0" ToolTip="{DynamicResource GameDataWindow_OpenGameDataFolderTooltip}">
                        <Image Source="{com:Icon Path=/Ark Server Manager;component/Art/FolderOpen.ico,Size=32}"/>
                    </Button>
                    <Button Width="22" Height="22" Click="GameDataForum_Click" Margin="20,0,0,0" ToolTip="{DynamicResource GameDataWindow_GameDataForumTooltip}">
                        <Image Source="{com:Icon Path=/Ark Server Manager;component/Art/Help.ico,Size=32}"/>
                    </Button>
                </StackPanel>
            </GroupBox.Header>

            <DataGrid ItemsSource="{Binding GameDataFiles}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="False" CanUserSortColumns="true" SelectionMode="Single" CanUserResizeColumns="False" CanUserResizeRows="False" RowHeaderWidth="25">
                <DataGrid.Resources>
                    <Style TargetType="{x:Type DataGridRow}">
                        <Style.Resources>
                            <SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}" Color="{x:Static SystemColors.HighlightColor}"/>
                            <SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightTextBrushKey}" Color="{x:Static SystemColors.HighlightTextColor}"/>
                        </Style.Resources>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding IsUserData}" Value="False">
                                <Setter Property="Foreground" Value="Blue" />
                            </DataTrigger>
                            <DataTrigger Binding="{Binding HasError}" Value="True">
                                <Setter Property="Foreground" Value="Red" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </DataGrid.Resources>

                <DataGrid.HorizontalGridLinesBrush>
                    <SolidColorBrush Color="#FFB4B4B4"/>
                </DataGrid.HorizontalGridLinesBrush>
                <DataGrid.VerticalGridLinesBrush>
                    <SolidColorBrush Color="#FFB4B4B4"/>
                </DataGrid.VerticalGridLinesBrush>

                <DataGrid.Columns>
                    <DataGridTextColumn     Width="4*" Binding="{Binding FileName, Mode=OneWay}">
                        <DataGridTextColumn.Header>
                            <TextBlock Text="{DynamicResource GameDataWindow_NameColumnLabel}" />
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                    <DataGridTextColumn     Width="Auto" MinWidth="80" Binding="{Binding Version, Mode=OneWay}">
                        <DataGridTextColumn.Header>
                            <TextBlock Text="{DynamicResource GameDataWindow_VersionColumnLabel}" />
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                    <DataGridTextColumn     Width="130" Binding="{Binding CreatedDate, Mode=OneWay}" Header="{DynamicResource GameDataWindow_DateColumnLabel}">
                        <DataGridTextColumn.HeaderStyle>
                            <Style TargetType="DataGridColumnHeader" BasedOn="{StaticResource {x:Type DataGridColumnHeader}}">
                                <Setter Property="HorizontalContentAlignment" Value="Right"/>
                            </Style>
                        </DataGridTextColumn.HeaderStyle>
                        <DataGridTextColumn.CellStyle>
                            <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}">
                                <Setter Property="HorizontalAlignment" Value="Right"/>
                            </Style>
                        </DataGridTextColumn.CellStyle>
                    </DataGridTextColumn>
                    <DataGridTemplateColumn Width="30" CanUserReorder="False" IsReadOnly="True">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <Button Width="22" Height="22" Margin="0" IsTabStop="False" HorizontalAlignment="Center" VerticalAlignment="Center" Click="RemoveGameData_Click" ToolTip="{DynamicResource GameDataWindow_RemoveGameDataTooltip}">
                                    <Image Source="{com:Icon Path=/Ark Server Manager;component/Art/Delete.ico,Size=32}"/>
                                </Button>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                        <DataGridTemplateColumn.CellStyle>
                            <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}">
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding IsUserData}" Value="False">
                                        <Setter Property="Visibility" Value="Hidden" />
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </DataGridTemplateColumn.CellStyle>
                    </DataGridTemplateColumn>
                </DataGrid.Columns>
            </DataGrid>
        </GroupBox>
    </Grid>
</Window>
