2024-03-17 18:37:06 -07:00
|
|
|
|
using System;
|
2024-02-05 23:08:37 -08:00
|
|
|
|
using System.Diagnostics.CodeAnalysis;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
using Avalonia.Threading;
|
|
|
|
|
|
|
|
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
|
|
|
|
|
|
|
|
namespace SourceGit.ViewModels
|
|
|
|
|
{
|
|
|
|
|
public class Popup : ObservableValidator
|
|
|
|
|
{
|
|
|
|
|
public string HostPageId
|
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
public object View
|
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
public bool InProgress
|
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
|
get => _inProgress;
|
|
|
|
|
set => SetProperty(ref _inProgress, value);
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
public string ProgressDescription
|
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
|
get => _progressDescription;
|
|
|
|
|
set => SetProperty(ref _progressDescription, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[UnconditionalSuppressMessage("AssemblyLoadTrimming", "IL2026:RequiresUnreferencedCode")]
|
2024-03-17 18:37:06 -07:00
|
|
|
|
public bool Check()
|
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
|
if (HasErrors) return false;
|
|
|
|
|
ValidateAllProperties();
|
|
|
|
|
return !HasErrors;
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
public virtual Task<bool> Sure()
|
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
protected void CallUIThread(Action action)
|
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
|
Dispatcher.UIThread.Invoke(action);
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
protected void SetProgressDescription(string description)
|
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
|
CallUIThread(() => ProgressDescription = description);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool _inProgress = false;
|
|
|
|
|
private string _progressDescription = string.Empty;
|
|
|
|
|
}
|
2024-03-17 18:37:06 -07:00
|
|
|
|
}
|