123 lines
3.3 KiB
C#
123 lines
3.3 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Globalization;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using System.Windows;
|
|||
|
using System.Windows.Data;
|
|||
|
|
|||
|
namespace DM_Weight.Converter
|
|||
|
{
|
|||
|
public class BiaoDingStatusConverter : IValueConverter
|
|||
|
{
|
|||
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|||
|
{
|
|||
|
bool bValue=int.TryParse(value.ToString(),out int bStatus);
|
|||
|
string param= parameter?.ToString();
|
|||
|
//显示是否标定状态
|
|||
|
if(bValue&& param.Equals("BiaoDingStatus"))
|
|||
|
{
|
|||
|
if(bStatus >= 1)
|
|||
|
{
|
|||
|
return "已标定";
|
|||
|
}
|
|||
|
else if (bStatus == 0)
|
|||
|
{
|
|||
|
return "待标定";
|
|||
|
}
|
|||
|
}
|
|||
|
//标定按钮状态
|
|||
|
if(bValue&¶m.Equals("BiaoDingBtnFlag"))
|
|||
|
{
|
|||
|
if (bStatus == 0)
|
|||
|
{
|
|||
|
return true;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
//标定按钮加载状态
|
|||
|
if(bValue&¶m.Equals("BiaoDingLoading"))
|
|||
|
{
|
|||
|
if(bStatus == 2)
|
|||
|
{
|
|||
|
return true;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
//确认按钮是否显示
|
|||
|
if(bValue&¶m.Equals("ConfirmVisibi"))
|
|||
|
{
|
|||
|
if (bStatus == 3|| bStatus == 4)
|
|||
|
{
|
|||
|
return Visibility.Visible;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
return Visibility.Collapsed;
|
|||
|
}
|
|||
|
}
|
|||
|
//确认按钮是否显示
|
|||
|
if(bValue&¶m.Equals("ConfirmIsEnabled"))
|
|||
|
{
|
|||
|
if (bStatus == 4)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
return true;
|
|||
|
}
|
|||
|
}
|
|||
|
//确认按钮加载状态
|
|||
|
if(bValue&¶m.Equals("ConfirmLoading"))
|
|||
|
{
|
|||
|
if(bStatus == 4)
|
|||
|
{
|
|||
|
return true;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
//取消按钮是否显示
|
|||
|
if(bValue&¶m.Equals("CancelVisibi"))
|
|||
|
{
|
|||
|
if(bStatus !=0&&bStatus!=1)
|
|||
|
{
|
|||
|
return Visibility.Visible;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
return Visibility.Collapsed;
|
|||
|
}
|
|||
|
}
|
|||
|
//添加数量是否可用
|
|||
|
if(bValue&¶m.Equals("AddQuantityEnabled"))
|
|||
|
{
|
|||
|
if(bStatus>0)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
return true;
|
|||
|
}
|
|||
|
}
|
|||
|
return "";
|
|||
|
}
|
|||
|
|
|||
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|||
|
{
|
|||
|
throw new NotImplementedException();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|