|
@@ -1,25 +1,34 @@
|
|
-using ReactiveUI;
|
|
|
|
|
|
+using HanumanInstitute.MvvmDialogs;
|
|
|
|
+using HanumanInstitute.MvvmDialogs.FrameworkDialogs;
|
|
|
|
+using ReactiveUI;
|
|
using System;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Collections.ObjectModel;
|
|
|
|
+using System.ComponentModel;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
using VeloeAvaloniaKemonoPartyApp.Models;
|
|
using VeloeAvaloniaKemonoPartyApp.Models;
|
|
|
|
+using static System.Net.Mime.MediaTypeNames;
|
|
|
|
|
|
namespace VeloeAvaloniaKemonoPartyApp.ViewModels
|
|
namespace VeloeAvaloniaKemonoPartyApp.ViewModels
|
|
{
|
|
{
|
|
- public class CreatorPostsViewModel : ViewModelBase
|
|
|
|
|
|
+ public class CreatorPostsViewModel : ViewModelBase, IModalDialogViewModel, IViewClosing, IViewLoaded, ICloseable
|
|
{
|
|
{
|
|
|
|
+ private readonly IDialogService _dialogService;
|
|
|
|
+ public event EventHandler? RequestClose;
|
|
|
|
+ public bool? DialogResult => true;
|
|
|
|
+
|
|
|
|
+
|
|
private Creator _creator;
|
|
private Creator _creator;
|
|
|
|
|
|
public ObservableCollection<PostViewModel> Posts { get; } = new();
|
|
public ObservableCollection<PostViewModel> Posts { get; } = new();
|
|
|
|
|
|
- public CreatorPostsViewModel(Creator creator)
|
|
|
|
|
|
+ public CreatorPostsViewModel(IDialogService dialogService)
|
|
{
|
|
{
|
|
- _creator = creator;
|
|
|
|
- InitPosts();
|
|
|
|
|
|
+ _dialogService = dialogService;
|
|
|
|
+ Close = ReactiveCommand.Create(CloseImpl);
|
|
}
|
|
}
|
|
|
|
|
|
private CancellationTokenSource? _cancellationTokenSource;
|
|
private CancellationTokenSource? _cancellationTokenSource;
|
|
@@ -31,6 +40,11 @@ namespace VeloeAvaloniaKemonoPartyApp.ViewModels
|
|
set => this.RaiseAndSetIfChanged(ref _isBusy, value);
|
|
set => this.RaiseAndSetIfChanged(ref _isBusy, value);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public Creator Creator { get => _creator; set {
|
|
|
|
+ _creator = value;
|
|
|
|
+ InitPosts();
|
|
|
|
+ } }
|
|
|
|
+
|
|
private async void InitPosts()
|
|
private async void InitPosts()
|
|
{
|
|
{
|
|
_cancellationTokenSource?.Cancel();
|
|
_cancellationTokenSource?.Cancel();
|
|
@@ -71,5 +85,29 @@ namespace VeloeAvaloniaKemonoPartyApp.ViewModels
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public ReactiveCommand<System.Reactive.Unit, System.Reactive.Unit> Close { get; }
|
|
|
|
+
|
|
|
|
+ public void OnLoaded()
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void OnClosing(CancelEventArgs e)
|
|
|
|
+ {
|
|
|
|
+ e.Cancel = true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void CloseImpl()
|
|
|
|
+ {
|
|
|
|
+ RequestClose?.Invoke(this, EventArgs.Empty);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public async Task OnClosingAsync(CancelEventArgs e)
|
|
|
|
+ {
|
|
|
|
+ //var result = await _dialogService.ShowMessageBoxAsync(this, "Do you want to close it?", "Confirmation", MessageBoxButton.YesNo);
|
|
|
|
+ _cancellationTokenSource?.Cancel();
|
|
|
|
+ e.Cancel = false;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|