You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

124 lines
4.2 KiB

using GummingEntity;
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.Media;
namespace Gumming
{
public class SlotStyleConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var slotStatus = (SlotStatus)value;
if(slotStatus != null)
{
if (slotStatus.Status == ExecuteStatusEnum.Prepare)
{
return Application.Current.FindResource("SlotPrepare") as Style;
}
else if (slotStatus.Status == ExecuteStatusEnum.Start || slotStatus.Status == ExecuteStatusEnum.Wait)
{
return Application.Current.FindResource("SlotHighlight") as Style;
}
else if (slotStatus.Status == ExecuteStatusEnum.Done)
{
return Application.Current.FindResource("SlotDone") as Style;
}
else if (slotStatus.Status == ExecuteStatusEnum.Error)
{
return Application.Current.FindResource("SlotError") as Style;
}
}
return Application.Current.FindResource("SlotNormal") as Style;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return value != null && value.Equals(true) ? parameter : Binding.DoNothing;
}
}
public class StationStyleConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
HomeStatus status = (HomeStatus)value;
if (status != null && !string.IsNullOrWhiteSpace(status.Message))
{
return Application.Current.FindResource("SlotHighlightTextBox") as Brush;
}
if (status != null && status.Status == ExecuteStatusEnum.Error)
{
return Application.Current.FindResource("SlotErroTextBox") as Brush;
}
return Application.Current.FindResource("SlotNormalTextBox") as Brush;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return value != null && value.Equals(true) ? parameter : Binding.DoNothing;
}
}
public class CSStyleConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if ((bool)value)
{
return Application.Current.FindResource("SlotHighlightTextBox") as Brush;
}
return Application.Current.FindResource("CSNormalTextBox") as Brush;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return value != null && value.Equals(true) ? parameter : Binding.DoNothing;
}
}
public class SlotDotConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
//if (((SlotStatus)value).InBasketStatus == SlotInBasketStatus.Exist)
//{
// return Visibility.Visible;
//}
return Visibility.Hidden;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return value != null && value.Equals(true) ? parameter : Binding.DoNothing;
}
}
public class ReverseConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (((bool)value))
{
return false;
}
return true;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return value != null && value.Equals(true) ? parameter : Binding.DoNothing;
}
}
}