Parcourir la source

云文档 - 获取文件夹列表

chenrongqian il y a 2 ans
Parent
commit
73b87c1549

+ 19 - 10
PDF Office/Model/CloudDrive/CloudFiles.cs

@@ -59,17 +59,29 @@ namespace PDF_Office.Model.CloudDrive
     #endregion
     #endregion
 
 
     #region GooglrDrive
     #region GooglrDrive
+    //文件夹
+    public class GoogleDriveFolder
+    {
+        public string fileId { get; set; }
+        public int Level { get; set; }
+    }
+    public class FilesBaseItem
+    {
+        public string Id { get; set; }
+        public bool IsFolder { get; set; }
+        public int Level { get; set; }
+        public string Name { get; set; }
+        public string MimeType { get; set; }
+        public long? Size { get; set; }
+        public DateTime? CreatedTime { get; set; }
+    }
 
 
     /// <summary>
     /// <summary>
     /// 谷歌云盘的文件
     /// 谷歌云盘的文件
     /// </summary>
     /// </summary>
-    public class GoogleDriveFiles
+    public class GoogleDriveFiles: FilesBaseItem
     {
     {
-        public string Id { get; set; }
-        public string Name { get; set; }
-        public long? Size { get; set; }
         public long? Version { get; set; }
         public long? Version { get; set; }
-        public DateTime? CreatedTime { get; set; }
     }
     }
 
 
     #endregion
     #endregion
@@ -80,12 +92,9 @@ namespace PDF_Office.Model.CloudDrive
     /// <summary>
     /// <summary>
     /// 谷歌云盘的文件
     /// 谷歌云盘的文件
     /// </summary>
     /// </summary>
-    public class DropbBoxFiles
+    public class DropbBoxFiles : FilesBaseItem
     {
     {
-        public string Id { get; set; }
-        public string Name { get; set; }
-        public long? Size { get; set; }
-        public DateTime? CreatedTime { get; set; }
+
     }
     }
 
 
     #endregion
     #endregion

+ 2 - 0
PDF Office/ViewModels/HomePanel/CloudDrive/CloudDriveContentViewModel.cs

@@ -35,6 +35,8 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive
 
 
         public async void CheckDrive(CloudBoxItem cloudDriveItem)
         public async void CheckDrive(CloudBoxItem cloudDriveItem)
         {
         {
+            //IshowContentHandler?.Invoke(null, false);
+            //return;
             bool result = false;
             bool result = false;
             result = await Manager.LoginUser(cloudDriveItem.CloudDiskType);
             result = await Manager.LoginUser(cloudDriveItem.CloudDiskType);
             IshowContentHandler?.Invoke(null, !result);
             IshowContentHandler?.Invoke(null, !result);

+ 6 - 1
PDF Office/ViewModels/HomePanel/CloudDrive/CloudDriveManager.cs

@@ -14,10 +14,15 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive
     //单实例化
     //单实例化
     public class CloudDriveManager
     public class CloudDriveManager
     {
     {
-      
+
+        #region 云盘类型
         public GoogleDriveManager GoogleDrive => GoogleDriveManager.GoogleDrive;
         public GoogleDriveManager GoogleDrive => GoogleDriveManager.GoogleDrive;
         public DropbBoxManager DropbBox => DropbBoxManager.DropbBox;
         public DropbBoxManager DropbBox => DropbBoxManager.DropbBox;
+
+        #endregion
+
         public CloudType cloudType;
         public CloudType cloudType;
+       // public ObservableCollection<>
 
 
         private static CloudDriveManager instance;
         private static CloudDriveManager instance;
 
 

+ 1 - 1
PDF Office/ViewModels/HomePanel/CloudDrive/CloudDriveType/DropbBoxManager.cs

@@ -15,7 +15,7 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType
         private static DropbBoxManager instance;
         private static DropbBoxManager instance;
         public static DropbBoxManager DropbBox => instance ?? (instance = new DropbBoxManager());
         public static DropbBoxManager DropbBox => instance ?? (instance = new DropbBoxManager());
 
 
-        public DropbBoxManager()
+        private DropbBoxManager()
         {
         {
         }
         }
 
 

+ 10 - 3
PDF Office/ViewModels/HomePanel/CloudDrive/CloudDriveType/DropbBoxUserItem.cs

@@ -32,12 +32,19 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType
         public async Task<List<DropbBoxFiles>> RefreshList(string path = "")
         public async Task<List<DropbBoxFiles>> RefreshList(string path = "")
         {
         {
             var files = await client.Files.ListFolderAsync(path);
             var files = await client.Files.ListFolderAsync(path);
-            DropbBoxFiles dropbBoxFiles = new DropbBoxFiles();
+           
             List<DropbBoxFiles> FileList = new List<DropbBoxFiles>();
             List<DropbBoxFiles> FileList = new List<DropbBoxFiles>();
             foreach (var file in files.Entries)
             foreach (var file in files.Entries)
             {
             {
-                dropbBoxFiles.Name = file.Name;
-                FileList.Add(dropbBoxFiles);
+                if(file.Name.ToLower().EndsWith(".pdf") == true || file.IsFolder == true)
+                {
+                    DropbBoxFiles dropbBoxFiles = new DropbBoxFiles();
+                    dropbBoxFiles.Name = file.Name;
+                    dropbBoxFiles.Id = file.ParentSharedFolderId;
+                    dropbBoxFiles.IsFolder = file.IsFolder;
+                    dropbBoxFiles.MimeType = ".pdf";
+                    FileList.Add(dropbBoxFiles);
+                }
             }
             }
             MetadataList = (List<Metadata>)files.Entries;
             MetadataList = (List<Metadata>)files.Entries;
             this.FilesList = FileList;
             this.FilesList = FileList;

+ 70 - 22
PDF Office/ViewModels/HomePanel/CloudDrive/CloudDriveType/GoogleDriveUserItem.cs

@@ -24,13 +24,12 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType
        
        
         public  DriveService Service { get; set; }//Google提供服务
         public  DriveService Service { get; set; }//Google提供服务
         private List<GoogleDriveFiles> FilesList = new List<GoogleDriveFiles>();//文件
         private List<GoogleDriveFiles> FilesList = new List<GoogleDriveFiles>();//文件
-
+        private List<GoogleDriveFolder> FolderList = new List<GoogleDriveFolder>();//文件
         public UserCredential CurrentCredential { get; set; }//当前用户访问令牌
         public UserCredential CurrentCredential { get; set; }//当前用户访问令牌
 
 
         public GoogleDriveUserItem()
         public GoogleDriveUserItem()
         {
         {
-         //   User = new User();
-            
+
         }
         }
       
       
         #region   对用户账号处理
         #region   对用户账号处理
@@ -68,7 +67,7 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType
                 userInfo = new UserInfo();
                 userInfo = new UserInfo();
                 var about = Service.About.Get();
                 var about = Service.About.Get();
                 about.Fields = "user";
                 about.Fields = "user";
-                var uss = await about.ExecuteAsync();
+                var uss =  about.Execute();
                 User user = uss.User;
                 User user = uss.User;
                 userInfo.UserAccount = user.EmailAddress;
                 userInfo.UserAccount = user.EmailAddress;
                 userInfo.Name = user.DisplayName;
                 userInfo.Name = user.DisplayName;
@@ -101,41 +100,87 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType
         /// <summary>
         /// <summary>
         /// 对单个用户,获取文件列表
         /// 对单个用户,获取文件列表
         /// </summary>
         /// </summary>
-        public async Task<List<GoogleDriveFiles>> GetDriveFiles(DriveService service = null)
+        /// <param name="service"></param>
+        /// <param name="parentFilesId">文件夹ID:file.Id</param>
+        /// <returns></returns>
+        public async Task<List<GoogleDriveFiles>> GetDriveFiles(DriveService service = null, string  parentFilesId = null)
         {
         {
             if (service == null)
             if (service == null)
                 return null;
                 return null;
-
-            // define parameters of request.
-            FilesResource.ListRequest FileListRequest = service.Files.List(); 
-
+          
+            FilesResource.ListRequest FileListRequest = service.Files.List();
             //listRequest.PageSize = 10;
             //listRequest.PageSize = 10;
             //listRequest.PageToken = 10;
             //listRequest.PageToken = 10;
-            FileListRequest.Fields = "nextPageToken, files(id, name, size, version, createdTime)";
+            if (parentFilesId == null)
+                //FileListRequest.Q = "'root' in parents or sharedWithMe = true";
+                FileListRequest.Q = "'root' in parents";
+            else
+                FileListRequest.Q = "'" + parentFilesId + "' in parents";
+            // FileListRequest.Fields = "nextPageToken, files(mimeType, id, name, size, version, createdTime)";
+            // FileListRequest.Fields = "nextPageToken, files(id, name)";
+            FileListRequest.Fields = "nextPageToken,kind,files(mimeType,id,kind,size,name,appProperties,webViewLink,webContentLink,createdTime,modifiedTime,ownedByMe,trashed,owners,lastModifyingUser,sharedWithMeTime,parents)";
+            FileListRequest.PageSize = 1000;
+             FileList result = FileListRequest.Execute();
 
 
             //get file list.
             //get file list.
-            IList<Google.Apis.Drive.v3.Data.File> files = FileListRequest.Execute().Files;
+            // String pageToken = null;
             List<GoogleDriveFiles> FileList = new List<GoogleDriveFiles>();
             List<GoogleDriveFiles> FileList = new List<GoogleDriveFiles>();
 
 
+            IList<Google.Apis.Drive.v3.Data.File> files = result.Files;
+
+
             if (files != null && files.Count > 0)
             if (files != null && files.Count > 0)
             {
             {
                 foreach (var file in files)
                 foreach (var file in files)
                 {
                 {
-                       GoogleDriveFiles File = new GoogleDriveFiles
+                    if (file.MimeType.EndsWith(GoogleDriveStatic.MimeType) == true || file.MimeType.EndsWith(GoogleDriveStatic.FolderType) == true)
                     {
                     {
-                        Id = file.Id,
-                        Name = file.Name,
-                        Size = file.Size,
-                        Version = file.Version,
-                        CreatedTime = file.CreatedTime
-                    };
-                    FileList.Add(File);
+                        bool isFolder = (file.MimeType == GoogleDriveStatic.FolderType ? true : false);
+                        GoogleDriveFiles File = new GoogleDriveFiles
+                        {
+                            Id = file.Id,
+                            MimeType = file.MimeType,
+                            IsFolder = isFolder,
+                            Name = file.Name,
+                            Size = file.Size,
+                            Version = file.Version,
+                            CreatedTime = file.CreatedTime
+                        };
+                        int level = 0;
+                        if (isFolder)
+                        {
+                            if (file.Parents != null)
+                            {
+
+                                level = file.Parents.Count;
+                                var folderItem = new GoogleDriveFolder();
+                                folderItem.Level = level;
+                                folderItem.fileId = file.Id;
+                                FolderList.Add(folderItem);
+                            }
+                        }
+                        else
+                        {
+                            level = -1;
+                        }
+
+                        File.Level = level;
+                        FileList.Add(File);
+                    }
+
                 }
                 }
-                this.FilesList = FileList;
+
             }
             }
+            if(parentFilesId == null)
+            this.FilesList = FileList;
             return FileList;
             return FileList;
         }
         }
 
 
+        private void SearchParentFiles()
+        {
+
+        }
+
         /// <summary>
         /// <summary>
         /// 上传文件
         /// 上传文件
         /// </summary>
         /// </summary>
@@ -248,6 +293,9 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType
         public static string[] Scopes = { DriveService.Scope.Drive };
         public static string[] Scopes = { DriveService.Scope.Drive };
         //Google Drive应用名称
         //Google Drive应用名称
         private static readonly string GoogleDriveAppName = "PDF Office";
         private static readonly string GoogleDriveAppName = "PDF Office";
+        public static readonly string MimeType = "application/pdf";
+        public static readonly string FolderType = "application/vnd.google-apps.folder";
+        
         //请求应用进行身份验证的信息
         //请求应用进行身份验证的信息
         public static string CredentialsPath { get; private set; }
         public static string CredentialsPath { get; private set; }
 
 
@@ -296,15 +344,15 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType
                         CancellationToken.None,
                         CancellationToken.None,
                         new FileDataStore(FilePath, true)).Result;
                         new FileDataStore(FilePath, true)).Result;
                 }
                 }
-
+                
                 //create Drive API service.
                 //create Drive API service.
                 DriveService service = new DriveService(new BaseClientService.Initializer()
                 DriveService service = new DriveService(new BaseClientService.Initializer()
                 {
                 {
                     HttpClientInitializer = credential,
                     HttpClientInitializer = credential,
                     ApplicationName = GoogleDriveAppName
                     ApplicationName = GoogleDriveAppName
                 });
                 });
-
                 return tuple = new Tuple<DriveService, UserCredential>(service, credential);
                 return tuple = new Tuple<DriveService, UserCredential>(service, credential);
+                
             }
             }
             catch (Exception e)
             catch (Exception e)
             {
             {

+ 86 - 31
PDF Office/ViewModels/HomePanel/CloudDrive/CloudFilesContentViewModel.cs

@@ -11,23 +11,78 @@ using System.Threading.Tasks;
 
 
 namespace PDF_Office.ViewModels.HomePanel.CloudDrive
 namespace PDF_Office.ViewModels.HomePanel.CloudDrive
 {
 {
+    public class FolderItem
+    {
+        public int FolderTreeId { get; set; }
+        public string FolderName { get; set; }
+        public int FolderType { get; set; }
+    }
     //各云盘事件
     //各云盘事件
     public class CloudFilesContentViewModel : BindableBase
     public class CloudFilesContentViewModel : BindableBase
     {
     {
      
      
+        public ObservableCollection<FolderItem> FolderItems { get; set; }
+
         public GoogleDriveManager GoogleDrive => GoogleDriveManager.GoogleDrive;
         public GoogleDriveManager GoogleDrive => GoogleDriveManager.GoogleDrive;
         public DropbBoxManager DropbBox => DropbBoxManager.DropbBox;
         public DropbBoxManager DropbBox => DropbBoxManager.DropbBox;
         public DelegateCommand OpenCloudDriveCommand { get; set; }
         public DelegateCommand OpenCloudDriveCommand { get; set; }
         public DelegateCommand CheckDriveUsersCommand { get; set; }
         public DelegateCommand CheckDriveUsersCommand { get; set; }
 
 
         public DelegateCommand<CloudBoxItem> CheckDriveCommand { get; set; }
         public DelegateCommand<CloudBoxItem> CheckDriveCommand { get; set; }
-        
+
+        public DelegateCommand<FolderItem> SelectedFolderCommand { get; set; }
+
         public CloudFilesContentViewModel()
         public CloudFilesContentViewModel()
+        {
+            InitVariable();
+            InitCommand();
+        }
+
+        private void InitCommand()
         {
         {
             OpenCloudDriveCommand = new DelegateCommand(OpenCloudDrive_Click);
             OpenCloudDriveCommand = new DelegateCommand(OpenCloudDrive_Click);
             OpenCloudDriveCommand = new DelegateCommand(CheckDriveUsers);
             OpenCloudDriveCommand = new DelegateCommand(CheckDriveUsers);
 
 
-            CheckDriveCommand = new DelegateCommand<CloudBoxItem>(CheckDrive);
+            CheckDriveCommand = new DelegateCommand<CloudBoxItem>(LoginUser);
+            SelectedFolderCommand = new DelegateCommand<FolderItem>(SelectedFolder_Command);
+        }
+
+        private void SelectedFolder_Command(FolderItem obj)
+        {
+           if(obj != null)
+            {
+                var count = FolderItems.Count;
+                if (obj.FolderTreeId == 0)
+                {
+                    
+                    for(int i = 1; i < count; i++)
+                    {
+                        FolderItems.RemoveAt(i);
+                    }
+                }
+                else
+                {
+                    var objIndex = FolderItems.IndexOf(obj);
+                    if(objIndex != -1)
+                    {
+                        for(int i = count - 1; i > objIndex; i--)
+                        {
+                            FolderItems.Remove(FolderItems[i]);
+                        }
+                    }
+                }
+            }
+        }
+
+        private void InitVariable()
+        {
+            FolderItems = new ObservableCollection<FolderItem>();
+            FolderItems.Add(new FolderItem() { FolderName = "云文档", FolderTreeId = 0 });
+            FolderItems.Add(new FolderItem() { FolderName = "文件夹1", FolderTreeId = 1 });
+            FolderItems.Add(new FolderItem() { FolderName = "文件夹2", FolderTreeId = 2 });
+            FolderItems.Add(new FolderItem() { FolderName = "文件夹3", FolderTreeId = 3 });
+            FolderItems.Add(new FolderItem() { FolderName = "文件夹4", FolderTreeId = 4 });
+            FolderItems.Add(new FolderItem() { FolderName = "文件夹5", FolderTreeId = 5 });
         }
         }
 
 
         public async void CheckDrive(CloudBoxItem cloudDriveItem)
         public async void CheckDrive(CloudBoxItem cloudDriveItem)
@@ -59,39 +114,22 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive
 
 
         }
         }
 
 
-
-        #region 谷歌云盘
-
-        public void LoginUser_Click()
-        {
-
-        }
-
-        public async Task<bool> GetHistoryUser()
-        {
-            bool isFound = false;
-
-            //if (await GoogleDrive.GetHistoryUsers())
-            //{
-            //    isFound = true;
-            //}
-            return isFound;
-
-        }
-
-        #endregion
-
-
-
-
         #region 用户帐号
         #region 用户帐号
 
 
         /// <summary>
         /// <summary>
         /// 登录
         /// 登录
         /// </summary>
         /// </summary>
-        public void LoginUser()
+        public async void LoginUser(CloudBoxItem cloudDriveItem)
         {
         {
-           
+            switch (cloudDriveItem.CloudDiskType)
+            {
+                case CloudType.GoogleDrive:
+                    await GoogleDrive.LoginUserCount();
+                    break;
+                case CloudType.DropBox:
+                    await DropbBox.LoginUser();
+                    break;
+            }
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -116,17 +154,34 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive
 
 
         #region 文件
         #region 文件
         
         
+        /// <summary>
+        /// 获取文件夹和文件的列表
+        /// </summary>
         public void GetFiles()
         public void GetFiles()
         {
         {
 
 
         }
         }
 
 
-        public void GetFolders()
+        /// <summary>
+        /// 选择为当前目录
+        /// </summary>
+        public void SelectedFolder()
         {
         {
 
 
         }
         }
 
 
-        public void UpLoad()
+        /// <summary>
+        /// 下载并打开文件
+        /// </summary>
+        public void OpenFile()
+        {
+
+        }
+
+        /// <summary>
+        /// 上传文件
+        /// </summary>
+        public void UpLoadFile()
         {
         {
 
 
         }
         }

+ 11 - 6
PDF Office/Views/HomePanel/CloudDrive/CloudDriveContent.xaml

@@ -4,6 +4,7 @@
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
              xmlns:local="clr-namespace:PDF_Office.Views.HomePanel.CloudDrive"
              xmlns:local="clr-namespace:PDF_Office.Views.HomePanel.CloudDrive"
+             
              xmlns:prism ="http://prismlibrary.com/"
              xmlns:prism ="http://prismlibrary.com/"
              prism:ViewModelLocator.AutoWireViewModel="True"
              prism:ViewModelLocator.AutoWireViewModel="True"
              mc:Ignorable="d" 
              mc:Ignorable="d" 
@@ -11,8 +12,7 @@
     <Grid  Margin="44,38,0,0">
     <Grid  Margin="44,38,0,0">
         <Grid.RowDefinitions>
         <Grid.RowDefinitions>
             <RowDefinition Height="auto"/>
             <RowDefinition Height="auto"/>
-            <RowDefinition Height="129.367"/>
-            <RowDefinition Height="67.633"/>
+            <RowDefinition />
         </Grid.RowDefinitions>
         </Grid.RowDefinitions>
 
 
         <Grid>
         <Grid>
@@ -27,7 +27,7 @@
                 </ComboBox.ItemTemplate>
                 </ComboBox.ItemTemplate>
             </ComboBox>
             </ComboBox>
         </Grid>
         </Grid>
-        <ListBox x:Name="ListCloudDrive" Grid.Row="1" Grid.RowSpan="2">
+        <ListBox x:Name="ListCloudDrive" Background="Transparent" Grid.Row="1" Grid.RowSpan="2" HorizontalAlignment="Left" VerticalAlignment='Top' BorderThickness="0">
              
              
             <ListBox.ItemsPanel>
             <ListBox.ItemsPanel>
                 <ItemsPanelTemplate>
                 <ItemsPanelTemplate>
@@ -37,14 +37,19 @@
 
 
             <ListBox.ItemTemplate>
             <ListBox.ItemTemplate>
                 <DataTemplate>
                 <DataTemplate>
-                    <Border Background="#DBDBDB" Width="218" Height="172">
-                        <TextBlock Text="{Binding DriveName}"/>
-                    </Border>
+                    <StackPanel Width="218" Height="192">
+                        <Rectangle  Fill="#DBDBDB" Width="218" Height="172"/>
+                        <TextBlock Grid.Row="1" Text="{Binding DriveName}" VerticalAlignment="Bottom" HorizontalAlignment="Center"/>
+                    </StackPanel>
                 </DataTemplate>
                 </DataTemplate>
             </ListBox.ItemTemplate>
             </ListBox.ItemTemplate>
 
 
             <ListBox.ItemContainerStyle>
             <ListBox.ItemContainerStyle>
                 <Style TargetType="{x:Type ListBoxItem}">
                 <Style TargetType="{x:Type ListBoxItem}">
+                    <Setter Property="Margin" Value="0,0,8,0"/>
+                    <Setter Property="Width" Value="218"/>
+                    <Setter Property="Height" Value="192"/>
+                    <Setter Property="Padding" Value="0"/>
                     <EventSetter Event="PreviewMouseLeftButtonUp" 
                     <EventSetter Event="PreviewMouseLeftButtonUp" 
                                  Handler="SelectCloudDrive_Click"
                                  Handler="SelectCloudDrive_Click"
                                  />
                                  />

+ 36 - 9
PDF Office/Views/HomePanel/CloudDrive/CloudFilesContent.xaml

@@ -3,12 +3,15 @@
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+             xmlns:DataConvert ="clr-namespace:PDF_Office.DataConvert"
              xmlns:prism ="http://prismlibrary.com/"
              xmlns:prism ="http://prismlibrary.com/"
              prism:ViewModelLocator.AutoWireViewModel="True"
              prism:ViewModelLocator.AutoWireViewModel="True"
              xmlns:local="clr-namespace:PDF_Office.Views.HomePanel.CloudDrive"
              xmlns:local="clr-namespace:PDF_Office.Views.HomePanel.CloudDrive"
              mc:Ignorable="d" 
              mc:Ignorable="d" 
              d:DesignHeight="450" d:DesignWidth="800">
              d:DesignHeight="450" d:DesignWidth="800">
     <UserControl.Resources>
     <UserControl.Resources>
+        <DataConvert:BoolToVisible x:Key="BoolToVisible"/>
+        <DataConvert:InvertBoolToVisibleConvert x:Key="InvertBoolToVisibleConvert"/>
         <ContextMenu x:Key="FlyoutMenu" FontSize="14"
         <ContextMenu x:Key="FlyoutMenu" FontSize="14"
                          >
                          >
             <ContextMenu.ItemContainerStyle>
             <ContextMenu.ItemContainerStyle>
@@ -44,12 +47,28 @@
                 <ColumnDefinition />
                 <ColumnDefinition />
                 <ColumnDefinition Width="auto"/>
                 <ColumnDefinition Width="auto"/>
             </Grid.ColumnDefinitions>
             </Grid.ColumnDefinitions>
-            <ListBox x:Name="ListFolder">
+            <ListBox x:Name="ListFolder" ItemsSource="{Binding FolderItems}">
+                <ListBox.ItemTemplate>
+                    <DataTemplate>
+                        <StackPanel Orientation="Horizontal">
+                            <TextBlock Text="{Binding FolderName}" HorizontalAlignment="Left"/>
+                            <TextBlock Text=" >" HorizontalAlignment="Left"/>
+                        </StackPanel>
+                    </DataTemplate>
+                </ListBox.ItemTemplate>
                 <ListBox.ItemsPanel>
                 <ListBox.ItemsPanel>
                     <ItemsPanelTemplate>
                     <ItemsPanelTemplate>
                         <WrapPanel Orientation="Horizontal"/>
                         <WrapPanel Orientation="Horizontal"/>
                     </ItemsPanelTemplate>
                     </ItemsPanelTemplate>
                 </ListBox.ItemsPanel>
                 </ListBox.ItemsPanel>
+                <ListBox.ItemContainerStyle>
+                    <Style TargetType="{x:Type ListBoxItem}">
+    
+                        <EventSetter Event="PreviewMouseLeftButtonUp" 
+                                 Handler="SelectListFolder_Click"
+                                 />
+                    </Style>
+                </ListBox.ItemContainerStyle>
             </ListBox>
             </ListBox>
             <StackPanel Grid.Column="1" Orientation="Horizontal">
             <StackPanel Grid.Column="1" Orientation="Horizontal">
                 <ComboBox x:Name="combCloudDrive" Grid.Column="1" Width="115" Height="32" Background="Wheat" HorizontalAlignment="Right" SelectionChanged="combCloudDrive_SelectionChanged">
                 <ComboBox x:Name="combCloudDrive" Grid.Column="1" Width="115" Height="32" Background="Wheat" HorizontalAlignment="Right" SelectionChanged="combCloudDrive_SelectionChanged">
@@ -76,7 +95,7 @@
                 <ListView.ItemTemplate>
                 <ListView.ItemTemplate>
                     <DataTemplate>
                     <DataTemplate>
                         <Grid Height="50" >
                         <Grid Height="50" >
-                            <TextBlock VerticalAlignment="Center" Text="{Binding user.UserAccount}"/>
+                            <TextBlock VerticalAlignment="Center" Text="{Binding userInfo.UserAccount}"/>
                         </Grid>
                         </Grid>
                        
                        
                     </DataTemplate>
                     </DataTemplate>
@@ -86,16 +105,24 @@
             <ListView x:Name="ListvmFiles" Grid.Column="1" ScrollViewer.VerticalScrollBarVisibility="Auto" ItemContainerStyle="{StaticResource itemstyle}">
             <ListView x:Name="ListvmFiles" Grid.Column="1" ScrollViewer.VerticalScrollBarVisibility="Auto" ItemContainerStyle="{StaticResource itemstyle}">
                 <ListView.ItemTemplate>
                 <ListView.ItemTemplate>
                     <DataTemplate>
                     <DataTemplate>
-                        <StackPanel Margin="0,5,0,5">
-                            <StackPanel Orientation="Horizontal">
-                                <TextBlock Text="Id:"/>
-                                <TextBlock Text="{Binding Id}"/>
+                        <Grid>
+                            <StackPanel Margin="0,5,0,5" Visibility="{Binding IsFolder,Converter={StaticResource InvertBoolToVisibleConvert}}">
+                                <StackPanel Orientation="Horizontal">
+                                    <TextBlock Text="Id:"/>
+                                    <TextBlock Text="{Binding Id}"/>
+                                </StackPanel>
+                                <StackPanel Orientation="Horizontal">
+                                    <TextBlock Text="文件名:"/>
+                                    <TextBlock Text="{Binding Name}"/>
+                                </StackPanel>
                             </StackPanel>
                             </StackPanel>
-                            <StackPanel Orientation="Horizontal">
-                                <TextBlock Text="文件名:"/>
+                            <StackPanel Visibility="{Binding IsFolder,Converter={StaticResource BoolToVisible}}" Background="YellowGreen">
+                                <TextBlock Text="文件:"/>
                                 <TextBlock Text="{Binding Name}"/>
                                 <TextBlock Text="{Binding Name}"/>
                             </StackPanel>
                             </StackPanel>
-                        </StackPanel>
+                           
+                        </Grid>
+                       
                     </DataTemplate>
                     </DataTemplate>
                 </ListView.ItemTemplate>
                 </ListView.ItemTemplate>
             </ListView>
             </ListView>

+ 13 - 7
PDF Office/Views/HomePanel/CloudDrive/CloudFilesContent.xaml.cs

@@ -29,6 +29,7 @@ namespace PDF_Office.Views.HomePanel.CloudDrive
         private CloudFilesContentViewModel ViewModel => DataContext as CloudFilesContentViewModel;
         private CloudFilesContentViewModel ViewModel => DataContext as CloudFilesContentViewModel;
 
 
         private List<CloudBoxItem> CloudeDrives = new List<CloudBoxItem>();
         private List<CloudBoxItem> CloudeDrives = new List<CloudBoxItem>();
+        private List<string> pathFolder = new List<string>();
 
 
         private CloudType cloudType;
         private CloudType cloudType;
         public CloudFilesContent()
         public CloudFilesContent()
@@ -53,6 +54,13 @@ namespace PDF_Office.Views.HomePanel.CloudDrive
                 if (Listusers.ItemsSource == null)
                 if (Listusers.ItemsSource == null)
                     Listusers.ItemsSource = Cloud.CloudLists;
                     Listusers.ItemsSource = Cloud.CloudLists;
             }
             }
+            InitListFolder();
+        }
+
+        private void InitListFolder()
+        {
+         
+
         }
         }
 
 
         private void combCloudDrive_SelectionChanged(object sender, SelectionChangedEventArgs e)
         private void combCloudDrive_SelectionChanged(object sender, SelectionChangedEventArgs e)
@@ -90,10 +98,7 @@ namespace PDF_Office.Views.HomePanel.CloudDrive
                             ObservableCollection<GoogleDriveFiles> filesList = new ObservableCollection<GoogleDriveFiles>();
                             ObservableCollection<GoogleDriveFiles> filesList = new ObservableCollection<GoogleDriveFiles>();
                             foreach (var file in files)
                             foreach (var file in files)
                             {
                             {
-                                if (file.Name.EndsWith(".pdf") == true)
-                                {
                                     filesList.Add(file);
                                     filesList.Add(file);
-                                }
                             }
                             }
                             ListvmFiles.ItemsSource = filesList;
                             ListvmFiles.ItemsSource = filesList;
                         }
                         }
@@ -107,10 +112,7 @@ namespace PDF_Office.Views.HomePanel.CloudDrive
                             ObservableCollection<DropbBoxFiles> filesList = new ObservableCollection<DropbBoxFiles>();
                             ObservableCollection<DropbBoxFiles> filesList = new ObservableCollection<DropbBoxFiles>();
                             foreach (var file in files)
                             foreach (var file in files)
                             {
                             {
-                                if (file.Name.EndsWith(".pdf") == true)
-                                {
                                     filesList.Add(file);
                                     filesList.Add(file);
-                                }
                             }
                             }
                             ListvmFiles.ItemsSource = filesList;
                             ListvmFiles.ItemsSource = filesList;
                         }
                         }
@@ -170,6 +172,10 @@ namespace PDF_Office.Views.HomePanel.CloudDrive
            
            
         }
         }
 
 
-       
+        private void SelectListFolder_Click(object sender, MouseButtonEventArgs e)
+        {
+            var folderItem = (sender as FrameworkElement).DataContext as FolderItem;
+            ViewModel?.SelectedFolderCommand?.Execute(folderItem);
+        }
     }
     }
 }
 }