mirror of
https://github.com/holgerb83/ModernWpfPlayground.git
synced 2025-04-19 06:53:50 +02:00
updated nuget packages
This commit is contained in:
parent
1cf692547f
commit
8cd47a0252
@ -57,19 +57,19 @@ namespace ModernWpfPlayground
|
||||
|
||||
public Visibility VisibilityEnumTest
|
||||
{
|
||||
get => GetProperty<Visibility>();
|
||||
get => GetProperty(Visibility.Visible);
|
||||
set => SetProperty(value);
|
||||
}
|
||||
|
||||
public double SliderTest
|
||||
{
|
||||
get => GetProperty<double>(100);
|
||||
get => GetProperty(100D);
|
||||
set => SetProperty(value);
|
||||
}
|
||||
|
||||
public double ValidationTest
|
||||
{
|
||||
get => GetProperty<double>();
|
||||
get => GetProperty(0D);
|
||||
set => SetProperty(value);
|
||||
}
|
||||
|
||||
|
@ -9,12 +9,12 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="FastMember" Version="1.5.0" />
|
||||
<PackageReference Include="ModernWpfUI" Version="0.9.0" />
|
||||
<PackageReference Include="Prism.DryIoc" Version="8.0.0.1740-pre" />
|
||||
<PackageReference Include="Prism.Wpf" Version="8.0.0.1740-pre" />
|
||||
<PackageReference Include="ModernWpfUI" Version="0.9.2-preview.200803.0" />
|
||||
<PackageReference Include="Prism.DryIoc" Version="8.0.0.1850-pre" />
|
||||
<PackageReference Include="Prism.Wpf" Version="8.0.0.1850-pre" />
|
||||
<PackageReference Include="YamlDotNet" Version="8.1.2" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="4.7.0" />
|
||||
<PackageReference Include="MahApps.Metro.IconPacks.FontAwesome" Version="4.3.0" />
|
||||
<PackageReference Include="MahApps.Metro.IconPacks.FontAwesome" Version="4.4.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -16,6 +16,7 @@ namespace ModernWpfPlayground.MvvmStuff
|
||||
|
||||
private readonly Dictionary<string, object?> _values = new Dictionary<string, object?>();
|
||||
protected readonly ObjectAccessor ObjectAccessor;
|
||||
private readonly Dictionary<string, object?> _defaultValues = new Dictionary<string, object?>();
|
||||
|
||||
protected IReadOnlyDictionary<string, object?> Values => _values;
|
||||
|
||||
@ -34,21 +35,21 @@ namespace ModernWpfPlayground.MvvmStuff
|
||||
protected T GetProperty<T>(T defaultValue = default, [CallerMemberName] string? propertyName = null)
|
||||
{
|
||||
if (propertyName == null) throw new ArgumentNullException(nameof(propertyName));
|
||||
return Values.TryGetValue(propertyName, out var obj) ? (T)obj! : defaultValue;
|
||||
if (Values.TryGetValue(propertyName, out var obj))
|
||||
{
|
||||
return (T) obj!;
|
||||
}
|
||||
|
||||
_defaultValues[propertyName] =defaultValue;
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
protected void ResetViewModel(Func<string, bool>? predicate = null)
|
||||
protected void ResetViewModel()
|
||||
{
|
||||
IEnumerable<string> keys = _values.Keys.ToArray();
|
||||
if (predicate != null) keys = keys.Where(predicate);
|
||||
foreach (var key in keys)
|
||||
foreach (var (key, value) in _values.ToArray())
|
||||
{
|
||||
var currentValue = ObjectAccessor[key];
|
||||
_values.Remove(key);
|
||||
var newValue = ObjectAccessor[key];
|
||||
if (Equals(currentValue, newValue)) continue;
|
||||
_values.Add(key, currentValue);
|
||||
ObjectAccessor[key] = newValue;
|
||||
if (_defaultValues.TryGetValue(key, out var defaultValue) && Equals(value, defaultValue)) continue;
|
||||
ObjectAccessor[key] = defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,14 +57,11 @@ namespace ModernWpfPlayground.MvvmStuff
|
||||
|
||||
protected void LoadViewModel()
|
||||
{
|
||||
var keysFromFile = new SortedSet<string>();
|
||||
ResetViewModel();
|
||||
foreach (var (key, value) in GetViewModelItems())
|
||||
{
|
||||
keysFromFile.Add(key);
|
||||
ObjectAccessor[key] = value;
|
||||
}
|
||||
|
||||
ResetViewModel(x => !keysFromFile.Contains(x));
|
||||
}
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ModernWpfUI" Version="0.9.0" />
|
||||
<PackageReference Include="ModernWpfUI" Version="0.9.2-preview.200803.0" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="4.7.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user