diff --git a/ConvertMoels/ProductTypeSQLConvert.cs b/ConvertMoels/ProductTypeSQLConvert.cs new file mode 100644 index 0000000..7e540f5 --- /dev/null +++ b/ConvertMoels/ProductTypeSQLConvert.cs @@ -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 +{ + /// + /// 原料类型数值转换器 + /// 将类型数值转换为类型名称返回 + /// + internal class ProductTypeSQLConvert : IValueConverter + { + /// + /// + 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 "未知类型"; + } + } + } + } + } + /// + /// + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + } +} diff --git a/ConvertMoels/StatenConvert.cs b/ConvertMoels/StatenConvert.cs new file mode 100644 index 0000000..8ad2fdd --- /dev/null +++ b/ConvertMoels/StatenConvert.cs @@ -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(); + } + + } +} diff --git a/DyeingComputer.csproj b/DyeingComputer.csproj index 2785773..be57368 100644 --- a/DyeingComputer.csproj +++ b/DyeingComputer.csproj @@ -62,6 +62,8 @@ MSBuild:Compile Designer + + True True @@ -91,6 +93,7 @@ + CurveDiagramView.xaml diff --git a/MainWindow.xaml b/MainWindow.xaml index 07d93b1..1020905 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -4,10 +4,11 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:lang="clr-namespace:DyeingComputer.Properties" - xmlns:local="clr-namespace:DyeingComputer" + xmlns:local="clr-namespace:DyeingComputer" xmlns:viewmodel="clr-namespace:DyeingComputer.ViewModel" + d:DataContext="{d:DesignInstance Type=viewmodel:MainWindowViewModel}" mc:Ignorable="d" Title="SUNLIGHT 838 b0.0.1 (2024/08/10)" - Height="720" Width="1280"> + Height="720" Width="1270"> - - + + @@ -70,8 +71,38 @@ - - + + + + + + + + + + + + + + diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index e135af2..d64abb5 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -26,6 +26,8 @@ namespace DyeingComputer { public MainWindow() { + DataContext = new MainWindowViewModel(); + InitializeComponent(); SQLiteStrat(); container.Content = new WorkOrderView(); diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs index c9b2750..aeb0c75 100644 --- a/Properties/Resources.Designer.cs +++ b/Properties/Resources.Designer.cs @@ -168,6 +168,15 @@ namespace DyeingComputer.Properties { } } + /// + /// 查找类似 Temperature 的本地化字符串。 + /// + public static string Temperature { + get { + return ResourceManager.GetString("Temperature", resourceCulture); + } + } + /// /// 查找类似 Worklist 的本地化字符串。 /// @@ -176,5 +185,14 @@ namespace DyeingComputer.Properties { return ResourceManager.GetString("WorkOrder", resourceCulture); } } + + /// + /// 查找类似 WorkOrderNumder 的本地化字符串。 + /// + public static string WorkOrderNumder { + get { + return ResourceManager.GetString("WorkOrderNumder", resourceCulture); + } + } } } diff --git a/Properties/Resources.en-US.resx b/Properties/Resources.en-US.resx index f4c5c2d..c4384c5 100644 --- a/Properties/Resources.en-US.resx +++ b/Properties/Resources.en-US.resx @@ -118,7 +118,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - WorkOrder + Work Order Process @@ -151,9 +151,15 @@ Parameter - ProgramGroup + Program Group System Data Lost + + Work Order Numder + + + Temperature + \ No newline at end of file diff --git a/Properties/Resources.resx b/Properties/Resources.resx index d0b3909..aeedcca 100644 --- a/Properties/Resources.resx +++ b/Properties/Resources.resx @@ -153,7 +153,13 @@ Process + + Temperature + Worklist + + WorkOrderNumder + \ No newline at end of file diff --git a/Properties/Resources.zh-CN.resx b/Properties/Resources.zh-CN.resx index 69026a7..fbcfb30 100644 --- a/Properties/Resources.zh-CN.resx +++ b/Properties/Resources.zh-CN.resx @@ -156,4 +156,10 @@ 系统数据丢失 + + 工单号 + + + 温度 + \ No newline at end of file diff --git a/Properties/Resources.zh-TW.resx b/Properties/Resources.zh-TW.resx index deba0e5..42d49aa 100644 --- a/Properties/Resources.zh-TW.resx +++ b/Properties/Resources.zh-TW.resx @@ -156,4 +156,10 @@ 系統資料遺失 + + 工單號碼 + + + 溫度 + \ No newline at end of file diff --git a/View/WorkOrderView.xaml b/View/WorkOrderView.xaml index 7958c02..3cdcccd 100644 --- a/View/WorkOrderView.xaml +++ b/View/WorkOrderView.xaml @@ -9,7 +9,7 @@ - + diff --git a/ViewModel/MainWindowViewModel.cs b/ViewModel/MainWindowViewModel.cs new file mode 100644 index 0000000..c0b9fa0 --- /dev/null +++ b/ViewModel/MainWindowViewModel.cs @@ -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 +{ + /// + /// 变量传递至ui + /// + 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"; + } + } +} diff --git a/ViewModel/ViewModelLocator.cs b/ViewModel/ViewModelLocator.cs index 50e13c4..a820b33 100644 --- a/ViewModel/ViewModelLocator.cs +++ b/ViewModel/ViewModelLocator.cs @@ -5,6 +5,8 @@ using System.Text; using System.Threading.Tasks; using CommunityToolkit.Mvvm.ComponentModel; using CommonServiceLocator; +using System.Windows.Navigation; +using CommunityToolkit.Mvvm.DependencyInjection; namespace DyeingComputer.ViewModel @@ -13,29 +15,17 @@ namespace DyeingComputer.ViewModel { public ViewModelLocator() { - // ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); - ////if (ViewModelBase.IsInDesignModeStatic) - ////{ - //// // Create design time view services and models - //// SimpleIoc.Default.Register(); - ////} - ////else - ////{ - //// // Create run time view services and models - //// SimpleIoc.Default.Register(); - ////} - // SimpleIoc.Default.Register(); } - // public MainWindowViewModel Main - // { - // get - // { - // return ServiceLocator.Current.GetInstance(); - // } - // } + public MainWindowViewModel Main + { + get + { + return ServiceLocator.Current.GetInstance(); + } + } } }