| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using InABox.Clients;
- using InABox.Core;
- using InABox.Mobile;
- using Xamarin.Forms;
- using Xamarin.Forms.Xaml;
- using XF.Material.Forms.UI.Dialogs;
- namespace PRS.Mobile
- {
- [XamlCompilation(XamlCompilationOptions.Compile)]
- public partial class EquipmentEditSpecificationsView
- {
- public EquipmentEditSpecificationsView()
- {
- InitializeComponent();
- }
- public override void Refresh()
- {
- var document = ViewModel.SpecificationSheet.FirstOrDefault();
- if (document != null)
- _viewer.Load(document.FileName, document.Data);
- _viewer.IsVisible = document != null;
- _noviewer.IsVisible = document == null;
- }
-
- 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<T>(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");
- ViewModel.Item.SpecificationSheetID = doc.ID;
- ViewModel.Item.Save("Specification Sheet updated from Mobile Device");
- ViewModel.SpecificationSheet.Refresh(true);
- Dispatcher.BeginInvokeOnMainThread(Refresh);
- }
- }
- }
-
- }
- }
|