public MessageFlowViewModel(
            IServiceControl serviceControl,
            IEventAggregator eventAggregator,
            IWindowManagerEx windowManager,
            SearchBarViewModel searchBar,
            MessageListViewModel messageList,
            Func <ExceptionDetailViewModel> exceptionDetail,
            ISettingsProvider settingsProvider,
            EndpointExplorerViewModel endpointExplorer,
            IClipboard clipboard)
        {
            this.serviceControl   = serviceControl;
            this.eventAggregator  = eventAggregator;
            this.windowManager    = windowManager;
            this.settingsProvider = settingsProvider;
            this.messageList      = messageList;
            this.endpointExplorer = endpointExplorer;
            this.exceptionDetail  = exceptionDetail;

            CopyConversationIDCommand = new CopyConversationIDCommand(clipboard);
            CopyMessageURICommand     = new CopyMessageURICommand(clipboard, serviceControl);
            SearchByMessageIDCommand  = new SearchByMessageIDCommand(eventAggregator, searchBar);
            RetryMessageCommand       = new RetryMessageCommand(eventAggregator, serviceControl);

            Diagram = new MessageFlowDiagram();
            nodeMap = new ConcurrentDictionary <string, MessageNode>();
        }
        public void Handle(SelectedMessageChanged @event)
        {
            if (loadingConversation)
            {
                return;
            }

            loadingConversation = true;
            originalSelectionId = string.Empty;
            nodeMap.Clear();

            SelectedMessage = null;
            Diagram         = new MessageFlowDiagram();

            var storedMessage = @event.Message;

            if (storedMessage == null)
            {
                loadingConversation = false;
                return;
            }

            var conversationId = storedMessage.ConversationId;

            if (conversationId == null)
            {
                loadingConversation = false;
                return;
            }

            try
            {
                var relatedMessagesTask = serviceControl.GetConversationById(conversationId);
                var nodes = relatedMessagesTask
                            .Select(x => new MessageNode(this, x)
                {
                    ShowEndpoints = ShowEndpoints
                })
                            .ToList();

                CreateConversationNodes(storedMessage.Id, nodes);
                LinkConversationNodes(nodes);
                UpdateLayout();
            }
            finally
            {
                loadingConversation = false;
            }
        }