From c153fab3ca0748ee367b3afbf9b5a49c941a8072 Mon Sep 17 00:00:00 2001 From: John Simons Date: Tue, 5 May 2015 16:56:07 +1000 Subject: [PATCH] Added buttons to copy to clipboard nuget commands Fixes #423 --- .../ExtensionMethods/ViewModelExtensions.cs | 9 ++++ src/ServiceInsight/Saga/SagaWindowView.xaml | 48 +++++++++++++++---- .../Saga/SagaWindowViewModel.cs | 15 +++++- 3 files changed, 63 insertions(+), 9 deletions(-) diff --git a/src/ServiceInsight/ExtensionMethods/ViewModelExtensions.cs b/src/ServiceInsight/ExtensionMethods/ViewModelExtensions.cs index 9126c592..bc46c33a 100644 --- a/src/ServiceInsight/ExtensionMethods/ViewModelExtensions.cs +++ b/src/ServiceInsight/ExtensionMethods/ViewModelExtensions.cs @@ -31,5 +31,14 @@ public static ICommand CreateCommand(this TViewModel viewModel, Acti command.Subscribe(_ => executAction()); return command; } + + // ReSharper disable UnusedParameter.Global + public static ICommand CreateCommand(this TViewModel viewModel, Action executAction) where TViewModel : class + // ReSharper restore UnusedParameter.Global + { + var command = new ReactiveCommand(); + command.Subscribe(arg => executAction(arg)); + return command; + } } } \ No newline at end of file diff --git a/src/ServiceInsight/Saga/SagaWindowView.xaml b/src/ServiceInsight/Saga/SagaWindowView.xaml index 07829855..b9bd4118 100644 --- a/src/ServiceInsight/Saga/SagaWindowView.xaml +++ b/src/ServiceInsight/Saga/SagaWindowView.xaml @@ -86,6 +86,28 @@ + + @@ -158,22 +180,32 @@ FontWeight="Bold" Foreground="#FF565656" Text="To visualize your saga, please install the appropriate nuget package in your endpoint" /> - + - + + + + + Text="For NSB v4 endpoints, install-package ServiceControl.Plugin.Nsb4.SagaAudit" /> + + diff --git a/src/ServiceInsight/Saga/SagaWindowViewModel.cs b/src/ServiceInsight/Saga/SagaWindowViewModel.cs index 5f8639fa..2acb05da 100644 --- a/src/ServiceInsight/Saga/SagaWindowViewModel.cs +++ b/src/ServiceInsight/Saga/SagaWindowViewModel.cs @@ -3,8 +3,11 @@ using System; using System.Collections.Generic; using System.Linq; + using System.Windows.Input; using Caliburn.Micro; using Models; + using Particular.ServiceInsight.Desktop.ExtensionMethods; + using Particular.ServiceInsight.Desktop.Framework; using Particular.ServiceInsight.Desktop.Framework.Events; using ServiceControl; @@ -15,14 +18,24 @@ public class SagaWindowViewModel : Screen, IHandle SagaMessage selectedMessage; IEventAggregator eventAggregator; IServiceControl serviceControl; + readonly IClipboard clipboard; - public SagaWindowViewModel(IEventAggregator eventAggregator, IServiceControl serviceControl) + public SagaWindowViewModel(IEventAggregator eventAggregator, IServiceControl serviceControl, IClipboard clipboard) { this.eventAggregator = eventAggregator; this.serviceControl = serviceControl; + this.clipboard = clipboard; ShowSagaNotFoundWarning = false; + CopyCommand = this.CreateCommand(arg => CopyNugetCommandToClipboard(arg.ToString())); } + void CopyNugetCommandToClipboard(string text) + { + clipboard.CopyTo(text); + } + + public ICommand CopyCommand { get; private set; } + public void OnShowMessageDataChanged() { RefreshShowData();