48 lines
1.5 KiB
C#
48 lines
1.5 KiB
C#
using DTS.Common.Interface.DASFactory.Diagnostics;
|
|
using DTS.Common.Strings;
|
|
using System;
|
|
using System.Windows.Data;
|
|
|
|
namespace HardwareList.Converters
|
|
{
|
|
/// <summary>
|
|
/// provides --- when the hardware is standin, otherwise the field requested
|
|
/// </summary>
|
|
public class StandInFieldConverter : IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
|
{
|
|
if (!(value is HardareList.Model.HardwareModel model))
|
|
{
|
|
return Strings.Table_NA;
|
|
}
|
|
if (!(model.Hardware is IISOHardware isoHW)) { return string.Empty; }
|
|
|
|
if (isoHW.StandIn)
|
|
{
|
|
return Strings.Table_NA;
|
|
}
|
|
|
|
if (parameter is string s)
|
|
{
|
|
switch (s)
|
|
{
|
|
case "CalDueDate":
|
|
return model.CalDueDate;
|
|
case "CalDate":
|
|
return model.CalDate;
|
|
case "Firmware":
|
|
return model.Firmware;
|
|
}
|
|
}
|
|
return Strings.Table_NA;
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
|
{
|
|
if (value is DateTime dt) { return dt; }
|
|
return Strings.Table_NA;
|
|
}
|
|
}
|
|
}
|