VPet.ModMaker/VPet.ModMaker/Views/ModMakerWindow.xaml.cs
Hakoyu 5a29c279e4 保存修改为文件夹对话框
修复载入模组错误时出现的问题
2023-11-27 22:18:03 +08:00

77 lines
2.1 KiB
C#

using LinePutScript;
using LinePutScript.Localization.WPF;
using Panuon.WPF.UI;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using VPet.ModMaker.Models;
using VPet.ModMaker.ViewModels;
using VPet.ModMaker.Views.ModEdit;
using VPet.ModMaker.Views.ModEdit.AnimeEdit;
using VPet.ModMaker.Views.ModEdit.PetEdit;
namespace VPet.ModMaker.Views;
/// <summary>
/// winModMaker.xaml 的交互逻辑
/// </summary>
public partial class ModMakerWindow : WindowX
{
public ModMakerWindowVM ViewModel => (ModMakerWindowVM)DataContext;
public Models.ModMaker ModMaker { get; internal set; }
public ModMakerWindow()
{
InitializeComponent();
DataContext = new ModMakerWindowVM(this);
Closed += ModMakerWindow_Closed;
//new AnimeEditWindow().Show();
}
private void ModMakerWindow_Closed(object sender, EventArgs e)
{
foreach (var item in Application.Current.Windows)
{
if (item is ModEditWindow window)
window.Close();
}
try
{
DataContext = null;
}
catch { }
}
private void ListBoxItem_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
if (sender is not ListBoxItem item)
return;
if (item.DataContext is not ModMakeHistory history)
return;
if (Directory.Exists(history.SourcePath) is false)
{
if (
MessageBox.Show($"路径不存在, 是否删除?".Translate(), "", MessageBoxButton.YesNo)
is MessageBoxResult.Yes
)
{
ViewModel.Histories.Remove(history);
ViewModel.ShowHistories.Value.Remove(history);
}
}
ViewModel.LoadMod(history.SourcePath);
}
}