private Color? GetThreadColor(Message msg) { if(msg.MessageContent == null || msg.MessageContent.Title == null) { return null; } if (!_threadColors.ContainsKey(msg.MessageContent.Title)) { Color newColor = Color.FromArgb(255, (byte)rand.Next(5, 256), (byte)rand.Next(5, 256), (byte)rand.Next(5, 256)); _threadColors[msg.MessageContent.Title] = newColor; } var color = _threadColors[msg.MessageContent.Title]; return color; }
private void EditMessage(Message msg) { if (_messages == null) { return; } var existingMsg = _messages.FirstOrDefault(m => m.Id == msg.MessageContent.Message); if (existingMsg != null) { existingMsg.Body = msg.MessageContent.UpdatedContent; existingMsg.WasEdited = true; } }
private Color?GetThreadColor(Message msg) { if (msg.MessageContent == null || msg.MessageContent.Title == null) { return(null); } if (!_threadColors.ContainsKey(msg.MessageContent.Title)) { Color newColor = Color.FromArgb(255, (byte)rand.Next(5, 256), (byte)rand.Next(5, 256), (byte)rand.Next(5, 256)); _threadColors[msg.MessageContent.Title] = newColor; } var color = _threadColors[msg.MessageContent.Title]; return(color); }
public void Constructor_passes_message_properties_through() { var content = "a message"; var message = new Message { Event = "message", Sent = 55555, Id = 123, User = 44 }; message.Content = content; var viewModel = new MessageViewModel(message, "some flow id", null, new NavigationManagerMoqaLate()); Assert.AreEqual(message.ExtractedBody, viewModel.Body); Assert.AreEqual(content, viewModel.Body); Assert.AreEqual(message.Id, viewModel.Id); Assert.AreEqual(message.TimeStamp, viewModel.TimeStamp); Assert.AreEqual(message.User, viewModel.UserId); }
private void OnMessageReceived(Message msg) { UIThread.Invoke(() => { if (msg.Displayable) { var viewModel = new MessageViewModel(msg, FlowId, GetThreadColor(msg), _navigationManager); FindAvatar(viewModel); Messages.Add(viewModel); // TODO: this is very inefficient AssignThreadStartersTheirColor(); } else if (msg.Event == "message-edit") { EditMessage(msg); } }); }
public MessageViewModel(Message message, string flowId, Color?threadColor, INavigationManager navigationManager) { _message = message.ThrowIfNull("message"); _threadColor = threadColor; _goToMessageThreadCommand = new GoToMessageThreadCommand(flowId, navigationManager); }
public void BeforeEach() { _message = new Message(); _viewModel = new MessageViewModel(_message, "some flow id", null, new NavigationManagerMoqaLate()); }
public MessageViewModel(Message message, string flowId, Color? threadColor, INavigationManager navigationManager) { _message = message.ThrowIfNull("message"); _threadColor = threadColor; _goToMessageThreadCommand = new GoToMessageThreadCommand(flowId, navigationManager); }