little cleanup

This commit is contained in:
2020-04-06 21:17:31 +02:00
parent b5744498dc
commit 365537102f
3 changed files with 30 additions and 49 deletions

View File

@@ -13,33 +13,10 @@ namespace ModernWpfPlayground
{
public class WindowViewModel : BaseViewModel
{
private const string AppName = "TaBEA 3.0.0";
private readonly PropertyInfo[] _properties;
private string? _path;
private string _title = AppName;
private const string AppName = "TaBEA 3.0.0";
public string? Path
{
get => _path;
private set
{
if (Equals(_path, value)) return;
_path = value;
OnPropertyChanged();
Title = value != null ? $"{System.IO.Path.GetFileName(value)} - {AppName}" : AppName;
}
}
public string Title
{
get => _title;
set
{
if (Equals(_title, value)) return;
_title = value;
OnPropertyChanged();
}
}
public WindowViewModel()
{
@@ -55,11 +32,17 @@ namespace ModernWpfPlayground
_properties = GetType().GetProperties();
}
private async Task ShowDialogAsync()
public string? Path
{
var dialog = new ContentDialogExample {Message = WelcomeMessage};
var result = await dialog.ShowAsync().ConfigureAwait(false);
WelcomeMessage = result.ToString();
get => _path;
private set => SetProperty(ref _path, value,
() => Title = value != null ? $"{System.IO.Path.GetFileName(value)} - {AppName}" : AppName);
}
public string Title
{
get => _title;
set => SetProperty(ref _title, value);
}
public bool BooleanValue
@@ -68,11 +51,6 @@ namespace ModernWpfPlayground
set => SetProperty(value, BooleanValue_OnChanged);
}
private void BooleanValue_OnChanged(bool obj)
{
VisibilityEnumTest = obj ? Visibility.Visible : Visibility.Collapsed;
}
public Visibility VisibilityEnumTest
{
get => GetProperty<Visibility>();
@@ -107,6 +85,18 @@ namespace ModernWpfPlayground
public ICommand ResetViewModelCommand { get; }
private async Task ShowDialogAsync()
{
var dialog = new ContentDialogExample {Message = WelcomeMessage};
var result = await dialog.ShowAsync().ConfigureAwait(false);
WelcomeMessage = result.ToString();
}
private void BooleanValue_OnChanged(bool obj)
{
VisibilityEnumTest = obj ? Visibility.Visible : Visibility.Collapsed;
}
private void SaveViewModel()
{
var contents = JsonSerializer.Serialize(Values);