private ChatItem CreateTextMessage(ChatroomTextMessage message, RadChat chat)
        {
            TextMessage textMessage = new TextMessage();

            textMessage.Data   = message;
            textMessage.Author = this.AuthorsMap.GetOrCreateAuthor(message.Sender);
            textMessage.SetBinding(TextMessage.TextProperty, new Binding {
                Path = nameof(message.Message), Source = message, Converter = this.emojiConverter
            });

            return(textMessage);
        }
        private void AddHistory()
        {
            for (int i = 0; i < 20; i++)
            {
                ChatroomTextMessage message = new ChatroomTextMessage();
                message.Sender  = i % 9 == 0 ? this.user : this.chatroomService.GetRandomParticipant();
                message.Message = ParticipantLines.GetRandomLine();
                this.items.Add(message);
            }

            this.items.Insert(8, new ChatroomTimebreak {
                Text = "2 hours ago"
            });
            this.items.Insert(18, new ChatroomTimebreak {
                Text = "1 hour ago"
            });
        }
        public ChatItem ConvertToChatItem(object dataItem, ChatItemConverterContext context)
        {
            ChatroomTextMessage message = dataItem as ChatroomTextMessage;

            if (message != null)
            {
                return(this.CreateTextMessage(message, context.Chat));
            }

            ChatroomTimebreak timebreak = dataItem as ChatroomTimebreak;

            if (timebreak != null)
            {
                return(this.CreateTimeBreak(timebreak));
            }

            throw new NotSupportedException("Unsupported item type was provided.");
        }