diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index e2baed1..ffa937b 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -31,6 +31,8 @@ namespace SunlightCentralizedControlManagement_SCCM_ { public static string user_; public static DataTable InfData = new DataTable(); + public UserInformation userInformation; + public MainWindow() { DataContext = new MainWindowViewModel(); @@ -53,14 +55,22 @@ namespace SunlightCentralizedControlManagement_SCCM_ InfData.Columns.Add("Code", Type.GetType("System.String")); InfData.Columns.Add("ID", Type.GetType("System.Int32")); - InfData.TableNewRow += new DataTableNewRowEventHandler(InfTable()); + InfData.RowChanged += new DataRowChangeEventHandler(InfTable);// } - private void InfTable(object sender, DataTableNewRowEventArgs e) + private void InfTable(object sender, DataRowChangeEventArgs e)//触发行改变事件 { - UserInformation userInformation = new UserInformation(); - userInformation.Topmost = true; - userInformation.Show(); - userInformation.Activate(); + if (userInformation == null || !userInformation.IsLoaded)//窗口不存在及创建 + { + userInformation = new UserInformation(); + userInformation.Topmost = true; + userInformation.Show(); + userInformation.Activate(); + } + else + {//窗口纯在及置顶 + userInformation.Activate(); + if (userInformation.WindowState == WindowState.Minimized) userInformation.WindowState = WindowState.Normal; + } } private void ButtonPopUpLogout_Click(object sender, RoutedEventArgs e) diff --git a/ViewModel/MainWindowViewModel.cs b/ViewModel/MainWindowViewModel.cs index 361a660..6a200b5 100644 --- a/ViewModel/MainWindowViewModel.cs +++ b/ViewModel/MainWindowViewModel.cs @@ -154,30 +154,29 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel public void CountDown() { + DispatcherTimer dis1s = new DispatcherTimer + { + Interval = TimeSpan.FromSeconds(1) //秒 + }; + dis1s.Tick += new EventHandler(Tick_Main_1S);//每执行的方法 + dis1s.Start();//计时开始 DispatcherTimer dis50ms = new DispatcherTimer { - Interval = TimeSpan.FromMilliseconds(50) //毫秒 + Interval = TimeSpan.FromMilliseconds(20) //毫秒 }; dis50ms.Tick += new EventHandler(DisTimer_50MS);//每执行的方法 dis50ms.Start();//计时开始 - }//时间周期初始化 - int Time1 = 0, Time5 = 0, Time60 = 0; + }//时间周期初始化 + int Time5 = 0, Time60 = 0; void DisTimer_50MS(object sender, EventArgs e)//Tick_Event周期执行事件50MS { if (stringQueue.Count > 0) //信息发送队列 { QueueString t = stringQueue.Dequeue(); MachiensTcpClient[t.ID].SendAsync(t.DAT); - } - - if (Time1 >= 20) - { - Tick_Main_1S(); - Time1 = 0; - } - else { Time1++; } + } } - void Tick_Main_1S()//Tick_Event周期执行事件1S + void Tick_Main_1S(object sender, EventArgs e)//Tick_Event周期执行事件1S { //下传工单信息 SQLiteHelper WorkOrderSQL = new SQLiteHelper(DBAddress); //数据库连接路径 @@ -290,7 +289,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel });//信息插入队列 } } - if (Time5 > 5) { Tick_Event_5S(); @@ -300,7 +298,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel if (Time60 > 60) { Tick_Event_60S(); - Time60= 0; + Time60 = 0; } else { Time60++; } } @@ -317,6 +315,12 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel });//信息插入队列 } }//发送800指令 + + + + MainWindow.InfData.Rows.Add(new object[] { "1", Properties.Resources.Pequest+"a", "423", "12" }); + + } void Tick_Event_60S() { @@ -357,14 +361,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel } } - /* public static void Inf_Data() - { - UserInformation userInformation = new UserInformation(); - userInformation.Topmost = true; - userInformation.Show(); - userInformation.Activate(); - }*/ - public static string SYS_WorkNumder; //工单号 public static int SYS_AT1; //附缸1-3 public static int SYS_AT2; diff --git a/WindowsView/UserInformation.xaml b/WindowsView/UserInformation.xaml index 8ba5bab..a7832c0 100644 --- a/WindowsView/UserInformation.xaml +++ b/WindowsView/UserInformation.xaml @@ -7,21 +7,15 @@ xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties" mc:Ignorable="d" Closing="Window_Closing" - Title="UserInformation" Height="450" Width="800"> + ResizeMode="NoResize" + WindowStyle="SingleBorderWindow" + Title="SUNLIGHT" Height="450" Width="800"> - - - + CanUserDeleteRows="False" SelectionMode="Single" FontSize="30" Focusable="True" >