CloudDriveContentViewModel.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using PDF_Office.Model.CloudDrive;
  2. using Prism.Commands;
  3. using Prism.Mvvm;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace PDF_Office.ViewModels.HomePanel.CloudDrive
  10. {
  11. public class CloudDriveContentViewModel : BindableBase
  12. {
  13. public DelegateCommand<CloudBoxItem> CheckDriveCommand { get; set; }
  14. public DelegateCommand<CloudBoxItem> CheckDriveLoginUserCommand { get; set; }
  15. private CloudDriveManager Manager =>CloudDriveManager.GetInstance();
  16. public event EventHandler<bool> IshowContentHandler;
  17. public CloudDriveContentViewModel()
  18. {
  19. CheckDriveCommand = new DelegateCommand<CloudBoxItem>(CheckDrive);
  20. CheckDriveLoginUserCommand = new DelegateCommand<CloudBoxItem>(CheckDriveLoginUser);
  21. }
  22. public void LoadUsers()
  23. {
  24. var result = Manager.LoadedUsers();
  25. IshowContentHandler?.Invoke(null, !result);
  26. }
  27. public async void CheckDrive(CloudBoxItem cloudDriveItem)
  28. {
  29. bool result = false;
  30. switch (cloudDriveItem.CloudDiskType)
  31. {
  32. case CloudType.GoogleDrive:
  33. result = await Manager.LoginUser(cloudDriveItem.CloudDiskType);
  34. break;
  35. }
  36. IshowContentHandler?.Invoke(null, !result);
  37. }
  38. public async void CheckDriveLoginUser(CloudBoxItem cloudDriveItem)
  39. {
  40. bool result = false;
  41. switch (cloudDriveItem.CloudDiskType)
  42. {
  43. case CloudType.GoogleDrive:
  44. result = await Manager.LoginUser(cloudDriveItem.CloudDiskType);
  45. break;
  46. }
  47. }
  48. }
  49. }