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:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:c="clr-namespace:VPet.ModMaker.Converters"> xmlns:c="clr-namespace:VPet.ModMaker.Converters">
<c:MarginConverter x:Key="MarginConverter" /> <c:MarginConverter x:Key="MarginConverter" />
<c:RatioMarginConverter x:Key="RatioMarginConverter" />
<c:CalculatorConverter x:Key="CalculatorConverter" />
<c:MaxConverter x:Key="MaxConverter" /> <c:MaxConverter x:Key="MaxConverter" />
</ResourceDictionary> </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; 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 class MarginConverter : IMultiValueConverter
{ {
public object Convert( public object Convert(
@ -51,7 +63,7 @@ public class MarginConverter : IMultiValueConverter
Bottom = default Bottom = default
}; };
} }
else else if (values.Length == 4)
{ {
return new Thickness() return new Thickness()
{ {
@ -61,6 +73,8 @@ public class MarginConverter : IMultiValueConverter
Bottom = System.Convert.ToDouble(values[3]) Bottom = System.Convert.ToDouble(values[3])
}; };
} }
else
throw new NotImplementedException();
} }
public object[] ConvertBack( 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) foreach (var work in pet.Works)
{ {
var workI18n = work.I18nDatas[i18nData.Key]; 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; workI18n.Name.Value = workName;
} }
} }
@ -174,7 +174,7 @@ public class ModInfoModel : I18nModel<I18nModInfoModel>
var targetImagePath = Path.Combine(path, Path.GetFileName(imagePath)); var targetImagePath = Path.Combine(path, Path.GetFileName(imagePath));
if (imagePath != targetImagePath) if (imagePath != targetImagePath)
File.Copy(imagePath, targetImagePath, true); File.Copy(imagePath, targetImagePath, true);
//lps.FindLine("vupmod").Info = Name.Value; //lps.FindLine("vupmod").Info = Id.Value;
//lps.FindLine("intro").Info = Description.Value; //lps.FindLine("intro").Info = Description.Value;
//lps.FindSub("gamever").Info = GameVersion.Value; //lps.FindSub("gamever").Info = GameVersion.Value;
//lps.FindSub("ver").Info = ModVersion.Value; //lps.FindSub("ver").Info = ModVersion.Value;

View File

@ -94,7 +94,7 @@ public class ModLoader
{ {
var name = lps.First().Info; var name = lps.First().Info;
Pets.Add(new PetLoader(lps, di)); 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) //if (p == null)
// mw.Pets.Add(new PetLoader(lps, di)); // mw.Pets.Add(new PetLoader(lps, di));
//else //else
@ -118,7 +118,7 @@ public class ModLoader
food.Image = imagePath; food.Image = imagePath;
Foods.Add(food); Foods.Add(food);
//string tmps = li.Find("name").info; //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)); //mw.Foods.Add(LPSConvert.DeserializeObject<Food>(li));
} }
} }
@ -159,7 +159,7 @@ public class ModLoader
//foreach (FileInfo fi in di.EnumerateFiles("*.lps")) //foreach (FileInfo fi in di.EnumerateFiles("*.lps"))
//{ //{
// //LocalizeCore.AddCulture( // //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)) // // new LPS_D(File.ReadAllText(fi.FullName))
// //); // //);
//} //}
@ -168,7 +168,7 @@ public class ModLoader
// foreach (FileInfo fi in dis.EnumerateFiles("*.lps")) // foreach (FileInfo fi in dis.EnumerateFiles("*.lps"))
// { // {
// //LocalizeCore.AddCulture( // //LocalizeCore.AddCulture(
// // dis.Name, // // dis.Id,
// // new LPS_D(File.ReadAllText(fi.FullName)) // // 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; } = public ObservableValue<VPet_Simulator.Core.GraphHelper.Work.WorkType> WorkType { get; } =
new(VPet_Simulator.Core.GraphHelper.Work.WorkType.Work); new(VPet_Simulator.Core.GraphHelper.Work.WorkType.Work);
public ObservableValue<string> Name { get; } = new(); public ObservableValue<string> Id { get; } = new();
public ObservableValue<string> Graph { get; } = new();
public ObservableValue<string> Graph { get; } = new();
public ObservableValue<double> MoneyLevel { get; } = new(); public ObservableValue<double> MoneyLevel { get; } = new();
public ObservableValue<double> MoneyBase { get; } = new(); public ObservableValue<double> MoneyBase { get; } = new();
public ObservableValue<double> StrengthFood { get; } = new(); public ObservableValue<double> StrengthFood { get; } = new();
@ -48,7 +48,7 @@ public class WorkModel : I18nModel<I18nWorkModel>
: this() : this()
{ {
WorkType.Value = model.WorkType.Value; WorkType.Value = model.WorkType.Value;
Name.Value = model.Name.Value; Id.Value = model.Id.Value;
Graph.Value = model.Graph.Value; Graph.Value = model.Graph.Value;
MoneyLevel.Value = model.MoneyLevel.Value; MoneyLevel.Value = model.MoneyLevel.Value;
MoneyBase.Value = model.MoneyBase.Value; MoneyBase.Value = model.MoneyBase.Value;
@ -78,7 +78,7 @@ public class WorkModel : I18nModel<I18nWorkModel>
: this() : this()
{ {
WorkType.Value = work.Type; WorkType.Value = work.Type;
Name.Value = work.Name; Id.Value = work.Name;
Graph.Value = work.Graph; Graph.Value = work.Graph;
MoneyLevel.Value = work.MoneyLevel; MoneyLevel.Value = work.MoneyLevel;
MoneyBase.Value = work.MoneyBase; MoneyBase.Value = work.MoneyBase;
@ -105,7 +105,7 @@ public class WorkModel : I18nModel<I18nWorkModel>
return new() return new()
{ {
Type = WorkType.Value, Type = WorkType.Value,
Name = Name.Value, Name = Id.Value,
Graph = Graph.Value, Graph = Graph.Value,
MoneyLevel = MoneyLevel.Value, MoneyLevel = MoneyLevel.Value,
MoneyBase = MoneyBase.Value, MoneyBase = MoneyBase.Value,

View File

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

View File

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

View File

@ -52,7 +52,7 @@ public class WorkPageVM
else else
{ {
ShowWorks.Value = new( 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( lps.Add(
new Line(nameof(history)) new Line(nameof(history))
{ {
new Sub("Name", history.Name), new Sub("Id", history.Name),
new Sub("SourcePath", history.SourcePath), new Sub("SourcePath", history.SourcePath),
new Sub("LastTime", history.LastTimeString) new Sub("LastTime", history.LastTimeString)
} }

View File

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

View File

@ -1,12 +1,18 @@
<Window x:Class="VPet.ModMaker.Views.ModEdit.WorkEdit.WorkEditWindow" <Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" x:Class="VPet.ModMaker.Views.ModEdit.WorkEdit.WorkEditWindow"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:VPet.ModMaker.Views.ModEdit.WorkEdit" xmlns:ll="clr-namespace:LinePutScript.Localization.WPF;assembly=LinePutScript.Localization.WPF"
mc:Ignorable="d" xmlns:local="clr-namespace:VPet.ModMaker.Views.ModEdit.WorkEdit"
Title="WorkEditWindow" Height="450" Width="800"> xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
<Grid> xmlns:pu="https://opensource.panuon.com/wpf-ui"
xmlns:vm="clr-namespace:VPet.ModMaker.ViewModels.ModEdit.WorkEdit"
</Grid> Title="WorkEditWindow"
Width="800"
Height="450"
mc:Ignorable="d">
<Grid >
</Grid>
</Window> </Window>

View File

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

View File

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