44 lines
1.1 KiB
C#
44 lines
1.1 KiB
C#
using System;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
using System.Collections.ObjectModel;
|
|
namespace VisionAsist.ViewModels;
|
|
using System.IO;
|
|
using System.Linq;
|
|
public class ModuleItem
|
|
{
|
|
public string Name { get; set; }
|
|
public IRelayCommand SettingsCommand { get; set; }
|
|
}
|
|
|
|
public class SettingsViewModel : ViewModelBase
|
|
{
|
|
string Plugin = Path.Combine(AppContext.BaseDirectory, "Modules");
|
|
public ObservableCollection<ModuleItem> Modules { get; } = new();
|
|
|
|
public SettingsViewModel()
|
|
{
|
|
string[] folderNames = new DirectoryInfo(Plugin)
|
|
.GetDirectories()
|
|
.Select(d => d.Name)
|
|
.ToArray();
|
|
foreach (string folderName in folderNames)
|
|
{
|
|
AddModule(folderName);
|
|
}
|
|
}
|
|
|
|
public void AddModule(string name)
|
|
{
|
|
Modules.Add(new ModuleItem
|
|
{
|
|
Name = name,
|
|
SettingsCommand = new RelayCommand(() => OpenSettings(name))
|
|
});
|
|
}
|
|
|
|
private void OpenSettings(string moduleName)
|
|
{
|
|
Console.WriteLine($"Нажата кнопка модуля: {moduleName}");
|
|
}
|
|
} |