Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added buttons to copy to clipboard nuget commands #447

Merged
merged 1 commit into from
May 6, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/ServiceInsight/ExtensionMethods/ViewModelExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,14 @@ public static ICommand CreateCommand<TViewModel>(this TViewModel viewModel, Acti
command.Subscribe(_ => executAction());
return command;
}

// ReSharper disable UnusedParameter.Global
public static ICommand CreateCommand<TViewModel>(this TViewModel viewModel, Action<object> executAction) where TViewModel : class
// ReSharper restore UnusedParameter.Global
{
var command = new ReactiveCommand();
command.Subscribe(arg => executAction(arg));
return command;
}
}
}
48 changes: 40 additions & 8 deletions src/ServiceInsight/Saga/SagaWindowView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,28 @@
</StackPanel>
</Grid>
</DataTemplate>
<Style x:Key="BlankButtonStyle" TargetType="{x:Type Button}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Padding" Value="1" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
SnapsToDevicePixels="true">
<ContentPresenter Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
Expand Down Expand Up @@ -158,22 +180,32 @@
FontWeight="Bold"
Foreground="#FF565656"
Text="To visualize your saga, please install the appropriate nuget package in your endpoint" />
<TextBlock Margin="5,2,5,5"
Padding="2"
HorizontalAlignment="Center"
<StackPanel Orientation="Horizontal" Margin="5,2,5,5" HorizontalAlignment="Center">
<TextBlock Padding="2"
Background="{x:Null}"
FontFamily="Consolas"
FontSize="16"
Style="{StaticResource CodeStyle}"
Text="For NSB v5 endpoints, install-package ServiceControl.Plugin.Nsb5.SagaAudit &lt;NameProjectWithSaga&gt;" />
<TextBlock Margin="5,2,5,5"
Padding="2"
HorizontalAlignment="Center"
Text="For NSB v5 endpoints, install-package ServiceControl.Plugin.Nsb5.SagaAudit" />
<Button ToolTip="Copy nuget command to clipboard" Style="{StaticResource BlankButtonStyle}" Margin="5,0,0,0" Command="{Binding CopyCommand}" CommandParameter="install-package ServiceControl.Plugin.Nsb5.SagaAudit">
<Image
VerticalAlignment="Center"
Source="/Images/Copy.png" />
</Button>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="5,2,5,5" HorizontalAlignment="Center">
<TextBlock Padding="2"
Background="{x:Null}"
FontFamily="Consolas"
FontSize="16"
Style="{StaticResource CodeStyle}"
Text="For NSB v4 endpoints, install-package ServiceControl.Plugin.Nsb4.SagaAudit &lt;NameProjectWithSaga&gt;" />
Text="For NSB v4 endpoints, install-package ServiceControl.Plugin.Nsb4.SagaAudit" />
<Button ToolTip="Copy nuget command to clipboard" Style="{StaticResource BlankButtonStyle}" Margin="5,0,0,0" Command="{Binding CopyCommand}" CommandParameter="install-package ServiceControl.Plugin.Nsb4.SagaAudit">
<Image
VerticalAlignment="Center"
Source="/Images/Copy.png" />
</Button>
</StackPanel>
</StackPanel>
</Border>
</StackPanel>
Expand Down
15 changes: 14 additions & 1 deletion src/ServiceInsight/Saga/SagaWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -15,14 +18,24 @@ public class SagaWindowViewModel : Screen, IHandle<SelectedMessageChanged>
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();
Expand Down