protected MessageViewModel(Message message) { this.Message = message; if (message.User != null) this.User = new UserViewModel(message.User); this.ID = message.ID; }
public MessageViewModel BuildFor(Message message) { if (builders.ContainsKey(message.Type)) { return builders[message.Type](message); } return new UnknownMessageViewModel(message); }
public UploadMessageViewModel(Message message) : base(message) { uploadObject = message.Room.GetUploadObject(message.ID); }
private MessageViewModel AddMessageViewModel(Message msg) { MessageViewModel mvm = null; this.dispatcher.Invoke(() => { var messages = this.Messages.Where(m => m is MessageGroupViewModel).Cast<MessageGroupViewModel>().SelectMany(mg => mg.Messages); if (messages.Any(m => m.ID == msg.ID)) return; lock (Messages) { if (Messages.Count() > 100) // todo: make this configurable Messages.Remove(Messages.First()); mvm = this.messageViewModelFactory.BuildFor(msg); if (mvm is TextMessageViewModel || mvm is PasteMessageViewModel) { if (Messages.Any() && Messages.Last() is MessageGroupViewModel && ((MessageGroupViewModel)Messages.Last()).Messages.First().User.ID == mvm.User.ID) { ((MessageGroupViewModel)Messages.Last()).Messages.Add(mvm); } else { var mgvm = new MessageGroupViewModel(mvm.User); mgvm.Messages.Add(mvm); Messages.Add(mgvm); } } else { Messages.Add(mvm); } } }); return mvm; }
public SoundMessageViewModel(Message message) : base(message) { }
public MessageEventArgs(Message message) { this.Message = message; }
public KickMessageViewModel(Message message) : base(message) { }
public TextMessageViewModel(Message message) : base(message) { this.Text = message.Body; }
public UnlockMessageViewModel(Message message) : base(message) { }
public LeaveMessageViewModel(Message message) : base(message) { }
public TimestampMessageViewModel(Message message) : base(message) { }
public UnknownMessageViewModel(Message message) : base(message) { //this.User = new UserViewModel(message.User); this.Message = string.Format("Unkown Message Type: {0} Contents: {1}", message.Type, message.Body); }
public SystemMessageViewModel(Message message) : base(message) { }
public AdvertisementMessageViewModel(Message message) : base(message) { }
public TopicChangeMessageViewModel(Message message) : base(message) { }
public DisallowGuestsMessageViewModel(Message message) : base(message) { }
private void AddMessage(Message m) { IMessageViewModel msg; // This would be a great opportunity for refactoring // for polymorphism >.< There's a lot of copy/paste // between these different view models. switch (m.Type) { case MessageType.Text: msg = new MessageViewModel(m.User.Name, m.Body, m.User.ID == room.Site.GetMe().ID); break; case MessageType.Timestamp: msg = new TimeStampMessageViewModel(m.CreatedAt); break; case MessageType.Enter: case MessageType.Leave: msg = new RosterMessageViewModel(m.User.Name, m.Type); if (m.Type == MessageType.Enter) { if (!users.Any(u => u.ID == m.User.ID)) users.Add(m.User); } else { users.RemoveRange(users.Where(u => u.ID == m.User.ID).ToList()); } break; case MessageType.Paste: msg = new PasteMessageViewModel(m.User.Name, m.Body, m.User.ID == room.Site.GetMe().ID); break; default: return; } dispatcher.BeginInvoke((ThreadStart) (() => { messages.Add(msg); view.MessageScroller.ScrollToBottom(); })); }
public IdleMessageViewModel(Message message) : base(message) { }
public MessageReceivedMessage(Message message) { this.Message = message; }
public PasteMessageViewModel(Message message) : base(message) { }
public EnterMessageViewModel(Message message) : base(message) { User = new UserViewModel(message.User); }