void AddNewMessage(MessageEntry entry) { var observable = _mimeMessageLoader.Get(entry); observable.ObserveOnDispatcher().Subscribe( message => { this._messageBus.Publish( new ShowBallonTip( 3500, "New Message Received", $"From: {message.From.ToString().Truncate(50)}\r\nSubject: {message.Subject.Truncate(50)}", ToolTipIcon.Info)); // Add it to the list box ClearSelected(); PopSelectedIndex(); entry.IsSelected = true; Messages.Add(new MimeMessageEntry(entry, _mimeMessageLoader)); }, e => { // NOOP }); }
void AddNewMessage(MessageEntry entry) { _mimeMessageLoader.Get(entry) .ObserveOnDispatcher() .Subscribe( message => { _publishEvent.Publish( new ShowBallonTip( 5000, "New Message Received", string.Format( "From: {0}\r\nSubject: {1}", message.From.ToString().Truncate(50), message.Subject.Truncate(50)), ToolTipIcon.Info)); // Add it to the list box ClearSelected(); entry.IsSelected = true; Messages.Add(new MimeMessageEntry(entry, _mimeMessageLoader)); }, e => { // NOOP }); }
public MimeMessageEntry(MessageEntry entry, MimeMessageLoader loader) : base(entry.File) { IsSelected = entry.IsSelected; loader.Get(this).Subscribe(m => { Subject = m.Subject; }, e => { Subject = "Failure loading message: " + e.Message; }); }
public void LoadMessageEntry(MessageEntry messageEntry) { if (_loadingDisposable != null) { _loadingDisposable.Dispose(); } var handleLoading = !IsLoading; if (messageEntry == null) { // show empty... DisplayMimeMessage(null); if (handleLoading) { IsLoading = false; } } else { if (handleLoading) { IsLoading = true; } // load and show it... _loadingDisposable = _mimeMessageLoader.Get(messageEntry).ObserveOnDispatcher().Subscribe(m => { DisplayMimeMessage(m); if (handleLoading) { IsLoading = false; } }, e => { var failureMessage = MimeMessage.CreateFromMailMessage(MailMessageHelper.CreateFailureMailMessage(e.Message)); DisplayMimeMessage(failureMessage); if (handleLoading) { IsLoading = false; } }); } }
public static MimeMessage LoadMailMessage([NotNull] this MimeMessageLoader loader, [NotNull] MessageEntry entry) { if (loader == null) { throw new ArgumentNullException(nameof(loader)); } if (entry == null) { throw new ArgumentNullException(nameof(entry)); } var loadTask = loader.Get(entry).ToTask(); loadTask.Wait(); return(loadTask.Result); }