diff --git a/MainWindow.xaml b/MainWindow.xaml index 0e76ae7..224cb25 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -50,7 +50,7 @@ - diff --git a/ViewModel/MainWindowViewModel.cs b/ViewModel/MainWindowViewModel.cs index 22fa73f..654836a 100644 --- a/ViewModel/MainWindowViewModel.cs +++ b/ViewModel/MainWindowViewModel.cs @@ -16,14 +16,27 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Windows.Threading; +using System.Xml.Linq; namespace formula_manage.ViewModel { -/// -/// RRODUCTiewModel -/// -/// -public class MainWindowViewModel : ViewModelBase + + 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 { DataTable DissolvedataTable = new DataTable(); //建立Dissolve缓存 DataTable STUFFdataTable = new DataTable(); //建立STUFF缓存 @@ -32,7 +45,12 @@ public class MainWindowViewModel : ViewModelBase DataTable RecipedataTable = new DataTable(); //建立Recipe缓存 public string INIPath = Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "formula.ini"; //配置文件路径 - public string Sys_Time; //显示系统时间 + public string sys_Time; //显示系统时间 + public string Sys_Time //通知UI控件参数改变 + { + get { return sys_Time; } + set { sys_Time = value; OnPropertyChanged("Sys_Time"); } + } string TEXT_SQLIP; string TEXT_SQLNAME; @@ -41,7 +59,7 @@ public class MainWindowViewModel : ViewModelBase string TEXT_SQLPASWOR; string Connstr_SC; - private async void sql_() + private async void Sql_() { UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(INIPath);//生效配置读取 TEXT_SQLIP = Configini.IniReadvalue("SQL_SERVER", "SQL1"); //读配置文件 @@ -86,7 +104,8 @@ public class MainWindowViewModel : ViewModelBase public MainWindowViewModel() { - sql_(); + CountDown(); + Sql_(); stuff_Product = ToObservableCollection(STUFFdataTable); //stuff_Product表转换 mac_Machine = ToObservableCollection(MACHINEdataTable); @@ -97,7 +116,7 @@ public class MainWindowViewModel : ViewModelBase public ObservableCollection stuff_Product { get; set; } //stuff_Product动态表实力化 public ObservableCollection mac_Machine { get; set; } //mac_Machine动态表实力化 public ObservableCollection flow_Workflow { get; set; } //Dissolve动态表实力化 - public ObservableCollection ToObservableCollection(DataTable dt) where T : class, new() + public ObservableCollection ToObservableCollection(DataTable dt) where T : class, new() //DataTable FOR ObservableCollection转换器 { Type t = typeof(T); PropertyInfo[] propertys = t.GetProperties(); @@ -143,14 +162,12 @@ public class MainWindowViewModel : ViewModelBase lst.Add(entity); } return lst; - } - + } //DataTable FOR ObservableCollection转换器 /// /// 循环事件设定 /// public void CountDown() { - //products = new ProductProvider().Select(); DispatcherTimer timer = new DispatcherTimer//初始化循环,每0.5秒调用一次Tick_Event { Interval = TimeSpan.FromSeconds(0.1) @@ -163,12 +180,10 @@ public class MainWindowViewModel : ViewModelBase // disTimer.Interval = new TimeSpan(10000000); //时间间隔为一秒。 // disTimer.Start();//计时开始 } - void Tick_Event(object sender, EventArgs e)//Tick_Event周期执行事件 { Sys_Time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); } - } public class Product //stuff_Product