<mah:MetroWindow x:Class="ZuneModdingHelper.OptionsUIDialog"
                 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:convert="clr-namespace:ZuneModdingHelper.Converters"
                 xmlns:mod="clr-namespace:ZuneModCore;assembly=ZuneModCore"
                 xmlns:absui="clr-namespace:OwlCore.Wpf.AbstractUI.Controls;assembly=OwlCore.Wpf"
                 xmlns:mah="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
                 mc:Ignorable="d"
                 Title="Options" Height="450" Width="800"
                 WindowStyle="ToolWindow"
                 Loaded="Window_Loaded">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/OwlCore.Wpf;component/AbstractUI/Themes/AbstractUIGroupPresenterStyle.xaml" />
            </ResourceDictionary.MergedDictionaries>

            <convert:BoolToSymbolConverter x:Key="BoolToSymbolConverter"/>
            <convert:NullToVisibilityConverter x:Key="NullToVisibilityConverter"/>
        </ResourceDictionary>
    </Window.Resources>

    <Window.DataContext>
        <mod:ModViewModel x:Name="ViewModel"/>
    </Window.DataContext>

    <Grid x:Name="OptionsUIGrid" Grid.RowSpan="2">
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        
        <ScrollViewer>
            <StackPanel Orientation="Vertical">
                <StackPanel Margin="10,10,10,0" Visibility="{Binding HasDependencies, Converter={StaticResource BooleanToVisibilityConverter}}">
                    <TextBlock Text="Dependencies" FontSize="26"/>
                    <ItemsControl x:Name="DependenciesPresenter" ItemsSource="{Binding Dependencies}">
                        <ItemsControl.ItemTemplate>
                            <DataTemplate DataType="{x:Type mod:ModDependency}">
                                <TextBlock Margin="4" FontSize="14">
                                <Run Text="{Binding Status, ConverterParameter='&#xE73E;,&#xE711;', Mode=OneWay, Converter={StaticResource BoolToSymbolConverter}}"
                                     Foreground="{Binding Status, ConverterParameter='#16c60c,#f03a17', Mode=OneWay, Converter={StaticResource BoolToSymbolConverter}}"
                                     FontFamily="Segoe MDL2 Assets" BaselineAlignment="Center"/>
                                <Run Text="{Binding Id}" BaselineAlignment="Center"/>
                                </TextBlock>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>

                    <Rectangle Fill="{StaticResource MahApps.Brushes.Control.Border}"
                               Height="2" Margin="0,10,0,-7"/>
                </StackPanel>
                
                <absui:AbstractUIGroupPresenter x:Name="OptionsUIPresenter" ViewModel="{Binding OptionsViewModel}"
                                                TemplateSelector="{StaticResource GroupTemplateSelector}"
                                                Visibility="{Binding OptionsViewModel, Converter={StaticResource NullToVisibilityConverter}}"/>
            </StackPanel>
        </ScrollViewer>
        
        <Border Grid.Row="1" BorderThickness="0,1,0,0" BorderBrush="{StaticResource MahApps.Brushes.Control.Border}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>

                <Grid.Resources>
                    <Style x:Key="PrimaryButton" TargetType="Button" BasedOn="{StaticResource MahApps.Styles.Button.Dialogs.Accent}">
                        <Setter Property="Margin" Value="8"/>
                        <Setter Property="Padding" Value="2"/>
                        <Setter Property="MinWidth" Value="75"/>
                        <Setter Property="HorizontalAlignment" Value="Right"/>
                    </Style>
                    <Style x:Key="SecondaryButton" TargetType="Button" BasedOn="{StaticResource MahApps.Styles.Button.Dialogs}">
                        <Setter Property="Margin" Value="8"/>
                        <Setter Property="Padding" Value="2"/>
                        <Setter Property="MinWidth" Value="75"/>
                        <Setter Property="HorizontalAlignment" Value="Right"/>
                    </Style>
                </Grid.Resources>
                
                <Button x:Name="OptionsUICancelButton" Content="Cancel" Click="OptionsUICancelButton_Click"
                        Grid.Column="1" Style="{StaticResource SecondaryButton}"/>
                
                <Button x:Name="OptionsUINextButton" Content="{Binding ActionButtonText}"
                        Command="{Binding ActionCommand}"
                        Grid.Column="2" Style="{StaticResource PrimaryButton}"/>
            </Grid>
        </Border>
    </Grid>
</mah:MetroWindow>
