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; }
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; }
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; }
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); }
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); }
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))); }
public void UpdateMessage(object textObject, Message message, User user) { throw new System.NotImplementedException(); }
public CurrentUserInformationReceivedMessage(User user) { User = user; }
public CampfireApiFake() { _meUser = new User() {Id = 42, Name = "Me"}; _users.Add(_meUser); }
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))); }
private void FormatAdvertisementMessage(Message message, User user, Paragraph paragraph) { user = new User {Name = "Advertisement"}; FormatUserMessage(message, user, paragraph); }
private static void RenderUserString(User user, Paragraph paragraph) { var name = FormatUserName(user); var item = new Run("<" + name + "> "); paragraph.Inlines.Add(item); }
private static string FormatUserName(User user) { var name = user != null ? user.Name : "<unknown>"; return name; }
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); }
public NotificationMessage(IRoom room, User user, Message message) { Room = room; User = user; Message = message; }
public MessageEntry(Message message, User user) { Message = message; User = user; }
public UserViewModel(User user) { _user = user; }
private void FormatLeaveMessage(Message message, User user, Paragraph paragraph) { var name = FormatUserName(user); paragraph.Inlines.Add(CreateMetaRun(String.Format("{0} left the room", name))); }
public User AddUser(string name) { var user = new User {Name = name, Id = _users.Max(u => u.Id) + 1}; _users.Add(user); return user; }
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; }
public UserInfoReceivedMessage(User user) { User = user; }
private void FormatTimestampMessage(Message message, User user, Paragraph paragraph) { var run = CreateMetaRun(message.CreatedAt.ToLocalTime().ToString()); paragraph.Inlines.Add(run); }