Files
ArchiSteamFarm/GUI/BotStatusForm.cs

47 lines
1.4 KiB
C#
Raw Normal View History

using System;
using System.Collections.Concurrent;
using System.ComponentModel;
using System.Windows.Forms;
using SteamKit2;
2017-01-13 23:47:12 +01:00
namespace ArchiSteamFarm {
internal sealed partial class BotStatusForm : Form {
internal static readonly ConcurrentDictionary<string, BotStatusForm> BotForms = new ConcurrentDictionary<string, BotStatusForm>();
private readonly Bot Bot;
internal BotStatusForm(Bot bot) {
2017-03-14 08:20:29 -03:00
Bot = bot ?? throw new ArgumentNullException(nameof(bot));
BotForms[bot.BotName] = this;
InitializeComponent();
Dock = DockStyle.Fill;
}
internal void OnStateUpdated(SteamFriends.PersonaStateCallback callback) {
if (callback == null) {
Bot.ArchiLogger.LogNullError(nameof(callback));
return;
}
2016-12-04 06:01:18 +01:00
if ((callback.AvatarHash == null) || (callback.AvatarHash.Length == 0)) {
return;
}
2016-12-04 06:01:18 +01:00
string avatarHash = BitConverter.ToString(callback.AvatarHash).Replace("-", "").ToLowerInvariant();
if (string.IsNullOrEmpty(avatarHash)) {
return;
}
string avatarURL = "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/" + avatarHash.Substring(0, 2) + "/" + avatarHash + "_full.jpg";
AvatarPictureBox.ImageLocation = avatarURL;
AvatarPictureBox.LoadAsync();
}
2017-04-05 16:59:48 +02:00
private void AvatarPictureBox_LoadCompleted(object sender, AsyncCompletedEventArgs e) {
MainForm.UpdateBotAvatar(Bot.BotName, AvatarPictureBox.Image);
}
}
}