| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using InABox.Clients;
- using InABox.Core;
- using InABox.Mobile;
- using Syncfusion.SfImageEditor.XForms;
- using Xamarin.Forms;
- using Xamarin.Forms.Xaml;
- using XF.Material.Forms.UI.Dialogs;
- namespace PRS.Mobile
- {
- [XamlCompilation(XamlCompilationOptions.Compile)]
- public partial class RequisitionEditDocumentsView : RequisitionEditView
- {
- public RequisitionEditDocumentsView()
- {
- InitializeComponent();
- }
- public override void Refresh()
- {
- _images.ItemsSource = ViewModel?.Documents;
- _images.ParentID = ViewModel?.Item.ID ?? Guid.Empty;
- }
-
- public async Task AddImage<T, TOptions>(TOptions options)
- where T : MobileImageSource<T,TOptions>
- where TOptions : MobileImageOptions<T>, new()
- {
-
- MobileDocument file = null;
- try
- {
- file = await MobileDocument.From(options);
- }
- catch (Exception e)
- {
- await MaterialDialog.Instance.AlertAsync(e.Message, "ERROR");
- }
-
- if (file != null)
- {
- using (await MaterialDialog.Instance.LoadingDialogAsync("Saving Image"))
- {
- Document doc = new Document()
- {
- FileName = file.FileName,
- Data = file.Data,
- CRC = CoreUtils.CalculateCRC(file.Data),
- TimeStamp = DateTime.Now
- };
- new Client<Document>().Save(doc, "Created on Mobile Device");
- var link = ViewModel.Documents.AddItem();
- link.DocumentID = doc.ID;
- link.FileName = doc.FileName;
- link.Thumbnail = MobileUtils.ImageTools.CreateThumbnail(doc.Data, 256, 256);
- link.ParentID = ViewModel.Item.ID;
- link.Save("Image added from Mobile Device");
- ViewModel.Documents.Refresh(true);
- Dispatcher.BeginInvokeOnMainThread(Refresh);
- }
- }
- }
-
- }
- }
|