using System; using Avalonia.Threading; using FluentAvalonia.UI.Controls; using StabilityMatrix.Avalonia.Controls; namespace StabilityMatrix.Avalonia.ViewModels.Base; public class ContentDialogViewModelBase : ViewModelBase { public virtual string? Title { get; set; } // Events for button clicks public event EventHandler? PrimaryButtonClick; public event EventHandler? SecondaryButtonClick; public event EventHandler? CloseButtonClick; public virtual void OnPrimaryButtonClick() { PrimaryButtonClick?.Invoke(this, ContentDialogResult.Primary); } public virtual void OnSecondaryButtonClick() { SecondaryButtonClick?.Invoke(this, ContentDialogResult.Secondary); } public virtual void OnCloseButtonClick() { CloseButtonClick?.Invoke(this, ContentDialogResult.None); } /// /// Return a that uses this view model as its content /// public virtual BetterContentDialog GetDialog() { Dispatcher.UIThread.VerifyAccess(); var dialog = new BetterContentDialog { Title = Title, Content = this }; return dialog; } }