mirror of
https://github.com/BeyondDimension/SteamTools.git
synced 2026-10-28 14:08:16 +08:00
Fix CircleImageStream
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.IO;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
#if !NET35 && !NOT_XE
|
||||
using Xamarin.Essentials;
|
||||
#endif
|
||||
@@ -219,8 +220,10 @@ namespace System
|
||||
return ioPath;
|
||||
}
|
||||
|
||||
public static FileStream OpenRead(string filePath)
|
||||
[return: NotNullIfNotNull("filePath")]
|
||||
public static FileStream? OpenRead(string? filePath)
|
||||
{
|
||||
if (filePath == null) return null;
|
||||
var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
|
||||
return fileStream;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
|
||||
namespace System.Application.Models
|
||||
@@ -60,16 +61,28 @@ namespace System.Application.Models
|
||||
|
||||
public class CircleImageStream : ImageClipStream
|
||||
{
|
||||
public CircleImageStream(Stream stream) : base(stream)
|
||||
{
|
||||
Circle = true;
|
||||
}
|
||||
public CircleImageStream(string path) : base(IOPath.OpenRead(path))
|
||||
private CircleImageStream(Stream stream) : base(stream)
|
||||
{
|
||||
Circle = true;
|
||||
}
|
||||
|
||||
public static implicit operator CircleImageStream?(Stream? stream)
|
||||
private CircleImageStream(string filePath) : base(IOPath.OpenRead(filePath))
|
||||
{
|
||||
Circle = true;
|
||||
}
|
||||
|
||||
[return: NotNullIfNotNull("stream")]
|
||||
public static CircleImageStream? Convert(Stream? stream)
|
||||
=> stream == null ? null : new(stream);
|
||||
|
||||
[return: NotNullIfNotNull("stream")]
|
||||
public static implicit operator CircleImageStream?(Stream? stream) => Convert(stream);
|
||||
|
||||
[return: NotNullIfNotNull("filePath")]
|
||||
public static CircleImageStream? Convert(string? filePath)
|
||||
=> filePath == null ? null : new(filePath);
|
||||
|
||||
[return: NotNullIfNotNull("filePath")]
|
||||
public static implicit operator CircleImageStream?(string? filePath) => Convert(filePath);
|
||||
}
|
||||
}
|
||||
@@ -160,9 +160,7 @@ namespace System.Application.Services
|
||||
IsConnectToSteam = true;
|
||||
CurrentSteamUser = await SteamworksWebApiService.GetUserInfo(id);
|
||||
CurrentSteamUser.AvatarStream = IHttpService.Instance.GetImageAsync(CurrentSteamUser.AvatarFull, ImageChannelType.SteamAvatars);
|
||||
var avater = await CurrentSteamUser.AvatarStream;
|
||||
if (avater != null)
|
||||
AvaterPath = new CircleImageStream(avater);
|
||||
AvaterPath = CircleImageStream.Convert(await CurrentSteamUser.AvatarStream);
|
||||
|
||||
CurrentSteamUser.IPCountry = ApiService.GetIPCountry();
|
||||
IsSteamChinaLauncher = ApiService.IsSteamChinaLauncher();
|
||||
|
||||
@@ -133,7 +133,7 @@ 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);
|
||||
AvaterPath = CircleImageStream.Convert(await CurrentSteamUser.AvatarStream);
|
||||
}
|
||||
|
||||
//AvaterPath = GetAvaterPath(User);
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace System.Diagnostics.CodeAnalysis
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)]
|
||||
public sealed class NotNullIfNotNullAttribute : Attribute
|
||||
{
|
||||
public NotNullIfNotNullAttribute(string parameterName) => ParameterName = parameterName;
|
||||
|
||||
public string ParameterName { get; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user