-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathItemPageAndroid.xaml.cs
106 lines (90 loc) · 3.52 KB
/
ItemPageAndroid.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
using PCCE.Model;
using PCCE.ViewModel;
using System.Collections.ObjectModel;
namespace PCCE;
public partial class ItemPageAndroid : ContentPage
{
readonly ItemViewModel iv;
public ItemPageAndroid(ItemViewModel vm)
{
InitializeComponent();
BindingContext = vm;
iv = vm;
}
private void CollectionView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var cv = (CollectionView)sender;
if (cv.SelectedItem == null)
return;
InventoryItem selected = (InventoryItem)cv.SelectedItem;
ItemIDEntry.Text = selected.ItemID.ToString();
ItemNumberEntry.Text = selected.ItemNum.ToString();
}
private void ItemIDEntry_TextChanged(object sender, TextChangedEventArgs e)
{
if (e.NewTextValue != null)
{
if (!int.TryParse(e.NewTextValue, out _))
{
ItemIDEntry.Text = new string(e.NewTextValue.Where(char.IsDigit).ToArray());
}
if (!string.IsNullOrEmpty(ItemIDEntry.Text))
{
HintIName.Text = Utilities.GetItemIName(Utilities.ConvertToUint(ItemIDEntry.Text));
HintDisplayName.Text = Utilities.GetItemDisplayName(Utilities.ConvertToUint(ItemIDEntry.Text));
}
}
}
private void ItemNumberEntry_TextChanged(object sender, TextChangedEventArgs e)
{
if (!int.TryParse(e.NewTextValue, out _))
{
ItemNumberEntry.Text = new string(e.NewTextValue.Where(char.IsDigit).ToArray());
}
}
private void SearchEntry_TextChanged(object sender, TextChangedEventArgs e)
{
/*
var searchTerm = e.NewTextValue;
if (string.IsNullOrWhiteSpace(searchTerm))
{
searchTerm = string.Empty;
}
searchTerm = searchTerm.ToLowerInvariant();
var filteredItem = iv.SourceItem.Where(item => item.ItemID.ToString().Contains(searchTerm) ||
item.ItemIName.ToLowerInvariant().Contains(searchTerm) ||
item.ItemDisplayName.ToLowerInvariant().Contains(searchTerm)
).ToList();
if (string.IsNullOrWhiteSpace(searchTerm))
{
filteredItem = iv.SourceItem.ToList();
}
foreach (var item in iv.SourceItem)
{
if (!filteredItem.Contains(item))
{
iv.InventoryItems.Remove(item);
}
else if (!iv.InventoryItems.Contains(item))
{
iv.InventoryItems.Add(item);
}
}
//Still lag as f
*/
if (string.IsNullOrEmpty(e.NewTextValue))
{
ItemCollectionView.ItemsSource = iv.InventoryItems;
}
else
{
ItemCollectionView.ItemsSource = iv.InventoryItems.Where(i => i.ItemID.ToString().Contains(e.NewTextValue, StringComparison.CurrentCultureIgnoreCase) ||
i.ItemIName.Contains(e.NewTextValue, StringComparison.CurrentCultureIgnoreCase) ||
i.ItemDisplayName.Contains(e.NewTextValue, StringComparison.CurrentCultureIgnoreCase));
}
}
private void SetBtn_Clicked(object sender, EventArgs e)
{
//ItemCollectionView.ScrollTo(ItemCollectionView.SelectedItem, null, ScrollToPosition.Center, false);
}
}