Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.
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
24 changes: 17 additions & 7 deletions src/GitHub.VisualStudio.UI/UI/Controls/AccountAvatar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,28 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:GitHub.VisualStudio.UI.Controls"
Name="root"
MinWidth="16" MinHeight="16">
<Grid>
<Grid.OpacityMask>
<VisualBrush Visual="{Binding ElementName=avatarMask}"/>
</Grid.OpacityMask>
<Border Name="avatarMask" Background="White" CornerRadius="3"
<Button Name="btn" Command="{Binding Command, ElementName=root}"
CommandParameter="{Binding CommandParameter, ElementName=root}"
CommandTarget="{Binding CommandTarget, ElementName=root}">
<Button.Template>
<ControlTemplate TargetType="Button">
<ContentPresenter/>
</ControlTemplate>
</Button.Template>
<Grid>
<Grid.OpacityMask>
<VisualBrush Visual="{Binding ElementName=avatarMask}"/>
</Grid.OpacityMask>
<Border Name="avatarMask" Background="White" CornerRadius="3"
Width="{Binding ActualWidth, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:AccountAvatar}}}"
Height="{Binding ActualHeight, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:AccountAvatar}}}"/>
<Image x:Name="avatar"
<Image x:Name="avatar"
Width="{Binding Width, ElementName=avatarMask}"
Height="{Binding Height, ElementName=avatarMask}"
RenderOptions.BitmapScalingMode="HighQuality"
Source="{Binding Account.Avatar, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:AccountAvatar}}}" />
</Grid>
</Grid>
</Button>
</UserControl>
28 changes: 27 additions & 1 deletion src/GitHub.VisualStudio.UI/UI/Controls/AccountAvatar.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using GitHub.Models;

namespace GitHub.VisualStudio.UI.Controls
{
public partial class AccountAvatar : UserControl
public partial class AccountAvatar : UserControl, ICommandSource
{
public static readonly DependencyProperty AccountProperty =
DependencyProperty.Register(
nameof(Account),
typeof(IAccount),
typeof(AccountAvatar));
public static readonly DependencyProperty CommandProperty =
ButtonBase.CommandProperty.AddOwner(typeof(AccountAvatar));
public static readonly DependencyProperty CommandParameterProperty =
ButtonBase.CommandParameterProperty.AddOwner(typeof(AccountAvatar));
public static readonly DependencyProperty CommandTargetProperty =
ButtonBase.CommandTargetProperty.AddOwner(typeof(AccountAvatar));

public AccountAvatar()
{
Expand All @@ -22,5 +30,23 @@ public IAccount Account
get { return (IAccount)GetValue(AccountProperty); }
set { SetValue(AccountProperty, value); }
}

public ICommand Command
{
get { return (ICommand)GetValue(CommandProperty); }
set { SetValue(CommandProperty, value); }
}

public object CommandParameter
{
get { return GetValue(CommandParameterProperty); }
set { SetValue(CommandParameterProperty, value); }
}

public IInputElement CommandTarget
{
get { return (IInputElement)GetValue(CommandTargetProperty); }
set { SetValue(CommandTargetProperty, value); }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>

<c:AccountAvatar Grid.Column="0" VerticalAlignment="Top" Margin="2" Account="{Binding User}"/>
<c:AccountAvatar Grid.Column="0"
VerticalAlignment="Top"
Margin="2"
Account="{Binding User}"
Command="{Binding Path=DataContext.ShowReview, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:PullRequestDetailView}}}"
CommandParameter="{Binding}"
Cursor="Hand"/>
<ui:GitHubActionLink Grid.Column="1" FontWeight="SemiBold" Margin="2 1 2 0"
Command="{Binding Path=DataContext.ShowReview, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:PullRequestDetailView}}}"
CommandParameter="{Binding}"
Expand Down