123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Xamarin.Forms;
- using Xamarin.Forms.Xaml;
- namespace comal.timesheets.CustomControls
- {
- [XamlCompilation(XamlCompilationOptions.Compile)]
- public partial class JobSelectionPage : ContentPage
- {
- public event ItemSelectedEvent OnItemSelected;
- bool bFirstPage = false;
- public JobShell Job { get; set; }
- public JobSelectionPage(bool firstpage = false)
- {
- Title = "Select Job";
- InitializeComponent();
- bFirstPage = firstpage;
- jobListView.ItemsSource = GlobalVariables.JobShells.Where(x => x.JobStatusDescription == "Active");
- searchEdt.IsEnabled = true;
- LoadButtons();
- }
- private void LoadButtons()
- {
- try
- {
- List<string> descriptions = new List<string>();
- List<Button> buttons = new List<Button>();
- foreach (JobShell job in GlobalVariables.JobShells)
- {
- if (!descriptions.Contains(job.JobStatusDescription))
- {
- if (!string.IsNullOrWhiteSpace(job.JobStatusDescription))
- descriptions.Add(job.JobStatusDescription);
- }
- }
- List<string> options = new List<string>();
- foreach (string s in descriptions)
- {
- options.Add(s);
- }
- filterOptionsControl.Options = options;
- filterOptionsControl.CreateRadioButtonsAndSetDefault("Active");
- filterOptionsControl.OnFilterOptionChanged += FilterOptionsControl_OnFilterOptionChanged;
- }
- catch { }
- }
- private void FilterOptionsControl_OnFilterOptionChanged(string filterOption)
- {
- if (filterOption == filterOptionsControl.CurrentOption)
- return;
- jobListView.ItemsSource = GlobalVariables.JobShells.Where(x => x.JobStatusDescription.Equals(filterOption));
- filterOptionsControl.CurrentOption = filterOption;
- }
- private void Job_Clicked(object sender, EventArgs e)
- {
- Job = jobListView.SelectedItem as JobShell;
- OnItemSelected?.Invoke();
- if (!bFirstPage)
- Navigation.PopAsync();
- }
- private void SearchEdt_Changed(object sender, EventArgs e)
- {
- jobListView.ItemsSource = GlobalVariables.JobShells.Where
- (
- x => x.Name.Contains(searchEdt.Text) || x.Name.Contains(UpperCaseFirst(searchEdt.Text))
- || x.Name.Contains(searchEdt.Text.ToUpper()) || x.Name.Contains(searchEdt.Text.ToLower())
- || x.JobNumber.Contains(searchEdt.Text) || x.JobNumber.Contains(UpperCaseFirst(searchEdt.Text))
- || x.Name.Contains(searchEdt.Text.ToUpper()) || x.JobNumber.Contains(searchEdt.Text.ToLower())
- );
- }
- static String UpperCaseFirst(string s)
- {
- char[] a = s.ToCharArray();
- a[0] = char.ToUpper(a[0]);
- return new string(a);
- }
- }
- public class JobShell
- {
- public delegate void JobIDChanged(Guid jobid);
- public event JobIDChanged OnJobIDChanged;
- private Guid id;
- public Guid ID
- {
- get => id;
- set
- {
- id = value;
- OnJobIDChanged?.Invoke(value);
- }
- }
- public string Name { get; set; }
- public string JobNumber { get; set; }
- public string DisplayName { get; set; }
- public Color Color { get; set; }
- public string JobStatusDescription { get; set; }
- public JobShell()
- {
- ID = Guid.Empty;
- Name = "";
- JobNumber = "";
- DisplayName = "";
- JobStatusDescription = "";
- Color = Color.LightGray;
- }
-
- }
- }
|