Add settings func
This commit is contained in:
@@ -1,6 +1,44 @@
|
||||
namespace VisionAsist.ViewModels;
|
||||
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}");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user