本文整理汇总了C#中ICollectionView.OfType方法的典型用法代码示例。如果您正苦于以下问题:C# ICollectionView.OfType方法的具体用法?C# ICollectionView.OfType怎么用?C# ICollectionView.OfType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICollectionView
的用法示例。
在下文中一共展示了ICollectionView.OfType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DisplayAttentions
public void DisplayAttentions(ICollectionView colview, string header)
{
if (colview == null)
{
return;
}
if (DPOS == null)
{
MessageBox.Show("Please refresh the database first before attentions check", "Warning!", MessageBoxButton.OK,
MessageBoxImage.Exclamation);
return;
}
var pass = colview.OfType<PAUPassenger>();
ObservableCollection<PAUPassenger> attentions = new ObservableCollection<PAUPassenger>();
ObservableCollection<PAUPassenger> wnAttentions = new ObservableCollection<PAUPassenger>();
ObservableCollection<PAUPassenger> dpos = new ObservableCollection<PAUPassenger>();
bool found = false;
foreach (PAUPassenger p in pass)
{
TimeSpan span = p.FlightDate.Value.Subtract(p.Date.Value);
if (span <= TimeSpan.FromDays(BookingDateRange))
{
attentions.Add(p);
found = true;
}
int count = (from dpo in DPOS
where
(p.FirstName.ToUpper().Contains(dpo.FirstName.ToUpper()) &&
p.LastName.ToUpper().Contains(dpo.LastName.ToUpper()))
//p.Passport.Equals(dpo.Passport)
select dpo).Distinct().Count();
if (count > 0)
{
dpos.Add(p);
}
foreach (NationalityAttention nat in Nationalities)
{
if (p.Nationality != null)
{
if (p.Nationality.Equals(nat.Nationality, StringComparison.OrdinalIgnoreCase))
{
if (wnAttentions.Contains(p) == false)
{
wnAttentions.Add(p);
found = true;
}
}
}
}
}
if (attentions.Count > 0)
{
DataGrid attentionGrid;
SpawnNewDockWindow(string.Format("Attentions ({0})", header), out attentionGrid);
if (attentionGrid != null)
{
attentionGrid.ItemsSource = CollectionViewSource.GetDefaultView(attentions);
}
}
if (wnAttentions.Count > 0)
{
DataGrid wnAttGrid;
SpawnNewDockWindow(string.Format("WN Att ({0})", header), out wnAttGrid);
if (wnAttGrid != null)
{
wnAttGrid.ItemsSource = CollectionViewSource.GetDefaultView(wnAttentions);
}
}
if (dpos.Count > 0)
{
DataGrid dpoGrid;
SpawnNewDockWindow(string.Format("Name(s) On DPO ({0})", header), out dpoGrid);
if (dpoGrid != null)
{
dpoGrid.ItemsSource = CollectionViewSource.GetDefaultView(dpos);
}
}
if (!found)
{
MessageBox.Show("No Attentions found", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
}
}