优化更新

This commit is contained in:
Hakoyu 2023-09-16 02:57:39 +08:00
parent ba969f91f3
commit b34d44194f
44 changed files with 632 additions and 162 deletions

View File

@ -23,6 +23,14 @@ namespace VPet.ModMaker.Converters;
/// <Binding Source="/" />
/// <Binding Path="Num5" />
/// </MultiBinding>
/// //
/// <MultiBinding Converter="{StaticResource CalculatorConverter}" ConverterParameter="+-*/">
/// <Binding Path="Num1" />
/// <Binding Path="Num2" />
/// <Binding Path="Num3" />
/// <Binding Path="Num4" />
/// <Binding Path="Num5" />
/// </MultiBinding>
/// ]]></code></para>
/// </summary>
/// <exception cref="Exception">绑定的数量不正确</exception>
@ -30,28 +38,40 @@ 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++)
double result = System.Convert.ToDouble(values[0]);
if (parameter is string operators)
{
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;
}
if (operators.Length != values.Length - 1)
throw new Exception("Parameter error: operator must be one more than parameter");
for (int i = 1; i < values.Length - 1; i++)
result = Operation(result, operators[i - 1], System.Convert.ToDouble(values[i]));
result = Operation(result, operators.Last(), System.Convert.ToDouble(values.Last()));
}
return Operation(result, currentOperator, System.Convert.ToDouble(values.Last()));
else
{
if (System.Convert.ToBoolean(values.Length & 1) is false)
throw new Exception("Parameter error: Incorrect quantity");
bool isNumber = false;
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;
}
}
result = Operation(result, currentOperator, System.Convert.ToDouble(values.Last()));
}
return result;
}
public static double Operation(double value1, char operatorChar, double value2)
@ -62,6 +82,7 @@ public class CalculatorConverter : IMultiValueConverter
'-' => value1 - value2,
'*' => value1 * value2,
'/' => value1 / value2,
'%' => value1 % value2,
_ => throw new NotImplementedException(),
};
}

View File

@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace VPet.ModMaker.Models;
public class EnumFlagsVM<T>
public class ObservableEnumFlagsVM<T>
where T : Enum
{
public ObservableValue<T> EnumValue { get; } = new();
@ -18,13 +18,13 @@ public class EnumFlagsVM<T>
public Type EnumType = typeof(T);
public Type UnderlyingType { get; } = Enum.GetUnderlyingType(typeof(T));
public EnumFlagsVM()
public ObservableEnumFlagsVM()
{
AddCommand.ExecuteEvent += AddCommand_ExecuteEvent;
RemoveCommand.ExecuteEvent += RemoveCommand_ExecuteEvent;
}
public EnumFlagsVM(T value)
public ObservableEnumFlagsVM(T value)
: this()
{
EnumValue.Value = value;

View File

@ -94,14 +94,12 @@ public class ModLoader
var name = lps.First().Info;
var pet = new PetLoader(lps, di);
Pets.Add(pet);
// 此方法会导致 LoadImageToStream 无法使用
// TODO : 此方法会导致 LoadImageToStream 无法使用
//var graphCore = new GraphCore(0);
//foreach (var p in pet.path)
// PetLoader.LoadGraph(graphCore, di, p);
//MultiGraphs.Add(pet.Name, graphCore);
//var p = mw.Pets.FirstOrDefault(x => x.Id == name);
//if (p == null)
// mw.Pets.Add(new PetLoader(lps, di));
@ -202,7 +200,7 @@ public class ModLoader
foreach (var item in lps)
{
if (OtherI18nDatas[dis.Name].ContainsKey(item.Name) is false)
OtherI18nDatas[dis.Name].Add(item.Name, item.Info);
OtherI18nDatas[dis.Name].TryAdd(item.Name, item.Info);
}
}
}

View File

@ -14,24 +14,149 @@ namespace VPet.ModMaker.Models.ModModel;
public class AnimeModel
{
public ObservableValue<string> Id { get; } = new();
public ObservableValue<GraphInfo.AnimatType> AnimeType { get; } = new();
public static ObservableCollection<GraphInfo.GraphType> GraphTypes { get; } =
new(Enum.GetValues(typeof(GraphInfo.GraphType)).Cast<GraphInfo.GraphType>());
public static ObservableCollection<GraphInfo.AnimatType> AnimatTypes { get; } =
new(Enum.GetValues(typeof(GraphInfo.AnimatType)).Cast<GraphInfo.AnimatType>());
public ObservableCollection<ObservableCollection<ImageModel>> MultiHappyImageModels = new();
public ObservableCollection<ObservableCollection<ImageModel>> MultiNomalImageModels = new();
public ObservableCollection<ObservableCollection<ImageModel>> MultiPoorConditionImageModels =
new();
public ObservableCollection<ObservableCollection<ImageModel>> MultiIllImageModels = new();
public static ObservableCollection<GameSave.ModeType> ModeTypes { get; } =
new(Enum.GetValues(typeof(GameSave.ModeType)).Cast<GameSave.ModeType>());
public ObservableValue<string> Id { get; } = new();
public ObservableValue<GraphInfo.GraphType> GraphType { get; } = new();
public ObservableValue<GraphInfo.AnimatType> AnimeType { get; } = new();
public ObservableValue<GameSave.ModeType> ModeType { get; } = new();
public ObservableCollection<ImageModels> MultiHappyImageModels = new();
public ObservableCollection<ImageModels> MultiNomalImageModels = new();
public ObservableCollection<ImageModels> MultiPoorConditionImageModels = new();
public ObservableCollection<ImageModels> MultiIllImageModels = new();
public AnimeModel() { }
public AnimeModel(string name, AnimatType animatType, IList<IGraph> graphList)
//public AnimeModel()
//{
//}
public static AnimeModel? Load(string path)
{
Id.Value = name;
AnimeType.Value = animatType;
foreach (IGraph graph in graphList)
var model = new AnimeModel();
var infoFile = Path.Combine(path, ModMakerInfo.InfoFile);
if (
Enum.TryParse<GraphInfo.GraphType>(Path.GetFileName(path), true, out var graphType)
is false
)
return null;
if (graphType is GraphInfo.GraphType.Default)
{
//if(graph.)
foreach (var dir in Directory.EnumerateDirectories(path))
{
var dirName = Path.GetFileName(dir);
if (
dirName.Contains(
nameof(GameSave.ModeType.Happy),
StringComparison.OrdinalIgnoreCase
)
)
{
if (Directory.GetFiles(dir).Length == 0)
{
foreach (var imageDir in Directory.EnumerateDirectories(dir))
{
model.MultiHappyImageModels.Add(new(imageDir));
}
}
else
{
model.MultiHappyImageModels.Add(new(dir));
}
}
else if (
dirName.Contains(
nameof(GameSave.ModeType.Nomal),
StringComparison.OrdinalIgnoreCase
)
)
{
if (Directory.GetFiles(dir).Length == 0)
{
foreach (var imageDir in Directory.EnumerateDirectories(dir))
{
model.MultiNomalImageModels.Add(new(imageDir));
}
}
else
{
model.MultiNomalImageModels.Add(new(dir));
}
}
else if (
dirName.Contains(
nameof(GameSave.ModeType.PoorCondition),
StringComparison.OrdinalIgnoreCase
)
)
{
if (Directory.GetFiles(dir).Length == 0)
{
foreach (var imageDir in Directory.EnumerateDirectories(dir))
{
model.MultiPoorConditionImageModels.Add(new(imageDir));
}
}
else
{
model.MultiPoorConditionImageModels.Add(new(dir));
}
}
else if (
dirName.Contains(
nameof(GameSave.ModeType.Ill),
StringComparison.OrdinalIgnoreCase
)
)
{
if (Directory.GetFiles(dir).Length == 0)
{
foreach (var imageDir in Directory.EnumerateDirectories(dir))
{
model.MultiIllImageModels.Add(new(imageDir));
}
}
else
{
model.MultiIllImageModels.Add(new(dir));
}
}
}
}
else
return null;
return model;
}
}
public class ImageModels : ObservableCollection<ImageModel>
{
private static readonly char[] _splits = new char[] { '_' };
public ImageModels(string imagePath)
{
foreach (var file in Directory.EnumerateFiles(imagePath))
{
var info = Path.GetFileNameWithoutExtension(file)
.Split(_splits, StringSplitOptions.RemoveEmptyEntries);
var id = info[0];
var duration = info.Last();
var imageModel = new ImageModel();
imageModel.Id.Value = id;
imageModel.Image.Value = Utils.LoadImageToMemoryStream(file);
imageModel.Duration.Value = int.Parse(duration);
Add(imageModel);
}
}
}

View File

@ -24,9 +24,9 @@ public class ClickTextModel : I18nModel<I18nClickTextModel>
public ObservableValue<string> Id { get; } = new();
public ObservableValue<string> Working { get; } = new();
public ObservableValue<ClickText.ModeType> Mode { get; } = new();
public ObservableEnumFlagsVM<ClickText.ModeType> Mode { get; } = new();
public ObservableValue<VPet_Simulator.Core.Main.WorkingState> WorkingState { get; } = new();
public ObservableValue<ClickText.DayTime> DayTime { get; } = new();
public ObservableEnumFlagsVM<ClickText.DayTime> DayTime { get; } = new();
public ObservableRange<double> Like { get; } = new(0, int.MaxValue);
public ObservableRange<double> Health { get; } = new(0, int.MaxValue);
@ -43,10 +43,10 @@ public class ClickTextModel : I18nModel<I18nClickTextModel>
: this()
{
Id.Value = clickText.Id.Value;
Mode.Value = clickText.Mode.Value;
Mode.EnumValue.Value = clickText.Mode.EnumValue.Value;
Working.Value = clickText.Working.Value;
WorkingState.Value = clickText.WorkingState.Value;
DayTime.Value = clickText.DayTime.Value;
DayTime.EnumValue.Value = clickText.DayTime.EnumValue.Value;
Like = clickText.Like.Copy();
Health = clickText.Health.Copy();
Level = clickText.Level.Copy();
@ -64,10 +64,10 @@ public class ClickTextModel : I18nModel<I18nClickTextModel>
: this()
{
Id.Value = clickText.Text;
Mode.Value = clickText.Mode;
Mode.EnumValue.Value = clickText.Mode;
Working.Value = clickText.Working;
WorkingState.Value = clickText.State;
DayTime.Value = clickText.DaiTime;
DayTime.EnumValue.Value = clickText.DaiTime;
Like.SetValue(clickText.LikeMin, clickText.LikeMax);
Health.SetValue(clickText.HealthMin, clickText.HealthMax);
Level.SetValue(clickText.LevelMin, clickText.LevelMax);
@ -83,10 +83,10 @@ public class ClickTextModel : I18nModel<I18nClickTextModel>
return new()
{
Text = Id.Value,
Mode = Mode.Value,
Mode = Mode.EnumValue.Value,
Working = Working.Value,
State = WorkingState.Value,
DaiTime = DayTime.Value,
DaiTime = DayTime.EnumValue.Value,
LikeMax = Like.Max.Value,
LikeMin = Like.Min.Value,
HealthMin = Health.Min.Value,

View File

@ -10,12 +10,8 @@ namespace VPet.ModMaker.Models.ModModel;
public class ImageModel
{
public ObservableValue<string> Id { get; } = new();
public ObservableValue<BitmapImage> Image { get; } = new();
public ObservableValue<int> Duration { get; } = new(100);
public ImageModel(BitmapImage image)
{
Image.Value = image;
}
}

View File

@ -12,6 +12,7 @@ using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Media.Imaging;
using VPet.ModMaker.Models.ModModel;
using VPet_Simulator.Windows.Interface;
namespace VPet.ModMaker.Models;
@ -58,8 +59,6 @@ public class ModInfoModel : I18nModel<I18nModInfoModel>
GameVersion.Value = loader.GameVer.ToString();
ModVersion.Value = loader.Ver.ToString();
var imagePath = Path.Combine(loader.ModPath.FullName, "icon.png");
Thread.Sleep(1000);
GC.Collect();
if (File.Exists(imagePath))
Image.Value = Utils.LoadImageToStream(imagePath);
foreach (var food in loader.Foods)
@ -71,7 +70,22 @@ public class ModInfoModel : I18nModel<I18nModInfoModel>
foreach (var selectText in loader.SelectTexts)
SelectTexts.Add(new(selectText));
foreach (var pet in loader.Pets)
Pets.Add(new(pet));
{
var petModel = new PetModel(pet);
Pets.Add(petModel);
// TODO: 动画加载
//foreach (var p in pet.path)
//{
// foreach (var dir in Directory.EnumerateDirectories(p))
// {
// var animeModel = AnimeModel.Load(dir);
// if (animeModel != null)
// {
// petModel.Animes.TryAdd(animeModel.GraphType.Value, animeModel);
// }
// }
//}
}
foreach (var lang in loader.I18nDatas)
I18nDatas.Add(lang.Key, lang.Value);
@ -214,6 +228,21 @@ public class ModInfoModel : I18nModel<I18nModInfoModel>
GetWorksInfo(lps, pet);
GetMoveInfo(lps, pet);
File.WriteAllText(petFile, lps.ToString());
foreach (var cultureName in I18nHelper.Current.CultureNames)
{
_saveI18nDatas[cultureName].TryAdd(
pet.Id.Value,
pet.I18nDatas[cultureName].Name.Value
);
_saveI18nDatas[cultureName].TryAdd(
pet.PetNameId.Value,
pet.I18nDatas[cultureName].PetName.Value
);
_saveI18nDatas[cultureName].TryAdd(
pet.DescriptionId.Value,
pet.I18nDatas[cultureName].Description.Value
);
}
}
}
@ -458,6 +487,15 @@ public class ModInfoModel : I18nModel<I18nModInfoModel>
}
}
}
public void Close()
{
Image.Value.CloseStream();
foreach (var food in Foods)
food.Close();
//foreach (var pet in Pets)
// pet.Close();
}
}
public class I18nModInfoModel

View File

@ -36,12 +36,12 @@ public class MoveModel
public ObservableValue<int> TriggerTop { get; } = new(100);
public ObservableValue<int> TriggerBottom { get; } = new(100);
public EnumFlagsVM<GraphHelper.Move.DirectionType> LocateType { get; } =
public ObservableEnumFlagsVM<GraphHelper.Move.DirectionType> LocateType { get; } =
new(GraphHelper.Move.DirectionType.None);
public EnumFlagsVM<GraphHelper.Move.DirectionType> TriggerType { get; } =
public ObservableEnumFlagsVM<GraphHelper.Move.DirectionType> TriggerType { get; } =
new(GraphHelper.Move.DirectionType.None);
public EnumFlagsVM<GraphHelper.Move.ModeType> ModeType { get; } =
public ObservableEnumFlagsVM<GraphHelper.Move.ModeType> ModeType { get; } =
new(GraphHelper.Move.ModeType.Nomal);
public MoveModel() { }

View File

@ -26,8 +26,7 @@ public class PetModel : I18nModel<I18nPetInfoModel>
public ObservableCollection<MoveModel> Moves { get; } = new();
public ObservableValue<AnimeModel> CurrentAnime { get; } = new();
public Dictionary<GraphInfo.GraphType, ObservableCollection<AnimeModel>> Animes { get; } =
new();
public Dictionary<GraphInfo.GraphType, AnimeModel> Animes { get; } = new();
public PetModel()
{
@ -117,20 +116,6 @@ public class PetModel : I18nModel<I18nPetInfoModel>
Moves.Add(new(move));
}
public void LoadAnime(GraphCore core)
{
foreach (var info in core.GraphsName)
{
var list = new ObservableCollection<AnimeModel>();
foreach (var name in info.Value)
{
foreach (var graph in core.GraphsList[name])
list.Add(new AnimeModel(name, graph.Key, graph.Value));
}
Animes.Add(info.Key, list);
}
}
public void Close() { }
}

View File

@ -28,7 +28,7 @@ public class SelectTextModel : I18nModel<I18nSelectTextModel>
public ObservableValue<string> Id { get; } = new();
public ObservableValue<string> ChooseId { get; } = new();
public ObservableValue<ClickText.ModeType> Mode { get; } = new();
public ObservableEnumFlagsVM<ClickText.ModeType> Mode { get; } = new();
//public ObservableValue<string> Working { get; } = new();
//public ObservableValue<VPet_Simulator.Core.Main.WorkingState> WorkingState { get; } = new();
@ -56,7 +56,7 @@ public class SelectTextModel : I18nModel<I18nSelectTextModel>
: this()
{
Id.Value = model.Id.Value;
Mode.Value = model.Mode.Value;
Mode.EnumValue.Value = model.Mode.EnumValue.Value;
Tags.Value = model.Tags.Value;
ToTags.Value = model.ToTags.Value;
//Working.EnumValue = model.Working.EnumValue;
@ -81,7 +81,7 @@ public class SelectTextModel : I18nModel<I18nSelectTextModel>
{
Id.Value = text.Text;
ChooseId.Value = text.Choose ?? string.Empty;
Mode.Value = text.Mode;
Mode.EnumValue.Value = text.Mode;
Tags.Value = text.Tags is null ? string.Empty : string.Join(", ", text.Tags);
ToTags.Value = text.ToTags is null ? string.Empty : string.Join(", ", text.ToTags);
//Working.EnumValue = text.Working;
@ -105,7 +105,7 @@ public class SelectTextModel : I18nModel<I18nSelectTextModel>
{
Text = Id.Value,
Choose = ChooseId.Value,
Mode = Mode.Value,
Mode = Mode.EnumValue.Value,
Tags = new(Tags.Value.Split(rs_splitChar, StringSplitOptions.RemoveEmptyEntries)),
ToTags = new(ToTags.Value.Split(rs_splitChar, StringSplitOptions.RemoveEmptyEntries)),
//Working = Working.EnumValue,

View File

@ -31,6 +31,7 @@ public class WorkModel : I18nModel<I18nWorkModel>
public ObservableValue<int> LevelLimit { get; } = new();
public ObservableValue<int> Time { get; } = new();
public ObservableValue<double> FinishBonus { get; } = new();
public ObservableValue<bool> IsOverLoad { get; } = new();
public ObservableValue<SolidColorBrush> BorderBrush { get; } =
new(new((Color)ColorConverter.ConvertFromString("#FF0290D5")));
@ -47,7 +48,23 @@ public class WorkModel : I18nModel<I18nWorkModel>
public ObservableValue<double> Top { get; } = new(160);
public ObservableValue<double> Width { get; } = new(300);
public WorkModel() { }
public WorkModel()
{
IsOverLoad.AddNotifyReceiver(
WorkType,
MoneyBase,
MoneyLevel,
StrengthFood,
StrengthDrink,
Feeling,
LevelLimit,
FinishBonus
);
IsOverLoad.NotifyReceived += (ref bool v) =>
{
v = VPet_Simulator.Windows.Interface.ExtensionFunction.IsOverLoad(ToWork());
};
}
public WorkModel(WorkModel model)
: this()

View File

@ -12,7 +12,7 @@ namespace HKW.HKWViewModels.SimpleObservable;
/// 可观察值
/// </summary>
/// <typeparam name="T"></typeparam>
[DebuggerDisplay("{EnumValue}")]
[DebuggerDisplay("{Value}")]
public class ObservableValue<T> : INotifyPropertyChanging, INotifyPropertyChanged
{
[DebuggerBrowsable(DebuggerBrowsableState.Never)]

View File

@ -43,4 +43,16 @@
</Grid>
</Grid>
</ControlTemplate>
<ControlTemplate x:Key="ListBox_ShowLangs" TargetType="ListBox">
<ListBox
ItemsSource="{Binding I18nData.CultureNames}"
ScrollViewer.VerticalScrollBarVisibility="Auto"
SelectedItem="{Binding I18nData.CultureName.Value}">
<ListBox.ItemContainerStyle>
<Style BasedOn="{StaticResource {x:Type ListBoxItem}}" TargetType="ListBoxItem">
<Setter Property="Content" Value="{Binding}" />
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
</ControlTemplate>
</ResourceDictionary>

View File

@ -14,6 +14,8 @@
<WarningLevel>4</WarningLevel>
<LangVersion>latest</LangVersion>
<Deterministic>true</Deterministic>
<IsWebBootstrapper>false</IsWebBootstrapper>
<Nullable>enable</Nullable>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
@ -26,10 +28,8 @@
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -117,6 +117,7 @@
<Compile Include="SimpleObservable\ObservableCommandT.cs" />
<Compile Include="Styles.cs" />
<Compile Include="ViewModels\ModEdit\AnimeEdit\AnimeEditWindowVM.cs" />
<Compile Include="ViewModels\ModEdit\AnimeEdit\AnimePageVM.cs" />
<Compile Include="ViewModels\ModEdit\ClickTextEdit\ClickTextEditWindowVM.cs" />
<Compile Include="ViewModels\ModEdit\ClickTextEdit\ClickTextPageVM.cs" />
<Compile Include="ViewModels\ModEdit\FoodEdit\FoodPageVM.cs" />

View File

@ -0,0 +1,109 @@
using HKW.HKWViewModels.SimpleObservable;
using LinePutScript.Localization.WPF;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using VPet.ModMaker.Models;
using VPet.ModMaker.Models.ModModel;
using VPet.ModMaker.Views.ModEdit.AnimeEdit;
namespace VPet.ModMaker.ViewModels.ModEdit.AnimeEdit;
public class AnimePageVM
{
//#region Value
//public ObservableValue<ObservableCollection<AnimeModel>> ShowAnimes { get; } = new();
//public ObservableCollection<AnimeModel> Works => CurrentPet.Value.Works;
//public ObservableCollection<PetModel> Pets => ModInfoModel.Current.Pets;
//public ObservableValue<PetModel> CurrentPet { get; } = new(new());
//public ObservableValue<string> Filter { get; } = new();
//#endregion
//#region Command
//public ObservableCommand AddCommand { get; } = new();
//public ObservableCommand<AnimeModel> EditCommand { get; } = new();
//public ObservableCommand<AnimeModel> RemoveCommand { get; } = new();
//#endregion
//public AnimePageVM()
//{
// ShowAnimes.Value = Works;
// CurrentPet.ValueChanged += CurrentPet_ValueChanged;
// Filter.ValueChanged += Filter_ValueChanged;
// AddCommand.ExecuteEvent += Add;
// EditCommand.ExecuteEvent += Edit;
// RemoveCommand.ExecuteEvent += Remove;
//}
//private void CurrentPet_ValueChanged(PetModel oldValue, PetModel newValue)
//{
// //ShowAnimes.Value = newValue.Animes;
//}
//private void Filter_ValueChanged(string oldValue, string newValue)
//{
// if (string.IsNullOrWhiteSpace(newValue))
// {
// ShowAnimes.Value = Works;
// }
// else
// {
// ShowAnimes.Value = new(
// Works.Where(m => m.Id.Value.Contains(newValue, StringComparison.OrdinalIgnoreCase))
// );
// }
//}
//public void Close() { }
//private void Add()
//{
// var window = new AnimeEditWindow();
// var vm = window.ViewModel;
// vm.CurrentPet = CurrentPet.Value;
// window.ShowDialog();
// if (window.IsCancel)
// return;
// Works.Add(vm.Work.Value);
//}
//public void Edit(AnimeModel model)
//{
// var window = new AnimeEditWindow();
// var vm = window.ViewModel;
// vm.CurrentPet = CurrentPet.Value;
// vm.OldWork = model;
// var newWork = vm.Work.Value = new(model);
// window.ShowDialog();
// if (window.IsCancel)
// return;
// if (ShowAnimes.Value.Count == Works.Count)
// {
// Works[Works.IndexOf(model)] = newWork;
// }
// else
// {
// Works[Works.IndexOf(model)] = newWork;
// ShowAnimes.Value[ShowAnimes.Value.IndexOf(model)] = newWork;
// }
//}
//private void Remove(AnimeModel food)
//{
// if (MessageBox.Show("确定删除吗".Translate(), "", MessageBoxButton.YesNo) is MessageBoxResult.No)
// return;
// if (ShowAnimes.Value.Count == Works.Count)
// {
// Works.Remove(food);
// }
// else
// {
// ShowAnimes.Value.Remove(food);
// Works.Remove(food);
// }
//}
}

View File

@ -12,6 +12,8 @@ namespace VPet.ModMaker.ViewModels.ModEdit.ClickTextEdit;
public class ClickTextEditWindowVM
{
public I18nHelper I18nData => I18nHelper.Current;
#region Value
public ClickTextModel OldClickText { get; set; }

View File

@ -16,6 +16,7 @@ namespace VPet.ModMaker.ViewModels.ModEdit.FoodEdit;
public class FoodEditWindowVM
{
public I18nHelper I18nData => I18nHelper.Current;
#region Value
public FoodModel OldFood { get; set; }
public ObservableValue<FoodModel> Food { get; } = new(new());

View File

@ -12,6 +12,7 @@ namespace VPet.ModMaker.ViewModels.ModEdit.LowTextEdit;
public class LowTextEditWindowVM
{
public I18nHelper I18nData => I18nHelper.Current;
#region Value
public LowTextModel OldLowText { get; set; }
public ObservableValue<LowTextModel> LowText { get; } = new(new());

View File

@ -103,6 +103,8 @@ public class ModEditWindowVM
if (window.IsCancel)
return;
I18nHelper.Current.CultureNames.Add(window.Lang.Value);
if (I18nHelper.Current.CultureNames.Count == 1)
I18nHelper.Current.CultureName.Value = window.Lang.Value;
}
private void EditLang(string oldLang)
@ -149,6 +151,8 @@ public class ModEditWindowVM
private void SaveTo()
{
if (ValidationData(ModInfo.Value) is false)
return;
SaveFileDialog saveFileDialog =
new()
{
@ -173,4 +177,29 @@ public class ModEditWindowVM
MessageBox.Show("保存成功".Translate());
}
}
private bool ValidationData(ModInfoModel model)
{
if (I18nHelper.Current.CultureNames.Count == 0)
{
MessageBox.Show(
"未添加任何语言".Translate(),
"",
MessageBoxButton.OK,
MessageBoxImage.Warning
);
return false;
}
if (string.IsNullOrWhiteSpace(model.Id.Value))
{
MessageBox.Show("Id不可为空".Translate(), "", MessageBoxButton.OK, MessageBoxImage.Warning);
return false;
}
if (string.IsNullOrWhiteSpace(model.Author.Value))
{
MessageBox.Show("作者不可为空".Translate(), "", MessageBoxButton.OK, MessageBoxImage.Warning);
return false;
}
return true;
}
}

View File

@ -14,6 +14,7 @@ namespace VPet.ModMaker.ViewModels.ModEdit.PetEdit;
public class PetEditWindowVM
{
public I18nHelper I18nData => I18nHelper.Current;
public PetModel OldPet { get; set; }
public ObservableValue<PetModel> Pet { get; } = new(new());
@ -38,7 +39,7 @@ public class PetEditWindowVM
public void Close()
{
Image.Value?.StreamSource?.Close();
Image.Value?.CloseStream();
}
private void AddImage()

View File

@ -10,6 +10,7 @@ namespace VPet.ModMaker.ViewModels.ModEdit.SelectTextEdit;
public class SelectTextEditWindowVM
{
public I18nHelper I18nData => I18nHelper.Current;
#region Value
public SelectTextModel OldSelectText { get; set; }
public ObservableValue<SelectTextModel> SelectText { get; } = new(new());

View File

@ -13,6 +13,7 @@ namespace VPet.ModMaker.ViewModels.ModEdit.WorkEdit;
public class WorkEditWindowVM
{
public I18nHelper I18nData => I18nHelper.Current;
#region Value
public PetModel CurrentPet { get; set; }
public WorkModel OldWork { get; set; }
@ -39,7 +40,7 @@ public class WorkEditWindowVM
public void Close()
{
Image.Value?.StreamSource?.Close();
Image.Value?.CloseStream();
}
private void AddImage()

View File

@ -81,8 +81,12 @@ public class ModMakerWindowVM
private void AddHistories(ModInfoModel modInfo)
{
if (Histories.FirstOrDefault(h => h.Id == modInfo.Id.Value) is ModMakerHistory history)
if (
Histories.FirstOrDefault(h => h.SourcePath == modInfo.SourcePath.Value)
is ModMakerHistory history
)
{
history.Id = modInfo.Id.Value;
history.SourcePath = modInfo.SourcePath.Value;
history.LastTime = DateTime.Now;
}
@ -121,6 +125,9 @@ public class ModMakerWindowVM
private void ShowEditWindow()
{
if (string.IsNullOrEmpty(ModInfoModel.Current.SourcePath.Value) is false)
AddHistories(ModInfoModel.Current);
SaveHistories();
ModEditWindow = new();
ModEditWindow.Show();
ModMakerWindow.Hide();
@ -130,7 +137,10 @@ public class ModMakerWindowVM
if (string.IsNullOrEmpty(modInfo.SourcePath.Value) is false)
AddHistories(modInfo);
SaveHistories();
ModMakerWindow.Close();
ModInfoModel.Current.Close();
ModInfoModel.Current = null;
I18nHelper.Current = new();
ModMakerWindow.Show();
};
}
@ -138,6 +148,7 @@ public class ModMakerWindowVM
{
ShowHistories.Value.Clear();
Histories.Clear();
File.WriteAllText(ModMakerInfo.HistoryFile, string.Empty);
}
public void LoadModFromFile()

View File

@ -11,7 +11,7 @@
Title="Window_AddLang"
Width="400"
Height="300"
WindowStartupLocation="CenterOwner"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
<d:Window.DataContext>
<local:Window_AddLang />

View File

@ -24,6 +24,14 @@ public partial class AnimeEditWindow : Window
{
InitializeComponent();
DataContext = new AnimeEditWindowVM();
Closed += (s, e) =>
{
try
{
DataContext = null;
}
catch { }
};
}
public AnimeEditWindowVM ViewModel => (AnimeEditWindowVM)DataContext;

View File

@ -11,14 +11,16 @@
Title="ClickTextWindow"
Width="800"
Height="450"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
<d:Window.DataContext>
<vm:ClickTextEditWindowVM />
</d:Window.DataContext>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="200" />
<ColumnDefinition MinWidth="300" />
<ColumnDefinition Width="Auto" MinWidth="300" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid>
<Grid.RowDefinitions>
@ -71,11 +73,30 @@
pu:TextBoxHelper.Watermark="{ll:Str 非必要}"
Text="{Binding ClickText.Value.Working.Value, UpdateSourceTrigger=PropertyChanged}" />
<Label Grid.Row="3" Content="{ll:Str 模式}" />
<ComboBox
Grid.Row="3"
Grid.Column="1"
ItemsSource="{Binding ClickText.Value.ModeTypes}"
SelectedItem="{Binding ClickText.Value.Mode.Value}" />
<Grid Grid.Row="3" Grid.Column="1">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding ClickText.Value.Mode.EnumValue.Value}" />
<ComboBox
x:Name="ComboBox_Mode"
Grid.Column="1"
ItemsSource="{Binding ClickText.Value.ModeTypes}"
SelectedIndex="0" />
<Button
Grid.Column="2"
Command="{Binding ClickText.Value.Mode.AddCommand}"
CommandParameter="{Binding SelectedItem, ElementName=ComboBox_Mode}"
Content="+" />
<Button
Grid.Column="3"
Command="{Binding ClickText.Value.Mode.RemoveCommand}"
CommandParameter="{Binding SelectedItem, ElementName=ComboBox_Mode}"
Content="-" />
</Grid>
<Label Grid.Row="4" Content="{ll:Str 工作状态}" />
<ComboBox
Grid.Row="4"
@ -83,11 +104,30 @@
ItemsSource="{Binding ClickText.Value.WorkingStates}"
SelectedItem="{Binding ClickText.Value.WorkingState.Value}" />
<Label Grid.Row="5" Content="{ll:Str 日期区间}" />
<ComboBox
Grid.Row="5"
Grid.Column="1"
ItemsSource="{Binding ClickText.Value.DayTimes}"
SelectedItem="{Binding ClickText.Value.DayTime.Value}" />
<Grid Grid.Row="5" Grid.Column="1">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding ClickText.Value.DayTime.EnumValue.Value}" />
<ComboBox
x:Name="ComboBox_DayTime"
Grid.Column="1"
ItemsSource="{Binding ClickText.Value.DayTimes}"
SelectedIndex="0" />
<Button
Grid.Column="2"
Command="{Binding ClickText.Value.DayTime.AddCommand}"
CommandParameter="{Binding SelectedItem, ElementName=ComboBox_DayTime}"
Content="+" />
<Button
Grid.Column="3"
Command="{Binding ClickText.Value.DayTime.RemoveCommand}"
CommandParameter="{Binding SelectedItem, ElementName=ComboBox_DayTime}"
Content="-" />
</Grid>
<ListBox Grid.Row="6" Grid.ColumnSpan="2">
<ListBoxItem
DataContext="{Binding ClickText.Value.Like}"
@ -141,5 +181,6 @@
Content="{ll:Str 确定}" />
</Grid>
</Grid>
<ListBox Grid.Column="2" Template="{StaticResource ListBox_ShowLangs}" />
</Grid>
</Window>

View File

@ -29,6 +29,14 @@ public partial class ClickTextEditWindow : Window
{
InitializeComponent();
DataContext = new ClickTextEditWindowVM();
Closed += (s, e) =>
{
try
{
DataContext = null;
}
catch { }
};
}
private void Button_Cancel_Click(object sender, RoutedEventArgs e)

View File

@ -65,10 +65,10 @@
</DataGridTextColumn.Header>
</DataGridTextColumn>
<DataGridTextColumn
Binding="{Binding Mode.Value}"
Binding="{Binding Mode.EnumValue.Value}"
CanUserSort="True"
IsReadOnly="True"
SortMemberPath="Mode.Value">
SortMemberPath="Mode.EnumValue.Value">
<DataGridTextColumn.Header>
<TextBlock Text="{ll:Str 状态}" />
</DataGridTextColumn.Header>
@ -92,10 +92,10 @@
</DataGridTextColumn.Header>
</DataGridTextColumn>
<DataGridTextColumn
Binding="{Binding DayTime.Value}"
Binding="{Binding DayTime.EnumValue.Value}"
CanUserSort="True"
IsReadOnly="True"
SortMemberPath="DayTime.Value">
SortMemberPath="DayTime.EnumValue.Value">
<DataGridTextColumn.Header>
<TextBlock Text="{ll:Str 时间}" />
</DataGridTextColumn.Header>

View File

@ -11,14 +11,16 @@
Title="Window_FoodEdit"
Width="800"
Height="450"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
<d:Window.DataContext>
<vm:FoodEditWindowVM />
</d:Window.DataContext>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="250" />
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid>
<Grid.RowDefinitions>
@ -28,8 +30,8 @@
<Grid>
<Image
x:Name="Image_FoodImage"
Width="256"
Height="256"
Width="250"
Height="250"
Source="{Binding Food.Value.Image.Value}"
Stretch="Uniform">
<Image.ContextMenu>
@ -187,5 +189,6 @@
Content="{ll:Str 确定}" />
</Grid>
</Grid>
<ListBox Grid.Column="2" Template="{StaticResource ListBox_ShowLangs}" />
</Grid>
</Window>

View File

@ -36,6 +36,11 @@ public partial class FoodEditWindow : Window
{
if (IsCancel)
ViewModel.Close();
try
{
DataContext = null;
}
catch { }
};
}
@ -56,11 +61,6 @@ public partial class FoodEditWindow : Window
MessageBox.Show("图像不可为空".Translate(), "", MessageBoxButton.OK, MessageBoxImage.Warning);
return;
}
if (string.IsNullOrWhiteSpace(ViewModel.Food.Value.CurrentI18nData.Value.Name.Value))
{
MessageBox.Show("名称不可为空".Translate(), "", MessageBoxButton.OK, MessageBoxImage.Warning);
return;
}
if (
ViewModel.OldFood?.Id.Value != ViewModel.Food.Value.Id.Value
&& ModInfoModel.Current.Foods.Any(i => i.Id == ViewModel.Food.Value.Id)

View File

@ -11,6 +11,7 @@
Title="Page_LowText"
Width="800"
Height="450"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
<d:Window.DataContext>
<vm:LowTextEditWindowVM />
@ -18,7 +19,8 @@
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition MinWidth="300" />
<ColumnDefinition Width="200" />
<ColumnDefinition Width="Auto" MinWidth="200" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid>
<Grid.RowDefinitions>
@ -95,5 +97,6 @@
Content="{ll:Str 确定}" />
</Grid>
</Grid>
<ListBox Grid.Column="2" Template="{StaticResource ListBox_ShowLangs}" />
</Grid>
</Window>

View File

@ -30,6 +30,14 @@ public partial class LowTextEditWindow : Window
{
InitializeComponent();
DataContext = new LowTextEditWindowVM();
Closed += (s, e) =>
{
try
{
DataContext = null;
}
catch { }
};
}
private void Button_Cancel_Click(object sender, RoutedEventArgs e)

View File

@ -11,7 +11,7 @@
Title="ModEditWindow"
Width="1000"
Height="500"
WindowStartupLocation="CenterOwner"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
<d:Window.DataContext>
<vm:ModEditWindowVM />

View File

@ -53,5 +53,17 @@ public partial class ModEditWindow : Window
private void Window_ModEdit_Closed(object sender, EventArgs e)
{
ViewModel.Close();
try
{
DataContext = null;
FoodPage.DataContext = null;
LowTextPage.DataContext = null;
ClickTextPage.DataContext = null;
SelectTextPage.DataContext = null;
PetPage.DataContext = null;
WorkPage.DataContext = null;
MovePage.DataContext = null;
}
catch { }
}
}

View File

@ -11,6 +11,7 @@
Title="MoveEditWindow"
Width="800"
Height="450"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
<d:Window.DataContext>
<vm:MoveEditWindowVM />

View File

@ -31,6 +31,11 @@ public partial class MoveEditWindow : Window
Closed += (s, e) =>
{
ViewModel.Close();
try
{
DataContext = null;
}
catch { }
};
}

View File

@ -11,6 +11,7 @@
Title="PetEditWindow"
Width="800"
Height="450"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
<d:Window.DataContext>
<vm:PetEditWindowVM />
@ -37,8 +38,9 @@
</Window.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="250" />
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid>
<Grid.RowDefinitions>
@ -63,18 +65,16 @@
<Style BasedOn="{StaticResource Label_ThouchRect}" TargetType="Label">
<Setter Property="Width">
<Setter.Value>
<MultiBinding Converter="{StaticResource CalculatorConverter}">
<MultiBinding Converter="{StaticResource CalculatorConverter}" ConverterParameter="*">
<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}">
<MultiBinding Converter="{StaticResource CalculatorConverter}" ConverterParameter="*">
<Binding Path="Pet.Value.TouchHeadRect.Value.Height.Value" />
<Binding Source="*" />
<Binding Path="LengthRatio.Value" />
</MultiBinding>
</Setter.Value>
@ -96,18 +96,16 @@
<Style BasedOn="{StaticResource Label_ThouchRect}" TargetType="Label">
<Setter Property="Width">
<Setter.Value>
<MultiBinding Converter="{StaticResource CalculatorConverter}">
<MultiBinding Converter="{StaticResource CalculatorConverter}" ConverterParameter="*">
<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}">
<MultiBinding Converter="{StaticResource CalculatorConverter}" ConverterParameter="*">
<Binding Path="Pet.Value.TouchRaisedRect.Value.Happy.Value.Height.Value" />
<Binding Source="*" />
<Binding Path="LengthRatio.Value" />
</MultiBinding>
</Setter.Value>
@ -129,18 +127,16 @@
<Style BasedOn="{StaticResource Label_ThouchRect}" TargetType="Label">
<Setter Property="Width">
<Setter.Value>
<MultiBinding Converter="{StaticResource CalculatorConverter}">
<MultiBinding Converter="{StaticResource CalculatorConverter}" ConverterParameter="*">
<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}">
<MultiBinding Converter="{StaticResource CalculatorConverter}" ConverterParameter="*">
<Binding Path="Pet.Value.TouchRaisedRect.Value.Nomal.Value.Height.Value" />
<Binding Source="*" />
<Binding Path="LengthRatio.Value" />
</MultiBinding>
</Setter.Value>
@ -162,18 +158,16 @@
<Style BasedOn="{StaticResource Label_ThouchRect}" TargetType="Label">
<Setter Property="Width">
<Setter.Value>
<MultiBinding Converter="{StaticResource CalculatorConverter}">
<MultiBinding Converter="{StaticResource CalculatorConverter}" ConverterParameter="*">
<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}">
<MultiBinding Converter="{StaticResource CalculatorConverter}" ConverterParameter="*">
<Binding Path="Pet.Value.TouchRaisedRect.Value.PoorCondition.Value.Height.Value" />
<Binding Source="*" />
<Binding Path="LengthRatio.Value" />
</MultiBinding>
</Setter.Value>
@ -195,18 +189,16 @@
<Style BasedOn="{StaticResource Label_ThouchRect}" TargetType="Label">
<Setter Property="Width">
<Setter.Value>
<MultiBinding Converter="{StaticResource CalculatorConverter}">
<MultiBinding Converter="{StaticResource CalculatorConverter}" ConverterParameter="*">
<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}">
<MultiBinding Converter="{StaticResource CalculatorConverter}" ConverterParameter="*">
<Binding Path="Pet.Value.TouchRaisedRect.Value.Ill.Value.Height.Value" />
<Binding Source="*" />
<Binding Path="LengthRatio.Value" />
</MultiBinding>
</Setter.Value>
@ -348,6 +340,7 @@
<TextBox
Grid.Row="3"
Grid.Column="1"
Style="{StaticResource TextBox_Wrap}"
Text="{Binding Pet.Value.CurrentI18nData.Value.Description.Value}" />
</Grid>
</Grid>
@ -805,5 +798,6 @@
Content="{ll:Str 确定}" />
</Grid>
</Grid>
<ListBox Grid.Column="2" Template="{StaticResource ListBox_ShowLangs}" />
</Grid>
</Window>

View File

@ -32,6 +32,11 @@ public partial class PetEditWindow : Window
Closed += (s, e) =>
{
ViewModel.Close();
try
{
DataContext = null;
}
catch { }
};
}

View File

@ -11,14 +11,16 @@
Title="SelectTextWindow"
Width="800"
Height="450"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
<d:Window.DataContext>
<vm:SelectTextEditWindowVM />
</d:Window.DataContext>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="200" />
<ColumnDefinition MinWidth="300" />
<ColumnDefinition Width="Auto" MinWidth="300" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid>
<Grid.RowDefinitions>
@ -78,11 +80,6 @@
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<!--<Label Content="{ll:Str 指定工作}" />
<TextBox
Grid.Column="1"
pu:TextBoxHelper.Watermark="{ll:Str 非必要}"
Text="{Binding SelectText.Value.Working.Value, UpdateSourceTrigger=PropertyChanged}" />-->
<Label Grid.Row="2" Content="{ll:Str 标签}" />
<TextBox
Grid.Row="2"
@ -96,23 +93,30 @@
pu:TextBoxHelper.Watermark="{ll:Str 多标签使用逗号分隔}"
Text="{Binding SelectText.Value.ToTags.Value, UpdateSourceTrigger=PropertyChanged}" />
<Label Grid.Row="4" Content="{ll:Str 模式}" />
<ComboBox
Grid.Row="4"
Grid.Column="1"
ItemsSource="{Binding SelectText.Value.ModeTypes}"
SelectedItem="{Binding SelectText.Value.Mode.Value}" />
<!--<Label Grid.Row="5" Content="{ll:Str 工作状态}" />
<ComboBox
Grid.Row="5"
Grid.Column="1"
ItemsSource="{Binding SelectText.Value.WorkingStates}"
SelectedItem="{Binding SelectText.Value.WorkingState.Value}" />
<Label Grid.Row="6" Content="{ll:Str 日期区间}" />
<ComboBox
Grid.Row="6"
Grid.Column="1"
ItemsSource="{Binding SelectText.Value.DayTimes}"
SelectedItem="{Binding SelectText.Value.DayTime.Value}" />-->
<Grid Grid.Row="4" Grid.Column="1">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding SelectText.Value.Mode.EnumValue.Value}" />
<ComboBox
x:Name="ComboBox_Mode"
Grid.Column="1"
ItemsSource="{Binding SelectText.Value.ModeTypes}"
SelectedIndex="0" />
<Button
Grid.Column="2"
Command="{Binding SelectText.Value.Mode.AddCommand}"
CommandParameter="{Binding SelectedItem, ElementName=ComboBox_Mode}"
Content="+" />
<Button
Grid.Column="3"
Command="{Binding SelectText.Value.Mode.RemoveCommand}"
CommandParameter="{Binding SelectedItem, ElementName=ComboBox_Mode}"
Content="-" />
</Grid>
<ListBox Grid.Row="7" Grid.ColumnSpan="2">
<ListBoxItem
DataContext="{Binding SelectText.Value.Like}"
@ -166,5 +170,6 @@
Content="{ll:Str 确定}" />
</Grid>
</Grid>
<ListBox Grid.Column="2" Template="{StaticResource ListBox_ShowLangs}" />
</Grid>
</Window>

View File

@ -29,6 +29,14 @@ public partial class SelectTextEditWindow : Window
{
InitializeComponent();
DataContext = new SelectTextEditWindowVM();
Closed += (s, e) =>
{
try
{
DataContext = null;
}
catch { }
};
}
private void Button_Cancel_Click(object sender, RoutedEventArgs e)

View File

@ -11,6 +11,7 @@
Title="WorkEditWindow"
Width="800"
Height="450"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
<d:Window.DataContext>
<vm:WorkEditWindowVM />
@ -19,6 +20,7 @@
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid>
<Grid.RowDefinitions>
@ -51,22 +53,18 @@
<Style BasedOn="{StaticResource {x:Type Label}}" TargetType="Label">
<Setter Property="Width">
<Setter.Value>
<MultiBinding Converter="{StaticResource CalculatorConverter}">
<MultiBinding Converter="{StaticResource CalculatorConverter}" ConverterParameter="*">
<Binding Path="Work.Value.Width.Value" />
<Binding Source="*" />
<Binding Path="LengthRatio.Value" />
</MultiBinding>
</Setter.Value>
</Setter>
<Setter Property="Height">
<Setter.Value>
<MultiBinding Converter="{StaticResource CalculatorConverter}">
<MultiBinding Converter="{StaticResource CalculatorConverter}" ConverterParameter="*/*">
<Binding Path="Work.Value.Width.Value" />
<Binding Source="*" />
<Binding Path="LengthRatio.Value" />
<Binding Source="/" />
<Binding Source="300" />
<Binding Source="*" />
<Binding Source="180" />
</MultiBinding>
</Setter.Value>
@ -125,6 +123,7 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Label Content="Id" />
<TextBox Grid.Column="1" Text="{Binding Work.Value.Id.Value}" />
@ -144,6 +143,11 @@
Grid.Row="3"
Grid.Column="1"
Text="{Binding Work.Value.Graph.Value}" />
<Label Grid.Row="4" Content="{ll:Str 是否超模}" />
<TextBlock
Grid.Row="4"
Grid.Column="1"
Text="{Binding Work.Value.IsOverLoad.Value}" />
<!--<Label Grid.Row="3" Content="{ll:Str 宠物描述}" />
<TextBox
Grid.Row="3"
@ -298,5 +302,6 @@
Content="{ll:Str 确定}" />
</Grid>
</Grid>
<ListBox Grid.Column="2" Template="{StaticResource ListBox_ShowLangs}" />
</Grid>
</Window>

View File

@ -32,6 +32,11 @@ public partial class WorkEditWindow : Window
Closed += (s, e) =>
{
ViewModel.Close();
try
{
DataContext = null;
}
catch { }
};
}

View File

@ -118,6 +118,15 @@
<TextBlock Text="{ll:Str 动画名称}" />
</DataGridTextColumn.Header>
</DataGridTextColumn>
<DataGridTextColumn
Binding="{Binding IsOverLoad.Value}"
CanUserSort="True"
IsReadOnly="True"
SortMemberPath="Graph.Value">
<DataGridTextColumn.Header>
<TextBlock Text="{ll:Str 是否超模}" />
</DataGridTextColumn.Header>
</DataGridTextColumn>
<DataGridTextColumn
Binding="{Binding MoneyBase.Value}"
CanUserSort="True"

View File

@ -12,6 +12,7 @@
Width="600"
Height="450"
FontSize="16"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
<d:Window.DataContext>
<vm:ModMakerWindowVM />