<Window
  x:Class="VPet.ModMaker.Views.ModEdit.ModEditWindow"
  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:ll="clr-namespace:LinePutScript.Localization.WPF;assembly=LinePutScript.Localization.WPF"
  xmlns:local="clr-namespace:VPet.ModMaker.Views.ModEdit"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  xmlns:pu="https://opensource.panuon.com/wpf-ui"
  xmlns:vm="clr-namespace:VPet.ModMaker.ViewModels.ModEdit"
  Title="{ll:Str 模组编辑器}"
  Width="1000"
  Height="500"
  d:DataContext="{d:DesignInstance Type=vm:ModEditWindowVM}"
  WindowStartupLocation="CenterScreen"
  mc:Ignorable="d">
  <Grid>
    <Grid.ColumnDefinitions>
      <ColumnDefinition />
      <ColumnDefinition Width="Auto" />
    </Grid.ColumnDefinitions>
    <Grid>
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition />
      </Grid.ColumnDefinitions>
      <Grid.Style>
        <Style TargetType="Grid">
          <Setter Property="IsEnabled" Value="True" />
          <Style.Triggers>
            <DataTrigger Binding="{Binding SelectedItem, ElementName=ListBox_Cultures}" Value="{x:Null}">
              <Setter Property="IsEnabled" Value="False" />
            </DataTrigger>
          </Style.Triggers>
        </Style>
      </Grid.Style>
      <Grid MaxWidth="256">
        <Grid.RowDefinitions>
          <RowDefinition Height="Auto" />
          <RowDefinition />
        </Grid.RowDefinitions>
        <Image
          x:Name="Image_ModImage"
          Width="256"
          Height="256"
          Source="{Binding ModInfo.Value.Image.Value}"
          Stretch="Uniform">
          <Image.ContextMenu>
            <ContextMenu>
              <MenuItem
                x:Name="MenuItem_ChangeModImage"
                Command="{Binding ChangeImageCommand}"
                Header="{ll:Str 修改图片}" />
            </ContextMenu>
          </Image.ContextMenu>
        </Image>
        <Button
          x:Name="Button_AddModImage"
          HorizontalAlignment="Center"
          VerticalAlignment="Center"
          Command="{Binding ChangeImageCommand}"
          Content="{ll:Str 添加图片}">
          <Button.Style>
            <Style BasedOn="{StaticResource {x:Type Button}}" TargetType="Button">
              <Setter Property="Visibility" Value="Hidden" />
              <Style.Triggers>
                <DataTrigger Binding="{Binding ModInfo.Value.Image.Value}" Value="{x:Null}">
                  <Setter Property="Visibility" Value="Visible" />
                </DataTrigger>
              </Style.Triggers>
            </Style>
          </Button.Style>
        </Button>
        <ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
          <Grid>
            <Grid.ColumnDefinitions>
              <ColumnDefinition Width="Auto" />
              <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
              <RowDefinition Height="Auto" />
              <RowDefinition Height="Auto" />
              <RowDefinition Height="Auto" />
              <RowDefinition Height="Auto" />
              <RowDefinition Height="Auto" />
              <RowDefinition />
            </Grid.RowDefinitions>
            <Label Content="Id" />
            <TextBox
              Grid.Column="1"
              pu:TextBoxHelper.Watermark="Id"
              Text="{Binding ModInfo.Value.Id.Value, UpdateSourceTrigger=PropertyChanged}" />
            <Label Grid.Row="1" Content="{ll:Str 作者}" />
            <TextBox
              x:Name="TextBox_Author"
              Grid.Row="1"
              Grid.Column="1"
              pu:TextBoxHelper.Watermark="{ll:Str 作者}"
              Text="{Binding ModInfo.Value.Author.Value, UpdateSourceTrigger=PropertyChanged}" />
            <Label Grid.Row="2" Content="{ll:Str 游戏版本}" />
            <TextBox
              x:Name="TextBox_GameVersion"
              Grid.Row="2"
              Grid.Column="1"
              pu:TextBoxHelper.Watermark="{ll:Str 游戏版本}"
              Text="{Binding ModInfo.Value.GameVersion.Value, UpdateSourceTrigger=PropertyChanged}" />
            <Label Grid.Row="3" Content="{ll:Str 模组版本}" />
            <TextBox
              x:Name="TextBox_ModVersion"
              Grid.Row="3"
              Grid.Column="1"
              pu:TextBoxHelper.Watermark="{ll:Str 模组版本}"
              Text="{Binding ModInfo.Value.ModVersion.Value, UpdateSourceTrigger=PropertyChanged}" />
            <Label Grid.Row="4" Content="{ll:Str 模组名称}" />
            <TextBox
              Grid.Row="4"
              Grid.Column="1"
              pu:TextBoxHelper.Watermark="{ll:Str 模组名称}"
              Text="{Binding ModInfo.Value.CurrentI18nData.Value.Name.Value, UpdateSourceTrigger=PropertyChanged}" />
            <Label Grid.Row="5" Content="{ll:Str 模组介绍}" />
            <TextBox
              x:Name="TextBox_Description"
              Grid.Row="5"
              Grid.Column="1"
              HorizontalContentAlignment="Left"
              VerticalContentAlignment="Top"
              d:Text="AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
              pu:TextBoxHelper.Watermark="{ll:Str 模组介绍}"
              Text="{Binding ModInfo.Value.CurrentI18nData.Value.Description.Value, UpdateSourceTrigger=PropertyChanged}"
              TextWrapping="Wrap" />
          </Grid>
        </ScrollViewer>
      </Grid>
      <Grid Grid.Column="1">
        <TabControl>
          <TabItem Tag="{ll:Str 食物}">
            <TabItem.Header>
              <MultiBinding Converter="{StaticResource StringFormatConverter}" ConverterParameter="{}{0} ({1})">
                <Binding Path="Tag" RelativeSource="{RelativeSource Mode=Self}" />
                <Binding Path="ModInfo.Value.Foods.Count" />
              </MultiBinding>
            </TabItem.Header>
            <Frame Content="{Binding ModEditWindow.FoodPage}" />
          </TabItem>
          <TabItem Tag="{ll:Str 点击文本}">
            <TabItem.Header>
              <MultiBinding Converter="{StaticResource StringFormatConverter}" ConverterParameter="{}{0} ({1})">
                <Binding Path="Tag" RelativeSource="{RelativeSource Mode=Self}" />
                <Binding Path="ModInfo.Value.ClickTexts.Count" />
              </MultiBinding>
            </TabItem.Header>
            <Frame Content="{Binding ModEditWindow.ClickTextPage}" />
          </TabItem>
          <TabItem Tag="{ll:Str 低状态文本}">
            <TabItem.Header>
              <MultiBinding Converter="{StaticResource StringFormatConverter}" ConverterParameter="{}{0} ({1})">
                <Binding Path="Tag" RelativeSource="{RelativeSource Mode=Self}" />
                <Binding Path="ModInfo.Value.LowTexts.Count" />
              </MultiBinding>
            </TabItem.Header>
            <Frame Content="{Binding ModEditWindow.LowTextPage}" />
          </TabItem>
          <TabItem Tag="{ll:Str 选择文本}">
            <TabItem.Header>
              <MultiBinding Converter="{StaticResource StringFormatConverter}" ConverterParameter="{}{0} ({1})">
                <Binding Path="Tag" RelativeSource="{RelativeSource Mode=Self}" />
                <Binding Path="ModInfo.Value.SelectTexts.Count" />
              </MultiBinding>
            </TabItem.Header>
            <Frame Content="{Binding ModEditWindow.SelectTextPage}" />
          </TabItem>
          <TabItem Tag="{ll:Str 宠物}">
            <TabItem.Header>
              <MultiBinding Converter="{StaticResource StringFormatConverter}" ConverterParameter="{}{0} ({1})">
                <Binding Path="Tag" RelativeSource="{RelativeSource Mode=Self}" />
                <Binding Path="ModInfo.Value.Pets.Count" />
              </MultiBinding>
            </TabItem.Header>
            <Frame Content="{Binding ModEditWindow.PetPage}" />
          </TabItem>
          <TabItem Tag="{ll:Str 工作}">
            <TabItem.Header>
              <MultiBinding Converter="{StaticResource StringFormatConverter}" ConverterParameter="{}{0} ({1})">
                <Binding Path="Tag" RelativeSource="{RelativeSource Mode=Self}" />
                <Binding Path="ModEditWindow.WorkPage.ViewModel.CurrentPet.Value.Works.Count" />
              </MultiBinding>
            </TabItem.Header>
            <Frame Content="{Binding ModEditWindow.WorkPage}" />
          </TabItem>
          <TabItem Tag="{ll:Str 移动}">
            <TabItem.Header>
              <MultiBinding Converter="{StaticResource StringFormatConverter}" ConverterParameter="{}{0} ({1})">
                <Binding Path="Tag" RelativeSource="{RelativeSource Mode=Self}" />
                <Binding Path="ModEditWindow.MovePage.ViewModel.CurrentPet.Value.Moves.Count" />
              </MultiBinding>
            </TabItem.Header>
            <Frame Content="{Binding ModEditWindow.MovePage}" />
          </TabItem>
          <TabItem Tag="{ll:Str 动画}">
            <TabItem.Header>
              <MultiBinding Converter="{StaticResource StringFormatConverter}" ConverterParameter="{}{0} ({1})">
                <Binding Path="Tag" RelativeSource="{RelativeSource Mode=Self}" />
                <Binding Path="ModEditWindow.AnimePage.ViewModel.CurrentPet.Value.Animes.Count" />
              </MultiBinding>
            </TabItem.Header>
            <Frame Content="{Binding ModEditWindow.AnimePage}" />
          </TabItem>
          <!--<TabItem Header="物品 (0)" Tag="{ll:Str 物品}">
            <Grid>
              <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition />
              </Grid.RowDefinitions>
              <TextBox x:Name="TextBox_SearchItem" />
              <ListBox x:Name="ListBox_Item" />
              <Button
                x:Name="Button_AddItem"
                Grid.Row="1"
                HorizontalAlignment="Right"
                VerticalAlignment="Bottom"
                Click="Button_AddItem_Click"
                Content="➕"
                Style="{StaticResource AddButton}" />
            </Grid>
          </TabItem>-->
          <!--<TabItem Header="动画 (0)">
            <Grid>
              <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition />
              </Grid.RowDefinitions>
              <TextBox x:Name="TextBox_SearchAnime" />
              <ListBox x:Name="ListBox_Anime" />
              <Button
                x:Name="Button_AddAnime"
                Grid.Row="1"
                HorizontalAlignment="Right"
                VerticalAlignment="Bottom"
                Click="Button_AddAnime_Click"
                Content="➕"
                Style="{StaticResource AddButton}" />
            </Grid>
          </TabItem>
          <TabItem Header="语音 (0)">
            <Grid>
              <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition />
              </Grid.RowDefinitions>
              <TextBox x:Name="TextBox_SearchAudio" />
              <ListBox x:Name="ListBox_Audio" />
              <Button
                x:Name="Button_AddAudio"
                Grid.Row="1"
                HorizontalAlignment="Right"
                VerticalAlignment="Bottom"
                Click="Button_AddAudio_Click"
                Content="➕"
                Style="{StaticResource AddButton}" />
            </Grid>
          </TabItem>-->
        </TabControl>
      </Grid>
    </Grid>
    <Grid Grid.Column="1">
      <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition />
        <RowDefinition Height="Auto" />
      </Grid.RowDefinitions>
      <Button Command="{Binding AddCultureCommand}" Content="{ll:Str 添加文化}" />
      <ListBox
        x:Name="ListBox_Cultures"
        Grid.Row="1"
        d:ItemsSource="{d:SampleData ItemCount=5}"
        ItemsSource="{Binding I18nData.CultureNames}"
        ScrollViewer.VerticalScrollBarVisibility="Auto"
        SelectedItem="{Binding I18nData.CultureName.Value}">
        <ListBox.ItemContainerStyle>
          <Style BasedOn="{StaticResource {x:Type ListBoxItem}}" TargetType="ListBoxItem">
            <Setter Property="Tag" Value="{Binding DataContext, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}" />
            <Setter Property="Content" Value="{Binding}" />
            <Setter Property="ContextMenu">
              <Setter.Value>
                <ContextMenu>
                  <MenuItem
                    Command="{Binding PlacementTarget.Tag.EditCultureCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"
                    CommandParameter="{Binding}"
                    Header="{ll:Str 修改语言}" />
                  <MenuItem
                    Command="{Binding PlacementTarget.Tag.RemoveCultureCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"
                    CommandParameter="{Binding}"
                    Header="{ll:Str 删除语言}" />
                </ContextMenu>
              </Setter.Value>
            </Setter>
          </Style>
        </ListBox.ItemContainerStyle>
      </ListBox>
      <StackPanel Grid.Row="2">
        <Button
          x:Name="Button_Save"
          Command="{Binding SaveCommand}"
          Content="{ll:Str 保存}" />
        <Button
          x:Name="Button_SaveTo"
          Command="{Binding SaveToCommand}"
          Content="{ll:Str 保存至}" />
      </StackPanel>
    </Grid>
  </Grid>
</Window>
