Sic.Framework-Nanjing-Baishi/MECF.Framework.UI.Client/CenterViews/Maintain/Booleans2MaintainStatusConv...

74 lines
2.6 KiB
C#
Raw Normal View History

2024-01-29 11:12:21 +08:00
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;
using System.Windows.Interactivity;
using System.Windows.Media;
namespace MECF.Framework.UI.Client.CenterViews.Maintain
{
public class Booleans2MaintainStatusConverter : Behavior<Booleans2MaintainStatusConverter>, IMultiValueConverter
{
public ImageSource UnMaintainImage
{
get { return (ImageSource)GetValue(UnMaintainImageProperty); }
set { SetValue(UnMaintainImageProperty, value); }
}
public static readonly DependencyProperty UnMaintainImageProperty =
DependencyProperty.Register("UnMaintainImage", typeof(ImageSource), typeof(Booleans2MaintainStatusConverter), new PropertyMetadata(null));
public ImageSource UnMaintainButTimeOutImage
{
get { return (ImageSource)GetValue(UnMaintainButTimeOutImageProperty); }
set { SetValue(UnMaintainButTimeOutImageProperty, value); }
}
public static readonly DependencyProperty UnMaintainButTimeOutImageProperty =
DependencyProperty.Register("UnMaintainButTimeOutImage", typeof(ImageSource), typeof(Booleans2MaintainStatusConverter), new PropertyMetadata(null));
public ImageSource MaintainImage
{
get { return (ImageSource)GetValue(MaintainImageProperty); }
set { SetValue(MaintainImageProperty, value); }
}
public static readonly DependencyProperty MaintainImageProperty =
DependencyProperty.Register("MaintainImage", typeof(ImageSource), typeof(Booleans2MaintainStatusConverter), new PropertyMetadata(null));
public object Convert(object[] values, Type targetType, object parameter,
CultureInfo culture)
{
if (values != null && values.Length == 2)
{
bool ismaintained = (bool)values[0];
bool timeout = (bool)values[1];
if (!ismaintained)
{
if (!timeout)
{
return UnMaintainImage;
}
else return UnMaintainButTimeOutImage;
}
else
return MaintainImage;
}
else
{
return null;
}
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter,
CultureInfo culture)
{
throw new NotImplementedException();
}
}
}