Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 02427b6

Browse files
committed
Make avatar in PR review summary clickable.
1 parent 41850a9 commit 02427b6

File tree

3 files changed

+51
-9
lines changed

3 files changed

+51
-9
lines changed

src/GitHub.VisualStudio.UI/UI/Controls/AccountAvatar.xaml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,28 @@
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:local="clr-namespace:GitHub.VisualStudio.UI.Controls"
5+
Name="root"
56
MinWidth="16" MinHeight="16">
6-
<Grid>
7-
<Grid.OpacityMask>
8-
<VisualBrush Visual="{Binding ElementName=avatarMask}"/>
9-
</Grid.OpacityMask>
10-
<Border Name="avatarMask" Background="White" CornerRadius="3"
7+
<Button Name="btn" Command="{Binding Command, ElementName=root}"
8+
CommandParameter="{Binding CommandParameter, ElementName=root}"
9+
CommandTarget="{Binding CommandTarget, ElementName=root}">
10+
<Button.Template>
11+
<ControlTemplate TargetType="Button">
12+
<ContentPresenter/>
13+
</ControlTemplate>
14+
</Button.Template>
15+
<Grid>
16+
<Grid.OpacityMask>
17+
<VisualBrush Visual="{Binding ElementName=avatarMask}"/>
18+
</Grid.OpacityMask>
19+
<Border Name="avatarMask" Background="White" CornerRadius="3"
1120
Width="{Binding ActualWidth, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:AccountAvatar}}}"
1221
Height="{Binding ActualHeight, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:AccountAvatar}}}"/>
13-
<Image x:Name="avatar"
22+
<Image x:Name="avatar"
1423
Width="{Binding Width, ElementName=avatarMask}"
1524
Height="{Binding Height, ElementName=avatarMask}"
1625
RenderOptions.BitmapScalingMode="HighQuality"
1726
Source="{Binding Account.Avatar, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:AccountAvatar}}}" />
18-
</Grid>
27+
</Grid>
28+
</Button>
1929
</UserControl>

src/GitHub.VisualStudio.UI/UI/Controls/AccountAvatar.xaml.cs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
using System.Windows;
22
using System.Windows.Controls;
3+
using System.Windows.Controls.Primitives;
4+
using System.Windows.Input;
35
using GitHub.Models;
46

57
namespace GitHub.VisualStudio.UI.Controls
68
{
7-
public partial class AccountAvatar : UserControl
9+
public partial class AccountAvatar : UserControl, ICommandSource
810
{
911
public static readonly DependencyProperty AccountProperty =
1012
DependencyProperty.Register(
1113
nameof(Account),
1214
typeof(IAccount),
1315
typeof(AccountAvatar));
16+
public static readonly DependencyProperty CommandProperty =
17+
ButtonBase.CommandProperty.AddOwner(typeof(AccountAvatar));
18+
public static readonly DependencyProperty CommandParameterProperty =
19+
ButtonBase.CommandParameterProperty.AddOwner(typeof(AccountAvatar));
20+
public static readonly DependencyProperty CommandTargetProperty =
21+
ButtonBase.CommandTargetProperty.AddOwner(typeof(AccountAvatar));
1422

1523
public AccountAvatar()
1624
{
@@ -22,5 +30,23 @@ public IAccount Account
2230
get { return (IAccount)GetValue(AccountProperty); }
2331
set { SetValue(AccountProperty, value); }
2432
}
33+
34+
public ICommand Command
35+
{
36+
get { return (ICommand)GetValue(CommandProperty); }
37+
set { SetValue(CommandProperty, value); }
38+
}
39+
40+
public object CommandParameter
41+
{
42+
get { return GetValue(CommandParameterProperty); }
43+
set { SetValue(CommandParameterProperty, value); }
44+
}
45+
46+
public IInputElement CommandTarget
47+
{
48+
get { return (IInputElement)GetValue(CommandTargetProperty); }
49+
set { SetValue(CommandTargetProperty, value); }
50+
}
2551
}
2652
}

src/GitHub.VisualStudio/Views/GitHubPane/PullRequestReviewSummaryView.xaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,13 @@
5757
<RowDefinition Height="Auto"/>
5858
</Grid.RowDefinitions>
5959

60-
<c:AccountAvatar Grid.Column="0" VerticalAlignment="Top" Margin="2" Account="{Binding User}"/>
60+
<c:AccountAvatar Grid.Column="0"
61+
VerticalAlignment="Top"
62+
Margin="2"
63+
Account="{Binding User}"
64+
Command="{Binding Path=DataContext.ShowReview, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:PullRequestDetailView}}}"
65+
CommandParameter="{Binding}"
66+
Cursor="Hand"/>
6167
<ui:GitHubActionLink Grid.Column="1" FontWeight="SemiBold" Margin="2 1 2 0"
6268
Command="{Binding Path=DataContext.ShowReview, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:PullRequestDetailView}}}"
6369
CommandParameter="{Binding}"

0 commit comments

Comments
 (0)