|
@@ -3,6 +3,7 @@ using System.Threading.Tasks;
|
|
|
using InABox.Mobile;
|
|
|
using Xamarin.Forms;
|
|
|
using Xamarin.Forms.Xaml;
|
|
|
+using Xamarin.Forms.Xaml.Internals;
|
|
|
using XF.Material.Forms.UI.Dialogs;
|
|
|
|
|
|
namespace PRS.Mobile
|
|
@@ -18,11 +19,26 @@ namespace PRS.Mobile
|
|
|
set
|
|
|
{
|
|
|
_itemsSource = value;
|
|
|
- _imagelist.ItemsSource = value.Items;
|
|
|
+ _imagelist.ItemsSource = value?.Items;
|
|
|
+ _imagelist.LastUpdated = value?.LastUpdated ?? DateTime.MinValue;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public Guid ParentID { get; set; }
|
|
|
+
|
|
|
+ public event MobileListRefreshEvent RefreshRequested;
|
|
|
+
|
|
|
+ public bool PullToRefresh
|
|
|
+ {
|
|
|
+ get => _imagelist.PullToRefresh;
|
|
|
+ set => _imagelist.PullToRefresh = value;
|
|
|
+ }
|
|
|
+
|
|
|
+ public bool ShowRecordCount
|
|
|
+ {
|
|
|
+ get => _imagelist.ShowRecordCount;
|
|
|
+ set => _imagelist.ShowRecordCount = value;
|
|
|
+ }
|
|
|
|
|
|
public DocumentList()
|
|
|
{
|
|
@@ -46,7 +62,7 @@ namespace PRS.Mobile
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public async Task<bool> AddImage<T, TShell>(bool pdf = false, Action<TShell> customiseshell = null)
|
|
|
+ public async Task<bool> AddImage<T, TShell>(bool pdf = false, Func<TShell, Task<bool>> customiseshell = null)
|
|
|
where T : MobileDocumentSource, new()
|
|
|
where TShell : class, IEntityDocumentShell
|
|
|
{
|
|
@@ -64,33 +80,38 @@ namespace PRS.Mobile
|
|
|
|
|
|
if (file != null)
|
|
|
{
|
|
|
- using (await MaterialDialog.Instance.LoadingDialogAsync("Saving Image"))
|
|
|
+ var shell = ItemsSource.AddItem() as TShell;
|
|
|
+ shell.ParentID = ParentID;
|
|
|
+
|
|
|
+ bool confirm = (customiseshell == null)
|
|
|
+ || await customiseshell.Invoke(shell);
|
|
|
+
|
|
|
+ if (confirm)
|
|
|
{
|
|
|
- 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"
|
|
|
- );
|
|
|
- Device.BeginInvokeOnMainThread(() =>
|
|
|
+ using (await MaterialDialog.Instance.LoadingDialogAsync("Saving Image"))
|
|
|
{
|
|
|
- ItemsSource.Search();
|
|
|
- _imagelist.ItemsSource = null;
|
|
|
- _imagelist.ItemsSource = ItemsSource.Items;
|
|
|
- });
|
|
|
- return true;
|
|
|
+ var thumbnail = MobileUtils.ImageTools.CreateThumbnail(file.Data, 256, 256);
|
|
|
+
|
|
|
+ shell.Thumbnail = thumbnail;
|
|
|
+
|
|
|
+ if (pdf)
|
|
|
+ file = file.ToPDF();
|
|
|
+
|
|
|
+ shell.FileName = file.FileName;
|
|
|
+
|
|
|
+ var docshell = EntityDocumentUtils.SaveDocument<TShell>(
|
|
|
+ file,
|
|
|
+ () => shell,
|
|
|
+ "Created on Mobile Device"
|
|
|
+ );
|
|
|
+ Device.BeginInvokeOnMainThread(() =>
|
|
|
+ {
|
|
|
+ ItemsSource.Search();
|
|
|
+ _imagelist.ItemsSource = null;
|
|
|
+ _imagelist.ItemsSource = ItemsSource.Items;
|
|
|
+ });
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -99,5 +120,10 @@ namespace PRS.Mobile
|
|
|
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ private void _imagelist_OnRefreshRequested(object sender, MobileListRefreshEventArgs args)
|
|
|
+ {
|
|
|
+ RefreshRequested?.Invoke(this,args);
|
|
|
+ }
|
|
|
}
|
|
|
}
|