|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413 |
- using Common.system;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Windows;
- using System.Windows.Input;
- using System.Windows.Threading;
- using XHZB.Desktop.Utils;
- using XHZB.Model;
-
- namespace XHZB.Desktop
- {
-
-
-
- public partial class AttendanceWindow : Window
- {
- #region 字段
-
-
-
-
- internal ToolbarAttendenceModel pageData = new ToolbarAttendenceModel();
-
- #endregion 字段
-
- #region 初始化
-
-
-
-
- public AttendanceWindow()
- {
- InitializeComponent();
- WindowStartupLocation = WindowStartupLocation.CenterScreen;
-
- Initialize();
- }
-
-
-
-
- public void Initialize()
- {
-
-
-
-
-
-
-
-
-
- pageData = new ToolbarAttendenceModel();
- int onlineUsersnum = APP.ClassStudentList.Count;
- txbTotalPeople.Text = onlineUsersnum.ToString();
- renderView();
-
-
-
-
-
- DataContext = pageData;
- }
-
- private void Window_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
- {
- DragMove();
- }
-
- public void receiveWsMsg(ZWsMsgVo msg)
- {
- }
-
- public void userListChange()
- {
- Console.WriteLine("抢答点名-渲染用户列表");
- Dispatcher.BeginInvoke(DispatcherPriority.Normal,
- new Action(() =>
- {
- renderView();
- }));
- }
-
- #endregion 初始化
-
- #region 事件
-
-
-
-
-
-
- private void btnEnd_Click(object sender, RoutedEventArgs e)
- {
- if (pageData.menuList.Count > 0)
- {
- pageData.menuList.Clear();
- }
-
-
- Hide();
- FreeMemoryHelper.ReallocateMemory();
- System.Threading.Thread.Sleep(0);
- }
-
- #endregion 事件
-
- private void renderView()
- {
-
- if (pageData.menuList.Count > 0)
- {
- pageData.menuList.Clear();
- }
- if (APP.OnlineUserList.Count > 0)
- {
- var userList = APP.OnlineUserList.ToArray();
-
- string userlistStr = JsonHelper.ToJson(userList);
- List<OnlineUserModel> userListNew = ZCache.JsonToList<OnlineUserModel>(userlistStr);
-
- List<ClassStudentListModel> classStudentList = APP.ClassStudentList;
-
-
-
-
-
- for (int i = 0; i < classStudentList.Count; i++)
- {
- classStudentList[i].status = 0;
- }
-
-
-
-
-
-
-
- foreach (OnlineUserModel user in userListNew)
- {
- if (user != null)
- {
-
-
- string userHeadPic;
- if (user.userpic != null)
- {
- userHeadPic = user.userpic;
- if (ZCache.headDic.ContainsKey(userHeadPic.Replace("/", "")))
- {
- string localpath = ZCache.headDic[userHeadPic.Replace("/", "")];
- userHeadPic = localpath;
- }
- else
- {
- userHeadPic = "../Images/RollCall/attendance_1.png";
- }
- }
- else
- {
- userHeadPic = "../Images/RollCall/attendance_1.png";
- }
- pageData.menuList.Add(new ToolbarAttendenceMenu()
- {
- Name = user.username,
- Pic = userHeadPic
- });
- foreach (ClassStudentListModel cl in classStudentList)
- {
- if (cl.studentid == user.userid)
- {
- cl.status = 1;
- }
- }
- }
- }
- string notOnline = string.Empty;
- foreach (ClassStudentListModel cl in classStudentList)
- {
- if (cl.status == 0)
- {
- notOnline += cl.studentname + " ";
- }
- }
- if (!string.IsNullOrWhiteSpace(notOnline))
- {
- txbNotOnline.Text = notOnline;
- }
- else
- {
- txbNotOnline.Text = "暂无";
- }
- txbOnlineUsers.Text = userListNew.Count.ToString();
-
-
- userList = null;
- userlistStr = null;
- userListNew = null;
- classStudentList = null;
- }
- else
- {
- List<ClassStudentListModel> classStudentList = APP.ClassStudentList;
-
-
- for (int i = 0; i < classStudentList.Count; i++)
- {
- classStudentList[i].status = 0;
- }
- string notOnline = string.Empty;
- foreach (ClassStudentListModel cl in classStudentList)
- {
- if (cl.status == 0)
- {
- notOnline += cl.studentname + " ";
- }
- }
- if (!string.IsNullOrWhiteSpace(notOnline))
- {
- txbNotOnline.Text = notOnline;
- }
- else
- {
- txbNotOnline.Text = "暂无";
- }
- txbOnlineUsers.Text = APP.OnlineUserList.Count.ToString();
- }
-
- }
-
- private void Window_Loaded(object sender, RoutedEventArgs e)
- {
- }
-
- private void Window_Unloaded(object sender, RoutedEventArgs e)
- {
-
- }
-
- private void Window_Closed(object sender, EventArgs e)
- {
- }
-
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
- protected virtual void Dispose(bool disposing)
- {
- if (!m_disposed)
- {
- if (disposing)
- {
-
- }
-
- m_disposed = true;
- }
- }
-
-
- ~AttendanceWindow()
- {
- Dispose(false);
- }
-
- private bool m_disposed;
-
-
-
-
-
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- try
- {
- if (gridImg.Visibility == Visibility.Visible)
- {
- gridImg.Visibility = Visibility.Collapsed;
- }
- else
- {
- gridImg.Visibility = Visibility.Visible;
- }
- }
- catch (Exception ex)
- {
-
- LogHelper.WriteErrLog("【AttendanceWindow】" + ex.Message, ex);
- }
-
- }
-
-
-
-
-
- public string GetFileAbsolutePath(string Path = "")
- {
- try
- {
- if (!string.IsNullOrWhiteSpace(Path))
- {
- Path = Path.Replace("\\", "/");
- if (Path != "/")
- {
- if (Path.Substring(1, 1) == ":")
- return Path;
- if (Path.Substring(0, 1) != "/")
- Path = "/" + Path;
- }
- }
- string AbsolutePath = System.Windows.Forms.Application.StartupPath.ToString().Replace("\\", "/") + Path;
- return AbsolutePath;
- }
- catch (Exception)
- {
- return Path;
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
-
- #region 动态数据集合
-
- public class ToolbarAttendenceModel : NotifyModel
- {
- public ObservableCollection<ToolbarAttendenceMenu> menuList { get; set; }
-
- public ToolbarAttendenceModel()
- {
- menuList = new ObservableCollection<ToolbarAttendenceMenu>();
- }
- }
-
- public class ToolbarAttendenceMenu : NotifyModel, IComparable<ToolbarAttendenceMenu>
- {
-
-
-
- public string Name { get; set; }
-
-
-
-
- public string Pic { get; set; }
-
- public int CompareTo(ToolbarAttendenceMenu other)
- {
- return string.Compare(Name, other.Name, true);
- }
- }
-
- #endregion 动态数据集合
- }
|