123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Windows.Data;
- using Aitex.Core.UI.ControlDataContext;
- using System.Windows.Media;
- namespace Aitex.Core.UI.Converters
- {
- public class MoNameConvert : IValueConverter
- {
- public object Convert(object MoLineData, Type targetType, object parameter, System.Globalization.CultureInfo culture)
- {
- string name="名字";
- if (MoLineData != null)
- {
- name = (MoLineData as MOLineDataItem).DisplayName.Replace("_", "__");
- }
- return name;
- }
- public object ConvertBack(object value, Type targetTypes, object parameter, System.Globalization.CultureInfo culture)
- {
- return null;
- }
- }
- public class MoSourceHeightConvert : IValueConverter
- {
- public object Convert(object MoLineData, Type targetType, object parameter, System.Globalization.CultureInfo culture)
- {
- double height = 37;
- if (MoLineData != null)
- {
- height = 4 + (MoLineData as MOLineDataItem).MoRemainedPercentage * (37 - 4);
- if (height > 37) height = 37;
- if (height < 4) height = 4;
- }
- return height;
- }
- public object ConvertBack(object value, Type targetTypes, object parameter, System.Globalization.CultureInfo culture)
- {
- return null;
- }
- }
- public class MoSourceCanvasTopConvert : IValueConverter
- {
- public object Convert(object MoLineData, Type targetType, object parameter, System.Globalization.CultureInfo culture)
- {
- double top = 237;
- if (MoLineData != null)
- {
- top = 273 - (MoLineData as MOLineDataItem).MoRemainedPercentage * (273 - 237);
- if (top < 237) top = 237;
- if (top > 273) top = 273;
- }
- return top;
- }
- public object ConvertBack(object value, Type targetTypes, object parameter, System.Globalization.CultureInfo culture)
- {
- return null;
- }
- }
- public class MoColorConvert : IValueConverter
- {
- public object Convert(object MoLineData, Type targetType, object parameter, System.Globalization.CultureInfo culture)
- {
- SolidColorBrush color = Brushes.Green ;
- if (MoLineData != null)
- {
- if ((MoLineData as MOLineDataItem).IsMoRemainedWeightAlarm)
- {
- color = Brushes.Pink;
- }
- else
- {
- color = Brushes.Green;
- }
- }
- return color;
- }
- public object ConvertBack(object value, Type targetTypes, object parameter, System.Globalization.CultureInfo culture)
- {
- return null;
- }
- }
- }
|