<Window x:Class="FFXIV_TexTools.Views.Controls.MaterialFlagsEditor"
        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:FFXIV_TexTools.Views.Controls"
        mc:Ignorable="d"
        xmlns:resx="clr-namespace:FFXIV_TexTools.Resources"
        resx:Localization.Enabled="True"
        Title="Material Flags Editor"
        ResizeMode="NoResize"
        SizeToContent="WidthAndHeight">
    <Window.Resources>
        <ToolTip x:Key="MaterialFlagsTooltip">
            <TextBlock>
            <Run Text="Material Flags are toggles that turn on/off specific behaviors."/><LineBreak/>
            <Run Text="Many flags do not (as of yet) have known purposes."/>
            </TextBlock>
        </ToolTip>
        <ToolTip x:Key="MaterialFlagsHexTooltip">
            <TextBlock>
            <Run Text="Hex representation of the Material Flags"/><LineBreak/>
            <Run Text="For use when copy-pasting to other tools. (Ex. Penumbra)"/>
            </TextBlock>
        </ToolTip>
        <ToolTip x:Key="AdditionalDataTooltip">
            <TextBlock>
            <Run Text="Additional Data that exists in the Material File."/><LineBreak/>
            <Run Text="Its purpose is not currently known."/>
            </TextBlock>
        </ToolTip>
        <ToolTip x:Key="AdditionalDataHexTooltip">
            <TextBlock>
            <Run Text="Hex representation of the Additional Data"/><LineBreak/>
            <Run Text="For use when copy-pasting to other tools. (Ex. Penumbra)"/>
            </TextBlock>
        </ToolTip>
    </Window.Resources>
    <Grid Height="460" Width="800">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="1*"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="1*"></RowDefinition>
            <RowDefinition Height="50"></RowDefinition>
            <RowDefinition Height="40"></RowDefinition>
        </Grid.RowDefinitions>

        <Border Grid.Row="0" Grid.Column="0" BorderBrush="Gray" Padding="0" Margin="5" BorderThickness="1">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="1*"></ColumnDefinition>
                    <ColumnDefinition Width="1*"></ColumnDefinition>
                    <ColumnDefinition Width="1*"></ColumnDefinition>
                    <ColumnDefinition Width="1*"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="40"></RowDefinition>
                    <RowDefinition Height="1*"></RowDefinition>
                    <RowDefinition Height="40"></RowDefinition>
                </Grid.RowDefinitions>

                <Label Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" Grid.ColumnSpan="4" ToolTip="{StaticResource MaterialFlagsTooltip}">Material Flags</Label>
                <local:BitflagControl x:Name="BitControl0" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" Grid.Column="0" Grid.Row="1"/>
                <local:BitflagControl x:Name="BitControl1" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" Grid.Column="1" Grid.Row="1"/>
                <local:BitflagControl x:Name="BitControl2" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" Grid.Column="2" Grid.Row="1"/>
                <local:BitflagControl x:Name="BitControl3" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" Grid.Column="3" Grid.Row="1"/>

                <Label Grid.Row="2" Grid.Column="1" HorizontalContentAlignment="right" HorizontalAlignment="right" VerticalAlignment="Center"  Content="Material Flags Hex Representation:" ToolTip="{StaticResource MaterialFlagsHexTooltip}" ></Label>

                <TextBox x:Name="HexBox" Grid.Row="2" Grid.Column="2" HorizontalAlignment="Left" VerticalAlignment="Center" Height="30" Width="100" PreviewTextInput="HexInput" ToolTip="{StaticResource MaterialFlagsHexTooltip}" >
                    <Binding Path="FullInt" UpdateSourceTrigger="PropertyChanged">
                        <Binding.ValidationRules>
                            <local:HexValidationRule />
                        </Binding.ValidationRules>
                        <Binding.Converter>
                            <local:HexValueConverter />
                        </Binding.Converter>
                    </Binding>
                </TextBox>
            </Grid>
        </Border>


        <Border Grid.Row="1" Grid.Column="0" BorderBrush="Gray" Padding="0" Margin="5" BorderThickness="1">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="1*"></ColumnDefinition>
                    <ColumnDefinition Width="1*"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="40"></RowDefinition>
                </Grid.RowDefinitions>

                <Label Grid.Row="1" Grid.Column="0" HorizontalContentAlignment="right" HorizontalAlignment="right" VerticalAlignment="Center"  Content="Additional Data:" ToolTip="{StaticResource AdditionalDataTooltip}"></Label>
                <TextBox Grid.Row="1" Grid.Column="1" HorizontalAlignment="Left" Height="30" Width="150"  VerticalAlignment="Center" ToolTip="{StaticResource AdditionalDataTooltip}" PreviewTextInput="HexInput">
                <Binding Path="AdditionalData" UpdateSourceTrigger="PropertyChanged">
                    <Binding.ValidationRules>
                        <local:HexValidationRule />
                    </Binding.ValidationRules>
                    <Binding.Converter>
                            <local:HexByteValueConverter />
                    </Binding.Converter>
                </Binding>
                </TextBox>
            </Grid>
        </Border>
        
        <Button x:Name="ConfirmButton" Content="Confirm" Grid.Row="2" Width="100" Height="30" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="10,0,10,0" Click="Confirm_Click"/>
        <Button x:Name="CancelButton" Content="Cancel" Grid.Row="2" Width="100" Height="30" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10,0,10,0" Click="Cancel_Click"/>
    </Grid>
</Window>
