57 lines
1.5 KiB
C#
57 lines
1.5 KiB
C#
namespace OMNIPruefung.ViewModels.Content
|
|
{
|
|
using OMNIPruefung.Models;
|
|
using OMNIPruefung.ViewModels.Base;
|
|
using OMNIPruefung.ViewModels.Options;
|
|
|
|
using System.Collections.ObjectModel;
|
|
using System.Linq;
|
|
|
|
public class SettingsContentVM : ContentVM
|
|
{
|
|
private readonly Appsettings appsettings;
|
|
|
|
public SettingsContentVM()
|
|
{
|
|
this.Header = "Einstellungen";
|
|
this.Option = new SettingsOptionVM(this);
|
|
this.Option.OptionSelected += this.NotifyOptionSelected;
|
|
this.appsettings = new Appsettings();
|
|
|
|
var settings = this.appsettings
|
|
.AllKeys
|
|
.Select(x => new SettingVM(x, this.appsettings));
|
|
this.Settings = new ObservableCollection<SettingVM>(settings);
|
|
}
|
|
|
|
public ObservableCollection<SettingVM> Settings { get; }
|
|
}
|
|
|
|
public class SettingVM : VM<SettingVM>
|
|
{
|
|
private readonly string key;
|
|
private readonly Appsettings appsettings;
|
|
|
|
public SettingVM(string key, Appsettings appsettings)
|
|
{
|
|
this.key = key;
|
|
this.appsettings = appsettings;
|
|
}
|
|
|
|
public string Key => this.key;
|
|
|
|
private string value;
|
|
|
|
public string Value
|
|
{
|
|
get => this.appsettings[this.key];
|
|
set
|
|
{
|
|
this.appsettings[this.key] = value;
|
|
|
|
this.NotifyPropertyChanged(nameof(this.Value));
|
|
}
|
|
}
|
|
}
|
|
}
|