Selaa lähdekoodia

新增 10秒一次心跳。 新增 页面切换关闭其他页面。

ZhangXueYang
zhangxueyang 3 vuotta sitten
vanhempi
commit
3905d2b5c1

+ 1
- 1
XHZB.Desktop/AttendanceWindow.xaml.cs Näytä tiedosto

@@ -86,7 +86,7 @@ namespace XHZB.Desktop
86 86
                 pageData.menuList.Clear();
87 87
             }
88 88
 
89
-            //ToolbarWindow.IsOpenAttendanceWindow = false;
89
+            ToolbarWindow.IsOpenAttendanceWindow = false;
90 90
             Hide();
91 91
             FreeMemoryHelper.ReallocateMemory();
92 92
             System.Threading.Thread.Sleep(0);

+ 3
- 22
XHZB.Desktop/RollCallWindow.xaml.cs Näytä tiedosto

@@ -616,10 +616,6 @@ namespace XHZB.Desktop
616 616
         private void btnDown_Click(object sender, RoutedEventArgs e)
617 617
         {
618 618
             WSocketClient.getInstance().SendMessage(SocketMsgManger.RushToAnswerEndMsg());
619
-
620
-
621
-
622
-
623 619
             //ToolbarWindow.IsNotOperation = false;
624 620
             APP.myloading.Show();
625 621
             new Thread(o =>
@@ -630,26 +626,14 @@ namespace XHZB.Desktop
630 626
                 useridsss = string.Empty;
631 627
                 isRollCall = false;
632 628
                 isRushToAnswer = false;
633
-                APP.RollCallList = new System.Collections.Generic.List<Model.RollCallModel>();
634
-                //string msg = ZSocketMsgManger.qiangdaEnd();
635
-                //ZSocketServer.getInstance().SendMessage(msg);
636
-                //ZSqliteManger.insertClassAction(new ClassAction()
637
-                //{
638
-                //    unix = DataProvider.TimestampTotalSeconds(),
639
-                //    roomid = ZCommonData.roomid,
640
-                //    type = 403,
641
-                //    json = msg,
642
-                //    askid = ZCommonData.askid
643
-                //});
644
-
629
+                APP.RollCallList = new List<Model.RollCallModel>();
645 630
                 Dispatcher.Invoke(new Action(() =>
646 631
                 {
647
-                    //ToolbarWindow.IsOpenRollCallWindow = false;
632
+                    ToolbarWindow.IsOpenRollCallWindow = false;
648 633
                     APP.myloading.Hide();
649 634
                     Hide();
650 635
                 }));
651 636
             }).Start();
652
-
653 637
         }
654 638
 
655 639
         /// <summary>
@@ -660,9 +644,6 @@ namespace XHZB.Desktop
660 644
         private void btnAnswer_Click(object sender, RoutedEventArgs e)
661 645
         {
662 646
             WSocketClient.getInstance().SendMessage(SocketMsgManger.RushToAnswerMsg());
663
-
664
-
665
-
666 647
             if (!IsRandomRollCallButton)
667 648
             {
668 649
                 returnNum = 0;
@@ -912,7 +893,7 @@ namespace XHZB.Desktop
912 893
         {
913 894
             //ToolbarWindow.IsNotOperation = false;
914 895
             click_closeClick();
915
-            //ZSocketServer.getInstance().removedWin(this);
896
+            WSocketClient.getInstance().removedWin(this);
916 897
         }
917 898
 
918 899
         #region 关闭委托

+ 130
- 81
XHZB.Desktop/ToolbarWindow.xaml.cs Näytä tiedosto

@@ -45,6 +45,20 @@ namespace XHZB.Desktop
45 45
         /// </summary>
46 46
         private bool heibanshow = false;
47 47
         private bool isTool = true;
48
+        #region 当前已打开页面
49
+        /// <summary>
50
+        /// 是否已打开个人空间
51
+        /// </summary>
52
+        public static bool IsOpenUserCenterWindow = false;
53
+        /// <summary>
54
+        /// 是否已打开课堂点名
55
+        /// </summary>
56
+        public static bool IsOpenRollCallWindow = false;
57
+        /// <summary>
58
+        /// 是否已打开考勤页面
59
+        /// </summary>
60
+        public static bool IsOpenAttendanceWindow = false;
61
+        #endregion 当前已打开页面
48 62
         #endregion
49 63
 
50 64
         #region 初始化
@@ -121,9 +135,23 @@ namespace XHZB.Desktop
121 135
             ToolbarMenu item = pageData.menuList[clickindex];
122 136
             if (clickindex == 0)//个人空间
123 137
             {
138
+                #region 关闭冲突页面
139
+                if (IsOpenUserCenterWindow)
140
+                {
141
+                    if (APP.W_UserCenterWindow != null && !APP.W_UserCenterWindow.IsFocused)
142
+                    {
143
+                        APP.W_UserCenterWindow.Focus();
144
+                    }
145
+                    return;
146
+                }
147
+                else
148
+                {
149
+                    CloseOrHideWindowPage();
150
+                }
151
+                #endregion 关闭冲突页面
124 152
                 try
125 153
                 {
126
-                    //HideLevel2();
154
+                    HideLevel2();
127 155
                     if (APP.W_UserCenterWindow != null && !APP.W_UserCenterWindow.IsFocused)
128 156
                     {
129 157
                         APP.W_UserCenterWindow.Focus();
@@ -134,23 +162,22 @@ namespace XHZB.Desktop
134 162
                         APP.W_UserCenterWindow.Show();
135 163
                         APP.W_UserCenterWindow.Closed += UserCenterWindow_Closed;
136 164
                     }
137
-                    //IsOpenUserCenterWindow = true;
165
+                    IsOpenUserCenterWindow = true;
138 166
                 }
139 167
                 catch (Exception ex)
140 168
                 {
141
-                    //IsOpenUserCenterWindow = false;
142
-                    //userCenterWindow = null;
169
+                    IsOpenUserCenterWindow = false;
170
+                    APP.W_UserCenterWindow = null;
143 171
                     LogHelper.WriteErrLog("【个人空间(toolbar_item_Click)" + ex.Message, ex);
144 172
                 }
145 173
             }
146 174
             else if (clickindex == 1)//直播
147 175
             {
148
-                //HideLevel2();
176
+                HideLevel2();
149 177
                 pageData.tongping = !pageData.tongping;
150 178
                 if (pageData.tongping&& isTool)
151 179
                 {
152 180
                     isTool = false;
153
-                    //tongpingBegin();
154 181
                     if (StartLive(out string ErrMessage))
155 182
                     {
156 183
                         pageData.menuList[1].Pic = "../Images/ToolBar/img_shared_1.gif";
@@ -171,36 +198,29 @@ namespace XHZB.Desktop
171 198
                         MessageWindow.Show(ErrMessage);
172 199
                     }
173 200
                 }
174
-                //else
175
-                //{
176
-                //    EndLive();
177
-                //    pageData.menuList[1].Pic = "../Images/ToolBar/直播@2x.png";
178
-                //    pageData.menuList[1].Name = "直播";
179
-                //    APP.W_CameraWindow.Hide();
180
-                //}
181 201
             }
182 202
             else if (clickindex == 2)//抢答点名
183 203
             {
184
-                //HideLevel2();
204
+                HideLevel2();
185 205
                 try
186 206
                 {
187
-                    //#region 关闭冲突页面
207
+                    #region 关闭冲突页面
188 208
 
189
-                    //if (IsOpenRollCallWindow)
190
-                    //{
191
-                    //    return;
192
-                    //}
193
-                    //else
194
-                    //{
195
-                    //    CloseOrHideWindowPage();
196
-                    //}
209
+                    if (IsOpenRollCallWindow)
210
+                    {
211
+                        return;
212
+                    }
213
+                    else
214
+                    {
215
+                        CloseOrHideWindowPage();
216
+                    }
197 217
 
198
-                    //#endregion 关闭冲突页面
218
+                    #endregion 关闭冲突页面
199 219
 
200 220
                     if (APP.W_RollCallWindow == null)
201 221
                     {
202 222
                         APP.W_RollCallWindow = new RollCallWindow();
203
-                        //APP.W_RollCallWindow.click_closeClick += RollCallWindow_click_closeClick;
223
+                        APP.W_RollCallWindow.click_closeClick += RollCallWindow_click_closeClick;
204 224
                     }
205 225
                     else
206 226
                     {
@@ -208,13 +228,13 @@ namespace XHZB.Desktop
208 228
                     }
209 229
                     APP.W_RollCallWindow.Owner = this;
210 230
                     //ZSocketServer.getInstance().addWin(rollCallWindow);
211
-                    //IsOpenRollCallWindow = true;
231
+                    IsOpenRollCallWindow = true;
212 232
                     APP.W_RollCallWindow.Show();
213 233
                 }
214 234
                 catch (Exception ex)
215 235
                 {
216
-                    //IsOpenRollCallWindow = false;
217
-                    //rollCallWindow = null;
236
+                    IsOpenRollCallWindow = false;
237
+                    APP.W_RollCallWindow = null;
218 238
                     LogHelper.WriteErrLog("【抢答点名(toolbar_item_Click)" + ex.Message, ex);
219 239
                 }
220 240
             }
@@ -228,16 +248,6 @@ namespace XHZB.Desktop
228 248
                         heiban_btn,
229 249
                         pizhu_btn
230 250
                     };
231
-                    //if (tangceshow)
232
-                    //{
233
-                    //    tangceshow = !tangceshow;
234
-                    //    List<DependencyObject> lists = new List<DependencyObject>
235
-                    //    {
236
-                    //        import_word_btn,
237
-                    //        jietu_btn
238
-                    //    };
239
-                    //    hideOrShow(tangceshow, tangceTool, lists);
240
-                    //}
241 251
                     hideOrShow(heibanshow, ketangTool, list);
242 252
                 }
243 253
                 catch (Exception ex)
@@ -247,7 +257,7 @@ namespace XHZB.Desktop
247 257
             }
248 258
             else if (clickindex == 4)//本节考勤
249 259
             {
250
-                //HideLevel2();
260
+                HideLevel2();
251 261
                 try
252 262
                 {
253 263
                     showKaoqin();
@@ -273,34 +283,43 @@ namespace XHZB.Desktop
273 283
         private void UserCenterWindow_Closed(object sender, EventArgs e)
274 284
         {
275 285
             APP.W_UserCenterWindow = null;
276
-            //IsOpenUserCenterWindow = false;
286
+            IsOpenUserCenterWindow = false;
287
+        }
288
+        /// <summary>
289
+        /// 课堂点名关闭
290
+        /// </summary>
291
+        private void RollCallWindow_click_closeClick()
292
+        {
293
+            IsOpenRollCallWindow = false;
294
+            APP.W_RollCallWindow = null;
295
+        }
296
+        /// <summary>
297
+        /// 考勤关闭
298
+        /// </summary>
299
+        /// <param name="sender"></param>
300
+        /// <param name="e"></param>
301
+        private void AttendanceWindow_Closed(object sender, EventArgs e)
302
+        {
303
+            IsOpenAttendanceWindow = false;
304
+            APP.W_AttendanceWindow = null;
277 305
         }
278 306
         /// <summary>
279 307
         /// 考勤
280 308
         /// </summary>
281 309
         private void showKaoqin()
282 310
         {
283
-            //if (
284
-            //        attendanceWindow != null &&
285
-            //        !attendanceWindow.IsFocused
286
-            //        )
287
-            //{
288
-            //    attendanceWindow.Focus();
289
-            //}
290
-            //else
291
-            //{
292 311
             try
293 312
             {
294 313
                 #region 关闭冲突页面
295 314
 
296
-                //if (IsOpenAttendanceWindow)
297
-                //{
298
-                //    return;
299
-                //}
300
-                //else
301
-                //{
302
-                //    CloseOrHideWindowPage();
303
-                //}
315
+                if (IsOpenAttendanceWindow)
316
+                {
317
+                    return;
318
+                }
319
+                else
320
+                {
321
+                    CloseOrHideWindowPage();
322
+                }
304 323
 
305 324
                 #endregion 关闭冲突页面
306 325
 
@@ -310,19 +329,19 @@ namespace XHZB.Desktop
310 329
                     {
311 330
                         Owner = this
312 331
                     };
313
-                    //APP.W_AttendanceWindow.Closed += AttendanceWindow_Closed;
332
+                    APP.W_AttendanceWindow.Closed += AttendanceWindow_Closed;
314 333
                 }
315 334
                 else
316 335
                 {
317
-                    //APP.W_AttendanceWindow.Initialize();
336
+                    APP.W_AttendanceWindow.Initialize();
318 337
                 }
319
-                //IsOpenAttendanceWindow = true;
338
+                IsOpenAttendanceWindow = true;
320 339
                 APP.W_AttendanceWindow.Show();
321 340
             }
322 341
             catch (Exception ex)
323 342
             {
324
-                //IsOpenAttendanceWindow = false;
325
-                //attendanceWindow = null;
343
+                IsOpenAttendanceWindow = false;
344
+                APP.W_AttendanceWindow = null;
326 345
                 LogHelper.WriteErrLog("【考勤(toolbar_item_Click)" + ex.Message, ex);
327 346
             }
328 347
             //}
@@ -339,9 +358,7 @@ namespace XHZB.Desktop
339 358
                 heibanshow = !heibanshow;
340 359
 
341 360
                 #region 关闭冲突页面
342
-
343
-                //CloseOrHideWindowPage();
344
-
361
+                CloseOrHideWindowPage();
345 362
                 #endregion 关闭冲突页面
346 363
 
347 364
                 List<DependencyObject> list = new List<DependencyObject>
@@ -693,18 +710,10 @@ namespace XHZB.Desktop
693 710
             if (txbName.Visibility == Visibility.Visible)
694 711
             {
695 712
                 txbName.Visibility = Visibility.Collapsed;
696
-                //if ("正在共享".Equals(pageData.menuList[1].Name))
697
-                //{
698
-                //    gridAnimated.Visibility = Visibility.Collapsed;
699
-                //}
700 713
             }
701 714
             else
702 715
             {
703 716
                 txbName.Visibility = Visibility.Visible;
704
-                //if("正在共享".Equals(pageData.menuList[1].Name))
705
-                //{
706
-                //    gridAnimated.Visibility = Visibility.Visible;
707
-                //}
708 717
             }
709 718
 
710 719
             Storyboard story = new Storyboard();
@@ -712,11 +721,11 @@ namespace XHZB.Desktop
712 721
             if (toolShow)
713 722
             {
714 723
                 da.From = 0;
715
-                da.To = 670;
724
+                da.To = 450;
716 725
             }
717 726
             else
718 727
             {
719
-                da.From = 670;
728
+                da.From = 450;
720 729
                 da.To = 0.0;
721 730
             }
722 731
 
@@ -767,7 +776,7 @@ namespace XHZB.Desktop
767 776
 
768 777
         private void Window_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
769 778
         {
770
-
779
+            time = NumUtil.unixTime();
771 780
         }
772 781
         private int time = NumUtil.unixTime();
773 782
         private void Rectangle_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
@@ -819,7 +828,52 @@ namespace XHZB.Desktop
819 828
         {
820 829
             WSocketClient.getInstance().StartWsClient();
821 830
         }
831
+        /// <summary>
832
+        /// 关闭或隐藏页面
833
+        /// </summary>
834
+        private void CloseOrHideWindowPage()
835
+        {
836
+            if (IsOpenUserCenterWindow)
837
+            {
838
+                IsOpenUserCenterWindow = false;
839
+                APP.W_UserCenterWindow.Close();
840
+            }
841
+            if (IsOpenRollCallWindow)
842
+            {
843
+                IsOpenRollCallWindow = false;
844
+                APP.W_RollCallWindow.Hide();
845
+            }
846
+            if (IsOpenAttendanceWindow)
847
+            {
848
+                IsOpenAttendanceWindow = false;
849
+                APP.W_AttendanceWindow.Hide();
850
+            }
851
+        }
852
+        /// <summary>
853
+        /// 隐藏二级菜单
854
+        /// </summary>
855
+        private void HideLevel2()
856
+        {
857
+            try
858
+            {
859
+                if (heibanshow)
860
+                {
861
+                    heibanshow = !heibanshow;
862
+                    List<DependencyObject> lists = new List<DependencyObject>
863
+                    {
864
+                        heiban_btn,
865
+                        pizhu_btn
866
+                    };
867
+                    hideOrShow(heibanshow, ketangTool, lists);
868
+                }
869
+            }
870
+            catch (Exception ex)
871
+            {
872
+                LogHelper.WriteErrLog("【工具栏(ToolbarWindow)" + ex.Message, ex);
873
+            }
874
+        }
822 875
         #endregion
876
+
823 877
         #region 直播
824 878
         /// <summary>
825 879
         /// 直播间节点和房号
@@ -870,23 +924,18 @@ namespace XHZB.Desktop
870 924
     public class ToolbarModel : NotifyModel
871 925
     {
872 926
         public ObservableCollection<ToolbarMenu> menuList { get; set; }
873
-
874 927
         internal bool _tongping = false;
875
-
876 928
         public bool tongping
877 929
         {
878 930
             get => _tongping;
879 931
             set { _tongping = value; OnPropertyChanged("tongping"); }
880 932
         }
881
-
882 933
         internal bool _IsOpen = true;
883
-
884 934
         public bool IsOpen
885 935
         {
886 936
             get => _IsOpen;
887 937
             set { _IsOpen = value; OnPropertyChanged("IsOpen"); }
888 938
         }
889
-
890 939
         public ToolbarModel()
891 940
         {
892 941
             menuList = new ObservableCollection<ToolbarMenu>();

+ 64
- 29
XHZB.Desktop/UserCenterWindow.xaml.cs Näytä tiedosto

@@ -1,6 +1,4 @@
1 1
 using Common.system;
2
-
3
-
4 2
 using System;
5 3
 using System.Collections.ObjectModel;
6 4
 using System.ComponentModel;
@@ -12,21 +10,28 @@ using System.Windows;
12 10
 using System.Windows.Controls;
13 11
 using System.Windows.Input;
14 12
 using System.Windows.Media;
15
-
16
-
17 13
 using XHZB.Desktop.Utils;
18 14
 using XHZB.Model;
19 15
 
20
-
21 16
 namespace XHZB.Desktop
22 17
 {
23 18
     /// <summary>
24
-    /// 个人空间 LessonPreparationWindow.xaml 的交互逻辑
19
+    /// 个人空间
25 20
     /// </summary>
26 21
     public partial class UserCenterWindow : Window, DownloadUtil.DownloadCallback
27 22
     {
23
+        #region 字段
24
+        /// <summary>
25
+        /// 接口返回 0 成功 1 失败
26
+        /// </summary>
28 27
         private int serverReturnCode = 0;
28
+        /// <summary>
29
+        /// 接口调用
30
+        /// </summary>
29 31
         private readonly RegisterController registerController = new RegisterController();
32
+        /// <summary>
33
+        /// 数据源
34
+        /// </summary>
30 35
         internal UserCenterPageData pageData = new UserCenterPageData();
31 36
         private bool isInitial = false;
32 37
         private Thread thread;
@@ -51,6 +56,9 @@ namespace XHZB.Desktop
51 56
         /// 资源分类1音频2视频3图片4文档
52 57
         /// </summary>
53 58
         private int Resourceclass = 0;
59
+        #endregion
60
+
61
+        #region 初始化
54 62
         /// <summary>
55 63
         /// 个人空间
56 64
         /// </summary>
@@ -84,6 +92,16 @@ namespace XHZB.Desktop
84 92
 
85 93
             }).Start();
86 94
         }
95
+        #endregion
96
+
97
+        #region 方法
98
+        /// <summary>
99
+        /// 刷新
100
+        /// </summary>
101
+        private void Refresh()
102
+        {
103
+            pageData.menuList.Clear();
104
+        }
87 105
         /// <summary>
88 106
         /// 教师教材列表服务-调用
89 107
         /// </summary>
@@ -134,7 +152,7 @@ namespace XHZB.Desktop
134 152
         private object InvokeDirectorListServering()
135 153
         {
136 154
             APP.DirectorList = null;
137
-            serverReturnCode = registerController.DirectorList(Lsbid,2,APP.LoginUser.userid);
155
+            serverReturnCode = registerController.DirectorList(Lsbid, 2, APP.LoginUser.userid);
138 156
             return APP.ErrorMessage;
139 157
         }
140 158
 
@@ -212,7 +230,6 @@ namespace XHZB.Desktop
212 230
                 }
213 231
             }
214 232
         }
215
-
216 233
         private string getSpace(int num)
217 234
         {
218 235
             string str = "";
@@ -222,7 +239,6 @@ namespace XHZB.Desktop
222 239
             }
223 240
             return str;
224 241
         }
225
-
226 242
         private void zhangjieClick(object sender, RoutedEventArgs e)
227 243
         {
228 244
             ChapterModel item = ((Button)sender).Tag as ChapterModel;
@@ -437,7 +453,9 @@ namespace XHZB.Desktop
437 453
                 this
438 454
                 );
439 455
         }
456
+        #endregion
440 457
 
458
+        #region 事件
441 459
         /// <summary>
442 460
         /// 下载
443 461
         /// </summary>
@@ -491,7 +509,6 @@ namespace XHZB.Desktop
491 509
                 }
492 510
             }
493 511
         }
494
-
495 512
         /// <summary>
496 513
         /// 打开
497 514
         /// </summary>
@@ -555,7 +572,6 @@ namespace XHZB.Desktop
555 572
                 }
556 573
             }
557 574
         }
558
-
559 575
         /// <summary>
560 576
         /// 全部
561 577
         /// </summary>
@@ -578,7 +594,11 @@ namespace XHZB.Desktop
578 594
             btnDoc.Foreground = new SolidColorBrush(Colors.Black);
579 595
             APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeResourceMyListServering, InvokeServerResourceMyListCompate);
580 596
         }
581
-
597
+        /// <summary>
598
+        /// 窗口关闭
599
+        /// </summary>
600
+        /// <param name="sender"></param>
601
+        /// <param name="e"></param>
582 602
         private void Window_Closing(object sender, CancelEventArgs e)
583 603
         {
584 604
             if (pageData.menuList.Count > 0)
@@ -587,7 +607,6 @@ namespace XHZB.Desktop
587 607
                 DataContext = null;
588 608
             }
589 609
         }
590
-
591 610
         /// <summary>
592 611
         /// 音频
593 612
         /// </summary>
@@ -610,7 +629,6 @@ namespace XHZB.Desktop
610 629
             btnDoc.Foreground = new SolidColorBrush(Colors.Black);
611 630
             APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeResourceMyListServering, InvokeServerResourceMyListCompate);
612 631
         }
613
-
614 632
         /// <summary>
615 633
         /// 视频
616 634
         /// </summary>
@@ -633,7 +651,6 @@ namespace XHZB.Desktop
633 651
             btnDoc.Foreground = new SolidColorBrush(Colors.Black);
634 652
             APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeResourceMyListServering, InvokeServerResourceMyListCompate);
635 653
         }
636
-
637 654
         /// <summary>
638 655
         /// 图片
639 656
         /// </summary>
@@ -656,7 +673,6 @@ namespace XHZB.Desktop
656 673
             btnDoc.Foreground = new SolidColorBrush(Colors.Black);
657 674
             APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeResourceMyListServering, InvokeServerResourceMyListCompate);
658 675
         }
659
-
660 676
         /// <summary>
661 677
         /// 文档
662 678
         /// </summary>
@@ -679,11 +695,6 @@ namespace XHZB.Desktop
679 695
             btnDoc.Foreground = new SolidColorBrush(Colors.White);
680 696
             APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeResourceMyListServering, InvokeServerResourceMyListCompate);
681 697
         }
682
-
683
-        private void Refresh()
684
-        {
685
-            pageData.menuList.Clear();
686
-        }
687 698
         /// <summary>
688 699
         /// 科目教材选择改变事件
689 700
         /// </summary>
@@ -721,7 +732,11 @@ namespace XHZB.Desktop
721 732
                 Refresh();
722 733
             }
723 734
         }
724
-
735
+        /// <summary>
736
+        /// 窗口移动事件
737
+        /// </summary>
738
+        /// <param name="sender"></param>
739
+        /// <param name="e"></param>
725 740
         private void Window_MouseMove(object sender, MouseEventArgs e)
726 741
         {
727 742
             if (e.LeftButton == MouseButtonState.Pressed)
@@ -730,7 +745,11 @@ namespace XHZB.Desktop
730 745
                 DragMove();
731 746
             }
732 747
         }
733
-
748
+        /// <summary>
749
+        /// 关闭窗口事件
750
+        /// </summary>
751
+        /// <param name="sender"></param>
752
+        /// <param name="e"></param>
734 753
         private void btnDown_Click(object sender, RoutedEventArgs e)
735 754
         {
736 755
             if (thread != null)
@@ -739,9 +758,12 @@ namespace XHZB.Desktop
739 758
             }
740 759
             APP.myloading.Hide();
741 760
             Close();
742
-            //ToolbarWindow.IsOpenUserCenterWindow = false;
761
+            ToolbarWindow.IsOpenUserCenterWindow = false;
743 762
         }
744
-
763
+        /// <summary>
764
+        /// 下载
765
+        /// </summary>
766
+        /// <param name="position"></param>
745 767
         public void downloadBegin(int position)
746 768
         {
747 769
             isDownloadStatus = true;
@@ -750,7 +772,11 @@ namespace XHZB.Desktop
750 772
                 tip_outer.Visibility = Visibility.Visible;
751 773
             }
752 774
         }
753
-
775
+        /// <summary>
776
+        /// 下载中
777
+        /// </summary>
778
+        /// <param name="position"></param>
779
+        /// <param name="progress"></param>
754 780
         public void downloadProgress(int position, int progress)
755 781
         {
756 782
             if (position >= 9999)
@@ -759,7 +785,11 @@ namespace XHZB.Desktop
759 785
                 lbProcess.Content = string.Format("{0}% / {1}%", progress, 100);
760 786
             }
761 787
         }
762
-
788
+        /// <summary>
789
+        /// 下载完成
790
+        /// </summary>
791
+        /// <param name="position"></param>
792
+        /// <param name="filepath"></param>
763 793
         public void downloadEnd(int position, string filepath)
764 794
         {
765 795
             isDownloadStatus = false;
@@ -839,7 +869,11 @@ namespace XHZB.Desktop
839 869
                 }
840 870
             }
841 871
         }
842
-
872
+        /// <summary>
873
+        /// 下载结束
874
+        /// </summary>
875
+        /// <param name="position"></param>
876
+        /// <param name="msg"></param>
843 877
         public void downloadError(int position, string msg)
844 878
         {
845 879
             Dispatcher.Invoke(new Action(() =>
@@ -851,7 +885,8 @@ namespace XHZB.Desktop
851 885
             {
852 886
                 MessageWindow.Show(msg);
853 887
             }
854
-        }
888
+        } 
889
+        #endregion
855 890
 
856 891
         public class ButtonBrush
857 892
         {

+ 37
- 6
XHZB.Desktop/WebSocket/WSocketClient.cs Näytä tiedosto

@@ -40,6 +40,10 @@ namespace XHZB.Desktop.WebSocket
40 40
         /// 检查重连线程
41 41
         /// </summary>
42 42
         Thread _thread;
43
+        /// <summary>
44
+        /// 心跳
45
+        /// </summary>
46
+        Thread thread;
43 47
         bool _isRunning = true;
44 48
         /// <summary>
45 49
         /// WebSocket连接地址
@@ -99,6 +103,10 @@ namespace XHZB.Desktop.WebSocket
99 103
                 this._isRunning = true;
100 104
                 this._thread = new Thread(new ThreadStart(CheckConnection));
101 105
                 this._thread.Start();
106
+
107
+
108
+                thread = new Thread(new ThreadStart(Heartbeat));
109
+                thread.Start();
102 110
             }
103 111
             catch (Exception ex)
104 112
             {
@@ -340,13 +348,36 @@ namespace XHZB.Desktop.WebSocket
340 348
             System.Threading.Thread.Sleep(5000);
341 349
         } while (this._isRunning);
342 350
     }
343
-    #endregion
351
+        /// <summary>
352
+        /// 心跳
353
+        /// </summary>
354
+        private void Heartbeat() 
355
+        {
356
+            do
357
+            {
358
+                try
359
+                {
360
+                    if(_webSocket != null && _webSocket.State == WebSocket4Net.WebSocketState.Open)
361
+                    {
362
+                        byte[] bt = new byte[] { 01 };
363
+                        _webSocket.Send(bt, 0, 1);
364
+                        Console.WriteLine("心跳:" + DateTime.Now.ToString());
365
+                    }
366
+                }
367
+                catch (Exception ex)
368
+                {
369
+                    _Logger.Error(ex.ToString());
370
+                }
371
+                Thread.Sleep(10000);
372
+            } while (true);
373
+        }
374
+        #endregion
344 375
 
345
-    /// <summary>
346
-    /// 发送消息
347
-    /// </summary>
348
-    /// <param name="Message"></param>
349
-    public void SendMessage(string Message)
376
+        /// <summary>
377
+        /// 发送消息
378
+        /// </summary>
379
+        /// <param name="Message"></param>
380
+        public void SendMessage(string Message)
350 381
     {
351 382
         Task.Factory.StartNew(() =>
352 383
         {

Loading…
Peruuta
Tallenna