<Window
  x:Class="VPet.ModMaker.Views.ModMakerWindow"
  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"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  xmlns:pu="clr-namespace:Panuon.WPF.UI;assembly=Panuon.WPF.UI"
  xmlns:vm="clr-namespace:VPet.ModMaker.ViewModels"
  Title="{ll:Str Mod制作器}"
  Width="600"
  Height="450"
  d:DataContext="{d:DesignInstance Type=vm:ModMakerWindowVM}"
  FontSize="16"
  WindowStartupLocation="CenterScreen"
  mc:Ignorable="d">
  <Grid>
    <Grid.ColumnDefinitions>
      <ColumnDefinition />
      <ColumnDefinition Width="Auto" />
    </Grid.ColumnDefinitions>
    <Grid>
      <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="Auto" />
        <RowDefinition />
      </Grid.RowDefinitions>
      <Label Background="{x:Null}" Content="{ll:Str 打开最近的内容}" />
      <Grid Grid.Row="1">
        <Grid.ColumnDefinitions>
          <ColumnDefinition />
          <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <TextBox pu:TextBoxHelper.Watermark="{ll:Str 最近的内容}" Text="{Binding HistoriesSearchText.Value}" />
        <Button
          Grid.Column="1"
          Command="{Binding ClearHistoriesCommand}"
          Content="{ll:Str 清空历史}" />
      </Grid>
      <ListBox
        Grid.Row="2"
        d:ItemsSource="{d:SampleData ItemCount=5}"
        ItemsSource="{Binding ShowHistories.Value}"
        Style="{StaticResource SideMenuListBoxStyle}">
        <ListBox.ItemContainerStyle>
          <Style BasedOn="{StaticResource {x:Type ListBoxItem}}" TargetType="ListBoxItem">
            <Setter Property="Height" Value="64" />
            <EventSetter Event="MouseDoubleClick" Handler="ListBoxItem_MouseDoubleClick" />
            <Setter Property="Template">
              <Setter.Value>
                <ControlTemplate>
                  <Grid
                    Margin="5"
                    Background="{DynamicResource PrimaryDark}"
                    Tag="{Binding DataContext, RelativeSource={RelativeSource AncestorType=Window, Mode=FindAncestor}}"
                    ToolTip="{Binding InfoFile}">
                    <Grid.ContextMenu>
                      <ContextMenu>
                        <MenuItem
                          Command="{Binding PlacementTarget.Tag.RemoveHistoryCommand, RelativeSource={RelativeSource AncestorType=ContextMenu, Mode=FindAncestor}}"
                          CommandParameter="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource AncestorType=ContextMenu, Mode=FindAncestor}}"
                          Header="{ll:Str 删除此历史}" />
                      </ContextMenu>
                    </Grid.ContextMenu>
                    <Grid.ColumnDefinitions>
                      <ColumnDefinition Width="Auto" />
                      <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Image Width="64" Source="{Binding Image}" />
                    <Grid Grid.Column="1">
                      <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition />
                      </Grid.RowDefinitions>
                      <TextBlock
                        d:Text="{ll:Str Mod名称}"
                        FontWeight="Bold"
                        Text="{Binding Id}"
                        TextWrapping="Wrap" />
                      <TextBlock
                        HorizontalAlignment="Right"
                        VerticalAlignment="Top"
                        Text="{Binding LastTime, StringFormat={}yyyy/MM/dd HH:mm}" />
                      <TextBlock
                        Grid.Row="1"
                        VerticalAlignment="Bottom"
                        d:Text="{ll:Str Mod描述}"
                        Text="{Binding SourcePath}"
                        TextWrapping="Wrap" />
                    </Grid>
                  </Grid>
                </ControlTemplate>
              </Setter.Value>
            </Setter>
          </Style>
        </ListBox.ItemContainerStyle>
      </ListBox>
    </Grid>
    <Grid Grid.Column="1">
      <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition />
      </Grid.RowDefinitions>
      <Label Background="{x:Null}" Content="{ll:Str 开始使用}" />
      <StackPanel Grid.Row="1">
        <Button
          x:Name="Button_CreateNewMod"
          Command="{Binding CreateNewModCommand}"
          Content="{ll:Str 创建新的模组}" />
        <Button
          x:Name="Button_OpenFromFile"
          Command="{Binding LoadModFromFileCommand}"
          Content="{ll:Str 从文件中载入}" />
      </StackPanel>
    </Grid>
  </Grid>
</Window>
