Beispiel #1
0
        public InboxViewModel(IEmailService emailService, IRegionManager regionManager)
        {
            synchronizationContext = SynchronizationContext.Current ?? new SynchronizationContext();

            _composeMessageCommand = new DelegateCommand<object>(ComposeMessage);
            _replyMessageCommand = new DelegateCommand<object>(ReplyMessage, CanReplyMessage);
            _openMessageCommand = new DelegateCommand<EmailDocument>(OpenMessage);

            messagesCollection = new ObservableCollection<EmailDocument>();
            Messages = new CollectionView(this.messagesCollection);
            Messages.CurrentChanged += (s, e) =>
                _replyMessageCommand.RaiseCanExecuteChanged();

            _emailService = emailService;
            _regionManager = regionManager;

            if (_emailService != null)
            {
                _emailService.BeginGetEmailDocuments(
                    r =>
                        {
                            var messages = _emailService.EndGetEmailDocuments(r);
                            synchronizationContext.Post(
                                s =>
                                    {
                                        foreach (var message in messages)
                                        {
                                            messagesCollection.Add(message);
                                        }
                                    }, null);
                        }, null);
            }
        }
Beispiel #2
0
        public InboxViewModel(IEmailService emailService, IRegionManager regionManager)
        {
            synchronizationContext = SynchronizationContext.Current ?? new SynchronizationContext();

            _composeMessageCommand = new DelegateCommand <object>(ComposeMessage);
            _replyMessageCommand   = new DelegateCommand <object>(ReplyMessage, CanReplyMessage);
            _openMessageCommand    = new DelegateCommand <EmailDocument>(OpenMessage);

            messagesCollection       = new ObservableCollection <EmailDocument>();
            Messages                 = new CollectionView(this.messagesCollection);
            Messages.CurrentChanged += (s, e) =>
                                       _replyMessageCommand.RaiseCanExecuteChanged();

            _emailService  = emailService;
            _regionManager = regionManager;

            if (_emailService != null)
            {
                _emailService.BeginGetEmailDocuments(
                    r =>
                {
                    var messages = _emailService.EndGetEmailDocuments(r);
                    synchronizationContext.Post(
                        s =>
                    {
                        foreach (var message in messages)
                        {
                            messagesCollection.Add(message);
                        }
                    }, null);
                }, null);
            }
        }