using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Data; using BPASmart.Model; namespace BPASmart.VariableManager.Converter { /// /// 报警类型文本转换 /// public class AlarmTypeTextConvert : IValueConverter { //当值从绑定源传播给绑定目标时,调用方法Convert,绑定源是控件的数据,绑定目标是后台值 //界面传递给后台数据 public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value != null) { if (value.ToString() == "Bool") return EAlarmType.离散量报警.ToString(); else return EAlarmType.模拟量报警.ToString(); } return EAlarmType.无.ToString(); } //当值从绑定目标传播给绑定源时,调用此方法ConvertBack //从后台数据传递给界面 public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { return value.ToString(); } } }