CVR Manager 1.0.0
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace CVRManager.ViewModels;
|
||||
|
||||
public abstract class ObservableObject : INotifyPropertyChanged
|
||||
{
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
protected bool Set<T>(ref T field, T value, [CallerMemberName] string? name = null)
|
||||
{
|
||||
if (EqualityComparer<T>.Default.Equals(field, value)) return false;
|
||||
field = value;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void Raise([CallerMemberName] string? name = null) =>
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
|
||||
}
|
||||
|
||||
public class RelayCommand : ICommand
|
||||
{
|
||||
readonly Func<Task> run;
|
||||
|
||||
public RelayCommand(Func<Task> run) => this.run = run;
|
||||
public RelayCommand(Action run) => this.run = () => { run(); return Task.CompletedTask; };
|
||||
|
||||
public event EventHandler? CanExecuteChanged { add { } remove { } }
|
||||
public bool CanExecute(object? parameter) => true;
|
||||
public async void Execute(object? parameter) => await run();
|
||||
}
|
||||
Reference in New Issue
Block a user