<window:StyleableAppWindow
    x:Class="Ryujinx.Ava.UI.Windows.CheatWindow"
    xmlns="https://github.com/avaloniaui"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:ext="clr-namespace:Ryujinx.Ava.Common.Markup"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:window="clr-namespace:Ryujinx.Ava.UI.Windows"
    xmlns:controls="clr-namespace:Ryujinx.Ava.UI.Controls"
    Width="600"
    Height="750"
    MinWidth="500"
    MinHeight="500"
    x:DataType="window:CheatWindow"
    WindowStartupLocation="CenterOwner"
    mc:Ignorable="d"
    Focusable="True">
    <Window.Styles>
        <Style Selector="TreeViewItem">
            <Setter Property="IsExpanded" Value="True" />
        </Style>
    </Window.Styles>
    <Grid Name="CheatGrid" Margin="15" RowDefinitions="Auto,Auto,Auto,*,Auto" ColumnDefinitions="*,*">
        <Grid Name="FlushHeader" Grid.Row="1" Column="0" ColumnSpan="2" RowDefinitions="Auto,Auto,Auto" ColumnDefinitions="Auto,*,Auto,*">
            <controls:RyujinxLogo
                Grid.Row="0"
                Grid.Column="0"
                HorizontalAlignment="Left"
                Margin="-7, -22, 7, 0"
                Height="28"
                Width="28"
                ToolTip.Tip="{ext:WindowTitle CheatWindowTitle}"/>
            <StackPanel Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2"
                        Margin="7, -7, 0, 5"
                        Orientation="Horizontal"
                        VerticalAlignment="Center"
                        HorizontalAlignment="Stretch">
                <TextBlock
                    MaxWidth="500"
                    Margin="0,8,5,0"
                    LineHeight="30"
                    Text="{ext:Locale BuildId}"
                    TextAlignment="Center"
                    TextWrapping="Wrap" />
                <TextBox
                    Margin="0,0,0,0"
                    MinWidth="135"
                    Text="{Binding BuildId}"
                    IsReadOnly="True" />
            </StackPanel>
            <TextBlock
                Grid.Row="1"
                Grid.Column="0"
                Grid.ColumnSpan="4"
                MaxWidth="500"
                Margin="0,10,0,5"
                HorizontalAlignment="Stretch"
                VerticalAlignment="Center"
                LineHeight="18"
                Text="{Binding Heading}"
                TextAlignment="Center"
                TextWrapping="Wrap" />

        </Grid>
        <Grid Name="NormalHeader" Grid.Row="1" Column="0" ColumnSpan="2" RowDefinitions="Auto,Auto,Auto" ColumnDefinitions="*,*">
            <TextBlock
                Grid.Row="1"
                Grid.Column="0"
                Grid.ColumnSpan="2"
                MaxWidth="500"
                Margin="20,15,20,5"
                HorizontalAlignment="Center"
                VerticalAlignment="Center"
                LineHeight="18"
                Text="{Binding Heading}"
                TextAlignment="Center"
                TextWrapping="Wrap" />
            <TextBlock
                Grid.Row="2"
                Grid.Column="0"
                MaxWidth="500"
                Margin="140,15,20,5"
                HorizontalAlignment="Center"
                VerticalAlignment="Center"
                LineHeight="30"
                Text="{ext:Locale BuildId}"
                TextAlignment="Center"
                TextWrapping="Wrap" />
            <TextBox
                Grid.Row="2"
                Grid.Column="1"
                Margin="0,5,110,5"
                MinWidth="160"
                HorizontalAlignment="Center"
                VerticalAlignment="Center"
                Text="{Binding BuildId}"
                IsReadOnly="True" />
        </Grid>
        <Border
            Grid.Row="3"
            Grid.Column="0"
            Grid.ColumnSpan="2"
            Margin="5"
            HorizontalAlignment="Stretch"
            VerticalAlignment="Stretch"
            BorderBrush="Gray"
            BorderThickness="1">
            <TreeView
                Name="CheatsView"
                MinHeight="300"
                HorizontalAlignment="Stretch"
                VerticalAlignment="Stretch"
                ItemsSource="{Binding LoadedCheats}">
                <TreeView.Styles>
                    <Styles>
                        <Style Selector="TreeViewItem:empty /template/ ItemsPresenter">
                            <Setter Property="IsVisible" Value="False" />
                        </Style>
                    </Styles>
                </TreeView.Styles>
                <TreeView.ItemTemplate>
                    <TreeDataTemplate ItemsSource="{Binding SubNodes}">
                        <StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
                            <CheckBox MinWidth="20" IsChecked="{Binding IsEnabled}" />
                            <TextBlock Width="150" Text="{Binding CleanName}" IsVisible="{Binding !IsRootNode}" />
                            <TextBlock Width="150" Text="{Binding BuildId}" IsVisible="{Binding IsRootNode}" />
                            <TextBlock Text="{Binding Path}" IsVisible="{Binding IsRootNode}" />
                        </StackPanel>
                    </TreeDataTemplate>
                </TreeView.ItemTemplate>
            </TreeView>
        </Border>
        <DockPanel
            Grid.Row="4"
            Grid.Column="0"
            Grid.ColumnSpan="2"
            Margin="0"
            HorizontalAlignment="Stretch">
            <DockPanel Margin="0" HorizontalAlignment="Right">
                <Button
                    Name="SaveButton"
                    MinWidth="90"
                    Margin="5"
                    HotKey="Ctrl+S"
                    Command="{Binding Save}"
                    IsVisible="{Binding !NoCheatsFound}">
                    <TextBlock Text="{ext:Locale SettingsButtonSave}" />
                </Button>
                <Button
                    Name="CancelButton"
                    MinWidth="90"
                    Margin="5"
                    HotKey="Escape"
                    Command="{Binding Close}">
                    <TextBlock Text="{ext:Locale InputDialogCancel}" />
                </Button>
            </DockPanel>
        </DockPanel>
    </Grid>
</window:StyleableAppWindow>
