<mah:MetroWindow x:Class="ZuneModdingHelper.MainWindow"
                 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:ZuneModdingHelper"
                 xmlns:core="clr-namespace:ZuneModCore;assembly=ZuneModCore"
                 xmlns:mah="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
                 xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
                 xmlns:b="clr-namespace:ZuneModdingHelper.Behaviors"
                 mc:Ignorable="d"
                 Title="{x:Static local:App.Title}" Height="450" Width="800" WindowStartupLocation="CenterScreen"
                 Loaded="Window_Loaded">

    <mah:MetroWindow.IconTemplate>
        <DataTemplate>
            <mah:FontIcon Glyph="&#xE000;" FontFamily="{StaticResource ZMHIcons}"
                          Margin="0,0,-6,0"/>
        </DataTemplate>
    </mah:MetroWindow.IconTemplate>

    <mah:MetroWindow.RightWindowCommands>
        <mah:WindowCommands>
            <Button Style="{StaticResource MahApps.Styles.Button.WindowCommands}" ToolTip="Check for updates" Click="UpdatesButton_Click">
                <mah:FontIcon Glyph="&#xE003;" FontFamily="{StaticResource ZMHIcons}"/>
            </Button>
            <Button Style="{StaticResource MahApps.Styles.Button.WindowCommands}" ToolTip="About" Click="AboutButton_Click">
                <mah:FontIcon Glyph="&#xE004;" FontFamily="{StaticResource ZMHIcons}"/>
            </Button>
        </mah:WindowCommands>
    </mah:MetroWindow.RightWindowCommands>

    <mah:MetroWindow.Flyouts>
        <mah:FlyoutsControl>
            <mah:Flyout x:Name="AboutFlyout" Position="Right" IsModal="True" Theme="Adapt">
                <mah:Flyout.Header>
                    <Grid>
                        <TextBlock Text="About" FontSize="26" FontWeight="Bold"/>
                        <Button Click="DonateButton_Click" ToolTip="Support development of this and other projects"
                                HorizontalAlignment="Right" Margin="4"
                                Style="{StaticResource MahApps.Styles.Button.MetroSquare.Accent}">
                            <mah:FontIcon Glyph="&#xE006;" FontFamily="{StaticResource ZMHIcons}"/>
                        </Button>
                    </Grid>
                </mah:Flyout.Header>
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>

                    <TextBlock FontSize="14" Padding="16" TextWrapping="Wrap">
                        <Run Text="{x:Static local:App.Title}" FontWeight="Bold" FontSize="16"/><LineBreak/>
                        <Run Text="{x:Static local:App.VersionStr}"/><LineBreak/>
                        <Hyperlink NavigateUri="https://github.com/ZuneDev/ZuneModdingHelper" RequestNavigate="Link_RequestNavigate">
                            <Run Text="&#xE005;" FontFamily="{StaticResource ZMHIcons}"/>
                            <Run Text="View source"/>
                        </Hyperlink><LineBreak/>
                        <Hyperlink NavigateUri="https://github.com/ZuneDev/ZuneModdingHelper/releases" RequestNavigate="Link_RequestNavigate">
                            <Run Text="&#xE003;" FontFamily="{StaticResource ZMHIcons}"/>
                            <Run Text="View releases"/>
                        </Hyperlink><LineBreak/>
                        <Hyperlink NavigateUri="https://reddit.com/r/Zune" RequestNavigate="Link_RequestNavigate">
                            <Run Text="&#xE001;" FontFamily="{StaticResource ZMHIcons}"/>
                            <Run Text="Join r/Zune subreddit"/>
                        </Hyperlink><LineBreak/>
                        <Hyperlink NavigateUri="https://discord.zunes.me/" RequestNavigate="Link_RequestNavigate">
                            <Run Text="&#xE002;" FontFamily="{StaticResource ZMHIcons}"/>
                            <Run Text="Join r/Zune Discord server"/>
                        </Hyperlink><LineBreak/><LineBreak/>
                        <Run Text="Developed by Joshua &quot;Yoshi&quot; Askharoun." FontWeight="SemiBold"/>
                        <Run Text="Mods included with authors' permission."/><LineBreak/><LineBreak/>
                        <Run Text="I am not liable for any damages caused directly or indirectly by this tool or any of the mods it contains."/>
                    </TextBlock>
                </Grid>
            </mah:Flyout>
        </mah:FlyoutsControl>
    </mah:MetroWindow.Flyouts>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <ListView x:Name="ModList" HorizontalContentAlignment="Stretch"
                  ScrollViewer.HorizontalScrollBarVisibility="Disabled">
            <ListView.Resources>
                <Style x:Key="MetroButton" TargetType="Button" BasedOn="{StaticResource MahApps.Styles.Button.Square}">
                    <Setter Property="VerticalAlignment" Value="Center"/>
                    <Setter Property="Margin" Value="8,0,0,0"/>
                    <Setter Property="Grid.RowSpan" Value="3"/>
                </Style>
                <Style x:Key="MetroAccentButton" TargetType="Button" BasedOn="{StaticResource MahApps.Styles.Button.Square.Accent}">
                    <Setter Property="VerticalAlignment" Value="Center"/>
                    <Setter Property="Margin" Value="8,0,0,0"/>
                    <Setter Property="Grid.RowSpan" Value="3"/>
                </Style>
            </ListView.Resources>

            <ListView.ItemTemplate>
                <DataTemplate DataType="{x:Type core:Mod}">
                    <Border BorderThickness="0,0,0,0" BorderBrush="{StaticResource MahApps.Brushes.Separator}"
                            Padding="8">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>

                            <TextBlock TextTrimming="CharacterEllipsis">
                            <Run Text="{Binding Title, Mode=OneWay}" FontWeight="SemiBold" FontSize="16"/>
                            <Run Text=" By "/><Run Text="{Binding Author, Mode=OneWay}"/>
                            </TextBlock>
                            <TextBlock Text="{Binding Description}" Grid.Row="1" FontSize="14" TextWrapping="Wrap"/>

                            <Button x:Name="ModResetButton" Grid.Column="1" Click="ModResetButton_Click" ToolTip="Reset"
                                    Style="{StaticResource MetroButton}">
                                <mah:FontIcon Glyph="&#xE10E;" FontFamily="Segoe MDL2 Assets" Margin="4" />
                            </Button>

                            <Button x:Name="ModInstallButton" Grid.Column="2" Click="ModInstallButton_Click" ToolTip="Install"
                                    Style="{StaticResource MetroAccentButton}">
                                <mah:FontIcon Glyph="&#xE73E;" FontFamily="Segoe MDL2 Assets" Margin="4" />
                            </Button>
                        </Grid>
                    </Border>
                </DataTemplate>
            </ListView.ItemTemplate>

            <i:Interaction.Behaviors>
                <b:FadeAnimateItemsBehavior Tick="0:0:0.05">
                    <b:FadeAnimateItemsBehavior.Animation>
                        <DoubleAnimation From="0" To="1" Duration="0:0:0.3"/>
                    </b:FadeAnimateItemsBehavior.Animation>
                </b:FadeAnimateItemsBehavior>
            </i:Interaction.Behaviors>
        </ListView>

        <Border Grid.Row="1" BorderThickness="0,1,0,0" BorderBrush="{StaticResource MahApps.Brushes.Control.Border}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>

                <TextBlock Text="Zune software install directory:" FontSize="14" Margin="4,4,0,2" />
                <TextBox x:Name="ZuneInstallDirBox" Grid.Row="1" Margin="4,0,0,4"/>

                <Button x:Name="LocateZuneButton" Content="..." ToolTip="Locate Zune software..." Click="LocateZuneButton_Click"
                        Grid.Row="1" Grid.Column="1" VerticalAlignment="Stretch" HorizontalAlignment="Right" Margin="4,0,4,4"
                        Style="{StaticResource MahApps.Styles.Button.MetroSquare}"/>
            </Grid>
        </Border>
    </Grid>
</mah:MetroWindow>
