Ejemplo n.º 1
0
 public void AddNotice(Notice notice)
 {
     NoticeList.Add(notice);
     Console.ForegroundColor = ConsoleColor.Blue;
     Console.WriteLine("*** Notice added: " + notice.Name + " ***");
     Console.ForegroundColor = ConsoleColor.Gray;
 }
Ejemplo n.º 2
0
        public async Task PrepareNoticeList()
        {
            if (NoticeListLoaded)
            {
                return;
            }
            List <Notice> list = Model.GetNoticeList(CourseId);

            NoticeList.Clear();
            foreach (Notice notice in list)
            {
                NoticeList.Add(new NoticeVM(notice));
            }

            string id = CourseId;

            if (await Model.RefNoticeList(CourseId) == MainModel.UpdateResult.Success)
            {
                if (id == CourseId)
                {
                    NoticeList.Clear();
                    foreach (Notice notice in list)
                    {
                        NoticeList.Add(new NoticeVM(notice));
                    }
                }
            }
            NoticeListLoaded = true;
            RaisePropertyChanged("NoticeList");
        }
Ejemplo n.º 3
0
 private void btnNoticeAddOne_Click(object sender, RoutedEventArgs e)
 {
     //ellNotice.Visibility = (ellNotice.Visibility == Visibility.Collapsed) ? Visibility.Visible : Visibility.Visible;
     model.AllNoticeWaitReads += 1;
     notices.Add(new Notice {
         UserId = "7777"
     });
 }
Ejemplo n.º 4
0
        protected override void SetNoticeList()
        {
            if (string.IsNullOrEmpty(SubAttr))
            {
                NoticeList.Add("SubAttr is not set.");
            }

            //var key = CurrentContext.CacheParameters["key"];
        }
Ejemplo n.º 5
0
        //好友确认回调
        private void AddComfimCallback(object sender, AddConfirm e)
        {
            this.model.AllNoticeWaitReads += 1; //通知数加一
            Notice notice = new Notice {
                UserId = e.UserId, UserName = e.UserName, status = Status.Waiting
            };

            notices.Add(notice);
        }
Ejemplo n.º 6
0
        public ClientWindow(TCPHelper helper, List <User> users, List <TalkContract> talks, List <AddFriend> addFriends, string id, string name)
        {
            this.UserName            = name;
            model                    = new ClientViewModel();
            friends                  = new FriendList();
            chats                    = new ChatList();
            notices                  = new NoticeList();
            model.AllNoticeWaitReads = 0;
            model.AllFriendWaitReads = 0;
            model.AllChatWaitReads   = 0;
            #region 数据到视图模型的转换
            foreach (var u in users)
            {
                friends.Add(new Friend {
                    UserId = u.UserId, UserName = u.UserName, IP = u.ip, status = u.IsOnline
                });
            }
            var senders = talks.Select(p => p.SenderId).ToList().Distinct();
            foreach (var s in senders)
            {
                MsgList m       = new MsgList();
                var     records = talks.Where(p => p.SenderId.Equals(s)).Select(q => q).ToList();
                foreach (var r in records)
                {
                    m.Add(new PerMsg
                    {
                        SenderName = talks.Where(p => p.SenderId.Equals(r.SenderId)).Select(q => q.SenderName).FirstOrDefault(),
                        Msg        = r.Content
                    });
                }
                chats.Add(new Chat {
                    SenderId = s, SenderName = talks.Where(p => p.SenderId.Equals(s)).Select(p => p.SenderName).FirstOrDefault(), ReceiverId = talks.Where(x => x.SenderId.Equals(s)).Select(y => y.ReceiverId).FirstOrDefault(), Msgs = m, WaitReadNum = m.Count
                });
            }
            foreach (var n in addFriends)
            {
                notices.Add(new Notice {
                    UserId = n.UserId, UserName = "******", status = Status.Waiting
                });
            }

            foreach (var c in chats)
            {
                model.AllChatWaitReads += c.WaitReadNum;
            }
            model.AllNoticeWaitReads = notices.Count();
            #endregion

            this.LocalId = id;

            InitializeComponent();
            this.Closing += ClientWindow_Closing;
            CC.DataHandle.UpdateFriendHandler += DataHandle_UpdateFriendHandler;
            CC.DataHandle.SearchHandler       += SearchCallBack;
            CC.DataHandle.AddComfirmHandler   += AddComfimCallback;
            CC.DataHandle.RemoveFriendHandler += DataHandle_RemoveFriendHandler;
            CC.DataHandle.GetMsgHandler       += GetMsgHandler;
            WindowStartupLocation              = WindowStartupLocation.CenterScreen;
            this.lblID.Content = LocalId;
            this.helper        = helper;
            //绑定关联数据

            this.tabMain.DataContext = model;
            this.gChat.DataContext   = chats;
            this.gFriend.DataContext = friends;
            this.gNotice.DataContext = notices;

            this.listChat.AddHandler(UIElement.MouseDownEvent, new MouseButtonEventHandler(listChat_MouseLeftButtonDown), true);
            this.listChat.AddHandler(UIElement.MouseDownEvent, new MouseButtonEventHandler(listChat_MouseRightButtonDown), true);
            this.listNotice.AddHandler(UIElement.MouseDownEvent, new MouseButtonEventHandler(listNotice_MouseLeftButtonDown), true);
        }