ソースを参照

Added Thumbnail and PDF rendering to Scan Module

Frank van den Bos 1 年間 前
コミット
b258d76f22

+ 11 - 2
prs.mobile.new/PRS.Mobile/Components/DocumentList/DocumentList.xaml.cs

@@ -45,8 +45,8 @@ namespace PRS.Mobile
                 }
             }
         }
-        
-        public async Task<bool> AddImage<T, TShell>() 
+
+        public async Task<bool> AddImage<T, TShell>(bool pdf = false, Action<TShell> customiseshell = null) 
             where T : MobileDocumentSource, new() 
             where TShell : class, IEntityDocumentShell
         {
@@ -56,6 +56,7 @@ namespace PRS.Mobile
             {
                 file = await MobileDocument.From<T>();
             }
+            
             catch (Exception e)
             {
                 await MaterialDialog.Instance.AlertAsync(e.Message, "ERROR");
@@ -65,12 +66,20 @@ namespace PRS.Mobile
             {
                 using (await MaterialDialog.Instance.LoadingDialogAsync("Saving Image"))
                 {
+                    var thumbnail = MobileUtils.ImageTools.CreateThumbnail(file.Data, 256, 256);
+                    
+                    if (pdf)
+                        file = file.ToPDF();
+                    
                     var docshell = EntityDocumentUtils.SaveDocument<TShell>(
                         file,
                         () =>
                         {
                             var shell = ItemsSource.AddItem() as TShell;
                             shell.ParentID = ParentID;
+                            shell.FileName = file.FileName;
+                            shell.Thumbnail = thumbnail;
+                            customiseshell?.Invoke(shell);
                             return shell;
                         },
                         "Created on Mobile Device"

+ 4 - 2
prs.mobile.new/PRS.Mobile/Modules/Scans/ScanModule.xaml.cs

@@ -45,12 +45,14 @@ namespace PRS.Mobile.Modules.Scans
 
         private async void TakePhoto_Clicked(object sender, EventArgs e)
         {
-            await _documents.AddImage<MobileDocumentCameraSource,ScanShell>();
+            await _documents.AddImage<MobileDocumentCameraSource,ScanShell>(
+                true, (shell) => shell.EmployeeID = App.Data.Me.ID);
         }
 
         private async void BrowseLibrary_Clicked(object sender, EventArgs e)
         {
-            await _documents.AddImage<MobileDocumentLibrarySource, ScanShell>();
+            await _documents.AddImage<MobileDocumentLibrarySource,ScanShell>(
+                true, (shell) => shell.EmployeeID = App.Data.Me.ID);
         }
     }
 }