Merge branch 'master' of http://www.scserverddns.top:13000/sc/DyeingComputer
This commit is contained in:
commit
51c2aae2e9
13 files changed
+281
-28
No files matched your search
@@ -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";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<IDataService, DesignDataService>();
|
||||
////}
|
||||
////else
|
||||
////{
|
||||
//// // Create run time view services and models
|
||||
//// SimpleIoc.Default.Register<IDataService, DataService>();
|
||||
////}
|
||||
|
||||
// SimpleIoc.Default.Register<MainWindowViewModel>();
|
||||
}
|
||||
|
||||
// public MainWindowViewModel Main
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// return ServiceLocator.Current.GetInstance<MainWindowViewModel>();
|
||||
// }
|
||||
// }
|
||||
public MainWindowViewModel Main
|
||||
{
|
||||
get
|
||||
{
|
||||
return ServiceLocator.Current.GetInstance<MainWindowViewModel>();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user