Browse Source

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

ZhangXueYang
zhangxueyang 3 years ago
parent
commit
3905d2b5c1

+ 1
- 1
XHZB.Desktop/AttendanceWindow.xaml.cs View File

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

+ 3
- 22
XHZB.Desktop/RollCallWindow.xaml.cs View File

616
         private void btnDown_Click(object sender, RoutedEventArgs e)
616
         private void btnDown_Click(object sender, RoutedEventArgs e)
617
         {
617
         {
618
             WSocketClient.getInstance().SendMessage(SocketMsgManger.RushToAnswerEndMsg());
618
             WSocketClient.getInstance().SendMessage(SocketMsgManger.RushToAnswerEndMsg());
619
-
620
-
621
-
622
-
623
             //ToolbarWindow.IsNotOperation = false;
619
             //ToolbarWindow.IsNotOperation = false;
624
             APP.myloading.Show();
620
             APP.myloading.Show();
625
             new Thread(o =>
621
             new Thread(o =>
630
                 useridsss = string.Empty;
626
                 useridsss = string.Empty;
631
                 isRollCall = false;
627
                 isRollCall = false;
632
                 isRushToAnswer = false;
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
                 Dispatcher.Invoke(new Action(() =>
630
                 Dispatcher.Invoke(new Action(() =>
646
                 {
631
                 {
647
-                    //ToolbarWindow.IsOpenRollCallWindow = false;
632
+                    ToolbarWindow.IsOpenRollCallWindow = false;
648
                     APP.myloading.Hide();
633
                     APP.myloading.Hide();
649
                     Hide();
634
                     Hide();
650
                 }));
635
                 }));
651
             }).Start();
636
             }).Start();
652
-
653
         }
637
         }
654
 
638
 
655
         /// <summary>
639
         /// <summary>
660
         private void btnAnswer_Click(object sender, RoutedEventArgs e)
644
         private void btnAnswer_Click(object sender, RoutedEventArgs e)
661
         {
645
         {
662
             WSocketClient.getInstance().SendMessage(SocketMsgManger.RushToAnswerMsg());
646
             WSocketClient.getInstance().SendMessage(SocketMsgManger.RushToAnswerMsg());
663
-
664
-
665
-
666
             if (!IsRandomRollCallButton)
647
             if (!IsRandomRollCallButton)
667
             {
648
             {
668
                 returnNum = 0;
649
                 returnNum = 0;
912
         {
893
         {
913
             //ToolbarWindow.IsNotOperation = false;
894
             //ToolbarWindow.IsNotOperation = false;
914
             click_closeClick();
895
             click_closeClick();
915
-            //ZSocketServer.getInstance().removedWin(this);
896
+            WSocketClient.getInstance().removedWin(this);
916
         }
897
         }
917
 
898
 
918
         #region 关闭委托
899
         #region 关闭委托

+ 130
- 81
XHZB.Desktop/ToolbarWindow.xaml.cs View File

45
         /// </summary>
45
         /// </summary>
46
         private bool heibanshow = false;
46
         private bool heibanshow = false;
47
         private bool isTool = true;
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
         #endregion
62
         #endregion
49
 
63
 
50
         #region 初始化
64
         #region 初始化
121
             ToolbarMenu item = pageData.menuList[clickindex];
135
             ToolbarMenu item = pageData.menuList[clickindex];
122
             if (clickindex == 0)//个人空间
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
                 try
152
                 try
125
                 {
153
                 {
126
-                    //HideLevel2();
154
+                    HideLevel2();
127
                     if (APP.W_UserCenterWindow != null && !APP.W_UserCenterWindow.IsFocused)
155
                     if (APP.W_UserCenterWindow != null && !APP.W_UserCenterWindow.IsFocused)
128
                     {
156
                     {
129
                         APP.W_UserCenterWindow.Focus();
157
                         APP.W_UserCenterWindow.Focus();
134
                         APP.W_UserCenterWindow.Show();
162
                         APP.W_UserCenterWindow.Show();
135
                         APP.W_UserCenterWindow.Closed += UserCenterWindow_Closed;
163
                         APP.W_UserCenterWindow.Closed += UserCenterWindow_Closed;
136
                     }
164
                     }
137
-                    //IsOpenUserCenterWindow = true;
165
+                    IsOpenUserCenterWindow = true;
138
                 }
166
                 }
139
                 catch (Exception ex)
167
                 catch (Exception ex)
140
                 {
168
                 {
141
-                    //IsOpenUserCenterWindow = false;
142
-                    //userCenterWindow = null;
169
+                    IsOpenUserCenterWindow = false;
170
+                    APP.W_UserCenterWindow = null;
143
                     LogHelper.WriteErrLog("【个人空间(toolbar_item_Click)" + ex.Message, ex);
171
                     LogHelper.WriteErrLog("【个人空间(toolbar_item_Click)" + ex.Message, ex);
144
                 }
172
                 }
145
             }
173
             }
146
             else if (clickindex == 1)//直播
174
             else if (clickindex == 1)//直播
147
             {
175
             {
148
-                //HideLevel2();
176
+                HideLevel2();
149
                 pageData.tongping = !pageData.tongping;
177
                 pageData.tongping = !pageData.tongping;
150
                 if (pageData.tongping&& isTool)
178
                 if (pageData.tongping&& isTool)
151
                 {
179
                 {
152
                     isTool = false;
180
                     isTool = false;
153
-                    //tongpingBegin();
154
                     if (StartLive(out string ErrMessage))
181
                     if (StartLive(out string ErrMessage))
155
                     {
182
                     {
156
                         pageData.menuList[1].Pic = "../Images/ToolBar/img_shared_1.gif";
183
                         pageData.menuList[1].Pic = "../Images/ToolBar/img_shared_1.gif";
171
                         MessageWindow.Show(ErrMessage);
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
             else if (clickindex == 2)//抢答点名
202
             else if (clickindex == 2)//抢答点名
183
             {
203
             {
184
-                //HideLevel2();
204
+                HideLevel2();
185
                 try
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
                     if (APP.W_RollCallWindow == null)
220
                     if (APP.W_RollCallWindow == null)
201
                     {
221
                     {
202
                         APP.W_RollCallWindow = new RollCallWindow();
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
                     else
225
                     else
206
                     {
226
                     {
208
                     }
228
                     }
209
                     APP.W_RollCallWindow.Owner = this;
229
                     APP.W_RollCallWindow.Owner = this;
210
                     //ZSocketServer.getInstance().addWin(rollCallWindow);
230
                     //ZSocketServer.getInstance().addWin(rollCallWindow);
211
-                    //IsOpenRollCallWindow = true;
231
+                    IsOpenRollCallWindow = true;
212
                     APP.W_RollCallWindow.Show();
232
                     APP.W_RollCallWindow.Show();
213
                 }
233
                 }
214
                 catch (Exception ex)
234
                 catch (Exception ex)
215
                 {
235
                 {
216
-                    //IsOpenRollCallWindow = false;
217
-                    //rollCallWindow = null;
236
+                    IsOpenRollCallWindow = false;
237
+                    APP.W_RollCallWindow = null;
218
                     LogHelper.WriteErrLog("【抢答点名(toolbar_item_Click)" + ex.Message, ex);
238
                     LogHelper.WriteErrLog("【抢答点名(toolbar_item_Click)" + ex.Message, ex);
219
                 }
239
                 }
220
             }
240
             }
228
                         heiban_btn,
248
                         heiban_btn,
229
                         pizhu_btn
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
                     hideOrShow(heibanshow, ketangTool, list);
251
                     hideOrShow(heibanshow, ketangTool, list);
242
                 }
252
                 }
243
                 catch (Exception ex)
253
                 catch (Exception ex)
247
             }
257
             }
248
             else if (clickindex == 4)//本节考勤
258
             else if (clickindex == 4)//本节考勤
249
             {
259
             {
250
-                //HideLevel2();
260
+                HideLevel2();
251
                 try
261
                 try
252
                 {
262
                 {
253
                     showKaoqin();
263
                     showKaoqin();
273
         private void UserCenterWindow_Closed(object sender, EventArgs e)
283
         private void UserCenterWindow_Closed(object sender, EventArgs e)
274
         {
284
         {
275
             APP.W_UserCenterWindow = null;
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
         /// <summary>
306
         /// <summary>
279
         /// 考勤
307
         /// 考勤
280
         /// </summary>
308
         /// </summary>
281
         private void showKaoqin()
309
         private void showKaoqin()
282
         {
310
         {
283
-            //if (
284
-            //        attendanceWindow != null &&
285
-            //        !attendanceWindow.IsFocused
286
-            //        )
287
-            //{
288
-            //    attendanceWindow.Focus();
289
-            //}
290
-            //else
291
-            //{
292
             try
311
             try
293
             {
312
             {
294
                 #region 关闭冲突页面
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
                 #endregion 关闭冲突页面
324
                 #endregion 关闭冲突页面
306
 
325
 
310
                     {
329
                     {
311
                         Owner = this
330
                         Owner = this
312
                     };
331
                     };
313
-                    //APP.W_AttendanceWindow.Closed += AttendanceWindow_Closed;
332
+                    APP.W_AttendanceWindow.Closed += AttendanceWindow_Closed;
314
                 }
333
                 }
315
                 else
334
                 else
316
                 {
335
                 {
317
-                    //APP.W_AttendanceWindow.Initialize();
336
+                    APP.W_AttendanceWindow.Initialize();
318
                 }
337
                 }
319
-                //IsOpenAttendanceWindow = true;
338
+                IsOpenAttendanceWindow = true;
320
                 APP.W_AttendanceWindow.Show();
339
                 APP.W_AttendanceWindow.Show();
321
             }
340
             }
322
             catch (Exception ex)
341
             catch (Exception ex)
323
             {
342
             {
324
-                //IsOpenAttendanceWindow = false;
325
-                //attendanceWindow = null;
343
+                IsOpenAttendanceWindow = false;
344
+                APP.W_AttendanceWindow = null;
326
                 LogHelper.WriteErrLog("【考勤(toolbar_item_Click)" + ex.Message, ex);
345
                 LogHelper.WriteErrLog("【考勤(toolbar_item_Click)" + ex.Message, ex);
327
             }
346
             }
328
             //}
347
             //}
339
                 heibanshow = !heibanshow;
358
                 heibanshow = !heibanshow;
340
 
359
 
341
                 #region 关闭冲突页面
360
                 #region 关闭冲突页面
342
-
343
-                //CloseOrHideWindowPage();
344
-
361
+                CloseOrHideWindowPage();
345
                 #endregion 关闭冲突页面
362
                 #endregion 关闭冲突页面
346
 
363
 
347
                 List<DependencyObject> list = new List<DependencyObject>
364
                 List<DependencyObject> list = new List<DependencyObject>
693
             if (txbName.Visibility == Visibility.Visible)
710
             if (txbName.Visibility == Visibility.Visible)
694
             {
711
             {
695
                 txbName.Visibility = Visibility.Collapsed;
712
                 txbName.Visibility = Visibility.Collapsed;
696
-                //if ("正在共享".Equals(pageData.menuList[1].Name))
697
-                //{
698
-                //    gridAnimated.Visibility = Visibility.Collapsed;
699
-                //}
700
             }
713
             }
701
             else
714
             else
702
             {
715
             {
703
                 txbName.Visibility = Visibility.Visible;
716
                 txbName.Visibility = Visibility.Visible;
704
-                //if("正在共享".Equals(pageData.menuList[1].Name))
705
-                //{
706
-                //    gridAnimated.Visibility = Visibility.Visible;
707
-                //}
708
             }
717
             }
709
 
718
 
710
             Storyboard story = new Storyboard();
719
             Storyboard story = new Storyboard();
712
             if (toolShow)
721
             if (toolShow)
713
             {
722
             {
714
                 da.From = 0;
723
                 da.From = 0;
715
-                da.To = 670;
724
+                da.To = 450;
716
             }
725
             }
717
             else
726
             else
718
             {
727
             {
719
-                da.From = 670;
728
+                da.From = 450;
720
                 da.To = 0.0;
729
                 da.To = 0.0;
721
             }
730
             }
722
 
731
 
767
 
776
 
768
         private void Window_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
777
         private void Window_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
769
         {
778
         {
770
-
779
+            time = NumUtil.unixTime();
771
         }
780
         }
772
         private int time = NumUtil.unixTime();
781
         private int time = NumUtil.unixTime();
773
         private void Rectangle_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
782
         private void Rectangle_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
819
         {
828
         {
820
             WSocketClient.getInstance().StartWsClient();
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
         #endregion
875
         #endregion
876
+
823
         #region 直播
877
         #region 直播
824
         /// <summary>
878
         /// <summary>
825
         /// 直播间节点和房号
879
         /// 直播间节点和房号
870
     public class ToolbarModel : NotifyModel
924
     public class ToolbarModel : NotifyModel
871
     {
925
     {
872
         public ObservableCollection<ToolbarMenu> menuList { get; set; }
926
         public ObservableCollection<ToolbarMenu> menuList { get; set; }
873
-
874
         internal bool _tongping = false;
927
         internal bool _tongping = false;
875
-
876
         public bool tongping
928
         public bool tongping
877
         {
929
         {
878
             get => _tongping;
930
             get => _tongping;
879
             set { _tongping = value; OnPropertyChanged("tongping"); }
931
             set { _tongping = value; OnPropertyChanged("tongping"); }
880
         }
932
         }
881
-
882
         internal bool _IsOpen = true;
933
         internal bool _IsOpen = true;
883
-
884
         public bool IsOpen
934
         public bool IsOpen
885
         {
935
         {
886
             get => _IsOpen;
936
             get => _IsOpen;
887
             set { _IsOpen = value; OnPropertyChanged("IsOpen"); }
937
             set { _IsOpen = value; OnPropertyChanged("IsOpen"); }
888
         }
938
         }
889
-
890
         public ToolbarModel()
939
         public ToolbarModel()
891
         {
940
         {
892
             menuList = new ObservableCollection<ToolbarMenu>();
941
             menuList = new ObservableCollection<ToolbarMenu>();

+ 64
- 29
XHZB.Desktop/UserCenterWindow.xaml.cs View File

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

+ 37
- 6
XHZB.Desktop/WebSocket/WSocketClient.cs View File

40
         /// 检查重连线程
40
         /// 检查重连线程
41
         /// </summary>
41
         /// </summary>
42
         Thread _thread;
42
         Thread _thread;
43
+        /// <summary>
44
+        /// 心跳
45
+        /// </summary>
46
+        Thread thread;
43
         bool _isRunning = true;
47
         bool _isRunning = true;
44
         /// <summary>
48
         /// <summary>
45
         /// WebSocket连接地址
49
         /// WebSocket连接地址
99
                 this._isRunning = true;
103
                 this._isRunning = true;
100
                 this._thread = new Thread(new ThreadStart(CheckConnection));
104
                 this._thread = new Thread(new ThreadStart(CheckConnection));
101
                 this._thread.Start();
105
                 this._thread.Start();
106
+
107
+
108
+                thread = new Thread(new ThreadStart(Heartbeat));
109
+                thread.Start();
102
             }
110
             }
103
             catch (Exception ex)
111
             catch (Exception ex)
104
             {
112
             {
340
             System.Threading.Thread.Sleep(5000);
348
             System.Threading.Thread.Sleep(5000);
341
         } while (this._isRunning);
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
         Task.Factory.StartNew(() =>
382
         Task.Factory.StartNew(() =>
352
         {
383
         {

Loading…
Cancel
Save