C00225155-02/C00225155/MegaRobo.C00225155/MegaRobo.C00225155App/MenuViews/Bottles/BoxTemplateSelector.cs

74 lines
2.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Common.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
namespace MegaRobo.C00225155App.MenuViews
{
public class BoxTemplateSelector : DataTemplateSelector
{
// 样品工装模板
public DataTemplate SampleBoxTemplate { get; set; }
// 原液工装模板
public DataTemplate SourceLiquidBoxTemplate { get; set; }
// 粉末工装模板 16ml
public DataTemplate PowderBoxTemplate_16ml { get; set; }
// 粉末工装模板 125ml
public DataTemplate PowderBoxTemplate_125ml { get; set; }
// 96孔的Tip头工装模板
public DataTemplate TipHeadersBoxTemplate { get; set; }
// 空工装模板
public DataTemplate EmptyBoxTemplate { get; set; }
public override DataTemplate SelectTemplate(object item, DependencyObject container)
{
// 直接判断 item 的类型BaseBottleBox 及其派生类)
if (item == null) return EmptyBoxTemplate;
// 样品工装
if (item is SampleBottleBoxModel)
{
return SampleBoxTemplate;
}
// 原液工装
else if (item is SourceLiquidBottleBoxModel)
{
return SourceLiquidBoxTemplate;
}
// 16ml粉末工装
else if (item is SourcePowderBottleBoxModel)
{
return PowderBoxTemplate_16ml;
}
// 125ml粉末工装
else if (item is SourcePowderBottleBoxModel_125ml)
{
return PowderBoxTemplate_125ml;
}
// Tip头工装
else if (item is TipBoxModel)
{
return TipHeadersBoxTemplate;
}
// 基类 BaseBottleBox无具体工装类型显示空
else if (item is BaseBottleBox baseBox && baseBox.IsEmpty)
{
return EmptyBoxTemplate;
}
// 其他情况默认空工装
return EmptyBoxTemplate;
}
}
}