123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Linq;
- using System.Runtime.CompilerServices;
- using System.Windows.Input;
- using Xamarin.Forms;
- using Xamarin.Forms.Xaml;
- using XF.Material.Forms.UI.Dialogs;
- namespace comal.timesheets
- {
- public class NewFormSelectedArgs : EventArgs
- {
-
- }
-
- 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) );
- _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 async void _digitalforms_OnItemTapped(object sender, MobileListItemTappedEventArgs args)
- {
- ItemSelected?.Invoke(this, new NewFormSelectedArgs());
- Navigation.PopAsync();
- }
- }
- }
|