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().Query( new Filter(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(x => x.Data); MemoryStream ms = new MemoryStream(data); Device.BeginInvokeOnMainThread(() => { this.pdf.LoadDocument(ms); }); } } } }