Skip to content

Commit

Permalink
chore: replace Lombok.NET with MvvmGen and improve property notificat…
Browse files Browse the repository at this point in the history
…ions on several types

Signed-off-by: Russell Camo <[email protected]>
  • Loading branch information
russkyc committed Sep 2, 2023
1 parent 748eabb commit a0e4e72
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@
// Unauthorized copying or redistribution of all files, in source and binary forms via any medium
// without written, signed consent from the author is strictly prohibited.

using Lombok.NET;
using MvvmGen;

namespace GroomWise.Application.Observables;

[NotifyPropertyChanged]
[ViewModel]
public partial class ObservableAppointmentService
{
[Property]
private ObservableGroomingService _groomingService;
[PropertyCallMethod(nameof(ServiceChanged))]
private ObservableGroomingService? _groomingService;

private void ServiceChanged()
{
OnPropertyChanged(nameof(GroomingService.TimeSpan));
}
}
18 changes: 6 additions & 12 deletions GroomWise.Application/Observables/ObservableGroomingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
// Unauthorized copying or redistribution of all files, in source and binary forms via any medium
// without written, signed consent from the author is strictly prohibited.

using Lombok.NET;
using MvvmGen;

namespace GroomWise.Application.Observables;

[NotifyPropertyChanged]
[ViewModel]
public partial class ObservableGroomingService
{
[Property]
Expand All @@ -22,16 +22,10 @@ public partial class ObservableGroomingService
[Property]
private double _minuteSpan;

public TimeSpan TimeSpan
{
get
{
return new TimeSpan()
.Add(TimeSpan.FromHours(HourSpan))
.Add(TimeSpan.FromMinutes(MinuteSpan));
}
}
[PropertyInvalidate(nameof(HourSpan), nameof(MinuteSpan))]
public TimeSpan TimeSpan =>
new TimeSpan().Add(TimeSpan.FromHours(HourSpan)).Add(TimeSpan.FromMinutes(MinuteSpan));

[Property]
[Lombok.NET.Property]
private string? _description;
}
32 changes: 32 additions & 0 deletions GroomWise.WPF/Converters/ObjectToVisibilityConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (C) 2023 Russell Camo (Russkyc).- All Rights Reserved
//
// Unauthorized copying or redistribution of all files, in source and binary forms via any medium
// without written, signed consent from the author is strictly prohibited.

using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace GroomWise.Converters;

[ValueConversion(typeof(object), typeof(Visibility))]
public class ObjectToVisibilityConverter : IValueConverter
{
public static ObjectToVisibilityConverter Instance = new();

public object Convert(object? value, Type targetType, object parameter, CultureInfo culture)
{
if (value is null)
{
return Visibility.Collapsed;
}

return Visibility.Visible;
}

public object ConvertBack(object? value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
Background="{DynamicResource primary-default}"
CornerRadius="10"
IsHitTestVisible="False"
Visibility="{Binding GroomingService.Type, Converter={x:Static converters:StringToVisibilityConverter.Instance}}">
Visibility="{Binding GroomingService, Converter={x:Static converters:ObjectToVisibilityConverter.Instance}, Mode=OneWay}">
<TextBlock
HorizontalAlignment="Stretch"
FontSize="10"
Expand Down

0 comments on commit a0e4e72

Please sign in to comment.