Example #1
0
        public MainViewModel(
            IViewModelWindowManager viewModelWindowManager,
            IPublishEvent publishEvent,
            ForwardRuleDispatch forwardRuleDispatch,
            Func <MessageListViewModel> messageListViewModelFactory,
            Func <MessageDetailViewModel> messageDetailViewModelFactory,
            LogClientSinkQueue logClientSinkQueue,
            AppResourceLocator resourceLocator)
        {
            _viewModelWindowManager = viewModelWindowManager;
            _publishEvent           = publishEvent;
            _forwardRuleDispatch    = forwardRuleDispatch;

            MessageListViewModel   = messageListViewModelFactory();
            MessageDetailViewModel = messageDetailViewModelFactory();

            MessageListViewModel.ConductWith(this);
            MessageDetailViewModel.ConductWith(this);

            _logClientSinkQueue = logClientSinkQueue;
            _resourceLocator    = resourceLocator;

            LogText = _resourceLocator.GetResourceString("LogClientSink.html");

            SetupObservables();
        }
Example #2
0
        void SetupObservables()
        {
            MessageListViewModel.GetPropertyValues(m => m.SelectedMessage)
            .Throttle(TimeSpan.FromMilliseconds(200), TaskPoolScheduler.Default)
            .ObserveOnDispatcher()
            .Subscribe(
                m =>
                MessageDetailViewModel.LoadMessageEntry(MessageListViewModel.SelectedMessage));

            Observable.FromEventPattern <EventHandler, EventArgs>(h => new EventHandler(h),
                                                                  h => _logClientSinkQueue.LogEvent += h,
                                                                  h => _logClientSinkQueue.LogEvent -= h).ObserveOnDispatcher().Subscribe(o =>
            {
                foreach (var e in _logClientSinkQueue.GetLastEvents().ToList())
                {
                    LogText = LogText.Replace("<body>",
                                              "<body>" + string.Join(" ", RenderLogEventParts(e)));
                }
            });

            this.GetPropertyValues(m => m.IsLogOpen)
            .ObserveOnDispatcher()
            .Subscribe(m =>
            {
                MessageListViewModel.IsLoading   = m;
                MessageDetailViewModel.IsLoading = m;
            });
        }