FileLoaderViewModel.cs 978 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. 
  2. using DryIoc;
  3. using System.IO;
  4. namespace HistoryView.ViewModels.Dialogs;
  5. public partial class FileLoaderViewModel : ObservableObject, IDialogAwareTitle
  6. {
  7. public DialogCloseListener RequestClose { get; set; }
  8. public string Title { get; set; } = "文件选择";
  9. public bool CanCloseDialog()
  10. {
  11. return true;
  12. }
  13. [ObservableProperty]
  14. private FileInfo? _SelectedFile;
  15. [RelayCommand]
  16. private void Confirm()
  17. {
  18. IDialogResult result = new DialogResult();
  19. if (this.SelectedFile is not null)
  20. result.Parameters.Add("File", this.SelectedFile);
  21. this.RequestClose.Invoke(result);
  22. }
  23. [RelayCommand]
  24. private void Cancel()
  25. {
  26. this.RequestClose.Invoke();
  27. }
  28. public void OnDialogClosed()
  29. {
  30. }
  31. public void OnDialogOpened(IDialogParameters parameters)
  32. {
  33. }
  34. [RelayCommand]
  35. private void Exit()
  36. {
  37. this.RequestClose.Invoke();
  38. }
  39. }