Browse Source

摄像头页面 考勤页面

ZhangXueYang
zhangxueyang 3 years ago
parent
commit
7d8db80c77

+ 4
- 0
XHZB.Desktop/App.cs View File

@@ -233,6 +233,10 @@ namespace XHZB.Desktop
233 233
         /// 批注
234 234
         /// </summary>
235 235
         public static PracticeWindow W_PracticeWindow = null;
236
+        /// <summary>
237
+        /// 摄像头
238
+        /// </summary>
239
+        public static CameraWindow W_CameraWindow = null;
236 240
         #endregion
237 241
         #endregion
238 242
         /// <summary>

+ 378
- 17
XHZB.Desktop/AttendanceWindow.xaml.cs View File

@@ -1,52 +1,413 @@
1
-using System;
1
+using Common.system;
2
+using System;
2 3
 using System.Collections.Generic;
3
-using System.Linq;
4
-using System.Text;
5
-using System.Threading.Tasks;
4
+using System.Collections.ObjectModel;
6 5
 using System.Windows;
7
-using System.Windows.Controls;
8
-using System.Windows.Data;
9
-using System.Windows.Documents;
10 6
 using System.Windows.Input;
11
-using System.Windows.Media;
12
-using System.Windows.Media.Imaging;
13
-using System.Windows.Shapes;
7
+using System.Windows.Threading;
8
+using XHZB.Desktop.Utils;
9
+using XHZB.Model;
14 10
 
15 11
 namespace XHZB.Desktop
16 12
 {
17 13
     /// <summary>
18
-    /// AttendanceWindow.xaml 的交互逻辑
14
+    /// 考勤统计
19 15
     /// </summary>
20
-    public partial class AttendanceWindow : Window
16
+    public partial class AttendanceWindow : Window/*, ZSocketCallback*/
21 17
     {
18
+        #region 字段
19
+
20
+        /// <summary>
21
+        /// 前台绑定数据源
22
+        /// </summary>
23
+        internal ToolbarAttendenceModel pageData = new ToolbarAttendenceModel();
24
+
25
+        #endregion 字段
26
+
27
+        #region 初始化
28
+
29
+        /// <summary>
30
+        /// 考勤统计
31
+        /// </summary>
22 32
         public AttendanceWindow()
23 33
         {
24 34
             InitializeComponent();
35
+            WindowStartupLocation = WindowStartupLocation.CenterScreen;
36
+
37
+            Initialize();
25 38
         }
26 39
 
27
-        private void Window_Closed(object sender, EventArgs e)
40
+        /// <summary>
41
+        /// 初始化 修改人:赵耀 修改时间:2020年8月11日
42
+        /// </summary>
43
+        public void Initialize()
28 44
         {
45
+            //try
46
+            //{
47
+            //    GetAddressIP();
48
+            //}
49
+            //catch (Exception ex)
50
+            //{
29 51
 
52
+            //    LogHelper.WriteErrLog("【AttendanceWindow】(Initialize)" + ex.Message, ex);
53
+            //}
54
+            pageData = new ToolbarAttendenceModel();
55
+            int onlineUsersnum = APP.ClassStudentList.Count;
56
+            txbTotalPeople.Text = onlineUsersnum.ToString();
57
+            renderView();
58
+            //ZSocketServer.getInstance().addWin(this);
59
+            //if (gridImg.Visibility == Visibility.Visible)
60
+            //{
61
+            //    gridImg.Visibility = Visibility.Collapsed;
62
+            //}
63
+            DataContext = pageData;
30 64
         }
31 65
 
32
-        private void Window_Loaded(object sender, RoutedEventArgs e)
66
+        private void Window_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
33 67
         {
34
-
68
+            DragMove();
35 69
         }
36 70
 
37
-        private void Window_Unloaded(object sender, RoutedEventArgs e)
71
+        public void receiveWsMsg(ZWsMsgVo msg)
38 72
         {
73
+        }
39 74
 
75
+        public void userListChange()
76
+        {
77
+            Console.WriteLine("抢答点名-渲染用户列表");
78
+            Dispatcher.BeginInvoke(DispatcherPriority.Normal,
79
+               new Action(() =>
80
+               {
81
+                   renderView();
82
+               }));
40 83
         }
41 84
 
85
+        #endregion 初始化
86
+
87
+        #region 事件
88
+
89
+        /// <summary>
90
+        /// 结束
91
+        /// </summary>
92
+        /// <param name="sender"></param>
93
+        /// <param name="e"></param>
42 94
         private void btnEnd_Click(object sender, RoutedEventArgs e)
43 95
         {
96
+            if (pageData.menuList.Count > 0)
97
+            {
98
+                pageData.menuList.Clear();
99
+            }
100
+
101
+            //ToolbarWindow.IsOpenAttendanceWindow = false;
44 102
             Hide();
103
+            FreeMemoryHelper.ReallocateMemory();
104
+            System.Threading.Thread.Sleep(0);
45 105
         }
46 106
 
47
-        private void Window_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
107
+        #endregion 事件
108
+
109
+        private void renderView()
110
+        {
111
+
112
+            if (pageData.menuList.Count > 0)
113
+            {
114
+                pageData.menuList.Clear();
115
+            }
116
+            if (APP.OnlineUserList.Count > 0)
117
+            {
118
+                var userList = APP.OnlineUserList.ToArray();
119
+
120
+                string userlistStr = JsonHelper.ToJson(userList);
121
+                List<OnlineUserModel> userListNew = ZCache.JsonToList<OnlineUserModel>(userlistStr);
122
+
123
+                List<ClassStudentListModel> classStudentList = APP.ClassStudentList;
124
+       
125
+                //if (APP.outputInforLog)
126
+                //{//OrderbyDescending  倒叙    OrderBy 顺序
127
+                //    userListNew = userListNew.OrderBy(x => x.userid).ToList();
128
+                //}
129
+                for (int i = 0; i < classStudentList.Count; i++)
130
+                {
131
+                    classStudentList[i].status = 0;
132
+                }
133
+
134
+
135
+                //if (userListNew.Count > 1)
136
+                //{
137
+                //    userListNew[1] = null;
138
+                //}
139
+                //userListNew[0] = null;
140
+                foreach (OnlineUserModel user in userListNew)
141
+                {
142
+                    if (user != null)
143
+                    {
144
+
145
+
146
+                        string userHeadPic;
147
+                        if (user.userpic != null)
148
+                        {
149
+                            userHeadPic = user.userpic;
150
+                            if (ZCache.headDic.ContainsKey(userHeadPic.Replace("/", "")))
151
+                            {
152
+                                string localpath = ZCache.headDic[userHeadPic.Replace("/", "")];
153
+                                userHeadPic = localpath;
154
+                            }
155
+                            else
156
+                            {
157
+                                userHeadPic = "../Images/RollCall/attendance_1.png";
158
+                            }
159
+                        }
160
+                        else
161
+                        {
162
+                            userHeadPic = "../Images/RollCall/attendance_1.png";
163
+                        }
164
+                        pageData.menuList.Add(new ToolbarAttendenceMenu()
165
+                        {
166
+                            Name = user.username,
167
+                            Pic = userHeadPic
168
+                        });
169
+                        foreach (ClassStudentListModel cl in classStudentList)
170
+                        {
171
+                            if (cl.studentid == user.userid)
172
+                            {
173
+                                cl.status = 1;
174
+                            }
175
+                        }
176
+                    }
177
+                }
178
+                string notOnline = string.Empty;
179
+                foreach (ClassStudentListModel cl in classStudentList)
180
+                {
181
+                    if (cl.status == 0)
182
+                    {
183
+                        notOnline += cl.studentname + "   ";
184
+                    }
185
+                }
186
+                if (!string.IsNullOrWhiteSpace(notOnline))
187
+                {
188
+                    txbNotOnline.Text = notOnline;
189
+                }
190
+                else
191
+                {
192
+                    txbNotOnline.Text = "暂无";
193
+                }
194
+                txbOnlineUsers.Text = userListNew.Count.ToString();
195
+
196
+
197
+                userList = null;
198
+                userlistStr = null;
199
+                userListNew = null;
200
+                classStudentList = null;
201
+            }
202
+            else
203
+            {
204
+                List<ClassStudentListModel> classStudentList = APP.ClassStudentList;
205
+                //userListNew.Sort();
206
+
207
+                for (int i = 0; i < classStudentList.Count; i++)
208
+                {
209
+                    classStudentList[i].status = 0;
210
+                }
211
+                string notOnline = string.Empty;
212
+                foreach (ClassStudentListModel cl in classStudentList)
213
+                {
214
+                    if (cl.status == 0)
215
+                    {
216
+                        notOnline += cl.studentname + "   ";
217
+                    }
218
+                }
219
+                if (!string.IsNullOrWhiteSpace(notOnline))
220
+                {
221
+                    txbNotOnline.Text = notOnline;
222
+                }
223
+                else
224
+                {
225
+                    txbNotOnline.Text = "暂无";
226
+                }
227
+                txbOnlineUsers.Text = APP.OnlineUserList.Count.ToString();
228
+            }
229
+
230
+        }
231
+
232
+        private void Window_Loaded(object sender, RoutedEventArgs e)
233
+        {
234
+        }
235
+
236
+        private void Window_Unloaded(object sender, RoutedEventArgs e)
237
+        {
238
+            //ZSocketServer.getInstance().removedWin(this);
239
+        }
240
+
241
+        private void Window_Closed(object sender, EventArgs e)
242
+        {
243
+        }
244
+
245
+        public void Dispose()
246
+        {
247
+            Dispose(true);
248
+            GC.SuppressFinalize(this);
249
+        }
250
+        protected virtual void Dispose(bool disposing)
48 251
         {
252
+            if (!m_disposed)
253
+            {
254
+                if (disposing)
255
+                {
256
+                    //Release managed resources
257
+                }
258
+                //Release unmanaged resources
259
+                m_disposed = true;
260
+            }
261
+        }
49 262
 
263
+        //C#的Finalize()方法
264
+        ~AttendanceWindow()
265
+        {
266
+            Dispose(false);
267
+        }
268
+
269
+        private bool m_disposed;
270
+        /// <summary>
271
+        /// 二维码
272
+        /// </summary>
273
+        /// <param name="sender"></param>
274
+        /// <param name="e"></param>
275
+        private void Button_Click(object sender, RoutedEventArgs e)
276
+        {
277
+            try
278
+            {
279
+                if (gridImg.Visibility == Visibility.Visible)
280
+                {
281
+                    gridImg.Visibility = Visibility.Collapsed;
282
+                }
283
+                else
284
+                {
285
+                    gridImg.Visibility = Visibility.Visible;
286
+                }
287
+            }
288
+            catch (Exception ex)
289
+            {
290
+
291
+                LogHelper.WriteErrLog("【AttendanceWindow】" + ex.Message, ex);
292
+            }
293
+
294
+        }
295
+        /// <summary>
296
+        /// 获取文件的绝对路径
297
+        /// </summary>
298
+        /// <param name="Path">相对路径</param>
299
+        /// <returns></returns>
300
+        public string GetFileAbsolutePath(string Path = "")
301
+        {
302
+            try
303
+            {
304
+                if (!string.IsNullOrWhiteSpace(Path))
305
+                {
306
+                    Path = Path.Replace("\\", "/");
307
+                    if (Path != "/")
308
+                    {
309
+                        if (Path.Substring(1, 1) == ":")
310
+                            return Path;
311
+                        if (Path.Substring(0, 1) != "/")
312
+                            Path = "/" + Path;
313
+                    }
314
+                }
315
+                string AbsolutePath = System.Windows.Forms.Application.StartupPath.ToString().Replace("\\", "/") + Path;
316
+                return AbsolutePath;
317
+            }
318
+            catch (Exception)
319
+            {
320
+                return Path;
321
+            }
322
+        }
323
+        //private void CreateQR(int pixelsPerModule, string info, System.Drawing.Color qrColor, System.Drawing.Color qrBackgroundColor, int iconSizePercent = 15, int iconBorderWidth = 6)
324
+        //{
325
+        //    try
326
+        //    {
327
+        //        gridImg.Visibility = Visibility.Visible;
328
+        //        QRCodeGenerator qrGenerator = new QRCodeGenerator();
329
+        //        QRCodeData qrCodeData = qrGenerator.CreateQrCode(info, QRCodeGenerator.ECCLevel.Q);
330
+        //        QRCode qrCode = new QRCode(qrCodeData);
331
+        //        //Bitmap qrCodeImage = qrCode.GetGraphic(pixelsPerModule, qrColor, qrBackgroundColor, logo, iconSizePercent, iconBorderWidth, true);
332
+        //        Bitmap qrCodeImage = qrCode.GetGraphic(pixelsPerModule, qrColor, qrBackgroundColor, true);
333
+
334
+        //        IntPtr hBitmap = qrCodeImage.GetHbitmap();
335
+        //        ImageSource wpfBitmap = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
336
+        //            hBitmap,
337
+        //            IntPtr.Zero,
338
+        //            Int32Rect.Empty,
339
+        //            BitmapSizeOptions.FromEmptyOptions());
340
+
341
+        //        img.Source = wpfBitmap;
342
+        //    }
343
+        //    catch (Exception ex)
344
+        //    {
345
+        //        LogHelper.WriteErrLog("【AttendanceWindow】(CreateQR)" + ex.Message, ex);
346
+        //    }
347
+
348
+        //}
349
+        //string localIp = string.Empty;
350
+        ///// <summary>
351
+        ///// 获取本地IP地址信息
352
+        ///// </summary>
353
+        //void GetAddressIP()
354
+        //{
355
+        //    try
356
+        //    {
357
+        //        ///获取本地的IP地址
358
+        //        string AddressIP = string.Empty;
359
+        //        foreach (IPAddress _IPAddress in Dns.GetHostEntry(Dns.GetHostName()).AddressList)
360
+        //        {
361
+        //            if (_IPAddress.AddressFamily.ToString() == "InterNetwork")
362
+        //            {
363
+        //                AddressIP = _IPAddress.ToString();
364
+        //            }
365
+        //        }
366
+        //        txtLocalIP.Text = AddressIP + ":10077";
367
+        //        if (!string.IsNullOrWhiteSpace(txtLocalIP.Text) && !txtLocalIP.Text.Equals(localIp))
368
+        //        {
369
+        //            localIp = txtLocalIP.Text;
370
+        //            CreateQR(100, txtLocalIP.Text, System.Drawing.Color.Black, System.Drawing.Color.White);
371
+        //        }
372
+        //    }
373
+        //    catch (Exception ex)
374
+        //    {
375
+
376
+        //        LogHelper.WriteErrLog("【AttendanceWindow】" + ex.Message, ex);
377
+        //    }
378
+
379
+        //}
380
+    }
381
+
382
+    #region 动态数据集合
383
+
384
+    public class ToolbarAttendenceModel : NotifyModel
385
+    {
386
+        public ObservableCollection<ToolbarAttendenceMenu> menuList { get; set; }
387
+
388
+        public ToolbarAttendenceModel()
389
+        {
390
+            menuList = new ObservableCollection<ToolbarAttendenceMenu>();
50 391
         }
51 392
     }
393
+
394
+    public class ToolbarAttendenceMenu : NotifyModel, IComparable<ToolbarAttendenceMenu>
395
+    {
396
+        /// <summary>
397
+        /// 姓名
398
+        /// </summary>
399
+        public string Name { get; set; }
400
+
401
+        /// <summary>
402
+        /// 头像
403
+        /// </summary>
404
+        public string Pic { get; set; }
405
+
406
+        public int CompareTo(ToolbarAttendenceMenu other)
407
+        {
408
+            return string.Compare(Name, other.Name, true);
409
+        }
410
+    }
411
+
412
+    #endregion 动态数据集合
52 413
 }

+ 2
- 1
XHZB.Desktop/CameraWindow.xaml View File

@@ -6,7 +6,8 @@
6 6
         xmlns:local="clr-namespace:XHZB.Desktop" xmlns:wfi="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
7 7
 xmlns:aforge ="clr-namespace:AForge.Controls;assembly=AForge.Controls"
8 8
         mc:Ignorable="d"
9
-        Title="CameraWindow" Height="250" Width="200" >
9
+        Title="CameraWindow" Height="180" Width="220" ResizeMode="NoResize"
10
+    >
10 11
     <Grid>
11 12
         <wfi:WindowsFormsHost Grid.Row="0" Grid.Column="1" x:Name="wfhCamera" Height="124" Width="172" HorizontalAlignment="Right" Margin="0,10,30.10,0" VerticalAlignment="Top">
12 13
             <aforge:VideoSourcePlayer x:Name="player" Height="124" Width="172"  />

+ 0
- 8
XHZB.Desktop/LoginWindow.xaml.cs View File

@@ -71,14 +71,6 @@ namespace XHZB.Desktop
71 71
         {
72 72
             InitializeComponent();
73 73
 
74
-
75
-            CameraWindow cameraWindow = new CameraWindow();
76
-            cameraWindow.Topmost = true;
77
-            cameraWindow.Show();
78
-
79
-
80
-
81
-
82 74
             WindowStartupLocation = WindowStartupLocation.CenterScreen;
83 75
 
84 76
             string typestr = APP.isDebug ? "测试版" : "正式版";

+ 10
- 0
XHZB.Desktop/ToolbarWindow.xaml.cs View File

@@ -145,12 +145,22 @@ namespace XHZB.Desktop
145 145
                     //tongpingBegin();
146 146
                     pageData.menuList[1].Pic = "../Images/ToolBar/img_shared_1.gif";
147 147
                     pageData.menuList[1].Name = "正在直播";
148
+
149
+                    if(APP.W_CameraWindow==null)
150
+                    {
151
+                        APP.W_CameraWindow = new CameraWindow();
152
+                        APP.W_CameraWindow.Topmost = true;
153
+                        APP.W_CameraWindow.Left = pwidth - 300;
154
+                        APP.W_CameraWindow.Top = 0;
155
+                    }
156
+                    APP.W_CameraWindow.Show();
148 157
                 }
149 158
                 else
150 159
                 {
151 160
                     //tongpingEnd();
152 161
                     pageData.menuList[1].Pic = "../Images/ToolBar/直播@2x.png";
153 162
                     pageData.menuList[1].Name = "直播";
163
+                    APP.W_CameraWindow.Hide();
154 164
                 }
155 165
             }
156 166
             else if (clickindex == 2)//抢答点名

+ 12
- 1
XHZB.Desktop/Utils/ZCache.cs View File

@@ -1,5 +1,7 @@
1
-using System;
1
+using Newtonsoft.Json;
2
+using System;
2 3
 using System.Collections.Generic;
4
+using System.IO;
3 5
 using System.Linq;
4 6
 using System.Text;
5 7
 using System.Threading.Tasks;
@@ -9,5 +11,14 @@ namespace XHZB.Desktop.Utils
9 11
     internal class ZCache
10 12
     {
11 13
         public static Dictionary<string, string> headDic = new Dictionary<string, string>();
14
+
15
+        internal static List<T> JsonToList<T>(string respstr)
16
+        {
17
+            JsonSerializer serializer = new JsonSerializer();
18
+            StringReader sr = new StringReader(respstr);
19
+            object o = serializer.Deserialize(new JsonTextReader(sr), typeof(List<T>));
20
+            List<T> list = o as List<T>;
21
+            return list;
22
+        }
12 23
     }
13 24
 }

Loading…
Cancel
Save