예제 #1
0
        private void RefreshSentMessagePanel(MessageObjects sentobjects)
        {
            MessageSentContainer.Children.Clear();

            foreach (Message item in sentobjects.Messages)
            {
                MessagePanel mp = new MessagePanel();
                mp.TbMessage.Text = item.Body.Plain;
                Reference refer = sentobjects.References.Find(o => o.Id == item.SenderId && o.ObjectType == ObjectType.USER);
                User user = (User)refer.Object;
                mp.TbUserId.Text = user.FullName;
                if (this.Session.Proxy != null)
                {
                    mp.ImgUser.Source = GetMugshotImage(user.MugshotUrl);
                }
                else
                {
                    mp.ImgUser.Source = new BitmapImage(user.MugshotUrl);
                }
                MessageSentContainer.Children.Add(mp);
            }
            MessageSentContainer.Children.Add(new MoreInformationPanel());
        }
예제 #2
0
        private void RefreshAllMessagePanel(MessageObjects allobjects)
        {
            MessageAllContainer.Children.Clear();

            //MessageObjects allobjects = messages.GetAllMessage();
            int i = 0;
            foreach (Message item in allobjects.Messages)
            {
                MessagePanel mp = new MessagePanel();
                mp.TbMessage.Text = item.Body.Plain;
                if (item.RepliedToId != 0)
                {
                    mp.TbReplyTo.Visibility = Visibility.Visible;
                    mp.TbReplyTo.MouseDown += new MouseButtonEventHandler(TbReplyTo_MouseDown);
                    mp.TbReplyTo.DataContext = item.RepliedToId;
                }
                Reference refer = allobjects.References.Find(o => o.Id == item.SenderId && o.ObjectType == ObjectType.USER);
                User user = (User)refer.Object;
                mp.TbUserId.Text = user.FullName;
                if (this.Session.Proxy != null)
                {
                    mp.ImgUser.Source = GetMugshotImage(user.MugshotUrl);
                }
                else
                {
                    mp.ImgUser.Source = new BitmapImage(user.MugshotUrl);
                }
                TimeSpan tp = DateTime.Now - item.CreatedAt;
                if (tp.Days != 0)
                {
                    mp.TbUpdateTime.Text = tp.Days + " days ago";
                }
                else if (tp.Hours != 0)
                {
                    mp.TbUpdateTime.Text = tp.Hours + " hours ago";
                }
                else if (tp.Minutes != 0)
                {
                    mp.TbUpdateTime.Text = tp.Minutes + " minutes ago";
                }
                else
                {
                    mp.TbUpdateTime.Text = tp.Seconds + " seconds ago";
                }

                if (i == 0)
                {
                    this.MostLastestMessageId = item.Id;
                }
                mp.DataContext = item.Id;
                mp.DeleteButton.Click += new RoutedEventHandler(DeleteButton_Click);
                mp.ReplyButton.Click += new RoutedEventHandler(ReplyButton_Click);
                MessageAllContainer.Children.Add(mp);
                i++;
            }
            MessageAllContainer.Children.Add(new MoreInformationPanel());
        }