Jelajahi Sumber

Merge branch 'dev' of http://git.kdan.cc:8865/Windows/PDFOffice_Windows_exe into dev

ZhouJieSheng 2 tahun lalu
induk
melakukan
4212c195dc
36 mengubah file dengan 690 tambahan dan 301 penghapusan
  1. 1 0
      PDF Office/App.xaml.cs
  2. 4 2
      PDF Office/Model/CloudDrive/CloudDriveItem.cs
  3. 55 12
      PDF Office/Model/CloudDrive/CloudFiles.cs
  4. 27 0
      PDF Office/PDF Office.csproj
  5. TEMPAT SAMPAH
      PDF Office/Resources/ToolBarIcon/MyTools/Arrow.png
  6. TEMPAT SAMPAH
      PDF Office/Resources/ToolBarIcon/MyTools/Bookmark.png
  7. TEMPAT SAMPAH
      PDF Office/Resources/ToolBarIcon/MyTools/Circle.png
  8. TEMPAT SAMPAH
      PDF Office/Resources/ToolBarIcon/MyTools/Freehande.png
  9. TEMPAT SAMPAH
      PDF Office/Resources/ToolBarIcon/MyTools/Freehande2.png
  10. TEMPAT SAMPAH
      PDF Office/Resources/ToolBarIcon/MyTools/Hand.png
  11. TEMPAT SAMPAH
      PDF Office/Resources/ToolBarIcon/MyTools/Highlight.png
  12. TEMPAT SAMPAH
      PDF Office/Resources/ToolBarIcon/MyTools/Hyperlink.png
  13. TEMPAT SAMPAH
      PDF Office/Resources/ToolBarIcon/MyTools/Image.png
  14. TEMPAT SAMPAH
      PDF Office/Resources/ToolBarIcon/MyTools/Line.png
  15. TEMPAT SAMPAH
      PDF Office/Resources/ToolBarIcon/MyTools/Note.png
  16. TEMPAT SAMPAH
      PDF Office/Resources/ToolBarIcon/MyTools/Point.png
  17. TEMPAT SAMPAH
      PDF Office/Resources/ToolBarIcon/MyTools/Rectangle.png
  18. TEMPAT SAMPAH
      PDF Office/Resources/ToolBarIcon/MyTools/Selecttool.png
  19. TEMPAT SAMPAH
      PDF Office/Resources/ToolBarIcon/MyTools/Stamp.png
  20. TEMPAT SAMPAH
      PDF Office/Resources/ToolBarIcon/MyTools/Textbox.png
  21. TEMPAT SAMPAH
      PDF Office/Resources/ToolBarIcon/MyTools/wavyline2.png
  22. 8 19
      PDF Office/ViewModels/HomePanel/CloudDrive/CloudDriveContentViewModel.cs
  23. 7 4
      PDF Office/ViewModels/HomePanel/CloudDrive/CloudDriveManager.cs
  24. 15 2
      PDF Office/ViewModels/HomePanel/CloudDrive/CloudDriveType/DropbBoxManager.cs
  25. 169 128
      PDF Office/ViewModels/HomePanel/CloudDrive/CloudDriveType/DropbBoxUserItem.cs
  26. 15 33
      PDF Office/ViewModels/HomePanel/CloudDrive/CloudDriveType/GoogleDriveManager.cs
  27. 56 24
      PDF Office/ViewModels/HomePanel/CloudDrive/CloudDriveType/GoogleDriveUserItem.cs
  28. 16 9
      PDF Office/ViewModels/HomePanel/CloudDrive/CloudFilesContentViewModel.cs
  29. 3 6
      PDF Office/ViewModels/HomePanel/HomeCloudContentViewModel.cs
  30. 1 1
      PDF Office/ViewModels/ViewContentViewModel.cs
  31. 6 17
      PDF Office/Views/HomePanel/CloudDrive/CloudDriveContent.xaml.cs
  32. 9 1
      PDF Office/Views/HomePanel/CloudDrive/CloudFilesContent.xaml
  33. 89 43
      PDF Office/Views/HomePanel/CloudDrive/CloudFilesContent.xaml.cs
  34. 139 0
      PDF Office/Views/Tools/AnnotToolContent.xaml
  35. 61 0
      PDF Office/Views/Tools/AnnotToolContent.xaml.cs
  36. 9 0
      PDF Office/index.html

+ 1 - 0
PDF Office/App.xaml.cs

@@ -100,6 +100,7 @@ namespace PDF_Office
             containerRegistry.RegisterForNavigation<BOTAContent>();
             containerRegistry.RegisterForNavigation<PageEditContent>();
             containerRegistry.RegisterForNavigation<ToolsBarContent>();
+            containerRegistry.RegisterForNavigation<AnnotToolContent>();
 
             //注册弹窗
             containerRegistry.RegisterDialog<VerifyPassWordDialog>(DialogNames.VerifyPassWordDialog);

+ 4 - 2
PDF Office/Model/CloudDrive/CloudDriveItem.cs

@@ -15,14 +15,16 @@ namespace PDF_Office.Model.CloudDrive
         GoogleDrive,
         OneDrive
     }
-    public class CloudDriveItem
+
+
+    public class CloudBoxItem
     {
         public CloudType CloudDiskType { get; set; }
         public List<UserCredential> UserCredentials { get; set; }
         public string UsersInfoPath { get; set; }
         public int Id { get; set; }
         public string DriveName { get; private set; }
-        public CloudDriveItem(CloudType cloudDiskType)
+        public CloudBoxItem(CloudType cloudDiskType)
         {
             CloudDiskType = cloudDiskType;
             GetName(CloudDiskType);

+ 55 - 12
PDF Office/Model/CloudDrive/CloudFiles.cs

@@ -2,41 +2,67 @@
 using Google.Apis.Drive.v3;
 using System;
 using System.Collections.Generic;
+using System.Collections.ObjectModel;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 
 namespace PDF_Office.Model.CloudDrive
 {
-    //某用户云盘的文件
-    internal class CloudFiles
+    public class Cloud
     {
-    }
+        public static ObservableCollection<UserBaseItem> CloudLists = new ObservableCollection<UserBaseItem>();
 
-    #region GooglrDrive
+        public static List<CloudBoxItem> InitCloudBoxs()
+        {
+            List<CloudBoxItem> CloudeDrives = new List<CloudBoxItem>();
 
-    public class CloudFileUser
-    {
-        public User user { get; set; }
-        public UserBaseItem driveItem{ get; set; }
+            var cloudDriveItem = new CloudBoxItem(CloudType.Box);
+            CloudeDrives.Add(cloudDriveItem);
+
+            cloudDriveItem = new CloudBoxItem(CloudType.DropBox);
+            CloudeDrives.Add(cloudDriveItem);
+
+            cloudDriveItem = new CloudBoxItem(CloudType.GoogleDrive);
+            CloudeDrives.Add(cloudDriveItem);
+
+            cloudDriveItem = new CloudBoxItem(CloudType.OneDrive);
+            CloudeDrives.Add(cloudDriveItem);
+
+            return CloudeDrives;
+        }
     }
 
-    public class User
+    #region 公有云盘
+
+    /// <summary>
+    /// 用户信息
+    /// </summary>
+    public class UserInfo
     {
-        public CloudType cloudType { get; set; }
+
         public string Name { get; set; }
         public int Id { get; set; }
 
         public string UserAccount { get; set; }
     }
 
+    /// <summary>
+    /// 用户云盘
+    /// </summary>
     public class UserBaseItem
     {
-      
+        public UserInfo userInfo { get; set; }
+        public CloudType cloudType { get; set; }
     }
 
+    #endregion
+
+    #region GooglrDrive
 
-    //谷歌云盘的文件
+    /// <summary>
+    /// 谷歌云盘的文件
+    /// </summary>
     public class GoogleDriveFiles
     {
         public string Id { get; set; }
@@ -48,4 +74,21 @@ namespace PDF_Office.Model.CloudDrive
 
     #endregion
 
+
+    #region GooglrDrive
+
+    /// <summary>
+    /// 谷歌云盘的文件
+    /// </summary>
+    public class DropbBoxFiles
+    {
+        public string Id { get; set; }
+        public string Name { get; set; }
+        public long? Size { get; set; }
+        public DateTime? CreatedTime { get; set; }
+    }
+
+    #endregion
+
+
 }

+ 27 - 0
PDF Office/PDF Office.csproj

@@ -340,6 +340,9 @@
     <Compile Include="Views\PageEdit\PageEditContent.xaml.cs">
       <DependentUpon>PageEditContent.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Views\Tools\AnnotToolContent.xaml.cs">
+      <DependentUpon>AnnotToolContent.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Views\Tools\ToolsBarContent.xaml.cs">
       <DependentUpon>ToolsBarContent.xaml</DependentUpon>
     </Compile>
@@ -528,6 +531,10 @@
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
+    <Page Include="Views\Tools\AnnotToolContent.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Views\Tools\ToolsBarContent.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
@@ -600,6 +607,26 @@
     <Resource Include="Resources\FilesType\ic_propertybar_file_pdf_lock.png" />
     <Resource Include="Resources\FilesType\ic_propertybar_file_png_Large.png" />
     <Resource Include="SDKLisence.xml" />
+    <Content Include="index.html">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+    <Resource Include="Resources\ToolBarIcon\MyTools\Arrow.png" />
+    <Resource Include="Resources\ToolBarIcon\MyTools\Bookmark.png" />
+    <Resource Include="Resources\ToolBarIcon\MyTools\Circle.png" />
+    <Resource Include="Resources\ToolBarIcon\MyTools\Freehande.png" />
+    <Resource Include="Resources\ToolBarIcon\MyTools\Freehande2.png" />
+    <Resource Include="Resources\ToolBarIcon\MyTools\Hand.png" />
+    <Resource Include="Resources\ToolBarIcon\MyTools\Highlight.png" />
+    <Resource Include="Resources\ToolBarIcon\MyTools\Hyperlink.png" />
+    <Resource Include="Resources\ToolBarIcon\MyTools\Image.png" />
+    <Resource Include="Resources\ToolBarIcon\MyTools\Line.png" />
+    <Resource Include="Resources\ToolBarIcon\MyTools\Note.png" />
+    <Resource Include="Resources\ToolBarIcon\MyTools\Point.png" />
+    <Resource Include="Resources\ToolBarIcon\MyTools\Rectangle.png" />
+    <Resource Include="Resources\ToolBarIcon\MyTools\Selecttool.png" />
+    <Resource Include="Resources\ToolBarIcon\MyTools\Stamp.png" />
+    <Resource Include="Resources\ToolBarIcon\MyTools\Textbox.png" />
+    <Resource Include="Resources\ToolBarIcon\MyTools\wavyline2.png" />
     <Content Include="SystemService\PreviewHandler.dll">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </Content>

TEMPAT SAMPAH
PDF Office/Resources/ToolBarIcon/MyTools/Arrow.png


TEMPAT SAMPAH
PDF Office/Resources/ToolBarIcon/MyTools/Bookmark.png


TEMPAT SAMPAH
PDF Office/Resources/ToolBarIcon/MyTools/Circle.png


TEMPAT SAMPAH
PDF Office/Resources/ToolBarIcon/MyTools/Freehande.png


TEMPAT SAMPAH
PDF Office/Resources/ToolBarIcon/MyTools/Freehande2.png


TEMPAT SAMPAH
PDF Office/Resources/ToolBarIcon/MyTools/Hand.png


TEMPAT SAMPAH
PDF Office/Resources/ToolBarIcon/MyTools/Highlight.png


TEMPAT SAMPAH
PDF Office/Resources/ToolBarIcon/MyTools/Hyperlink.png


TEMPAT SAMPAH
PDF Office/Resources/ToolBarIcon/MyTools/Image.png


TEMPAT SAMPAH
PDF Office/Resources/ToolBarIcon/MyTools/Line.png


TEMPAT SAMPAH
PDF Office/Resources/ToolBarIcon/MyTools/Note.png


TEMPAT SAMPAH
PDF Office/Resources/ToolBarIcon/MyTools/Point.png


TEMPAT SAMPAH
PDF Office/Resources/ToolBarIcon/MyTools/Rectangle.png


TEMPAT SAMPAH
PDF Office/Resources/ToolBarIcon/MyTools/Selecttool.png


TEMPAT SAMPAH
PDF Office/Resources/ToolBarIcon/MyTools/Stamp.png


TEMPAT SAMPAH
PDF Office/Resources/ToolBarIcon/MyTools/Textbox.png


TEMPAT SAMPAH
PDF Office/Resources/ToolBarIcon/MyTools/wavyline2.png


+ 8 - 19
PDF Office/ViewModels/HomePanel/CloudDrive/CloudDriveContentViewModel.cs

@@ -13,16 +13,16 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive
     {
 
 
-        public DelegateCommand<CloudDriveItem> CheckDriveCommand { get; set; }
-        public DelegateCommand<CloudDriveItem> CheckDriveLoginUserCommand { get; set; }
+        public DelegateCommand<CloudBoxItem> CheckDriveCommand { get; set; }
+        public DelegateCommand<CloudBoxItem> CheckDriveLoginUserCommand { get; set; }
 
         private CloudDriveManager Manager =>CloudDriveManager.GetInstance();
         public event EventHandler<bool> IshowContentHandler;
       
         public CloudDriveContentViewModel()
         {
-            CheckDriveCommand = new DelegateCommand<CloudDriveItem>(CheckDrive);
-            CheckDriveLoginUserCommand = new DelegateCommand<CloudDriveItem>(CheckDriveLoginUser);
+            CheckDriveCommand = new DelegateCommand<CloudBoxItem>(CheckDrive);
+            CheckDriveLoginUserCommand = new DelegateCommand<CloudBoxItem>(CheckDriveLoginUser);
           
         }
 
@@ -33,28 +33,17 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive
             IshowContentHandler?.Invoke(null, !result);
         }
 
-        public async void CheckDrive(CloudDriveItem cloudDriveItem)
+        public async void CheckDrive(CloudBoxItem cloudDriveItem)
         {
             bool result = false;
-            switch (cloudDriveItem.CloudDiskType)
-            {
-                case CloudType.GoogleDrive:
-                     result = await Manager.LoginUser(cloudDriveItem.CloudDiskType);
-                    break;
-            }
-
+            result = await Manager.LoginUser(cloudDriveItem.CloudDiskType);
             IshowContentHandler?.Invoke(null, !result);
         }
 
-        public async void CheckDriveLoginUser(CloudDriveItem cloudDriveItem)
+        public async void CheckDriveLoginUser(CloudBoxItem cloudDriveItem)
         {
             bool result = false;
-            switch (cloudDriveItem.CloudDiskType)
-            {
-                case CloudType.GoogleDrive:
-                    result = await Manager.LoginUser(cloudDriveItem.CloudDiskType);
-                    break;
-            }
+            result = await Manager.LoginUser(cloudDriveItem.CloudDiskType);
         }
 
 

+ 7 - 4
PDF Office/ViewModels/HomePanel/CloudDrive/CloudDriveManager.cs

@@ -2,6 +2,7 @@
 using PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType;
 using System;
 using System.Collections.Generic;
+using System.Collections.ObjectModel;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
@@ -13,8 +14,9 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive
     //单实例化
     public class CloudDriveManager
     {
-       public GoogleDriveManager GoogleDrive => GoogleDriveManager.GoogleDrive;
-       // public DropbBoxManager DropbBox;
+      
+        public GoogleDriveManager GoogleDrive => GoogleDriveManager.GoogleDrive;
+        public DropbBoxManager DropbBox => DropbBoxManager.DropbBox;
         public CloudType cloudType;
 
         private static CloudDriveManager instance;
@@ -28,7 +30,6 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive
         }
         private CloudDriveManager()
         {
-         //   DropbBox = new DropbBoxManager();
         }
 
 
@@ -43,6 +44,8 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive
             {
                 case CloudType.GoogleDrive:
                    return await GoogleDrive.LoginUserCount();
+                case CloudType.DropBox:
+                    return await DropbBox.LoginUser();
             }
             return false;
         }
@@ -50,7 +53,7 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive
         public bool LoadedUsers()
         {
             bool isUsers = false;
-            if (CloudFilesContentViewModel.CloudFileUserLists.Count > 0)
+            if (Cloud.CloudLists.Count > 0)
                 isUsers = true;
 
             return isUsers;

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

@@ -26,9 +26,22 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType
         /// <summary>
         /// 登录
         /// </summary>
-        public void LoginUser()
+        public async Task<bool> LoginUser()
         {
-
+            bool result = false;
+            DropbBoxUserItem dropbBoxUserItem = new DropbBoxUserItem();
+            result = await dropbBoxUserItem.LoginUser();
+            if(result)
+            {
+                dropbBoxUserItem.cloudType = CloudType.DropBox;
+                   UserInfo user = new UserInfo();
+                user.Name = "DropBox测试" + (Cloud.CloudLists.Count + 1).ToString();
+                dropbBoxUserItem.userInfo = user;
+
+                Cloud.CloudLists.Add(dropbBoxUserItem);
+
+            }
+            return result;
         }
 
         /// <summary>

+ 169 - 128
PDF Office/ViewModels/HomePanel/CloudDrive/CloudDriveType/DropbBoxUserItem.cs

@@ -1,5 +1,6 @@
 using Dropbox.Api;
 using Dropbox.Api.Files;
+using PDF_Office.Model.CloudDrive;
 using System;
 using System.Collections.Generic;
 using System.IO;
@@ -11,10 +12,146 @@ using System.Windows;
 
 namespace PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType
 {
-    
-    public class DropbBoxUserItem
+    /// <summary>
+    /// 单用户
+    /// </summary>
+    public class DropbBoxUserItem : UserBaseItem
     {
         DropboxClient client;
+        private List<DropbBoxFiles> FilesList = new List<DropbBoxFiles>();//文件
+        private List<Metadata> MetadataList = new List<Metadata>();//文件
+        public async Task<bool> LoginUser()
+        {
+            client = await DropbBoxStatic.Connect();
+            if (client == null)
+                return false;
+            else
+                return true;
+        }
+
+        public async Task<List<DropbBoxFiles>> RefreshList(string path = "")
+        {
+            var files = await client.Files.ListFolderAsync(path);
+            DropbBoxFiles dropbBoxFiles = new DropbBoxFiles();
+            List<DropbBoxFiles> FileList = new List<DropbBoxFiles>();
+            foreach (var file in files.Entries)
+            {
+                dropbBoxFiles.Name = file.Name;
+                FileList.Add(dropbBoxFiles);
+            }
+            MetadataList = (List<Metadata>)files.Entries;
+            this.FilesList = FileList;
+            return FileList;
+        }
+
+
+
+        public async Task<string> Download(string name, string savePath)
+        {
+            Metadata metadata = null;
+            foreach(var item in MetadataList)
+            {
+                if (item.IsFolder)
+                    continue;
+
+                if (item.Name == name)
+                {
+                    metadata = item;
+                    break;
+                }
+            }
+
+            if (metadata != null)
+            {
+                savePath = savePath + "\\" + metadata.Name;
+                using (var response = await client.Files.DownloadAsync(metadata.PathDisplay))
+                {
+                    var result = await response.GetContentAsStreamAsync();
+                    var stream = StreamToMemoryStream(result);
+                    using (var fileStream = System.IO.File.Create(savePath))
+                    {
+                        stream.Seek(0, System.IO.SeekOrigin.Begin);
+                        stream.CopyTo(fileStream);
+                    }
+                }
+               // System.Diagnostics.Process.Start(@"explorer.exe", "/select,\"" + savePath + "\"");
+                RefreshList(savePath);
+
+                return savePath;
+            }
+            
+            return "";
+
+        }
+
+        public MemoryStream StreamToMemoryStream(Stream stream)
+        {
+            MemoryStream memoryStream = new MemoryStream();
+
+            //将基础流写入内存流
+            const int bufferLength = 1024;
+            byte[] buffer = new byte[bufferLength];
+            int actual = stream.Read(buffer, 0, bufferLength);
+            while (actual > 0)
+            {
+                // 读、写过程中,流的位置会自动走。
+                memoryStream.Write(buffer, 0, actual);
+                actual = stream.Read(buffer, 0, bufferLength);
+            }
+            memoryStream.Position = 0;
+
+            return memoryStream;
+        }
+
+        private void Upload()
+        {
+            //if (ItemList.SelectedItem != null)
+            //{
+            //    var item = ItemList.SelectedItem as Metadata;
+            //    if (item.IsFolder)
+            //        return;
+
+            //OpenFileDialog openFileDialog = new OpenFileDialog();
+            //if ((bool)openFileDialog.ShowDialog())
+            //{
+            //    string folder = currentFolder; /*= item.PathDisplay.Replace("/" + item.Name, "");*/
+            //    using (var stream = System.IO.File.OpenRead(openFileDialog.FileName))
+            //    {
+            //        await client.Files.UploadAsync(folder + "/" + openFileDialog.SafeFileName, WriteMode.Overwrite.Instance, body: stream);
+            //    }
+            //    MessageBox.Show("上传完成");
+            //    RefreshList(folder);
+            //}
+            //}
+        }
+
+        private void Loaded()
+        {
+            //var text = sender as TextBlock;
+            //if (text == null)
+            //    return;
+            //if (text.DataContext is Metadata)
+            //{
+            //    var data = (text.DataContext as Metadata);
+            //    if (data.IsFile)
+            //    {
+            //        text.Text = "File";
+            //    }
+            //    if (data.IsFolder)
+            //    {
+            //        text.Text = "Folder";
+            //    }
+            //}
+        }
+
+
+    }
+
+
+    #region 身份验证
+
+    public static class DropbBoxStatic
+    {
         // This loopback host is for demo purpose. If this port is not
         // available on your machine you need to update this URL with an unused port.
         public static readonly string LoopbackHost = "http://127.0.0.1:8080/";
@@ -22,15 +159,13 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType
         public static readonly string ApiKey = "k1hv3601odbsmln";
         // URL to receive OAuth 2 redirect from Dropbox server.
         // You also need to register this redirect URL on https://www.dropbox.com/developers/apps.
-        public readonly Uri RedirectUri = new Uri(LoopbackHost + "authorize");
+        public static readonly Uri RedirectUri = new Uri(LoopbackHost + "authorize");
 
         // URL to receive access token from JS.
-        public readonly Uri JSRedirectUri = new Uri(LoopbackHost + "token");
-
-        private string currentFolder = "";
+        public static readonly Uri JSRedirectUri = new Uri(LoopbackHost + "token");
 
-        HttpListener http = new HttpListener();
-        private async void Connect()
+        private static HttpListener http = new HttpListener();
+        public static async Task<DropboxClient> Connect()
         {
             DropboxCertHelper.InitializeCertPinning();
             var state = Guid.NewGuid().ToString("N");
@@ -49,15 +184,36 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType
 
             var tokenResult = await OAuthflow.ProcessCodeFlowAsync(redirectUri, ApiKey, RedirectUri.ToString(), state);
 
-          //  Window.GetWindow(this).Activate();
+            //  Window.GetWindow(this).Activate();
             DropboxClientConfig dropboxClientConfig = new DropboxClientConfig("ControlTest");
 
+            DropboxClient client;
             client = new DropboxClient(tokenResult.AccessToken, dropboxClientConfig);
+            return client;
+        }
 
-            RefreshList();
+        /// <summary>
+        /// Handle the redirect from JS and process raw redirect URI with fragment to
+        /// complete the authorization flow.
+        /// </summary>
+        /// <param name="http">The http listener.</param>
+        /// <returns>The <see cref="OAuth2Response"/></returns>
+        private static async Task<Uri> HandleJSRedirect(HttpListener http)
+        {
+            var context = await http.GetContextAsync();
+
+            // We only care about request to TokenRedirectUri endpoint.
+            while (context.Request.Url.AbsolutePath != JSRedirectUri.AbsolutePath)
+            {
+                context = await http.GetContextAsync();
+            }
 
+            var redirectUri = new Uri(context.Request.QueryString["url_with_fragment"]);
+
+            return redirectUri;
         }
 
+
         public static void ListenerCallback(IAsyncResult result)
         {
             HttpListener listener = (HttpListener)result.AsyncState;
@@ -77,12 +233,6 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType
             output.Close();
         }
 
-        public async void RefreshList(string path = "")
-        {
-            var files = await client.Files.ListFolderAsync(path);
-
-      //      ItemList.ItemsSource = files.Entries;
-        }
 
         /// <summary>
         /// Handles the redirect from Dropbox server. Because we are using token flow, the local
@@ -91,7 +241,7 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType
         /// </summary>
         /// <param name="http">The http listener.</param>
         /// <returns>The <see cref="Task"/></returns>
-        private async Task HandleOAuth2Redirect(HttpListener http)
+        private static async Task HandleOAuth2Redirect(HttpListener http)
         {
             var context = await http.GetContextAsync();
 
@@ -113,121 +263,12 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType
             context.Response.OutputStream.Close();
         }
 
-        /// <summary>
-        /// Handle the redirect from JS and process raw redirect URI with fragment to
-        /// complete the authorization flow.
-        /// </summary>
-        /// <param name="http">The http listener.</param>
-        /// <returns>The <see cref="OAuth2Response"/></returns>
-        private async Task<Uri> HandleJSRedirect(HttpListener http)
-        {
-            var context = await http.GetContextAsync();
-
-            // We only care about request to TokenRedirectUri endpoint.
-            while (context.Request.Url.AbsolutePath != JSRedirectUri.AbsolutePath)
-            {
-                context = await http.GetContextAsync();
-            }
-
-            var redirectUri = new Uri(context.Request.QueryString["url_with_fragment"]);
 
-            return redirectUri;
-        }
-
-
-
-
-
-        private void Download()
-        {
-            //if (ItemList.SelectedItem != null)
-            //{
-            //    var item = ItemList.SelectedItem as Metadata;
-            //    if (item.IsFolder)
-            //        return;
-
-            //    SaveFileDialog saveFileDialog = new SaveFileDialog();
-            //    saveFileDialog.FileName = item.Name;
-            //    if ((bool)saveFileDialog.ShowDialog())
-            //    {
-            //        string folder = item.PathDisplay.Replace("/" + item.Name, "");
-            //        using (var response = await client.Files.DownloadAsync(item.PathDisplay))
-            //        {
-            //            var result = await response.GetContentAsStreamAsync();
-            //            var stream = StreamToMemoryStream(result);
-            //            using (var fileStream = System.IO.File.Create(saveFileDialog.FileName))
-            //            {
-            //                stream.Seek(0, System.IO.SeekOrigin.Begin);
-            //                stream.CopyTo(fileStream);
-            //            }
-            //        }
-            //        MessageBox.Show("下载完成");
-            //        System.Diagnostics.Process.Start(@"explorer.exe", "/select,\"" + saveFileDialog.FileName + "\"");
-            //        RefreshList(folder);
-            //    }
-            //}
-        }
-
-        public MemoryStream StreamToMemoryStream(Stream stream)
-        {
-            MemoryStream memoryStream = new MemoryStream();
-
-            //将基础流写入内存流
-            const int bufferLength = 1024;
-            byte[] buffer = new byte[bufferLength];
-            int actual = stream.Read(buffer, 0, bufferLength);
-            while (actual > 0)
-            {
-                // 读、写过程中,流的位置会自动走。
-                memoryStream.Write(buffer, 0, actual);
-                actual = stream.Read(buffer, 0, bufferLength);
-            }
-            memoryStream.Position = 0;
+    }
 
-            return memoryStream;
-        }
 
-        private void Upload()
-        {
-            //if (ItemList.SelectedItem != null)
-            //{
-            //    var item = ItemList.SelectedItem as Metadata;
-            //    if (item.IsFolder)
-            //        return;
-
-            //OpenFileDialog openFileDialog = new OpenFileDialog();
-            //if ((bool)openFileDialog.ShowDialog())
-            //{
-            //    string folder = currentFolder; /*= item.PathDisplay.Replace("/" + item.Name, "");*/
-            //    using (var stream = System.IO.File.OpenRead(openFileDialog.FileName))
-            //    {
-            //        await client.Files.UploadAsync(folder + "/" + openFileDialog.SafeFileName, WriteMode.Overwrite.Instance, body: stream);
-            //    }
-            //    MessageBox.Show("上传完成");
-            //    RefreshList(folder);
-            //}
-            //}
-        }
+    #endregion
 
-        private void Loaded()
-        {
-            //var text = sender as TextBlock;
-            //if (text == null)
-            //    return;
-            //if (text.DataContext is Metadata)
-            //{
-            //    var data = (text.DataContext as Metadata);
-            //    if (data.IsFile)
-            //    {
-            //        text.Text = "File";
-            //    }
-            //    if (data.IsFolder)
-            //    {
-            //        text.Text = "Folder";
-            //    }
-            //}
-        }
 
 
-    }
 }

+ 15 - 33
PDF Office/ViewModels/HomePanel/CloudDrive/CloudDriveType/GoogleDriveManager.cs

@@ -17,9 +17,6 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType
     //多用户UX交互
     public class GoogleDriveManager
     {
-        //已登录的所有用户
-     //   public ObservableCollection<CloudFileUser> GoogleDriveUsers = new ObservableCollection<CloudFileUser>();
-
         private static GoogleDriveManager instance;
         public static GoogleDriveManager GoogleDrive => instance ?? (instance = new GoogleDriveManager());
         private GoogleDriveManager()
@@ -36,7 +33,7 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType
         public async Task<bool> GetHistoryUsers()
         {
             var tuples = await GoogleDriveStatic.GetHistoryService();
-            CloudFilesContentViewModel.CloudFileUserLists.Clear();
+            Cloud.CloudLists.Clear();
             foreach (var tuple in tuples)
             {
 
@@ -46,7 +43,7 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType
                 }
             }
 
-            if (CloudFilesContentViewModel.CloudFileUserLists.Count > 0)
+            if (Cloud.CloudLists.Count > 0)
             {
                 return true;
             }
@@ -55,18 +52,16 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType
 
         public async void AddGoogleDriveUser(Tuple<DriveService, UserCredential> tuple)
         {
-            CloudFileUser cloudFileUser = new CloudFileUser();
-           GoogleDriveUserItem userItem = new GoogleDriveUserItem();
+            GoogleDriveUserItem userItem = new GoogleDriveUserItem();
             userItem.Service = tuple.Item1;
             userItem.CurrentCredential = tuple.Item2;
-            cloudFileUser.driveItem = userItem;
-          
-            User user = new User();
-            user.UserAccount = await userItem.GetUserAcountAsync();
-            user.cloudType = CloudType.GoogleDrive;
-            cloudFileUser.user = user;
+            userItem.cloudType = CloudType.GoogleDrive;
+
+            UserInfo user = new UserInfo();
+            user = await userItem.GetUserAcountAsync();
+            userItem.userInfo = user;
 
-            CloudFilesContentViewModel.CloudFileUserLists.Add(cloudFileUser);
+            Cloud.CloudLists.Add(userItem);
         }
 
         public async Task<bool> LoginUserCount()
@@ -76,13 +71,7 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType
             if (tuple != null)
             {
                 result = true;
-
-           //     Task.Run(async () =>
-           //     {
-
-                    await GetUserInfo(tuple);
-           //     });
-
+                await GetUserInfo(tuple);//此处不可用异步处理,否则导致的结果是没法刷新集合呈现在UI上
             }
 
             return result;
@@ -90,23 +79,16 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType
 
         public async Task<bool> GetUserInfo(Tuple<DriveService, UserCredential> tuple)
         {
-            CloudFileUser cloudFileUser = new CloudFileUser();
             GoogleDriveUserItem userItem = new GoogleDriveUserItem();
             userItem.Service = tuple.Item1;
             userItem.CurrentCredential = tuple.Item2;
-            cloudFileUser.driveItem = userItem;
+            userItem.cloudType = CloudType.GoogleDrive;
 
-            User user = new User();
-            user.UserAccount = await userItem.GetUserAcountAsync();
-            user.cloudType = CloudType.GoogleDrive;
-            cloudFileUser.user = user;
+            UserInfo user = new UserInfo();
+            user = await userItem.GetUserAcountAsync();
+            userItem.userInfo = user;
 
-            CloudFilesContentViewModel.CloudFileUserLists.Add(cloudFileUser);
-            //GoogleDriveUserItem userItem = new GoogleDriveUserItem();
-            //userItem.Service = tuple.Item1;
-            //userItem.CurrentCredential = tuple.Item2;
-            //userItem.User.UserAccount = await userItem.GetUserAcountAsync();
-            //CloudFilesContentViewModel.CloudFileUserLists.Add(userItem);
+            Cloud.CloudLists.Add(userItem);
             return true;
         }
 

+ 56 - 24
PDF Office/ViewModels/HomePanel/CloudDrive/CloudDriveType/GoogleDriveUserItem.cs

@@ -1,6 +1,7 @@
 using Google.Apis.Auth.OAuth2;
 using Google.Apis.Download;
 using Google.Apis.Drive.v3;
+using Google.Apis.Drive.v3.Data;
 using Google.Apis.Services;
 using Google.Apis.Util.Store;
 using PDF_Office.Model.CloudDrive;
@@ -16,7 +17,7 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType
 {
 
     /// <summary>
-    /// 对单账号处理的核心功能类
+    /// 单个用户
     /// </summary>
     public class GoogleDriveUserItem: UserBaseItem
     {
@@ -46,7 +47,11 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType
                 result = await CurrentCredential.RevokeTokenAsync(CancellationToken.None);
             }
             if (result == true)
+            {
                 CurrentCredential = null;
+                FilesList.Clear();
+            }
+               
 
             return result;
         }
@@ -55,25 +60,28 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType
         /// 获取帐号
         /// </summary>
         /// <returns>返回用户帐号地址</returns>
-        private async Task<string> GetUserAcount()
+        private async Task<UserInfo> GetUserAcount()
         {
-            string userAcount = "";
+            UserInfo userInfo = null;
             if (Service != null)
             {
+                userInfo = new UserInfo();
                 var about = Service.About.Get();
                 about.Fields = "user";
-                var uss = about.Execute().User;
-                userAcount = uss.EmailAddress;
+                var uss = await about.ExecuteAsync();
+                User user = uss.User;
+                userInfo.UserAccount = user.EmailAddress;
+                userInfo.Name = user.DisplayName;
             }
 
-            return userAcount;
+            return userInfo;
         }
 
         /// <summary>
         /// 获取帐号
         /// </summary>
         /// <returns>返回用户帐号地址</returns>
-        public async Task<string> GetUserAcountAsync()
+        public async Task<UserInfo> GetUserAcountAsync()
         {
             return await GetUserAcount();
         }
@@ -123,6 +131,7 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType
                     };
                     FileList.Add(File);
                 }
+                this.FilesList = FileList;
             }
             return FileList;
         }
@@ -238,7 +247,7 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType
     {
         public static string[] Scopes = { DriveService.Scope.Drive };
         //Google Drive应用名称
-        private static readonly string GoogleDriveAppName = "PDF Office848";
+        private static readonly string GoogleDriveAppName = "PDF Office";
         //请求应用进行身份验证的信息
         public static string CredentialsPath { get; private set; }
 
@@ -276,25 +285,33 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType
                 FilePath = System.IO.Path.Combine(FilesPathTemp, time + ".json");
             }
 
-
-            using (var stream = new FileStream(CredentialsPath, FileMode.Open, FileAccess.Read))
+            try
             {
-                credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
-                    GoogleClientSecrets.Load(stream).Secrets,
-                    Scopes,
-                    "user",
-                    CancellationToken.None,
-                    new FileDataStore(FilePath, true)).Result;
-            }
+                using (var stream = new FileStream(CredentialsPath, FileMode.Open, FileAccess.Read))
+                {
+                    credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
+                        GoogleClientSecrets.Load(stream).Secrets,
+                        Scopes,
+                        "user",
+                        CancellationToken.None,
+                        new FileDataStore(FilePath, true)).Result;
+                }
 
-            //create Drive API service.
-            DriveService service = new DriveService(new BaseClientService.Initializer()
-            {
-                HttpClientInitializer = credential,
-                ApplicationName = GoogleDriveAppName
-            });
+                //create Drive API service.
+                DriveService service = new DriveService(new BaseClientService.Initializer()
+                {
+                    HttpClientInitializer = credential,
+                    ApplicationName = GoogleDriveAppName
+                });
 
-            return tuple = new Tuple<DriveService, UserCredential>(service, credential);
+                return tuple = new Tuple<DriveService, UserCredential>(service, credential);
+            }
+            catch (Exception e)
+            {
+                //网络连接失败的情况
+                return null;
+            }
+            
         }
 
 
@@ -338,6 +355,21 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive.CloudDriveType
             return FolderPath;
         }
 
+        public static bool ClearFilesPathTemp()
+        {
+            bool result = false;
+            string str_1 = System.AppDomain.CurrentDomain.BaseDirectory;
+            String FolderPath = str_1 + "GoogleDriveUsers";
+
+            if (Directory.Exists(FolderPath) == false)
+            {
+                Directory.Delete(FolderPath);
+                result = true;
+            }
+            return result;
+        }
+
+
         /// <summary>
         /// 获取本地身份验证文件
         /// </summary>

+ 16 - 9
PDF Office/ViewModels/HomePanel/CloudDrive/CloudFilesContentViewModel.cs

@@ -14,26 +14,33 @@ namespace PDF_Office.ViewModels.HomePanel.CloudDrive
     //各云盘事件
     public class CloudFilesContentViewModel : BindableBase
     {
-        public static ObservableCollection<CloudFileUser> CloudFileUserLists = new ObservableCollection<CloudFileUser>();
+     
         public GoogleDriveManager GoogleDrive => GoogleDriveManager.GoogleDrive;
         public DropbBoxManager DropbBox => DropbBoxManager.DropbBox;
         public DelegateCommand OpenCloudDriveCommand { get; set; }
         public DelegateCommand CheckDriveUsersCommand { get; set; }
 
-        //向外触发
-      //  public event EventHandler<bool> isFoundUserHandler;
+        public DelegateCommand<CloudBoxItem> CheckDriveCommand { get; set; }
+        
         public CloudFilesContentViewModel()
         {
-          //  Manager = new GoogleDriveManager(); 
-         //   GoogleDrive = new GoogleDriveManager();
-
             OpenCloudDriveCommand = new DelegateCommand(OpenCloudDrive_Click);
             OpenCloudDriveCommand = new DelegateCommand(CheckDriveUsers);
 
-          //  CheckDriveUsersCommand = new DelegateCommand(CheckDriveUsers);
-
+            CheckDriveCommand = new DelegateCommand<CloudBoxItem>(CheckDrive);
+        }
 
-         
+        public async void CheckDrive(CloudBoxItem cloudDriveItem)
+        {
+            switch (cloudDriveItem.CloudDiskType)
+            {
+                case CloudType.GoogleDrive:
+                     await GoogleDrive.LoginUserCount();
+                    break;
+                case CloudType.DropBox:
+                     await DropbBox.LoginUser();
+                    break;
+            }
         }
 
         #region 云盘公用接口

+ 3 - 6
PDF Office/ViewModels/HomePanel/HomeCloudContentViewModel.cs

@@ -13,16 +13,13 @@ namespace PDF_Office.ViewModels.HomePanel
 {
     public class HomeCloudContentViewModel:BindableBase
     {
-     //   public GoogleDriveManager googleDriveManager;
-        
-        public DelegateCommand<CloudDriveItem> OpenCloudDriveCommand { get; set; }
+        public DelegateCommand<CloudBoxItem> OpenCloudDriveCommand { get; set; }
         public HomeCloudContentViewModel()
         {
-         //   googleDriveManager = new GoogleDriveManager();
-            OpenCloudDriveCommand = new DelegateCommand<CloudDriveItem>(OpenCloudDrive_Click);
+            OpenCloudDriveCommand = new DelegateCommand<CloudBoxItem>(OpenCloudDrive_Click);
         }
 
-        public void OpenCloudDrive_Click(CloudDriveItem cloudDiskItem)
+        public void OpenCloudDrive_Click(CloudBoxItem cloudDiskItem)
         {
             if (cloudDiskItem != null)
             {

+ 1 - 1
PDF Office/ViewModels/ViewContentViewModel.cs

@@ -237,7 +237,7 @@ namespace PDF_Office.ViewModels
         {
             dictionary.Add("TabItemPageEdit", "PageEditContent");
             dictionary.Add("TabItemTool", "ToolsBarContent");
-            dictionary.Add("TabItemAnnotation", "");
+            dictionary.Add("TabItemAnnotation", "AnnotToolContent");
             dictionary.Add("TabItemConvert", "");
             dictionary.Add("TabItemScan", "");
             dictionary.Add("TabItemEdit", "");

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

@@ -22,7 +22,7 @@ namespace PDF_Office.Views.HomePanel.CloudDrive
     /// </summary>
     public partial class CloudDriveContent : UserControl
     {
-        private List<CloudDriveItem> CloudeDrives = new List<CloudDriveItem>();
+        private List<CloudBoxItem> CloudBoxs = new List<CloudBoxItem>();
         private CloudDriveContentViewModel ViewModel => DataContext as CloudDriveContentViewModel;
 
         public CloudDriveContent()
@@ -50,26 +50,15 @@ namespace PDF_Office.Views.HomePanel.CloudDrive
 
         private void InitCloudDrive()
         {
-            var cloudDriveItem = new CloudDriveItem(CloudType.Box);
-            CloudeDrives.Add(cloudDriveItem);
-
-            cloudDriveItem = new CloudDriveItem(CloudType.DropBox);
-            CloudeDrives.Add(cloudDriveItem);
-
-            cloudDriveItem = new CloudDriveItem(CloudType.GoogleDrive);
-            CloudeDrives.Add(cloudDriveItem);
-
-            cloudDriveItem = new CloudDriveItem(CloudType.OneDrive);
-            CloudeDrives.Add(cloudDriveItem);
-
-            ListCloudDrive.ItemsSource = CloudeDrives;
-            combCloudDrive.ItemsSource = CloudeDrives;
+            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 CloudDriveItem;
+           var cloudDriveItem = (sender as FrameworkElement).DataContext as CloudBoxItem;
             if(cloudDriveItem != null)
             {
                 ViewModel.CheckDriveCommand.Execute(cloudDriveItem);
@@ -78,7 +67,7 @@ namespace PDF_Office.Views.HomePanel.CloudDrive
 
         private void combCloudDrive_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
-            var cloudDriveItem = combCloudDrive.SelectedItem as CloudDriveItem;
+            var cloudDriveItem = combCloudDrive.SelectedItem as CloudBoxItem;
             if (cloudDriveItem != null)
             {
                 ViewModel.CheckDriveCommand.Execute(cloudDriveItem);

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

@@ -52,7 +52,15 @@
                 </ListBox.ItemsPanel>
             </ListBox>
             <StackPanel Grid.Column="1" Orientation="Horizontal">
-                <ComboBox x:Name="combCloudDisk" Grid.Column="1" Width="115" Height="32" Background="Wheat" HorizontalAlignment="Right"/>
+                <ComboBox x:Name="combCloudDrive" Grid.Column="1" Width="115" Height="32" Background="Wheat" HorizontalAlignment="Right" SelectionChanged="combCloudDrive_SelectionChanged">
+                    <ComboBox.ItemTemplate>
+                        <DataTemplate>
+                            <Border Background="#DBDBDB">
+                                <TextBlock Text="{Binding DriveName}"/>
+                            </Border>
+                        </DataTemplate>
+                    </ComboBox.ItemTemplate>
+                </ComboBox>
                 <Button Content="Test" Click="Button_Click"/>
             </StackPanel>
            

+ 89 - 43
PDF Office/Views/HomePanel/CloudDrive/CloudFilesContent.xaml.cs

@@ -28,7 +28,7 @@ namespace PDF_Office.Views.HomePanel.CloudDrive
      
         private CloudFilesContentViewModel ViewModel => DataContext as CloudFilesContentViewModel;
 
-        private List<CloudDriveItem> CloudeDrives = new List<CloudDriveItem>();
+        private List<CloudBoxItem> CloudeDrives = new List<CloudBoxItem>();
 
         private CloudType cloudType;
         public CloudFilesContent()
@@ -40,20 +40,9 @@ namespace PDF_Office.Views.HomePanel.CloudDrive
 
         private void InitCloudDrive()
         {
-            var cloudDriveItem = new CloudDriveItem(CloudType.Box);
-            CloudeDrives.Add(cloudDriveItem);
-
-            cloudDriveItem = new CloudDriveItem(CloudType.DropBox);
-            CloudeDrives.Add(cloudDriveItem);
-
-            cloudDriveItem = new CloudDriveItem(CloudType.GoogleDrive);
-            CloudeDrives.Add(cloudDriveItem);
-
-            cloudDriveItem = new CloudDriveItem(CloudType.OneDrive);
-            CloudeDrives.Add(cloudDriveItem);
-
-            combCloudDisk.ItemsSource = CloudeDrives;
-            combCloudDisk.SelectedIndex = 0;
+            CloudeDrives = Cloud.InitCloudBoxs();
+            combCloudDrive.ItemsSource = CloudeDrives;
+            combCloudDrive.SelectedIndex = 0;
         }
 
         private void usercontrol_Loaded(object sender, RoutedEventArgs e)
@@ -62,68 +51,125 @@ namespace PDF_Office.Views.HomePanel.CloudDrive
             {
                 ViewModel.CheckDriveUsers();
                 if (Listusers.ItemsSource == null)
-                    Listusers.ItemsSource = CloudFilesContentViewModel.CloudFileUserLists;
+                    Listusers.ItemsSource = Cloud.CloudLists;
             }
         }
 
-        public void SelectCloudTye(CloudType cloudType)
+        private void combCloudDrive_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
-            switch (cloudType)
+            var cloudDriveItem = combCloudDrive.SelectedItem as CloudBoxItem;
+            if (cloudDriveItem != null)
             {
-                case CloudType.GoogleDrive:
-                    cloudType = CloudType.GoogleDrive;
-                    break;
+                ViewModel.CheckDriveCommand.Execute(cloudDriveItem);
             }
         }
 
+
         private void Button_Click(object sender, RoutedEventArgs e)
         {
 
-         //  SelectCloudTye(CloudType.GoogleDrive);
+         
         }
 
-        private CloudFileUser CurrentUser;
-        
+        private UserBaseItem CurrentUser;
 
         private async void Listusers_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
-            var cloudFileUser = Listusers.SelectedItem as CloudFileUser;
+            var cloudFileUser = Listusers.SelectedItem as UserBaseItem;
             if(cloudFileUser != null)
             {
                 CurrentUser = cloudFileUser;
-                if ((CurrentUser.driveItem as GoogleDriveUserItem) != null)
+
+                switch(cloudFileUser.cloudType)
                 {
-                    var item = CurrentUser.driveItem as GoogleDriveUserItem;
-                    var files = await item.GetDriveFiles(item.Service);
-                    ObservableCollection<GoogleDriveFiles> filesList = new ObservableCollection<GoogleDriveFiles>();
-                    foreach (var file in files)
-                    {
-                        if(file.Name.EndsWith(".pdf") == true)
+                    case CloudType.GoogleDrive:
+                        if ((CurrentUser as GoogleDriveUserItem) != null)
                         {
-                            filesList.Add(file);
+                            var item = CurrentUser as GoogleDriveUserItem;
+                            var files = await item.GetDriveFiles(item.Service);
+                            ObservableCollection<GoogleDriveFiles> filesList = new ObservableCollection<GoogleDriveFiles>();
+                            foreach (var file in files)
+                            {
+                                if (file.Name.EndsWith(".pdf") == true)
+                                {
+                                    filesList.Add(file);
+                                }
+                            }
+                            ListvmFiles.ItemsSource = filesList;
                         }
-                    }
-                    ListvmFiles.ItemsSource = filesList;
+                        break;
+
+                    case CloudType.DropBox:
+                        if ((CurrentUser as DropbBoxUserItem) != null)
+                        {
+                            var item = CurrentUser as DropbBoxUserItem;
+                            var files = await item.RefreshList();
+                            ObservableCollection<DropbBoxFiles> filesList = new ObservableCollection<DropbBoxFiles>();
+                            foreach (var file in files)
+                            {
+                                if (file.Name.EndsWith(".pdf") == true)
+                                {
+                                    filesList.Add(file);
+                                }
+                            }
+                            ListvmFiles.ItemsSource = filesList;
+                        }
+                        break;
+
                 }
+               
             }
         }
 
         private async void OpenDocMenuItem_Click(object sender, RoutedEventArgs e)
         {
             var menuItem = sender as MenuItem;
-           var item = menuItem.DataContext as GoogleDriveFiles;
+            if (menuItem == null)
+                return;
 
-            var googleItem = CurrentUser.driveItem as GoogleDriveUserItem;
             string docPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
 
-            var filename = await googleItem.DownloadGoogleFile(item, docPath);
-            if (filename != null)
+            switch (CurrentUser.cloudType)
             {
-                string[] filePaths = { filename };
-                await Task.Delay(3);
-                MainWindow parentWindow = Window.GetWindow(this) as MainWindow;
-                parentWindow.LoadPdfViewer(filePaths);
+                case CloudType.GoogleDrive:
+               
+                    var item = menuItem.DataContext as GoogleDriveFiles;
+                    if (menuItem == null || item == null)
+                        return;
+
+                    var googleItem = CurrentUser as GoogleDriveUserItem;
+                    var filename = await googleItem.DownloadGoogleFile(item, docPath);
+                    if (filename != null)
+                    {
+                        string[] filePaths = { filename };
+                        await Task.Delay(3);
+                        MainWindow parentWindow = Window.GetWindow(this) as MainWindow;
+                        parentWindow.LoadPdfViewer(filePaths);
+                    }
+                    break;
+
+                case CloudType.DropBox:
+
+                    var file = menuItem.DataContext as DropbBoxFiles;
+                    var dropBoxItem = CurrentUser as DropbBoxUserItem;
+
+                    var dropBoxFileName = await dropBoxItem.Download(file.Name, docPath);
+                    if (dropBoxFileName != null)
+                    {
+                        string[] filePaths = { dropBoxFileName };
+                        await Task.Delay(3);
+                        MainWindow parentWindow = Window.GetWindow(this) as MainWindow;
+                        parentWindow.LoadPdfViewer(filePaths);
+                    }
+                    break;
+
             }
+
+
+
+           
         }
+
+       
     }
 }

File diff ditekan karena terlalu besar
+ 139 - 0
PDF Office/Views/Tools/AnnotToolContent.xaml


+ 61 - 0
PDF Office/Views/Tools/AnnotToolContent.xaml.cs

@@ -0,0 +1,61 @@
+using PDF_Office.CustomControl;
+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_Office.Views.Tools
+{
+    /// <summary>
+    /// AnnotToolContent.xaml 的交互逻辑
+    /// </summary>
+    public partial class AnnotToolContent : UserControl
+    {
+        public AnnotToolContent()
+        {
+            InitializeComponent();
+        }
+
+        private void BtnHand_Click(object sender, RoutedEventArgs e)
+        {
+
+        }
+
+        private void BtnTool_Click(object sender, RoutedEventArgs e)
+        {
+            CustomIconToggleBtn keepBtn = sender as CustomIconToggleBtn;
+
+            if (keepBtn != null)
+            {
+                ClearSelectedToolPanel(keepBtn);
+            }
+        }
+
+        private void ClearSelectedToolPanel(CustomIconToggleBtn keepBtn = null)
+        {
+            foreach (var item in ToolPanel.Children)
+            {
+                CustomIconToggleBtn checkBtn = item as CustomIconToggleBtn;
+                if (checkBtn != null && checkBtn != keepBtn)
+                {
+                    checkBtn.IsChecked = false;
+                }
+            }
+        }
+
+        private void BtnBookMark_Click(object sender, RoutedEventArgs e)
+        {
+
+        }
+    }
+}

+ 9 - 0
PDF Office/index.html

@@ -0,0 +1,9 @@
+<html>
+<script type="text/javascript">
+    function redirect() {
+        // Append fragment as query string so that server can receive it.
+        document.location.href = "/token?url_with_fragment=" + encodeURIComponent(document.location.href);
+    }
+</script>
+<body onload="redirect()"/>
+</html>