| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using InABox.Clients;
- using InABox.Core;
- using Xamarin.Forms;
- namespace comal.timesheets
- {
- public partial class FrameDocumentPage
- {
- private Guid _documentid = Guid.Empty;
- public FrameDocumentPage(Guid documentid, String filename)
- {
- InitializeComponent();
- NavigationPage.SetHasBackButton(this, false);
- ToolbarItems.Clear();
- ToolbarItems.Add(new ToolbarItem("Back", "", () =>
- {
- Navigation.PopAsync();
- }));
- Title = filename;
- pdf.Toolbar.Enabled = false;
- _documentid = documentid;
- new Client<Document>().Query(
- new Filter<Document>(x => x.ID).IsEqualTo(_documentid),
- null,
- null,
- (docs, error) =>
- {
- LoadDocument(docs);
- }
- );
- }
- private void LoadDocument(CoreTable docs)
- {
- if (docs.Rows.Any())
- {
- byte[] data = docs.Rows.First().Get<Document, byte[]>(x => x.Data);
- MemoryStream ms = new MemoryStream(data);
- Device.BeginInvokeOnMainThread(() =>
- {
- this.pdf.LoadDocument(ms);
- });
- }
- }
- }
- }
|