| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Linq;
- using System.Runtime.CompilerServices;
- using System.Windows.Input;
- using InABox.Mobile;
- using Xamarin.Forms;
- using Xamarin.Forms.Xaml;
- using XF.Material.Forms.UI;
- using XF.Material.Forms.UI.Dialogs;
- namespace PRS.Mobile
- {
- public class NewFormSelectedArgs : EventArgs
- {
- public DigitalFormShell Form { get; private set; }
- public NewFormSelectedArgs(DigitalFormShell form)
- {
- Form = form;
- }
- }
-
- public delegate void NewFormSelectedEvent(object sender, NewFormSelectedArgs args);
-
- [XamlCompilation(XamlCompilationOptions.Compile)]
- public partial class NewForms
- {
- private String _appliesTo = "";
- public String AppliesTo
- {
- get => _appliesTo;
- set
- {
- _appliesTo = value;
- RefreshData(false, true);
- }
- }
- public event NewFormSelectedEvent ItemSelected;
- private String _currentfilter = "";
-
- public NewForms()
- {
- InitializeComponent();
- }
-
- public void RefreshData(bool force, bool async)
- {
- if (async)
- App.Data.DigitalForms.Refresh(force, Refresh);
- else
- {
- App.Data.DigitalForms.Refresh(true);
- Refresh();
- }
- }
-
- private void Refresh()
- {
- App.Data.DigitalForms.Search((shell) => String.Equals(shell.AppliesTo, AppliesTo) && FilterShell(shell) );
- Dispatcher.BeginInvokeOnMainThread(
- () =>
- {
- _digitalforms.ItemsSource = App.Data.DigitalForms.Items;
- }
- );
- }
-
- private bool FilterShell(DigitalFormShell shell)
- {
- if (String.IsNullOrWhiteSpace(_currentfilter))
- return true;
- return shell.Code.ToUpper().Contains(_currentfilter.ToUpper())
- || shell.Description.ToUpper().Contains(_currentfilter.ToUpper());
- }
- private void _search_OnTextChanged(object sender, MobileSearchBarTextChangedArgs args)
- {
- _currentfilter = args.Text;
- Refresh();
- }
- private void _digitalforms_OnRefresh(object sender, MobileListRefreshEventArgs args)
- {
- RefreshData(true,false);
- }
-
- private void Form_Clicked(object sender, EventArgs e)
- {
- var shell = (sender as MobileCard)?.BindingContext as DigitalFormShell;
- ItemSelected?.Invoke(this, new NewFormSelectedArgs(shell));
- Navigation.PopAsync();
- }
- }
- }
|