상속: Caliburn.Micro.Screen
예제 #1
0
        public MainViewModel(
            IViewModelWindowManager viewModelWindowManager,
            IMessageBus messageBus,
            ForwardRuleDispatch forwardRuleDispatch,
            Func <MessageListViewModel> messageListViewModelFactory,
            Func <MessageDetailViewModel> messageDetailViewModelFactory,
            LogClientSinkQueue logClientSinkQueue,
            AppResourceLocator resourceLocator)
        {
            _viewModelWindowManager = viewModelWindowManager;
            this._messageBus        = messageBus;
            _forwardRuleDispatch    = forwardRuleDispatch;

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

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

            _logClientSinkQueue = logClientSinkQueue;
            _resourceLocator    = resourceLocator;

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

            SetupObservables();
        }
예제 #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;
            });
        }
예제 #3
0
        void IHandle <ShowMainWindowEvent> .Handle(ShowMainWindowEvent message)
        {
            if (!_window.IsVisible)
            {
                _window.Show();
            }

            if (_window.WindowState == WindowState.Minimized)
            {
                _window.WindowState = WindowState.Normal;
            }

            _window.Activate();

            _window.Topmost = true;
            _window.Topmost = false;

            _window.Focus();

            if (message.SelectMostRecentMessage)
            {
                MessageListViewModel.TryGetValidSelectedIndex();
            }
        }