Implement reset settings feature.

- NEU: Auf Werkseinstellungen zurücksetzen.
This commit is contained in:
Daniel Kraus
2015-08-11 21:39:21 +02:00
parent 0708f2a2b3
commit 5a0923e8e8
3 changed files with 36 additions and 31 deletions

View File

@ -149,6 +149,7 @@ namespace zaaReloaded2.ViewModels
return _exportSettingsCommand;
}
}
public DelegatingCommand ImportSettingsCommand
{
get
@ -270,12 +271,7 @@ namespace zaaReloaded2.ViewModels
public SettingsRepositoryViewModel(SettingsRepository repository)
{
_repository = repository;
SettingsList = new ObservableCollection<SettingsViewModel>();
foreach (Settings s in repository.SettingsList)
{
SettingsViewModel vm = new SettingsViewModel(s);
AddSettingsViewModel(vm);
}
BuildSettingsList();
RequestCloseView += (sender, args) =>
{
_repository.Store();
@ -286,6 +282,17 @@ namespace zaaReloaded2.ViewModels
#region Private methods
void BuildSettingsList()
{
SettingsList = new ObservableCollection<SettingsViewModel>();
foreach (Settings s in _repository.SettingsList)
{
SettingsViewModel vm = new SettingsViewModel(s);
AddSettingsViewModel(vm);
}
OnPropertyChanged("SettingsList");
}
void DoEditSettings()
{
if (CanEditSettings())
@ -356,7 +363,8 @@ namespace zaaReloaded2.ViewModels
{
if (content.Confirmed)
{
_repository = new SettingsRepository();
BuildSettingsList();
}
}
@ -365,6 +373,10 @@ namespace zaaReloaded2.ViewModels
if (LastSelected != null)
{
SettingsViewModel copy = LastSelected.Clone() as SettingsViewModel;
if (IsDefaultSettings())
{
copy.Name = copy.Name.Replace(SettingsRepository.BUILTIN_LABEL, String.Empty);
}
_repository.SettingsList.Add(copy.RevealModelObject() as Settings);
AddSettingsViewModel(copy);
LastSelected.IsSelected = false;
@ -390,9 +402,7 @@ namespace zaaReloaded2.ViewModels
{
if (LastSelected != null)
{
return
(LastSelected.Name == zaaReloaded2.Properties.Settings.Default.SettingsNameClinic
|| LastSelected.Name == zaaReloaded2.Properties.Settings.Default.SettingsNameWard);
return SettingsRepository.IsDefaultSettings(LastSelected.RevealModelObject() as Settings);
}
else
{