CloudDriveContent.xaml.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. using PDF_Master.Model.CloudDrive;
  2. using PDF_Master.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_Master.Views.HomePanel.CloudDrive
  18. {
  19. /// <summary>
  20. /// CloudDriveContent.xaml 的交互逻辑
  21. /// </summary>
  22. public partial class CloudDriveContent : UserControl
  23. {
  24. private List<CloudBoxItem> CloudBoxs = new List<CloudBoxItem>();
  25. private CloudDriveContentViewModel ViewModel => DataContext as CloudDriveContentViewModel;
  26. public CloudDriveContent()
  27. {
  28. InitializeComponent();
  29. InitCloudDrive();
  30. Loaded += CloudDriveContent_Loaded;
  31. }
  32. private void CloudDriveContent_Loaded(object sender, RoutedEventArgs e)
  33. {
  34. if (ViewModel != null)
  35. {
  36. ViewModel.IshowContentHandler -= ViewModel_IshowContent;
  37. ViewModel.IshowContentHandler += ViewModel_IshowContent;
  38. ViewModel.LoadUsers();
  39. }
  40. }
  41. private void ViewModel_IshowContent(object sender, bool e)
  42. {
  43. IsShow = e;
  44. }
  45. private void InitCloudDrive()
  46. {
  47. CloudBoxs = Cloud.InitCloudBoxs();
  48. ListCloudDrive.ItemsSource = CloudBoxs;
  49. combCloudDrive.ItemsSource = CloudBoxs;
  50. combCloudDrive.SelectedIndex = 0;
  51. }
  52. private void SelectCloudDrive_Click(object sender, MouseButtonEventArgs e)
  53. {
  54. var cloudDriveItem = (sender as FrameworkElement).DataContext as CloudBoxItem;
  55. if(cloudDriveItem != null)
  56. {
  57. ViewModel.CheckDriveCommand.Execute(cloudDriveItem);
  58. }
  59. }
  60. private void combCloudDrive_SelectionChanged(object sender, SelectionChangedEventArgs e)
  61. {
  62. var cloudDriveItem = combCloudDrive.SelectedItem as CloudBoxItem;
  63. if (cloudDriveItem != null)
  64. {
  65. ViewModel.CheckDriveCommand.Execute(cloudDriveItem);
  66. }
  67. }
  68. public bool IsShow
  69. {
  70. get { return (bool)GetValue(IsShowProperty); }
  71. set { SetValue(IsShowProperty, value); }
  72. }
  73. public static readonly DependencyProperty IsShowProperty =
  74. DependencyProperty.Register("IsShow", typeof(bool), typeof(CloudDriveContent), new PropertyMetadata(true));
  75. }
  76. }