<!-- Game Resource browser

Copyright (C) 2014-2016 by morkt

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
-->
<w:ModalWindow x:Class="GARbro.GUI.AboutBox"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:GARbro.GUI"
        xmlns:w="clr-namespace:Rnd.Windows"
        xmlns:s="clr-namespace:GARbro.GUI.Strings"
        xmlns:gr="clr-namespace:GameRes;assembly=GameRes"
        xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
        xmlns:sys="clr-namespace:System;assembly=System"
        Title="{x:Static s:guiStrings.TextAboutTitle}" Height="306" Width="550" ResizeMode="NoResize"
        Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"
        ShowInTaskbar="False" WindowStartupLocation="CenterOwner">
    <Window.Resources>
        <local:BooleanToVisibiltyConverter x:Key="guiBoolToVisibilityConverter" />
        <local:CanCreateConverter x:Key="guiCanCreateConverter"/>
        <CollectionViewSource x:Key="ArcFormatsSource" Source="{Binding Source={x:Static gr:FormatCatalog.Instance}, Path=ArcFormats, Mode=OneWay}">
            <CollectionViewSource.SortDescriptions>
                <scm:SortDescription PropertyName="Tag" Direction="Ascending"/>
            </CollectionViewSource.SortDescriptions>
        </CollectionViewSource>
        <CollectionViewSource x:Key="ImageFormatsSource" Source="{Binding Source={x:Static gr:FormatCatalog.Instance}, Path=ImageFormats, Mode=OneWay}">
            <CollectionViewSource.SortDescriptions>
                <scm:SortDescription PropertyName="IsBuiltin" Direction="Descending"/>
                <scm:SortDescription PropertyName="Tag" Direction="Ascending"/>
            </CollectionViewSource.SortDescriptions>
        </CollectionViewSource>
        <Style x:Key="HiddenHeaderStyle" TargetType="{x:Type GridViewColumnHeader}">
            <Setter Property="Visibility" Value="Collapsed" />
        </Style>
        <Style x:Key="DisableSelectionStyle" TargetType="{x:Type ListViewItem}">
            <Setter Property="Focusable" Value="false"/>
            <Setter Property="Margin" Value="-5,-1,-5,-1"/>
            <Setter Property="Padding" Value="0"/>
        </Style>
    </Window.Resources>
    <Grid DataContext="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:AboutBox}}}">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <StackPanel Grid.Column="0" Margin="10">
            <TextBox Text="{Binding Path=AssemblyTitle, Mode=OneWay}" IsReadOnly="True" Background="Transparent" BorderThickness="0" Margin="0,0,0,10" />
            <TextBox Text="{Binding Path=VersionString, Mode=OneWay}" IsReadOnly="True" Background="Transparent" BorderThickness="0" Margin="0,0,0,10" />
            <TextBox Text="{Binding Path=AssemblyCopyright, Mode=OneWay}" IsReadOnly="True" Background="Transparent" BorderThickness="0" Margin="0,0,0,10" />
            <TextBlock Background="Transparent" Margin="0,0,0,10" Padding="3,0,0,0">
                <Hyperlink NavigateUri="{StaticResource DevLink}" RequestNavigate="Hyperlink_RequestNavigate">
                    <TextBlock Text="{x:Static s:guiStrings.LabelDevSite}" ToolTip="{StaticResource DevLink}"/>
                </Hyperlink>
            </TextBlock>
        </StackPanel>
        <Button Grid.Column="0" VerticalAlignment="Bottom" HorizontalAlignment="Left" VerticalContentAlignment="Center" IsDefault="true"
                Content="{x:Static s:guiStrings.ButtonOK}" Margin="10,0,0,10" Width="70" Height="25" Click="Button_Click" IsCancel="True"/>
        <Grid Grid.Column="1" Margin="10">
            <TabControl>
                <TabItem Header="{x:Static s:guiStrings.TextAboutArchives}">
                    <Border BorderThickness="1" BorderBrush="Black" VerticalAlignment="Stretch" Margin="0" SnapsToDevicePixels="True">
                        <ListView Name="ArchiveFormats" ItemsSource="{Binding Source={StaticResource ArcFormatsSource}}"
                                  ItemContainerStyle="{StaticResource DisableSelectionStyle}" BorderThickness="0" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.CanContentScroll="False">
                            <ListView.View>
                                <GridView ColumnHeaderContainerStyle="{StaticResource HiddenHeaderStyle}">
                                    <GridViewColumn>
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding Tag}" Margin="0"/>
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                    <GridViewColumn>
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding Path=CanWrite, Converter={StaticResource guiCanCreateConverter}}" Margin="-6,0,-6,0"/>
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                    <GridViewColumn>
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding Description}" Margin="0"/>
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                </GridView>
                            </ListView.View>
                        </ListView>
                    </Border> 
                </TabItem>
                <TabItem Header="{x:Static s:guiStrings.TextAboutImages}">
                    <Border BorderThickness="1" BorderBrush="Black" VerticalAlignment="Stretch" Margin="0" SnapsToDevicePixels="True">
                        <ScrollViewer VerticalAlignment="Stretch" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Margin="0" Background="{DynamicResource {x:Static SystemColors.ControlLightLightBrushKey}}">
                            <ItemsControl Name="ImageFormats" ItemsSource="{Binding Source={StaticResource ImageFormatsSource}}">
                                <ItemsControl.ItemTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="{Binding Tag}" Margin="3,0,5,0" />
                                            <TextBlock Text="{x:Static s:guiStrings.TextAboutBuiltin}" Margin="0,0,5,0" Visibility="{Binding IsBuiltin, Converter={StaticResource guiBoolToVisibilityConverter}}"/>
                                            <TextBlock Text="{Binding Description}" />
                                        </StackPanel>
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                            </ItemsControl>
                        </ScrollViewer>
                    </Border>
                </TabItem>
                <TabItem Header="{x:Static s:guiStrings.TextAboutAudio}">
                    <Border BorderThickness="1" BorderBrush="Black" VerticalAlignment="Stretch" Margin="0" SnapsToDevicePixels="True">
                        <ScrollViewer VerticalAlignment="Stretch" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Margin="0" Background="{DynamicResource {x:Static SystemColors.ControlLightLightBrushKey}}">
                            <ItemsControl Name="AudioFormats" ItemsSource="{Binding Source={x:Static gr:FormatCatalog.Instance}, Path=AudioFormats, Mode=OneWay}">
                                <ItemsControl.ItemTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="{Binding Tag}" Margin="3,0,7,0" />
                                            <TextBlock Text="{Binding Description}" />
                                        </StackPanel>
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                            </ItemsControl>
                        </ScrollViewer>
                    </Border>
                </TabItem>
                <TabItem Header="{x:Static s:guiStrings.TextAboutLicense}">
                    <ScrollViewer>
                        <RichTextBox Name="LicenseTabText" IsReadOnly="True"/>
                    </ScrollViewer>
                </TabItem>
            </TabControl>
        </Grid>
    </Grid>
</w:ModalWindow>
