CloudFilesContent.xaml.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. using PDF_Office.Model.CloudDrive;
  2. using PDF_Office.ViewModels.HomePanel.CloudDrive;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows;
  9. using System.Windows.Controls;
  10. using System.Windows.Data;
  11. using System.Windows.Documents;
  12. using System.Windows.Input;
  13. using System.Windows.Media;
  14. using System.Windows.Media.Imaging;
  15. using System.Windows.Navigation;
  16. using System.Windows.Shapes;
  17. namespace PDF_Office.Views.HomePanel.CloudDrive
  18. {
  19. /// <summary>
  20. /// CloudFilesContent.xaml 的交互逻辑
  21. /// </summary>
  22. public partial class CloudFilesContent : UserControl
  23. {
  24. private List<string> list = new List<string>();
  25. // private GoogleDriveViewModel GoogleDrive = new GoogleDriveViewModel();
  26. private CloudFilesContentViewModel CloudFilesDrive=>DataContext as CloudFilesContentViewModel;
  27. private CloudType cloudType;
  28. public CloudFilesContent()
  29. {
  30. InitializeComponent();
  31. list.Add("Box");
  32. list.Add("DropBox");
  33. list.Add("GoogleDrive");
  34. list.Add("OneDrive");
  35. ListFolder.ItemsSource = list;
  36. // Listusers.ItemsSource = list;
  37. // combCloudDisk.ItemsSource = list;
  38. // ListvmFiles.ItemsSource = list;
  39. this.Loaded += usercontrol_Loaded;
  40. }
  41. private void usercontrol_Loaded(object sender, RoutedEventArgs e)
  42. {
  43. if(CloudFilesDrive != null)
  44. {
  45. CloudFilesDrive.isFoundUserHandler += isFoundUserEvent;
  46. CloudFilesDrive.CheckDriveUsers();
  47. }
  48. }
  49. private async void isFoundUserEvent(object sender, bool e)
  50. {
  51. isShow = e;
  52. if(isShow)
  53. {
  54. List<GoogleDriveUser> GoogleDriveUsers = new List<GoogleDriveUser>();
  55. // await Task.Run(async () =>
  56. // {
  57. foreach (var item in CloudFilesDrive.GoogleDrive.GoogleDriveUsers)
  58. {
  59. GoogleDriveUsers.Add(item.User);
  60. }
  61. // });
  62. Listusers.ItemsSource = GoogleDriveUsers;
  63. }
  64. }
  65. public void SelectCloudTye(CloudType cloudType)
  66. {
  67. switch (cloudType)
  68. {
  69. case CloudType.GoogleDrive:
  70. cloudType = CloudType.GoogleDrive;
  71. break;
  72. }
  73. }
  74. private void Button_Click(object sender, RoutedEventArgs e)
  75. {
  76. SelectCloudTye(CloudType.GoogleDrive);
  77. }
  78. public bool isShow
  79. {
  80. get { return (bool)GetValue(NormalIconProperty); }
  81. set { SetValue(NormalIconProperty, value); }
  82. }
  83. public static readonly DependencyProperty NormalIconProperty =
  84. DependencyProperty.Register("isShow", typeof(bool), typeof(CloudFilesContent), new PropertyMetadata(false));
  85. }
  86. }