修复steam登录账号头像显示问题

This commit is contained in:
rmbgame
2021-05-08 20:09:48 +08:00
parent a35e551fe9
commit 460775b7ee
4 changed files with 17 additions and 11 deletions
@@ -82,12 +82,12 @@
<StackPanel>
<Panel x:Name="UserMenu" Width="300" Margin="0 20">
<StackPanel Spacing="15">
<Image Source="{ReflectionBinding Path=AvaterPath, Source={x:Static service:UserService.Current},Mode=OneWay,Converter={StaticResource BitmapAssetValueConverter},ConverterParameter=80}"
<Image Source="{ReflectionBinding Path=AvaterPath, Source={x:Static service:UserService.Current},Mode=OneWay,Converter={StaticResource BitmapAssetValueConverter},ConverterParameter=100}"
Stretch="Uniform"
Height="80" Width="80"
Height="100" Width="100"
HorizontalAlignment="Center">
<!--<Image.Clip>
<EllipseGeometry Rect="0,0,100,100" />
<EllipseGeometry Rect="0,0,80,80" />
</Image.Clip>-->
</Image>
<TextBlock
@@ -62,7 +62,7 @@
<controls:ProgressRing IsIndeterminate="True" HorizontalAlignment="Stretch" Height="100" Width="100" IsVisible="{Binding IsLoading}"/>
<StackPanel VerticalAlignment="Center" IsVisible="{Binding !IsLoading}">
<DockPanel>
<Image Source="/Application/UI/Assets/AppResources/avater.jpg" Width="184" Height="184"/>
<Image Source="{ReflectionBinding Path=AvaterPath, Source={x:Static service:UserService.Current},Mode=OneWay,Converter={StaticResource BitmapAssetValueConverter},ConverterParameter=184}" Width="184" Height="184"/>
<StackPanel Orientation="Vertical" Margin="16,0,0,0">
<Button Content="{ReflectionBinding Path=Res.RefreshSteamAvatar,Mode=OneWay,Source={x:Static resx:R.Current}}"
Opacity="0"
@@ -1,4 +1,4 @@
using System.IO;
using System.IO;
namespace System.Application.Models
{
@@ -64,7 +64,10 @@ namespace System.Application.Models
{
Circle = true;
}
public CircleImageStream(string path) : base(IOPath.OpenRead(path))
{
Circle = true;
}
public static implicit operator CircleImageStream?(Stream? stream)
=> stream == null ? null : new(stream);
}
@@ -86,11 +86,12 @@ namespace System.Application.Services
const string DefaultAvaterPath = "avares://System.Application.SteamTools.Client.Desktop.Avalonia/Application/UI/Assets/AppResources/avater_default.png";
//string _AvaterPath = DefaultAvaterPath;
public object AvaterPath
object? _AvaterPath = DefaultAvaterPath;
public object? AvaterPath
{
get => GetAvaterPath(User);
//set => this.RaiseAndSetIfChanged(ref _AvaterPath, value);
get => _AvaterPath;
set => this.RaiseAndSetIfChanged(ref _AvaterPath, value);
}
public UserService()
@@ -130,9 +131,11 @@ namespace System.Application.Services
{
CurrentSteamUser = await ISteamworksWebApiService.Instance.GetUserInfo(User.SteamAccountId.Value);
CurrentSteamUser.AvatarStream = IHttpService.Instance.GetImageAsync(CurrentSteamUser.AvatarFull, ImageChannelType.SteamAvatars);
AvaterPath = new CircleImageStream(await CurrentSteamUser.AvatarStream);
}
this.RaisePropertyChanged(nameof(AvaterPath));
//AvaterPath = GetAvaterPath(User);
var userInfo = await userManager.GetCurrentUserAsync();
HasPhoneNumber = !string.IsNullOrWhiteSpace(userInfo?.PhoneNumber);
}