Sic.Framework-Nanjing-Baishi/MECF.Framework.UI.Client/TrayThickness/HistoryData/HistoryDataViewModel.cs

76 lines
2.2 KiB
C#
Raw Normal View History

2023-05-22 18:32:18 +08:00
using Aitex.Core.RT.OperationCenter;
using MECF.Framework.UI.Client.ClientBase;
using System;
using System.Collections.Generic;
using System.Globalization;
2023-05-22 18:32:18 +08:00
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media;
2023-05-22 18:32:18 +08:00
namespace MECF.Framework.UI.Client.TrayThickness.HistoryData
{
public class HistoryDataViewModel : UiViewModelBase, ISupportMultipleSystem
{
HistoryCoatingSqlHelp HistoryCoatingSqlHelp=new HistoryCoatingSqlHelp();
public List<CoatingData> CoatingData { get; set; } = new List<CoatingData>();
public HistoryDataViewModel()
{
QueryUpdate();
}
protected override void OnActivate()
{
QueryUpdate();
}
private void QueryUpdate()
{
CoatingData = HistoryCoatingSqlHelp.QueryUpdate();
Refresh();
}
}
/// <summary>
/// 检测厚度是否大于最大值
/// </summary>
class ColorConverter : IMultiValueConverter
{
public object Convert(object[] value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
try
{
if (value[0] == null || value[1] == null)
{
return new SolidColorBrush(Colors.Black);
}
double _current;
if (!double.TryParse(value[0].ToString(), out _current))
return new SolidColorBrush(Colors.Red);
double _max;
if (!double.TryParse(value[1].ToString(), out _max))
return new SolidColorBrush(Colors.Black);
if (_current > _max)
{
return new SolidColorBrush(Colors.Red);
}
else
{
return new SolidColorBrush(Colors.Black);
}
}
catch (Exception)
{
return new SolidColorBrush(Colors.Red);
}
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
return null;
}
}
2023-05-22 18:32:18 +08:00
}