WIn_RustTools/RustTools/ViewModels/ModuleViewModel.cs

46 lines
1.1 KiB
C#
Raw Normal View History

2024-08-15 01:40:33 +00:00
using System.Collections.ObjectModel;
using CommunityToolkit.Mvvm.ComponentModel;
2024-08-08 04:29:27 +00:00
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using RustTools.muqing;
using RustTools.Views;
namespace RustTools.ViewModels;
/// <summary>
/// 模组界面配置
/// </summary>
2024-08-15 01:40:33 +00:00
public class ModuleViewModel : ObservableRecipient
{
2024-08-08 04:29:27 +00:00
public ObservableCollection<DataObject> ListMod = new();
public ModuleViewModel()
{
2024-08-08 04:29:27 +00:00
var iniHelper = new IniHelper();
iniHelper.Load(IniHelper.FILE.Config);
var v = iniHelper.GetValue(IniHelper.CODE.Rust, IniHelper.KEY.ModFileUrl);
if (v == string.Empty)
{
return;
}
var subfolders = Directory.GetDirectories(v);
foreach (var item in subfolders)
{
var info = new DirectoryInfo(item);
ListMod.Add(new DataObject(info));
}
var files = Directory.GetFiles(v);
foreach (var item in files)
{
var info = new FileInfo(item);
if (info.Name.EndsWith(".rwmod"))
{
ListMod.Add(new DataObject(info));
}
}
}
2024-08-16 10:09:19 +00:00
}