mirror of
https://github.com/LorisYounger/VPet.ModMaker.git
synced 2024-08-30 18:22:21 +00:00
优化界面
This commit is contained in:
parent
355742b219
commit
bfd45fd2aa
@ -217,8 +217,8 @@ public class AnimeEditWindowVM
|
||||
/// <param name="value">动画模型</param>
|
||||
private void RemoveImageCommand_ExecuteEvent(AnimeModel value)
|
||||
{
|
||||
value.Images.Remove(CurrentImageModel.Value);
|
||||
CurrentImageModel.Value.Close();
|
||||
value.Images.Remove(CurrentImageModel.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1,5 +1,6 @@
|
||||
using HKW.HKWViewModels.SimpleObservable;
|
||||
using LinePutScript.Localization.WPF;
|
||||
using Panuon.WPF.UI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
@ -180,14 +181,15 @@ public class AnimePageVM
|
||||
/// <param name="model">动画类型模型</param>
|
||||
public void Edit(object model)
|
||||
{
|
||||
var pendingHandler = PendingBox.Show("载入中".Translate());
|
||||
if (model is AnimeTypeModel animeTypeModel)
|
||||
{
|
||||
// TODO: FoodAnime
|
||||
var window = new AnimeEditWindow();
|
||||
var vm = window.ViewModel;
|
||||
vm.CurrentPet = CurrentPet.Value;
|
||||
vm.OldAnime = animeTypeModel;
|
||||
var newAnime = vm.Anime.Value = new(animeTypeModel);
|
||||
pendingHandler.Close();
|
||||
window.ShowDialog();
|
||||
if (window.IsCancel)
|
||||
return;
|
||||
@ -208,6 +210,7 @@ public class AnimePageVM
|
||||
vm.CurrentPet = CurrentPet.Value;
|
||||
vm.OldAnime = foodAnimeTypeModel;
|
||||
var newAnime = vm.Anime.Value = new(foodAnimeTypeModel);
|
||||
pendingHandler.Close();
|
||||
window.ShowDialog();
|
||||
if (window.IsCancel)
|
||||
return;
|
||||
|
@ -126,6 +126,11 @@ public class FoodAnimeEditWindowVM
|
||||
/// 清除顶层图片命令
|
||||
/// </summary>
|
||||
public ObservableCommand<FoodAnimeModel> ClearFrontImageCommand { get; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// 改变顶层图片命令
|
||||
/// </summary>
|
||||
public ObservableCommand<FoodAnimeModel> ChangeFrontImageCommand { get; } = new();
|
||||
#endregion
|
||||
|
||||
#region BackImage
|
||||
@ -143,6 +148,11 @@ public class FoodAnimeEditWindowVM
|
||||
/// 清除底层图片命令
|
||||
/// </summary>
|
||||
public ObservableCommand<FoodAnimeModel> ClearBackImageCommand { get; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// 改变底层图片命令
|
||||
/// </summary>
|
||||
public ObservableCommand<FoodAnimeModel> ChangeBackImageCommand { get; } = new();
|
||||
#endregion
|
||||
#region FoodLocation
|
||||
/// <summary>
|
||||
@ -169,6 +179,7 @@ public class FoodAnimeEditWindowVM
|
||||
/// 重置食物图片
|
||||
/// </summary>
|
||||
public ObservableCommand ResetFoodImageCommand { get; } = new();
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
@ -210,10 +221,12 @@ public class FoodAnimeEditWindowVM
|
||||
AddFrontImageCommand.ExecuteEvent += AddFrontImageCommand_ExecuteEvent;
|
||||
RemoveFrontImageCommand.ExecuteEvent += RemoveFrontImageCommand_ExecuteEvent;
|
||||
ClearFrontImageCommand.ExecuteEvent += ClearFrontImageCommand_ExecuteEvent;
|
||||
ChangeFrontImageCommand.ExecuteEvent += ChangeFrontImageCommand_ExecuteEvent;
|
||||
|
||||
AddBackImageCommand.ExecuteEvent += AddBackImageCommand_ExecuteEvent;
|
||||
RemoveBackImageCommand.ExecuteEvent += RemoveBackImageCommand_ExecuteEvent;
|
||||
ClearBackImageCommand.ExecuteEvent += ClearBackImageCommand_ExecuteEvent;
|
||||
ChangeBackImageCommand.ExecuteEvent += ChangeBackImageCommand_ExecuteEvent;
|
||||
|
||||
AddeFoodLocationCommand.ExecuteEvent += AddeFoodLocationCommand_ExecuteEvent;
|
||||
RemoveFoodLocationCommand.ExecuteEvent += RemoveFoodLocationCommand_ExecuteEvent;
|
||||
@ -318,8 +331,8 @@ public class FoodAnimeEditWindowVM
|
||||
/// <param name="value">动画模型</param>
|
||||
private void RemoveFrontImageCommand_ExecuteEvent(FoodAnimeModel value)
|
||||
{
|
||||
value.FrontImages.Remove(CurrentFrontImageModel.Value);
|
||||
CurrentFrontImageModel.Value.Close();
|
||||
value.FrontImages.Remove(CurrentFrontImageModel.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -338,6 +351,33 @@ public class FoodAnimeEditWindowVM
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 替换顶层图片
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void ChangeFrontImageCommand_ExecuteEvent(FoodAnimeModel value)
|
||||
{
|
||||
OpenFileDialog openFileDialog =
|
||||
new() { Title = "选择图片".Translate(), Filter = $"图片|*.png".Translate() };
|
||||
if (openFileDialog.ShowDialog() is not true)
|
||||
return;
|
||||
BitmapImage newImage;
|
||||
try
|
||||
{
|
||||
newImage = Utils.LoadImageToMemoryStream(openFileDialog.FileName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("替换失败失败 \n{0}".Translate(ex));
|
||||
return;
|
||||
}
|
||||
if (newImage is null)
|
||||
return;
|
||||
CurrentFrontImageModel.Value.Close();
|
||||
CurrentFrontImageModel.Value.Image.Value = newImage;
|
||||
}
|
||||
|
||||
private void ShowFrontImagesPathInfo(FoodImagesPath imagesPath)
|
||||
{
|
||||
MessageBox.Show(
|
||||
@ -375,8 +415,8 @@ public class FoodAnimeEditWindowVM
|
||||
/// <param name="value">动画模型</param>
|
||||
private void RemoveBackImageCommand_ExecuteEvent(FoodAnimeModel value)
|
||||
{
|
||||
value.BackImages.Remove(CurrentBackImageModel.Value);
|
||||
CurrentBackImageModel.Value.Close();
|
||||
value.BackImages.Remove(CurrentBackImageModel.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -394,6 +434,33 @@ public class FoodAnimeEditWindowVM
|
||||
value.BackImages.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 替换底层图片
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void ChangeBackImageCommand_ExecuteEvent(FoodAnimeModel value)
|
||||
{
|
||||
OpenFileDialog openFileDialog =
|
||||
new() { Title = "选择图片".Translate(), Filter = $"图片|*.png".Translate() };
|
||||
if (openFileDialog.ShowDialog() is not true)
|
||||
return;
|
||||
BitmapImage newImage;
|
||||
try
|
||||
{
|
||||
newImage = Utils.LoadImageToMemoryStream(openFileDialog.FileName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("替换失败失败 \n{0}".Translate(ex));
|
||||
return;
|
||||
}
|
||||
if (newImage is null)
|
||||
return;
|
||||
CurrentBackImageModel.Value.Close();
|
||||
CurrentBackImageModel.Value.Image.Value = newImage;
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
|
@ -84,11 +84,13 @@
|
||||
ItemsSource="{Binding Images, IsAsync=True}"
|
||||
PreviewMouseMove="ListBox_PreviewMouseMove"
|
||||
PreviewMouseWheel="ListBox_PreviewMouseWheel"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Auto"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Hidden"
|
||||
SelectedItem="{Binding DataContext.CurrentImageModel.Value, RelativeSource={RelativeSource AncestorType=Window, Mode=FindAncestor}}"
|
||||
SelectionChanged="ListBox_SelectionChanged">
|
||||
<ListBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<WrapPanel />
|
||||
<StackPanel Orientation="Horizontal" />
|
||||
</ItemsPanelTemplate>
|
||||
</ListBox.ItemsPanel>
|
||||
<ListBox.ItemTemplate>
|
||||
|
@ -97,8 +97,8 @@ public partial class AnimeEditWindow : Window
|
||||
if (listBoxItem == null || listBoxItem.Content != listBox.SelectedItem)
|
||||
return;
|
||||
var dataObj = new DataObject(listBoxItem.Content);
|
||||
DragDrop.DoDragDrop(listBox, dataObj, DragDropEffects.Move);
|
||||
_dropSender = sender;
|
||||
DragDrop.DoDragDrop(listBox, dataObj, DragDropEffects.Move);
|
||||
}
|
||||
|
||||
private void ListBox_Drop(object sender, DragEventArgs e)
|
||||
@ -141,6 +141,7 @@ public partial class AnimeEditWindow : Window
|
||||
return;
|
||||
if (listBox.DataContext is AnimeModel model)
|
||||
ViewModel.CurrentAnimeModel.Value = model;
|
||||
listBox.ScrollIntoView(listBox.SelectedItem);
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
|
@ -53,185 +53,34 @@
|
||||
<Expander.Header>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" MinWidth="200" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<!--<TextBlock Margin="10,0,10,0">
|
||||
<TextBlock Margin="10,0,10,0">
|
||||
<TextBlock.Text>
|
||||
<MultiBinding Converter="{StaticResource StringFormatConverter}" ConverterParameter="{}({0})">
|
||||
<Binding Path="Images.Count" />
|
||||
<MultiBinding Converter="{StaticResource StringFormatConverter}" ConverterParameter="{}({0}, {1}, {2})">
|
||||
<Binding Path="FrontImages.Count" />
|
||||
<Binding Path="BackImages.Count" />
|
||||
<Binding Path="FoodLocations.Count" />
|
||||
</MultiBinding>
|
||||
</TextBlock.Text>
|
||||
</TextBlock>-->
|
||||
<TextBox Grid.Column="1" Text="{Binding Id.Value, UpdateSourceTrigger=PropertyChanged}" />
|
||||
</TextBlock>
|
||||
<TextBox
|
||||
Grid.Column="1"
|
||||
pu:TextBoxHelper.Watermark="{ll:Str 动画Id(非必要)}"
|
||||
Text="{Binding Id.Value, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<!-- pu:TextBoxHelper.Watermark="{ll:Str 动画Id(非必要)}" -->
|
||||
</Grid>
|
||||
</Expander.Header>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="Auto" MinWidth="200" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<GroupBox>
|
||||
<GroupBox.Header>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Label d:Content="顶层图片" Content="{ll:Str 顶层图片}" />
|
||||
<TextBlock Margin="10,0,0,0">
|
||||
<TextBlock.Text>
|
||||
<MultiBinding Converter="{StaticResource StringFormatConverter}" ConverterParameter="{}({0})">
|
||||
<Binding Path="FrontImages.Count" />
|
||||
</MultiBinding>
|
||||
</TextBlock.Text>
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</GroupBox.Header>
|
||||
<ListBox
|
||||
d:ItemsSource="{d:SampleData ItemCount=5}"
|
||||
AllowDrop="True"
|
||||
Drop="ListBox_Drop"
|
||||
ItemsSource="{Binding FrontImages, IsAsync=True}"
|
||||
PreviewMouseMove="ListBox_PreviewMouseMove"
|
||||
SelectedItem="{Binding DataContext.CurrentFrontImageModel.Value, RelativeSource={RelativeSource AncestorType=Window, Mode=FindAncestor}}"
|
||||
SelectionChanged="ListBox_SelectionChanged">
|
||||
<ListBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<WrapPanel />
|
||||
</ItemsPanelTemplate>
|
||||
</ListBox.ItemsPanel>
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid DataContext="{Binding DataContext, RelativeSource={RelativeSource AncestorType=Expander, Mode=FindAncestor}}" Tag="{Binding DataContext, RelativeSource={RelativeSource AncestorType=Window, Mode=FindAncestor}}">
|
||||
<Grid.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem
|
||||
d:Header="修改图片"
|
||||
Command="{Binding PlacementTarget.Tag.ChangeImageCommand, RelativeSource={RelativeSource AncestorType=ContextMenu, Mode=FindAncestor}}"
|
||||
CommandParameter="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource AncestorType=ContextMenu, Mode=FindAncestor}}"
|
||||
Header="{ll:Str 修改图片}"
|
||||
IsEnabled="{Binding PlacementTarget.Tag.PlayCommand.CurrentCanExecute.Value, RelativeSource={RelativeSource AncestorType=ContextMenu, Mode=FindAncestor}}" />
|
||||
<MenuItem
|
||||
d:Header="删除图片"
|
||||
Command="{Binding PlacementTarget.Tag.RemoveImageCommand, RelativeSource={RelativeSource AncestorType=ContextMenu, Mode=FindAncestor}}"
|
||||
CommandParameter="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource AncestorType=ContextMenu, Mode=FindAncestor}}"
|
||||
Header="{ll:Str 删除图片}"
|
||||
IsEnabled="{Binding PlacementTarget.Tag.PlayCommand.CurrentCanExecute.Value, RelativeSource={RelativeSource AncestorType=ContextMenu, Mode=FindAncestor}}" />
|
||||
</ContextMenu>
|
||||
</Grid.ContextMenu>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Image
|
||||
Width="150"
|
||||
Height="150"
|
||||
d:DataContext=""
|
||||
DataContext="{Binding DataContext, RelativeSource={RelativeSource AncestorType=ListBoxItem, Mode=FindAncestor}}"
|
||||
Source="{Binding Image.Value, IsAsync=True}">
|
||||
<Image.ToolTip>
|
||||
<Image
|
||||
Width="250"
|
||||
Height="250"
|
||||
Source="{Binding Image.Value, IsAsync=True}" />
|
||||
</Image.ToolTip>
|
||||
</Image>
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label d:Content="持续时间(ms)" Content="{ll:Str 持续时间(ms)}" />
|
||||
<pu:NumberInput Grid.Column="1" Value="{Binding DataContext.Duration.Value, RelativeSource={RelativeSource AncestorType=ListBoxItem, Mode=FindAncestor}}" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</GroupBox>
|
||||
<GroupBox Grid.Row="1">
|
||||
<GroupBox.Header>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Label d:Content="底层图片" Content="{ll:Str 底层图片}" />
|
||||
<TextBlock Margin="10,0,0,0">
|
||||
<TextBlock.Text>
|
||||
<MultiBinding Converter="{StaticResource StringFormatConverter}" ConverterParameter="{}({0})">
|
||||
<Binding Path="BackImages.Count" />
|
||||
</MultiBinding>
|
||||
</TextBlock.Text>
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</GroupBox.Header>
|
||||
<ListBox
|
||||
d:ItemsSource="{d:SampleData ItemCount=5}"
|
||||
AllowDrop="True"
|
||||
Drop="ListBox_Drop"
|
||||
ItemsSource="{Binding BackImages, IsAsync=True}"
|
||||
PreviewMouseMove="ListBox_PreviewMouseMove"
|
||||
SelectedItem="{Binding DataContext.CurrentBackImageModel.Value, RelativeSource={RelativeSource AncestorType=Window, Mode=FindAncestor}}"
|
||||
SelectionChanged="ListBox_SelectionChanged">
|
||||
<ListBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<WrapPanel />
|
||||
</ItemsPanelTemplate>
|
||||
</ListBox.ItemsPanel>
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid DataContext="{Binding DataContext, RelativeSource={RelativeSource AncestorType=Expander, Mode=FindAncestor}}" Tag="{Binding DataContext, RelativeSource={RelativeSource AncestorType=Window, Mode=FindAncestor}}">
|
||||
<Grid.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem
|
||||
d:Header="修改图片"
|
||||
Command="{Binding PlacementTarget.Tag.ChangeImageCommand, RelativeSource={RelativeSource AncestorType=ContextMenu, Mode=FindAncestor}}"
|
||||
CommandParameter="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource AncestorType=ContextMenu, Mode=FindAncestor}}"
|
||||
Header="{ll:Str 修改图片}"
|
||||
IsEnabled="{Binding PlacementTarget.Tag.PlayCommand.CurrentCanExecute.Value, RelativeSource={RelativeSource AncestorType=ContextMenu, Mode=FindAncestor}}" />
|
||||
<MenuItem
|
||||
d:Header="删除图片"
|
||||
Command="{Binding PlacementTarget.Tag.RemoveImageCommand, RelativeSource={RelativeSource AncestorType=ContextMenu, Mode=FindAncestor}}"
|
||||
CommandParameter="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource AncestorType=ContextMenu, Mode=FindAncestor}}"
|
||||
Header="{ll:Str 删除图片}" />
|
||||
</ContextMenu>
|
||||
</Grid.ContextMenu>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Image
|
||||
Width="150"
|
||||
Height="150"
|
||||
d:DataContext=""
|
||||
DataContext="{Binding DataContext, RelativeSource={RelativeSource AncestorType=ListBoxItem, Mode=FindAncestor}}"
|
||||
Source="{Binding Image.Value, IsAsync=True}">
|
||||
<Image.ToolTip>
|
||||
<Image
|
||||
Width="250"
|
||||
Height="250"
|
||||
Source="{Binding Image.Value, IsAsync=True}" />
|
||||
</Image.ToolTip>
|
||||
</Image>
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label d:Content="持续时间(ms)" Content="{ll:Str 持续时间(ms)}" />
|
||||
<pu:NumberInput Grid.Column="1" Value="{Binding DataContext.Duration.Value, RelativeSource={RelativeSource AncestorType=ListBoxItem, Mode=FindAncestor}}" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</GroupBox>
|
||||
</Grid>
|
||||
<GroupBox Grid.Column="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<GroupBox>
|
||||
<GroupBox.Header>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Label d:Content="食物位置" Content="{ll:Str 食物位置}" />
|
||||
<Label d:Content="顶层图片" Content="{ll:Str 顶层图片}" />
|
||||
<TextBlock Margin="10,0,0,0">
|
||||
<TextBlock.Text>
|
||||
<MultiBinding Converter="{StaticResource StringFormatConverter}" ConverterParameter="{}({0})">
|
||||
@ -241,11 +90,172 @@
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</GroupBox.Header>
|
||||
<ListBox
|
||||
d:ItemsSource="{d:SampleData ItemCount=5}"
|
||||
AllowDrop="True"
|
||||
Drop="ListBox_Drop"
|
||||
ItemsSource="{Binding FrontImages, IsAsync=True}"
|
||||
PreviewMouseMove="ListBox_PreviewMouseMove"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Auto"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Hidden"
|
||||
SelectedItem="{Binding DataContext.CurrentFrontImageModel.Value, RelativeSource={RelativeSource AncestorType=Window, Mode=FindAncestor}}"
|
||||
SelectionChanged="ListBox_SelectionChanged">
|
||||
<ListBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel Orientation="Horizontal" />
|
||||
</ItemsPanelTemplate>
|
||||
</ListBox.ItemsPanel>
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid DataContext="{Binding DataContext, RelativeSource={RelativeSource AncestorType=Expander, Mode=FindAncestor}}" Tag="{Binding DataContext, RelativeSource={RelativeSource AncestorType=Window, Mode=FindAncestor}}">
|
||||
<Grid.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem
|
||||
d:Header="修改图片"
|
||||
Command="{Binding PlacementTarget.Tag.ChangeFrontImageCommand, RelativeSource={RelativeSource AncestorType=ContextMenu, Mode=FindAncestor}}"
|
||||
CommandParameter="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource AncestorType=ContextMenu, Mode=FindAncestor}}"
|
||||
Header="{ll:Str 修改图片}"
|
||||
IsEnabled="{Binding PlacementTarget.Tag.PlayCommand.CurrentCanExecute.Value, RelativeSource={RelativeSource AncestorType=ContextMenu, Mode=FindAncestor}}" />
|
||||
<MenuItem
|
||||
d:Header="删除图片"
|
||||
Command="{Binding PlacementTarget.Tag.RemoveFrontImageCommand, RelativeSource={RelativeSource AncestorType=ContextMenu, Mode=FindAncestor}}"
|
||||
CommandParameter="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource AncestorType=ContextMenu, Mode=FindAncestor}}"
|
||||
Header="{ll:Str 删除图片}"
|
||||
IsEnabled="{Binding PlacementTarget.Tag.PlayCommand.CurrentCanExecute.Value, RelativeSource={RelativeSource AncestorType=ContextMenu, Mode=FindAncestor}}" />
|
||||
</ContextMenu>
|
||||
</Grid.ContextMenu>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Image
|
||||
Width="150"
|
||||
Height="150"
|
||||
d:DataContext=""
|
||||
DataContext="{Binding DataContext, RelativeSource={RelativeSource AncestorType=ListBoxItem, Mode=FindAncestor}}"
|
||||
Source="{Binding Image.Value, IsAsync=True}">
|
||||
<Image.ToolTip>
|
||||
<Image
|
||||
Width="250"
|
||||
Height="250"
|
||||
Source="{Binding Image.Value, IsAsync=True}" />
|
||||
</Image.ToolTip>
|
||||
</Image>
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label d:Content="持续时间(ms)" Content="{ll:Str 持续时间(ms)}" />
|
||||
<pu:NumberInput Grid.Column="1" Value="{Binding DataContext.Duration.Value, RelativeSource={RelativeSource AncestorType=ListBoxItem, Mode=FindAncestor}}" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</GroupBox>
|
||||
<GroupBox Grid.Row="1">
|
||||
<GroupBox.Header>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Label d:Content="底层图片" Content="{ll:Str 底层图片}" />
|
||||
<TextBlock Margin="10,0,0,0">
|
||||
<TextBlock.Text>
|
||||
<MultiBinding Converter="{StaticResource StringFormatConverter}" ConverterParameter="{}({0})">
|
||||
<Binding Path="BackImages.Count" />
|
||||
</MultiBinding>
|
||||
</TextBlock.Text>
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</GroupBox.Header>
|
||||
<ListBox
|
||||
d:ItemsSource="{d:SampleData ItemCount=5}"
|
||||
AllowDrop="True"
|
||||
Drop="ListBox_Drop"
|
||||
ItemsSource="{Binding BackImages, IsAsync=True}"
|
||||
PreviewMouseMove="ListBox_PreviewMouseMove"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Auto"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Hidden"
|
||||
SelectedItem="{Binding DataContext.CurrentBackImageModel.Value, RelativeSource={RelativeSource AncestorType=Window, Mode=FindAncestor}}"
|
||||
SelectionChanged="ListBox_SelectionChanged">
|
||||
<ListBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel Orientation="Horizontal" />
|
||||
</ItemsPanelTemplate>
|
||||
</ListBox.ItemsPanel>
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid DataContext="{Binding DataContext, RelativeSource={RelativeSource AncestorType=Expander, Mode=FindAncestor}}" Tag="{Binding DataContext, RelativeSource={RelativeSource AncestorType=Window, Mode=FindAncestor}}">
|
||||
<Grid.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem
|
||||
d:Header="修改图片"
|
||||
Command="{Binding PlacementTarget.Tag.ChangeBackImageCommand, RelativeSource={RelativeSource AncestorType=ContextMenu, Mode=FindAncestor}}"
|
||||
CommandParameter="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource AncestorType=ContextMenu, Mode=FindAncestor}}"
|
||||
Header="{ll:Str 修改图片}"
|
||||
IsEnabled="{Binding PlacementTarget.Tag.PlayCommand.CurrentCanExecute.Value, RelativeSource={RelativeSource AncestorType=ContextMenu, Mode=FindAncestor}}" />
|
||||
<MenuItem
|
||||
d:Header="删除图片"
|
||||
Command="{Binding PlacementTarget.Tag.RemoveBackImageCommand, RelativeSource={RelativeSource AncestorType=ContextMenu, Mode=FindAncestor}}"
|
||||
CommandParameter="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource AncestorType=ContextMenu, Mode=FindAncestor}}"
|
||||
Header="{ll:Str 删除图片}"
|
||||
IsEnabled="{Binding PlacementTarget.Tag.PlayCommand.CurrentCanExecute.Value, RelativeSource={RelativeSource AncestorType=ContextMenu, Mode=FindAncestor}}" />
|
||||
</ContextMenu>
|
||||
</Grid.ContextMenu>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Image
|
||||
Width="150"
|
||||
Height="150"
|
||||
d:DataContext=""
|
||||
DataContext="{Binding DataContext, RelativeSource={RelativeSource AncestorType=ListBoxItem, Mode=FindAncestor}}"
|
||||
Source="{Binding Image.Value, IsAsync=True}">
|
||||
<Image.ToolTip>
|
||||
<Image
|
||||
Width="250"
|
||||
Height="250"
|
||||
Source="{Binding Image.Value, IsAsync=True}" />
|
||||
</Image.ToolTip>
|
||||
</Image>
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label d:Content="持续时间(ms)" Content="{ll:Str 持续时间(ms)}" />
|
||||
<pu:NumberInput Grid.Column="1" Value="{Binding DataContext.Duration.Value, RelativeSource={RelativeSource AncestorType=ListBoxItem, Mode=FindAncestor}}" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</GroupBox>
|
||||
<GroupBox Grid.Row="2">
|
||||
<GroupBox.Header>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Label d:Content="食物位置" Content="{ll:Str 食物位置}" />
|
||||
<TextBlock Margin="10,0,0,0">
|
||||
<TextBlock.Text>
|
||||
<MultiBinding Converter="{StaticResource StringFormatConverter}" ConverterParameter="{}({0})">
|
||||
<Binding Path="FoodLocations.Count" />
|
||||
</MultiBinding>
|
||||
</TextBlock.Text>
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</GroupBox.Header>
|
||||
<ListBox
|
||||
d:ItemsSource="{d:SampleData ItemCount=5}"
|
||||
ItemsSource="{Binding FoodLocations, IsAsync=True}"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Auto"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Hidden"
|
||||
SelectedItem="{Binding DataContext.CurrentFoodLocationModel.Value, RelativeSource={RelativeSource AncestorType=Window, Mode=FindAncestor}}"
|
||||
SelectionChanged="ListBox_SelectionChanged">
|
||||
<ListBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel Orientation="Horizontal" />
|
||||
</ItemsPanelTemplate>
|
||||
</ListBox.ItemsPanel>
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
|
@ -1,5 +1,6 @@
|
||||
using LinePutScript.Localization.WPF;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -12,6 +13,7 @@ using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using VPet.ModMaker.Models;
|
||||
using VPet.ModMaker.Models.ModModel;
|
||||
using VPet.ModMaker.ViewModels.ModEdit.AnimeEdit;
|
||||
using VPet_Simulator.Core;
|
||||
@ -88,54 +90,69 @@ public partial class FoodAnimeEditWindow : Window
|
||||
|
||||
private void ListBox_PreviewMouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
//if (sender is not ListBox listBox)
|
||||
// return;
|
||||
//if (e.LeftButton != MouseButtonState.Pressed)
|
||||
// return;
|
||||
//var pos = e.GetPosition(listBox);
|
||||
//HitTestResult result = VisualTreeHelper.HitTest(listBox, pos);
|
||||
//if (result is null)
|
||||
// return;
|
||||
//var listBoxItem = FindVisualParent<ListBoxItem>(result.VisualHit);
|
||||
//if (listBoxItem == null || listBoxItem.Content != listBox.SelectedItem)
|
||||
// return;
|
||||
//var dataObj = new DataObject(listBoxItem.Content);
|
||||
//DragDrop.DoDragDrop(listBox, dataObj, DragDropEffects.Move);
|
||||
//_dropSender = sender;
|
||||
if (sender is not ListBox listBox)
|
||||
return;
|
||||
if (e.LeftButton != MouseButtonState.Pressed)
|
||||
return;
|
||||
var pos = e.GetPosition(listBox);
|
||||
HitTestResult result = VisualTreeHelper.HitTest(listBox, pos);
|
||||
if (result is null)
|
||||
return;
|
||||
var listBoxItem = result.VisualHit.FindParent<ListBoxItem>();
|
||||
if (listBoxItem == null || listBoxItem.Content != listBox.SelectedItem)
|
||||
return;
|
||||
var dataObj = new DataObject(listBoxItem.Content);
|
||||
_dropSender = sender;
|
||||
DragDrop.DoDragDrop(listBox, dataObj, DragDropEffects.Move);
|
||||
}
|
||||
|
||||
private void ListBox_Drop(object sender, DragEventArgs e)
|
||||
{
|
||||
//if (sender is not ListBox listBox)
|
||||
// return;
|
||||
//if (e.Data.GetData(DataFormats.FileDrop) is Array array)
|
||||
// ViewModel.AddImages(((AnimeModel)listBox.DataContext, array.Cast<string>());
|
||||
//if (_dropSender is not null && sender.Equals(_dropSender) is false)
|
||||
//{
|
||||
// MessageBox.Show("无法移动不同动画的图片".Translate());
|
||||
// return;
|
||||
//}
|
||||
//var pos = e.GetPosition(listBox);
|
||||
//var result = VisualTreeHelper.HitTest(listBox, pos);
|
||||
//if (result == null)
|
||||
// return;
|
||||
////查找元数据
|
||||
//if (e.Data.GetData(typeof(ImageModel)) is not ImageModel sourcePerson)
|
||||
// return;
|
||||
////查找目标数据
|
||||
//var listBoxItem = FindVisualParent<ListBoxItem>(result.VisualHit);
|
||||
//if (listBoxItem == null)
|
||||
// return;
|
||||
//var targetPerson = listBoxItem.Content as ImageModel;
|
||||
//if (ReferenceEquals(targetPerson, sourcePerson))
|
||||
// return;
|
||||
//if (listBox.ItemsSource is not IList<ImageModel> list)
|
||||
// return;
|
||||
//var sourceIndex = list.IndexOf(sourcePerson);
|
||||
//var targetIndex = list.IndexOf(targetPerson);
|
||||
//var temp = list[sourceIndex];
|
||||
//list[sourceIndex] = list[targetIndex];
|
||||
//list[targetIndex] = temp;
|
||||
if (sender is not ListBox listBox)
|
||||
return;
|
||||
if (e.Data.GetData(DataFormats.FileDrop) is Array array)
|
||||
{
|
||||
if (listBox.Name == "ListBox_FrontImages")
|
||||
{
|
||||
ViewModel.AddImages(
|
||||
((FoodAnimeModel)listBox.DataContext).FrontImages,
|
||||
array.Cast<string>()
|
||||
);
|
||||
}
|
||||
else if (listBox.Name == "ListBox_BackImages")
|
||||
{
|
||||
ViewModel.AddImages(
|
||||
((FoodAnimeModel)listBox.DataContext).BackImages,
|
||||
array.Cast<string>()
|
||||
);
|
||||
}
|
||||
}
|
||||
if (_dropSender is not null && sender.Equals(_dropSender) is false)
|
||||
{
|
||||
MessageBox.Show("无法移动不同动画的图片".Translate());
|
||||
return;
|
||||
}
|
||||
var pos = e.GetPosition(listBox);
|
||||
var result = VisualTreeHelper.HitTest(listBox, pos);
|
||||
if (result == null)
|
||||
return;
|
||||
//查找元数据
|
||||
if (e.Data.GetData(typeof(ImageModel)) is not ImageModel sourcePerson)
|
||||
return;
|
||||
//查找目标数据
|
||||
var listBoxItem = result.VisualHit.FindParent<ListBoxItem>();
|
||||
if (listBoxItem == null)
|
||||
return;
|
||||
var targetPerson = listBoxItem.Content as ImageModel;
|
||||
if (ReferenceEquals(targetPerson, sourcePerson))
|
||||
return;
|
||||
if (listBox.ItemsSource is not IList<ImageModel> list)
|
||||
return;
|
||||
var sourceIndex = list.IndexOf(sourcePerson);
|
||||
var targetIndex = list.IndexOf(targetPerson);
|
||||
var temp = list[sourceIndex];
|
||||
list[sourceIndex] = list[targetIndex];
|
||||
list[targetIndex] = temp;
|
||||
}
|
||||
|
||||
private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
@ -144,6 +161,7 @@ public partial class FoodAnimeEditWindow : Window
|
||||
return;
|
||||
if (listBox.DataContext is FoodAnimeModel model)
|
||||
ViewModel.CurrentAnimeModel.Value = model;
|
||||
listBox.ScrollIntoView(listBox.SelectedItem);
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user