Exemplo 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;
 }
Exemplo 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");
        }
Exemplo n.º 3
0
        protected override void SetNoticeList()
        {
            if (string.IsNullOrEmpty(SubAttr))
            {
                NoticeList.Add("SubAttr is not set.");
            }

            //var key = CurrentContext.CacheParameters["key"];
        }
Exemplo n.º 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         NoticeList.DataSource = new DAL.DNotice().GetFirstSix();
         NoticeList.DataBind();
         ArticleList.DataSource = new DAL.DArticle().GetFirstSeven();
         ArticleList.DataBind();
     }
 }
Exemplo n.º 5
0
 public void ChangeCourse(string courseId)
 {
     if (courseId == CourseId)
     {
         return;
     }
     CourseId   = courseId;
     Course     = (Model.GetCourseList()).Find(c => c.Id == courseId);
     CourseName = Course.Name;
     NoticeList.Clear();
     NoticeListLoaded = false;
     FileList.Clear();
     FileListLoaded = false;
     WorkList.Clear();
     WorkListLoaded = false;
     UpdateNumbers();
     RaisePropertyChanged("CourseName");
 }
Exemplo n.º 6
0
        public MainWindow()
        {
            PerMsg  p1 = new PerMsg("wang", "ceshi");
            PerMsg  p2 = new PerMsg("wang", "ceshi");
            PerMsg  p3 = new PerMsg("wang", "ceshi");
            MsgList m1 = new MsgList();

            m1.Add(p1);
            m1.Add(p2);
            m1.Add(p3);

            PerMsg  p4 = new PerMsg("ming", "ceshi");
            PerMsg  p5 = new PerMsg("ming", "ceshi");
            PerMsg  p6 = new PerMsg("ming", "ceshi");
            MsgList m2 = new MsgList();

            m2.Add(p4);
            m2.Add(p5);
            m2.Add(p6);

            PerMsg  p7 = new PerMsg("gao", "ceshi");
            PerMsg  p8 = new PerMsg("gao", "ceshi");
            PerMsg  p9 = new PerMsg("gao", "ceshi");
            MsgList m3 = new MsgList();

            m3.Add(p7);
            m3.Add(p8);
            m3.Add(p9);


            friends = new FriendList
            {
                new Friend {
                    UserId = "1234", UserName = "******", IP = "192.168.1.1", status = Status.Online
                },
                new Friend {
                    UserId = "2345", UserName = "******", IP = "192,168.1.2", status = Status.Online
                },
                new Friend {
                    UserId = "3456", UserName = "******", IP = "192.168.1.3", status = Status.Offline
                }
            };

            chats = new ChatList
            {
                //new Chat{SenderId = "1234", sName="wang", ReceiverId = "1111", Content = "测试测试测试测试测试测试", Msgs = m1, WaitReads = 3},
                //new Chat{SenderId = "2345", sName="ming", ReceiverId = "1111", Content = "测试测试测试测试测试", Msgs = m2,WaitReads = 3},
                //new Chat{SenderId = "3456", sName="gao", ReceiverId = "1111", Content= "测试测试测试测试", Msgs = m3,WaitReads = 3}
                new Chat("1234", "wang", "1111", "测试测试测试测试测试测试", m1, 0),
                new Chat("2345", "ming", "1111", "测试测试测试测试测试", m2, 0),
                new Chat("3456", "gao", "1111", "测试测试测试测试", m3, 0),
            };
            notices = new NoticeList
            {
                new Notice {
                    UserId = "5678"
                },
                new Notice {
                    UserId = "4567"
                }
            };
            model = new ChatViewModel {
                AllChatWaitReads = 0, AllFriendWaitReads = 0, AllNoticeWaitReads = 0
            };

            InitializeComponent();
            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);
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
0
 private static void InitCache()
 {
     NoticeList        = GetNotices();
     NoticeList_Active = NoticeList.FindAll(delegate(Notice n) { return(n.IsActive.Equals(1)); });
 }
Exemplo n.º 9
0
 public static Notice Load(string nID)
 {
     return(NoticeList.Find(delegate(Notice n) { return n.NoticeID.Equals(nID); }));
     //return VesselPlansList.Find(vp => vp.ID.Equals(vpID));
 }