示例#1
0
        public object AddMessage(Message message, User user, object textObject)
        {
            var entry = new MessageEntry(message, user);

            var afterEntry = textObject as MessageEntry;
            if (afterEntry != null)
            {
                var index = _messages.IndexOf(afterEntry);
                _messages.Insert(index, entry);
            }
            else
            {
                _messages.Add(entry);
            }
            return entry;
        }
示例#2
0
        public object AddMessage(Message message, User user, object textObject)
        {
            Action<Message, User, Paragraph> handler;
            if (!_handlers.TryGetValue(message.Type, out handler))
            {
                return null;
            }
            var paragraph = new Paragraph {Margin = new Thickness(0)};
            handler(message, user, paragraph);

            var after = textObject as Paragraph;
            if (after != null)
            {
                Blocks.InsertAfter(after, paragraph);
            }
            else
            {
                Blocks.Add(paragraph);
            }

            return paragraph;
        }
示例#3
0
        private void FormatUserMessage(Message message, User user, Paragraph paragraph)
        {
            if (message.Body.StartsWith("/me", StringComparison.InvariantCultureIgnoreCase))
            {
                paragraph.Inlines.Add(RenderUserMessage(user.Name + message.Body.Substring("/me".Length)));

                paragraph.FontStyle = FontStyles.Italic;
            }
            else
            {
                RenderUserString(user, paragraph);
                var inline = RenderUserMessage(message.Body);
                paragraph.Inlines.Add(inline);
            }

            paragraph.BorderThickness = new Thickness(0, 0, 0, 0.2);
            paragraph.BorderBrush = Brushes.LightGray;
        }
示例#4
0
        private void FormatUploadMessage(Message msg, User user, Paragraph paragraph)
        {
            var vm = _factory.Create(msg);
            var view = _factory.Create(vm);

            RenderUserString(user, paragraph);
            paragraph.Inlines.Add(new LineBreak());

            paragraph.Inlines.Add(view.Element);
        }
示例#5
0
        private void FormatTweetMessage(Message msg, User user, Paragraph paragraph)
        {
            if (msg.Tweet != null)
            {
                var bodyInline = RenderUserMessage(msg.Tweet.Message);

                var tweetView = new InlineTweetView(bodyInline, msg.Tweet);

                paragraph.Inlines.Add(FormatUserName(user) + ":" + Environment.NewLine);
                paragraph.Inlines.Add(tweetView);
                return;
            }

            // fallback
            FormatUserMessage(msg, user, paragraph);
        }
示例#6
0
 private void FormatTopicChangeMessage(Message message, User user, Paragraph paragraph)
 {
     var name = FormatUserName(user);
     paragraph.Inlines.Add(CreateMetaRun(String.Format("{0} changed the topic to '{1}'", name, message.Body)));
 }
示例#7
0
 public void UpdateMessage(object textObject, Message message, User user)
 {
     throw new System.NotImplementedException();
 }
示例#8
0
 public CurrentUserInformationReceivedMessage(User user)
 {
     User = user;
 }
示例#9
0
 public CampfireApiFake()
 {
     _meUser = new User() {Id = 42, Name = "Me"};
     _users.Add(_meUser);
 }
示例#10
0
 private void FormatKickMessage(Message message, User user, Paragraph paragraph)
 {
     var name = FormatUserName(user);
     paragraph.Inlines.Add(CreateMetaRun(String.Format("{0} was kicked from the room", name)));
 }
示例#11
0
 private void FormatAdvertisementMessage(Message message, User user, Paragraph paragraph)
 {
     user = new User {Name = "Advertisement"};
     FormatUserMessage(message, user, paragraph);
 }
示例#12
0
        private static void RenderUserString(User user, Paragraph paragraph)
        {
            var name = FormatUserName(user);

            var item = new Run("<" + name + "> ");
            paragraph.Inlines.Add(item);
        }
示例#13
0
 private static string FormatUserName(User user)
 {
     var name = user != null ? user.Name : "<unknown>";
     return name;
 }
示例#14
0
        public void UpdateMessage(object textObject, Message message, User user)
        {
            var paragraph = textObject as Paragraph;
            if (paragraph == null)
            {
                throw new InvalidOperationException("Invalid object passed in");
            }

            Action<Message, User, Paragraph> handler;
            if (!_handlers.TryGetValue(message.Type, out handler))
            {
                return;
            }
            paragraph.Inlines.Clear();
            handler(message, user, paragraph);
        }
示例#15
0
 public NotificationMessage(IRoom room, User user, Message message)
 {
     Room = room;
     User = user;
     Message = message;
 }
示例#16
0
 public MessageEntry(Message message, User user)
 {
     Message = message;
     User = user;
 }
示例#17
0
 public UserViewModel(User user)
 {
     _user = user;
 }
示例#18
0
 private void FormatLeaveMessage(Message message, User user, Paragraph paragraph)
 {
     var name = FormatUserName(user);
     paragraph.Inlines.Add(CreateMetaRun(String.Format("{0} left the room", name)));
 }
示例#19
0
 public User AddUser(string name)
 {
     var user = new User {Name = name, Id = _users.Max(u => u.Id) + 1};
     _users.Add(user);
     return user;
 }
示例#20
0
        private void FormatPasteMessage(Message message, User user, Paragraph paragraph)
        {
            var name = FormatUserName(user);
            paragraph.Inlines.Add(name + ": " + Environment.NewLine);

            var run = RenderUserMessage(message.Body);
            run.FontFamily = new FontFamily("Consolas");
            paragraph.Inlines.Add(run);

            paragraph.BorderThickness = new Thickness(0, 0.5, 0, 0.5);
            paragraph.BorderBrush = Brushes.Black;
            paragraph.Margin = new Thickness(0, 1, 0, 6);
            paragraph.Padding = new Thickness(0, 1, 0, 6);
            paragraph.Background = Brushes.LightGoldenrodYellow;
        }
示例#21
0
 public UserInfoReceivedMessage(User user)
 {
     User = user;
 }
示例#22
0
 private void FormatTimestampMessage(Message message, User user, Paragraph paragraph)
 {
     var run = CreateMetaRun(message.CreatedAt.ToLocalTime().ToString());
     paragraph.Inlines.Add(run);
 }