// AddMessage adds a new message to the desired datasource. It removes the first placeholder message if present, // and it adds the message to the list in the datasource. It then reloads the tableview and it scrolls it to // the last message. public static void AddMessage(Message message, ChatListDataSource dataSource, NSTableView chatList) { if (dataSource.Messages.Count > 0 && dataSource.Messages[0].content.Contains("No messages yet")) { dataSource.Messages.RemoveAt(0); } dataSource.Messages.Add(message); chatList.ReloadData(); chatList.ScrollRowToVisible(dataSource.Messages.Count - 1); }
// UpdateBufferSize updates the buffer size and adds an info message to the chatlist. public static int UpdateBufferSize(string enteredBufferSizeString, string name, ChatListDataSource chatListDataSource, NSTableView chatList) { try { var enteredBufferSize = Validation.ValidateBufferSize(enteredBufferSizeString); var message = new Message(MessageType.Info, name, $"The buffer size was changed to {enteredBufferSize}.", DateTime.Now); UI.AddMessage(message, chatListDataSource, chatList); return(enteredBufferSize); } catch (InvalidInputException e) { UI.ShowAlert(e.Title, e.Message); return(0); } }
public ChatListDelegate(ChatListDataSource dataSource) { _dataSource = dataSource; }