13 changed files with 281 additions and 28 deletions
@ -0,0 +1,59 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Globalization; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using System.Windows.Data; |
|||
|
|||
namespace DyeingComputer.ConvertMoels |
|||
{ |
|||
/// <summary>
|
|||
/// 原料类型数值转换器
|
|||
/// 将类型数值转换为类型名称返回
|
|||
/// </summary>
|
|||
internal class ProductTypeSQLConvert : IValueConverter |
|||
{ |
|||
/// <summary>
|
|||
/// </summary>
|
|||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
|||
{ |
|||
string ProductType = System.Convert.ToString(value); |
|||
if (ProductType == "1")//类型0:染料,1:助剂,2:粉体助剂,3:液体染料,其它:未知
|
|||
{ |
|||
return "染料"; |
|||
} |
|||
else |
|||
{ |
|||
if (ProductType == "2") |
|||
{ |
|||
return "助剂"; |
|||
} |
|||
else |
|||
{ |
|||
if (ProductType == "3") |
|||
{ |
|||
return "粉体助剂"; |
|||
} |
|||
else |
|||
{ |
|||
if (ProductType == "4") |
|||
{ |
|||
return "液体染料"; |
|||
} |
|||
else |
|||
{ |
|||
return "未知类型"; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
/// <summary>
|
|||
/// </summary>
|
|||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
|||
{ |
|||
return null; |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,42 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using System.Windows.Data; |
|||
|
|||
namespace DyeingComputer.ConvertMoels |
|||
{ |
|||
internal class StatenConvert : IValueConverter |
|||
{ |
|||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) |
|||
{ |
|||
if (value == null) |
|||
{ |
|||
return null; |
|||
} |
|||
else |
|||
{ |
|||
string Staten = null; |
|||
string i = value.ToString(); |
|||
|
|||
if (i == "101") Staten = "准备就绪"; |
|||
if (i == "102") Staten = "计量输送"; |
|||
if (i == "201") Staten = "自动状态"; |
|||
if (i == "202") Staten = "转入排队"; |
|||
if (i == "203") Staten = "等待命令"; |
|||
if (i == "301") Staten = "步骤完成"; |
|||
if (i == "309") Staten = "输送异常"; |
|||
|
|||
return Staten; |
|||
} |
|||
} |
|||
|
|||
|
|||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
|
|||
} |
|||
} |
@ -0,0 +1,84 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.ComponentModel; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using CommunityToolkit.Mvvm.ComponentModel; |
|||
using CommonServiceLocator; |
|||
using System.Windows.Threading; |
|||
|
|||
namespace DyeingComputer.ViewModel |
|||
{ |
|||
/// <summary>
|
|||
/// 变量传递至ui
|
|||
/// </summary>
|
|||
public class ViewModelBase : INotifyPropertyChanged |
|||
{ |
|||
public event PropertyChangedEventHandler PropertyChanged; |
|||
|
|||
protected virtual void OnPropertyChanged(string propertyName) |
|||
{ |
|||
if (this.PropertyChanged != null) |
|||
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); |
|||
} |
|||
} |
|||
|
|||
public class MainWindowViewModel: ViewModelBase |
|||
{ |
|||
public MainWindowViewModel() |
|||
{ |
|||
CountDown(); |
|||
} |
|||
|
|||
public string work_Temp; //显示温度
|
|||
public string Work_Temp //通知UI控件参数改变
|
|||
{ |
|||
get { return work_Temp; } |
|||
set { work_Temp = value; OnPropertyChanged("Work_Temp"); } |
|||
} |
|||
|
|||
public string work_Numder; //显示工单号
|
|||
public string Work_Numder //通知UI控件参数改变
|
|||
{ |
|||
get { return work_Numder; } |
|||
set { work_Numder = value; OnPropertyChanged("Work_Numder"); } |
|||
} |
|||
|
|||
public string status_Str; //显示状态
|
|||
public string Status_Str //通知UI控件参数改变
|
|||
{ |
|||
get { return status_Str; } |
|||
set { status_Str = value; OnPropertyChanged("Status_Str"); } |
|||
} |
|||
|
|||
public string sys_Time; //显示系统时间
|
|||
public string Sys_Time //通知UI控件参数改变
|
|||
{ |
|||
get { return sys_Time; } |
|||
set { sys_Time = value; OnPropertyChanged("Sys_Time"); } |
|||
} |
|||
|
|||
public void CountDown() |
|||
{ |
|||
DispatcherTimer timer1s = new DispatcherTimer//初始化循环,每0.5秒调用一次Tick
|
|||
{ |
|||
Interval = TimeSpan.FromSeconds(1) |
|||
}; |
|||
timer1s.Tick += Tick_Event_1S; |
|||
timer1s.Start(); |
|||
|
|||
//设置定时器
|
|||
// disTimer.Tick += new EventHandler(DisTimer_Tick);//每一秒执行的方法
|
|||
// disTimer.Interval = new TimeSpan(10000000); //时间间隔为一秒。
|
|||
// disTimer.Start();//计时开始
|
|||
} |
|||
void Tick_Event_1S(object sender, EventArgs e)//Tick_Event周期执行事件
|
|||
{ |
|||
Sys_Time = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); |
|||
Work_Temp = "130"+"℃"; |
|||
Work_Numder = "r2024011200014"; |
|||
Status_Str = "qweqeqwqqfwfqef"; |
|||
} |
|||
} |
|||
} |
Loading…
Reference in new issue