using PDF_Master.Model.CloudDrive;
using PDF_Master.ViewModels.HomePanel.CloudDrive;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace PDF_Master.Views.HomePanel.CloudDrive
{
///
/// CloudDriveContent.xaml 的交互逻辑
///
public partial class CloudDriveContent : UserControl
{
private List CloudBoxs = new List();
private CloudDriveContentViewModel ViewModel => DataContext as CloudDriveContentViewModel;
public CloudDriveContent()
{
InitializeComponent();
InitCloudDrive();
Loaded += CloudDriveContent_Loaded;
}
private void CloudDriveContent_Loaded(object sender, RoutedEventArgs e)
{
if (ViewModel != null)
{
ViewModel.IshowContentHandler -= ViewModel_IshowContent;
ViewModel.IshowContentHandler += ViewModel_IshowContent;
ViewModel.LoadUsers();
}
}
private void ViewModel_IshowContent(object sender, bool e)
{
IsShow = e;
}
private void InitCloudDrive()
{
CloudBoxs = Cloud.InitCloudBoxs();
ListCloudDrive.ItemsSource = CloudBoxs;
combCloudDrive.ItemsSource = CloudBoxs;
combCloudDrive.SelectedIndex = 0;
}
private void SelectCloudDrive_Click(object sender, MouseButtonEventArgs e)
{
var cloudDriveItem = (sender as FrameworkElement).DataContext as CloudBoxItem;
if(cloudDriveItem != null)
{
ViewModel.CheckDriveCommand.Execute(cloudDriveItem);
}
}
private void combCloudDrive_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var cloudDriveItem = combCloudDrive.SelectedItem as CloudBoxItem;
if (cloudDriveItem != null)
{
ViewModel.CheckDriveCommand.Execute(cloudDriveItem);
}
}
public bool IsShow
{
get { return (bool)GetValue(IsShowProperty); }
set { SetValue(IsShowProperty, value); }
}
public static readonly DependencyProperty IsShowProperty =
DependencyProperty.Register("IsShow", typeof(bool), typeof(CloudDriveContent), new PropertyMetadata(true));
}
}