37 lines
910 B
C#
37 lines
910 B
C#
using System.ComponentModel;
|
|
using System.IO;
|
|
using System.Runtime.CompilerServices;
|
|
|
|
namespace GifResizer.ViewModels;
|
|
|
|
public class MainViewModel : INotifyPropertyChanged
|
|
{
|
|
|
|
|
|
public event PropertyChangedEventHandler? PropertyChanged;
|
|
|
|
public MainViewModel()
|
|
{
|
|
FilePath = Directory.GetCurrentDirectory();
|
|
}
|
|
|
|
|
|
public string FilePath
|
|
{
|
|
get;
|
|
set => SetField(ref field, value);
|
|
}
|
|
|
|
private bool SetField<T>(ref T field, T value, [CallerMemberName] string? propertyName = null)
|
|
{
|
|
if (EqualityComparer<T>.Default.Equals(field, value)) return false;
|
|
field = value;
|
|
OnPropertyChanged(propertyName);
|
|
return true;
|
|
}
|
|
|
|
protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
|
|
{
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
}
|
|
} |