PetEditWindow 添加缩放倍率支持

This commit is contained in:
Hakoyu 2023-09-08 16:47:46 +08:00
parent a4bf3b6990
commit 2a259377de
15 changed files with 368 additions and 86 deletions

View File

@ -3,5 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:c="clr-namespace:VPet.ModMaker.Converters">
<c:MarginConverter x:Key="MarginConverter" />
<c:RatioMarginConverter x:Key="RatioMarginConverter" />
<c:CalculatorConverter x:Key="CalculatorConverter" />
<c:MaxConverter x:Key="MaxConverter" />
</ResourceDictionary>

View File

@ -0,0 +1,78 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace VPet.ModMaker.Converters;
/// <summary>
/// 计算器转换器
/// <para>示例:
/// <code><![CDATA[
/// <MultiBinding Converter="{StaticResource CalculatorConverter}">
/// <Binding Path="Num1" />
/// <Binding Source="+" />
/// <Binding Path="Num2" />
/// <Binding Source="-" />
/// <Binding Path="Num3" />
/// <Binding Source="*" />
/// <Binding Path="Num4" />
/// <Binding Source="/" />
/// <Binding Path="Num5" />
/// </MultiBinding>
/// ]]></code></para>
/// </summary>
/// <exception cref="Exception">绑定的数量不正确</exception>
public class CalculatorConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
if (System.Convert.ToBoolean(values.Length & 1) is false)
throw new Exception("Parameter error: Incorrect quantity");
if (values.Length == 1)
return values[0];
bool isNumber = false;
double result = (double)values[0];
char currentOperator = '0';
for (int i = 1; i < values.Length - 1; i++)
{
if (isNumber is false)
{
currentOperator = ((string)values[i])[0];
isNumber = true;
}
else
{
var value = System.Convert.ToDouble(values[i]);
result = Operation(result, currentOperator, value);
isNumber = false;
}
}
return Operation(result, currentOperator, System.Convert.ToDouble(values.Last()));
}
public static double Operation(double value1, char operatorChar, double value2)
{
return operatorChar switch
{
'+' => value1 + value2,
'-' => value1 - value2,
'*' => value1 * value2,
'/' => value1 / value2,
_ => throw new NotImplementedException(),
};
}
public object[] ConvertBack(
object value,
Type[] targetTypes,
object parameter,
CultureInfo culture
)
{
throw new NotImplementedException();
}
}

View File

@ -8,6 +8,18 @@ using System.Windows.Data;
namespace VPet.ModMaker.Converters;
/// <summary>
/// 边距转换器
/// <para>示例:
/// <code><![CDATA[
/// <MultiBinding Converter="{StaticResource MarginConverter}">
/// <Binding Path="Left" />
/// <Binding Path="Top" />
/// <Binding Path="Right" />
/// <Binding Path="Bottom" />
/// </MultiBinding>
/// ]]></code></para>
/// </summary>
public class MarginConverter : IMultiValueConverter
{
public object Convert(
@ -51,7 +63,7 @@ public class MarginConverter : IMultiValueConverter
Bottom = default
};
}
else
else if (values.Length == 4)
{
return new Thickness()
{
@ -61,6 +73,8 @@ public class MarginConverter : IMultiValueConverter
Bottom = System.Convert.ToDouble(values[3])
};
}
else
throw new NotImplementedException();
}
public object[] ConvertBack(

View File

@ -0,0 +1,94 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
namespace VPet.ModMaker.Converters;
/// <summary>
/// 边距转换器
/// <para>示例:
/// <code><![CDATA[
/// <MultiBinding Converter="{StaticResource RatioMarginConverter}">
/// <Binding Path="Left" />
/// <Binding Path="Top" />
/// <Binding Path="Right" />
/// <Binding Path="Bottom" />
/// </MultiBinding>
/// ]]></code></para>
/// </summary>
public class RatioMarginConverter : IMultiValueConverter
{
public object Convert(
object[] values,
Type targetType,
object parameter,
System.Globalization.CultureInfo culture
)
{
if (values.Length == 0)
{
return new Thickness();
}
else if (values.Length == 1)
{
return new Thickness();
}
var ratio = System.Convert.ToDouble(values[0]);
if (values.Length == 2)
{
return new Thickness()
{
Left = System.Convert.ToDouble(values[1]) * ratio,
Top = default,
Right = default,
Bottom = default
};
}
else if (values.Length == 3)
{
return new Thickness()
{
Left = System.Convert.ToDouble(values[1]) * ratio,
Top = System.Convert.ToDouble(values[2]) * ratio,
Right = default,
Bottom = default
};
}
else if (values.Length == 4)
{
return new Thickness()
{
Left = System.Convert.ToDouble(values[1]) * ratio,
Top = System.Convert.ToDouble(values[2]) * ratio,
Right = System.Convert.ToDouble(values[3]) * ratio,
Bottom = default
};
}
else if (values.Length == 5)
{
return new Thickness()
{
Left = System.Convert.ToDouble(values[1]) * ratio,
Top = System.Convert.ToDouble(values[2]) * ratio,
Right = System.Convert.ToDouble(values[3]) * ratio,
Bottom = System.Convert.ToDouble(values[4]) * ratio
};
}
else
throw new NotImplementedException();
}
public object[] ConvertBack(
object value,
Type[] targetTypes,
object parameter,
System.Globalization.CultureInfo culture
)
{
throw new NotImplementedException();
}
}

View File

@ -128,7 +128,7 @@ public class ModInfoModel : I18nModel<I18nModInfoModel>
foreach (var work in pet.Works)
{
var workI18n = work.I18nDatas[i18nData.Key];
if (i18nData.Value.TryGetValue(work.Name.Value, out var workName))
if (i18nData.Value.TryGetValue(work.Id.Value, out var workName))
workI18n.Name.Value = workName;
}
}
@ -174,7 +174,7 @@ public class ModInfoModel : I18nModel<I18nModInfoModel>
var targetImagePath = Path.Combine(path, Path.GetFileName(imagePath));
if (imagePath != targetImagePath)
File.Copy(imagePath, targetImagePath, true);
//lps.FindLine("vupmod").Info = Name.Value;
//lps.FindLine("vupmod").Info = Id.Value;
//lps.FindLine("intro").Info = Description.Value;
//lps.FindSub("gamever").Info = GameVersion.Value;
//lps.FindSub("ver").Info = ModVersion.Value;

View File

@ -94,7 +94,7 @@ public class ModLoader
{
var name = lps.First().Info;
Pets.Add(new PetLoader(lps, di));
//var p = mw.Pets.FirstOrDefault(x => x.Name == name);
//var p = mw.Pets.FirstOrDefault(x => x.Id == name);
//if (p == null)
// mw.Pets.Add(new PetLoader(lps, di));
//else
@ -118,7 +118,7 @@ public class ModLoader
food.Image = imagePath;
Foods.Add(food);
//string tmps = li.Find("name").info;
//mw.Foods.RemoveAll(x => x.Name == tmps);
//mw.Foods.RemoveAll(x => x.Id == tmps);
//mw.Foods.Add(LPSConvert.DeserializeObject<Food>(li));
}
}
@ -159,7 +159,7 @@ public class ModLoader
//foreach (FileInfo fi in di.EnumerateFiles("*.lps"))
//{
// //LocalizeCore.AddCulture(
// // fi.Name.Substring(0, fi.Name.Length - fi.Extension.Length),
// // fi.Id.Substring(0, fi.Id.Length - fi.Extension.Length),
// // new LPS_D(File.ReadAllText(fi.FullName))
// //);
//}
@ -168,7 +168,7 @@ public class ModLoader
// foreach (FileInfo fi in dis.EnumerateFiles("*.lps"))
// {
// //LocalizeCore.AddCulture(
// // dis.Name,
// // dis.Id,
// // new LPS_D(File.ReadAllText(fi.FullName))
// //);
// }

View File

@ -20,9 +20,9 @@ public class WorkModel : I18nModel<I18nWorkModel>
public ObservableValue<VPet_Simulator.Core.GraphHelper.Work.WorkType> WorkType { get; } =
new(VPet_Simulator.Core.GraphHelper.Work.WorkType.Work);
public ObservableValue<string> Name { get; } = new();
public ObservableValue<string> Graph { get; } = new();
public ObservableValue<string> Id { get; } = new();
public ObservableValue<string> Graph { get; } = new();
public ObservableValue<double> MoneyLevel { get; } = new();
public ObservableValue<double> MoneyBase { get; } = new();
public ObservableValue<double> StrengthFood { get; } = new();
@ -48,7 +48,7 @@ public class WorkModel : I18nModel<I18nWorkModel>
: this()
{
WorkType.Value = model.WorkType.Value;
Name.Value = model.Name.Value;
Id.Value = model.Id.Value;
Graph.Value = model.Graph.Value;
MoneyLevel.Value = model.MoneyLevel.Value;
MoneyBase.Value = model.MoneyBase.Value;
@ -78,7 +78,7 @@ public class WorkModel : I18nModel<I18nWorkModel>
: this()
{
WorkType.Value = work.Type;
Name.Value = work.Name;
Id.Value = work.Name;
Graph.Value = work.Graph;
MoneyLevel.Value = work.MoneyLevel;
MoneyBase.Value = work.MoneyBase;
@ -105,7 +105,7 @@ public class WorkModel : I18nModel<I18nWorkModel>
return new()
{
Type = WorkType.Value,
Name = Name.Value,
Name = Id.Value,
Graph = Graph.Value,
MoneyLevel = MoneyLevel.Value,
MoneyBase = MoneyBase.Value,

View File

@ -90,6 +90,8 @@
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="Converters\CalculatorConverter.cs" />
<Compile Include="Converters\RatioMarginConverter.cs" />
<Compile Include="Converters\MaxConverter.cs" />
<Compile Include="Converters\MarginConverter.cs" />
<Compile Include="Models\ClickTextModel.cs" />

View File

@ -17,6 +17,8 @@ public class PetEditWindowVM
public PetModel OldPet { get; set; }
public ObservableValue<PetModel> Pet { get; } = new(new());
public ObservableValue<double> BorderLength { get; } = new(250);
public ObservableValue<double> LengthRatio { get; } = new(250.0 / 500.0);
public ObservableValue<BitmapImage> Image { get; } = new();
#region Command
public ObservableCommand AddImageCommand { get; } = new();
@ -26,6 +28,12 @@ public class PetEditWindowVM
{
AddImageCommand.ExecuteEvent += AddImage;
ChangeImageCommand.ExecuteEvent += ChangeImage;
Image.ValueChanged += Image_ValueChanged;
}
private void Image_ValueChanged(BitmapImage value)
{
LengthRatio.Value = BorderLength.Value / value.PixelWidth;
}
public void Close()

View File

@ -52,7 +52,7 @@ public class WorkPageVM
else
{
ShowWorks.Value = new(
Works.Where(m => m.Name.Value.Contains(value, StringComparison.OrdinalIgnoreCase))
Works.Where(m => m.Id.Value.Contains(value, StringComparison.OrdinalIgnoreCase))
);
}
}

View File

@ -67,7 +67,7 @@ public class ModMakerWindowVM
lps.Add(
new Line(nameof(history))
{
new Sub("Name", history.Name),
new Sub("Id", history.Name),
new Sub("SourcePath", history.SourcePath),
new Sub("LastTime", history.LastTimeString)
}

View File

@ -28,8 +28,6 @@
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Background" Value="#19FF0000" />
<Setter Property="BorderBrush" Value="Red" />
<Setter Property="Width" Value="{Binding Width.Value}" />
<Setter Property="Height" Value="{Binding Height.Value}" />
<Style.Triggers>
<DataTrigger Binding="{Binding Tag, RelativeSource={RelativeSource Mode=Self}}" Value="True">
<Setter Property="Visibility" Value="Visible" />
@ -50,8 +48,8 @@
<Grid>
<Grid>
<Image
Width="500"
Height="500"
Width="250"
Height="250"
Source="{Binding Image.Value}"
Stretch="Uniform">
<Image.ContextMenu>
@ -78,85 +76,165 @@
</Button>
</Grid>
<Grid>
<Label
Content="TouchHeadRect"
DataContext="{Binding Pet.Value.TouchHeadRect.Value}"
Tag="{Binding IsChecked, ElementName=ToggleButton_TouchHead}">
<Label Content="TouchHeadRect" Tag="{Binding IsChecked, ElementName=ToggleButton_TouchHead}">
<Label.Style>
<Style BasedOn="{StaticResource Label_ThouchRect}" TargetType="Label">
<Setter Property="Width">
<Setter.Value>
<MultiBinding Converter="{StaticResource CalculatorConverter}">
<Binding Path="Pet.Value.TouchHeadRect.Value.Width.Value" />
<Binding Source="*" />
<Binding Path="LengthRatio.Value" />
</MultiBinding>
</Setter.Value>
</Setter>
<Setter Property="Height">
<Setter.Value>
<MultiBinding Converter="{StaticResource CalculatorConverter}">
<Binding Path="Pet.Value.TouchHeadRect.Value.Height.Value" />
<Binding Source="*" />
<Binding Path="LengthRatio.Value" />
</MultiBinding>
</Setter.Value>
</Setter>
<Setter Property="Margin">
<Setter.Value>
<MultiBinding Converter="{StaticResource MarginConverter}">
<Binding Path="X.Value" />
<Binding Path="Y.Value" />
<MultiBinding Converter="{StaticResource RatioMarginConverter}">
<Binding Path="LengthRatio.Value" />
<Binding Path="Pet.Value.TouchHeadRect.Value.X.Value" />
<Binding Path="Pet.Value.TouchHeadRect.Value.Y.Value" />
</MultiBinding>
</Setter.Value>
</Setter>
</Style>
</Label.Style>
</Label>
<Label
Content="TouchRaisedRect_Happy"
DataContext="{Binding Pet.Value.TouchRaisedRect.Value.Happy.Value}"
Tag="{Binding IsChecked, ElementName=ToggleButton_TouchRaisedRect_HappyState}">
<Label Content="TouchRaisedRect_Happy" Tag="{Binding IsChecked, ElementName=ToggleButton_TouchRaisedRect_HappyState}">
<Label.Style>
<Style BasedOn="{StaticResource Label_ThouchRect}" TargetType="Label">
<Setter Property="Width">
<Setter.Value>
<MultiBinding Converter="{StaticResource CalculatorConverter}">
<Binding Path="Pet.Value.TouchRaisedRect.Value.Happy.Value.Width.Value" />
<Binding Source="*" />
<Binding Path="LengthRatio.Value" />
</MultiBinding>
</Setter.Value>
</Setter>
<Setter Property="Height">
<Setter.Value>
<MultiBinding Converter="{StaticResource CalculatorConverter}">
<Binding Path="Pet.Value.TouchRaisedRect.Value.Happy.Value.Height.Value" />
<Binding Source="*" />
<Binding Path="LengthRatio.Value" />
</MultiBinding>
</Setter.Value>
</Setter>
<Setter Property="Margin">
<Setter.Value>
<MultiBinding Converter="{StaticResource MarginConverter}">
<Binding Path="X.Value" />
<Binding Path="Y.Value" />
<MultiBinding Converter="{StaticResource RatioMarginConverter}">
<Binding Path="LengthRatio.Value" />
<Binding Path="Pet.Value.TouchRaisedRect.Value.Happy.Value.X.Value" />
<Binding Path="Pet.Value.TouchRaisedRect.Value.Happy.Value.Y.Value" />
</MultiBinding>
</Setter.Value>
</Setter>
</Style>
</Label.Style>
</Label>
<Label
Content="TouchRaisedRect_Nomal"
DataContext="{Binding Pet.Value.TouchRaisedRect.Value.Nomal.Value}"
Tag="{Binding IsChecked, ElementName=ToggleButton_TouchRaisedRect_NomalState}">
<Label Content="TouchRaisedRect_Nomal" Tag="{Binding IsChecked, ElementName=ToggleButton_TouchRaisedRect_NomalState}">
<Label.Style>
<Style BasedOn="{StaticResource Label_ThouchRect}" TargetType="Label">
<Setter Property="Width">
<Setter.Value>
<MultiBinding Converter="{StaticResource CalculatorConverter}">
<Binding Path="Pet.Value.TouchRaisedRect.Value.Nomal.Value.Width.Value" />
<Binding Source="*" />
<Binding Path="LengthRatio.Value" />
</MultiBinding>
</Setter.Value>
</Setter>
<Setter Property="Height">
<Setter.Value>
<MultiBinding Converter="{StaticResource CalculatorConverter}">
<Binding Path="Pet.Value.TouchRaisedRect.Value.Nomal.Value.Height.Value" />
<Binding Source="*" />
<Binding Path="LengthRatio.Value" />
</MultiBinding>
</Setter.Value>
</Setter>
<Setter Property="Margin">
<Setter.Value>
<MultiBinding Converter="{StaticResource MarginConverter}">
<Binding Path="X.Value" />
<Binding Path="Y.Value" />
<MultiBinding Converter="{StaticResource RatioMarginConverter}">
<Binding Path="LengthRatio.Value" />
<Binding Path="Pet.Value.TouchRaisedRect.Value.Nomal.Value.X.Value" />
<Binding Path="Pet.Value.TouchRaisedRect.Value.Nomal.Value.Y.Value" />
</MultiBinding>
</Setter.Value>
</Setter>
</Style>
</Label.Style>
</Label>
<Label
Content="TouchRaisedRect_PoorCondition"
DataContext="{Binding Pet.Value.TouchRaisedRect.Value.PoorCondition.Value}"
Tag="{Binding IsChecked, ElementName=ToggleButton_TouchRaisedRect_PoorConditionState}">
<Label Content="TouchRaisedRect_PoorCondition" Tag="{Binding IsChecked, ElementName=ToggleButton_TouchRaisedRect_PoorConditionState}">
<Label.Style>
<Style BasedOn="{StaticResource Label_ThouchRect}" TargetType="Label">
<Setter Property="Width">
<Setter.Value>
<MultiBinding Converter="{StaticResource CalculatorConverter}">
<Binding Path="Pet.Value.TouchRaisedRect.Value.PoorCondition.Value.Width.Value" />
<Binding Source="*" />
<Binding Path="LengthRatio.Value" />
</MultiBinding>
</Setter.Value>
</Setter>
<Setter Property="Height">
<Setter.Value>
<MultiBinding Converter="{StaticResource CalculatorConverter}">
<Binding Path="Pet.Value.TouchRaisedRect.Value.PoorCondition.Value.Height.Value" />
<Binding Source="*" />
<Binding Path="LengthRatio.Value" />
</MultiBinding>
</Setter.Value>
</Setter>
<Setter Property="Margin">
<Setter.Value>
<MultiBinding Converter="{StaticResource MarginConverter}">
<Binding Path="X.Value" />
<Binding Path="Y.Value" />
<MultiBinding Converter="{StaticResource RatioMarginConverter}">
<Binding Path="LengthRatio.Value" />
<Binding Path="Pet.Value.TouchRaisedRect.Value.PoorCondition.Value.X.Value" />
<Binding Path="Pet.Value.TouchRaisedRect.Value.PoorCondition.Value.Y.Value" />
</MultiBinding>
</Setter.Value>
</Setter>
</Style>
</Label.Style>
</Label>
<Label
Content="TouchRaisedRect_Ill"
DataContext="{Binding Pet.Value.TouchRaisedRect.Value.Ill.Value}"
Tag="{Binding IsChecked, ElementName=ToggleButton_TouchRaisedRect_IllState}">
<Label Content="TouchRaisedRect_Ill" Tag="{Binding IsChecked, ElementName=ToggleButton_TouchRaisedRect_IllState}">
<Label.Style>
<Style BasedOn="{StaticResource Label_ThouchRect}" TargetType="Label">
<Setter Property="Width">
<Setter.Value>
<MultiBinding Converter="{StaticResource CalculatorConverter}">
<Binding Path="Pet.Value.TouchRaisedRect.Value.Ill.Value.Width.Value" />
<Binding Source="*" />
<Binding Path="LengthRatio.Value" />
</MultiBinding>
</Setter.Value>
</Setter>
<Setter Property="Height">
<Setter.Value>
<MultiBinding Converter="{StaticResource CalculatorConverter}">
<Binding Path="Pet.Value.TouchRaisedRect.Value.Ill.Value.Height.Value" />
<Binding Source="*" />
<Binding Path="LengthRatio.Value" />
</MultiBinding>
</Setter.Value>
</Setter>
<Setter Property="Margin">
<Setter.Value>
<MultiBinding Converter="{StaticResource MarginConverter}">
<Binding Path="X.Value" />
<Binding Path="Y.Value" />
<MultiBinding Converter="{StaticResource RatioMarginConverter}">
<Binding Path="LengthRatio.Value" />
<Binding Path="Pet.Value.TouchRaisedRect.Value.Ill.Value.X.Value" />
<Binding Path="Pet.Value.TouchRaisedRect.Value.Ill.Value.Y.Value" />
</MultiBinding>
</Setter.Value>
</Setter>
@ -168,15 +246,15 @@
Height="5"
Background="Red"
Content="RaisePoint_Happy"
DataContext="{Binding Pet.Value.RaisePoint.Value.Happy.Value}"
Tag="{Binding IsChecked, ElementName=ToggleButton_RaisePoint_Happy}">
<Label.Style>
<Style BasedOn="{StaticResource Label_ThouchRect}" TargetType="Label">
<Setter Property="Margin">
<Setter.Value>
<MultiBinding Converter="{StaticResource MarginConverter}">
<Binding Path="X.Value" />
<Binding Path="Y.Value" />
<MultiBinding Converter="{StaticResource RatioMarginConverter}">
<Binding Path="LengthRatio.Value" />
<Binding Path="Pet.Value.RaisePoint.Value.Happy.Value.X.Value" />
<Binding Path="Pet.Value.RaisePoint.Value.Happy.Value.Y.Value" />
</MultiBinding>
</Setter.Value>
</Setter>
@ -188,15 +266,15 @@
Height="5"
Background="Red"
Content="RaisePoint_Nomal"
DataContext="{Binding Pet.Value.RaisePoint.Value.Nomal.Value}"
Tag="{Binding IsChecked, ElementName=ToggleButton_RaisePoint_Nomal}">
<Label.Style>
<Style BasedOn="{StaticResource Label_ThouchRect}" TargetType="Label">
<Setter Property="Margin">
<Setter.Value>
<MultiBinding Converter="{StaticResource MarginConverter}">
<Binding Path="X.Value" />
<Binding Path="Y.Value" />
<MultiBinding Converter="{StaticResource RatioMarginConverter}">
<Binding Path="LengthRatio.Value" />
<Binding Path="Pet.Value.RaisePoint.Value.Nomal.Value.X.Value" />
<Binding Path="Pet.Value.RaisePoint.Value.Nomal.Value.Y.Value" />
</MultiBinding>
</Setter.Value>
</Setter>
@ -208,15 +286,15 @@
Height="5"
Background="Red"
Content="RaisePoint_PoorCondition"
DataContext="{Binding Pet.Value.RaisePoint.Value.PoorCondition.Value}"
Tag="{Binding IsChecked, ElementName=ToggleButton_RaisePoint_PoorCondition}">
<Label.Style>
<Style BasedOn="{StaticResource Label_ThouchRect}" TargetType="Label">
<Setter Property="Margin">
<Setter.Value>
<MultiBinding Converter="{StaticResource MarginConverter}">
<Binding Path="X.Value" />
<Binding Path="Y.Value" />
<MultiBinding Converter="{StaticResource RatioMarginConverter}">
<Binding Path="LengthRatio.Value" />
<Binding Path="Pet.Value.RaisePoint.Value.PoorCondition.Value.X.Value" />
<Binding Path="Pet.Value.RaisePoint.Value.PoorCondition.Value.Y.Value" />
</MultiBinding>
</Setter.Value>
</Setter>
@ -228,15 +306,15 @@
Height="5"
Background="Red"
Content="RaisePoint_Ill"
DataContext="{Binding Pet.Value.RaisePoint.Value.Ill.Value}"
Tag="{Binding IsChecked, ElementName=ToggleButton_RaisePoint_Ill}">
<Label.Style>
<Style BasedOn="{StaticResource Label_ThouchRect}" TargetType="Label">
<Setter Property="Margin">
<Setter.Value>
<MultiBinding Converter="{StaticResource MarginConverter}">
<Binding Path="X.Value" />
<Binding Path="Y.Value" />
<MultiBinding Converter="{StaticResource RatioMarginConverter}">
<Binding Path="LengthRatio.Value" />
<Binding Path="Pet.Value.RaisePoint.Value.Ill.Value.X.Value" />
<Binding Path="Pet.Value.RaisePoint.Value.Ill.Value.Y.Value" />
</MultiBinding>
</Setter.Value>
</Setter>
@ -307,7 +385,7 @@
<pu:NumberInput
Grid.Column="1"
d:Value="100"
Value="{Binding Pet.Value.TouchHeadRect.Value.X.Value, Mode=TwoWay}" />
Value="{Binding Pet.Value.TouchHeadRect.Value.X.Value}" />
<Label
Grid.Column="2"
Background="{x:Null}"

View File

@ -1,12 +1,18 @@
<Window x:Class="VPet.ModMaker.Views.ModEdit.WorkEdit.WorkEditWindow"
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:VPet.ModMaker.Views.ModEdit.WorkEdit"
mc:Ignorable="d"
Title="WorkEditWindow" Height="450" Width="800">
<Grid>
</Grid>
<Window
x:Class="VPet.ModMaker.Views.ModEdit.WorkEdit.WorkEditWindow"
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.WorkEdit"
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.WorkEdit"
Title="WorkEditWindow"
Width="800"
Height="450"
mc:Ignorable="d">
<Grid >
</Grid>
</Window>

View File

@ -38,7 +38,7 @@ public partial class WorkEditWindow : Window
private void Button_Yes_Click(object sender, RoutedEventArgs e)
{
if (string.IsNullOrEmpty(ViewModel.Work.Value.Name.Value))
if (string.IsNullOrEmpty(ViewModel.Work.Value.Id.Value))
{
MessageBox.Show("Id不可为空".Translate(), "", MessageBoxButton.OK, MessageBoxImage.Warning);
return;
@ -54,8 +54,8 @@ public partial class WorkEditWindow : Window
return;
}
if (
ViewModel.OldWork?.Name.Value != ViewModel.Work.Value.Name.Value
&& ViewModel.CurrentPet.Works.Any(i => i.Name.Value == ViewModel.Work.Value.Name.Value)
ViewModel.OldWork?.Id.Value != ViewModel.Work.Value.Id.Value
&& ViewModel.CurrentPet.Works.Any(i => i.Id.Value == ViewModel.Work.Value.Id.Value)
)
{
MessageBox.Show("此Id已存在".Translate(), "", MessageBoxButton.OK, MessageBoxImage.Warning);

View File

@ -83,10 +83,10 @@
</DataGrid.RowStyle>
<DataGrid.Columns>
<DataGridTextColumn
Binding="{Binding Name.Value}"
Binding="{Binding Id.Value}"
CanUserSort="True"
IsReadOnly="True"
SortMemberPath="Name.Value">
SortMemberPath="Id.Value">
<DataGridTextColumn.Header>
<TextBlock Text="Id" />
</DataGridTextColumn.Header>