using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Comal.Classes; using InABox.Core; using InABox.Mobile.Shared; using Xamarin.Forms; using Xamarin.Forms.Xaml; using XF.Material.Forms.UI.Dialogs; namespace PRS.Mobile { [XamlCompilation(XamlCompilationOptions.Compile)] public partial class KanbanForms { public KanbanForms() { InitializeComponent(); _forms.DataModel = App.Data.KanbanForms; _forms.AppliesTo = "Kanban"; _forms.Property = model => App.Data.KanbanForms.Forms; _forms.RefreshData(false,true); } private void AddForm_Clicked(object sender, EventArgs e) { var selector = new NewForms() { AppliesTo = _forms.AppliesTo }; selector.ItemSelected += CreateNewForm; Navigation.PushAsync(selector); } private async void CreateNewForm(object sender, NewFormSelectedArgs args) { KanbanShell kanban; KanbanFormShell form; using (await (MaterialDialog.Instance.LoadingDialogAsync("Creating Form"))) { kanban = App.Data.Kanbans.AddItem(); kanban.EmployeeID = App.Data.Me.ID; kanban.ManagerID = App.Data.Me.ID; kanban.Title = args.Form.Description; //kanban.Save("Created on Mobile Device"); form = App.Data.KanbanForms.AddItem(); form.FormID = args.Form.ID; form.FormCode = args.Form.Code; form.FormDescription = args.Form.Description; form.ParentID = kanban.ID; //form.Save("Created on Mobile Device"); } Dispatcher.BeginInvokeOnMainThread(() => { var model = new DigitalFormHostModel(); model.LoadItems(kanban.Entity, form.FormID, form.Entity, null); var host = new DigitalFormHost(model); host.OnClosing += (_, _) => _forms.RefreshData(true, false); Navigation.PushAsync(host); //_forms.RefreshData(false,false); //_forms.EditForm(form,kanban.Entity); }); } private void _forms_OnFormTapped(object sender, ExistingFormTappedEventArgs args) { Kanban entity = null; ProgressVisible = true; Task.Run(() => { entity = App.Data.Kanbans.FirstOrDefault(x => x.ID == args.Shell.ParentID)?.Entity; if (entity == null) { var model = new KanbanModel(App.Data, () => new Filter(x => x.ID).IsEqualTo(args.Shell.ParentID)); model.Refresh(true); entity = model.FirstOrDefault().Entity; } }).BeginInvokeOnMainThread((_) => { if (entity != null) _forms.EditForm(args.Shell,entity); ProgressVisible = false; }); } } }