public static Color GetStatusColor( Friend steamid ) { Color inGame = Color.FromArgb( 177, 251, 80 ); Color online = Color.FromArgb( 111, 189, 255 ); Color offline = Color.FromArgb( 137, 137, 137 ); Color blocked = Color.FromArgb( 251, 80, 80 ); Color invited = Color.FromArgb( 250, 218, 94 ); Color requesting = Color.FromArgb( 135, 169, 107 ); if ( steamid.IsAcceptingFriendship() ) return invited; if ( steamid.IsRequestingFriendship() ) return requesting; if ( steamid.IsBlocked() ) return blocked; if ( steamid.IsInGame() ) return inGame; if ( !steamid.IsOnline() ) return offline; return online; }
public void HandleChat( SteamID sender, EChatEntryType type, string msg ) { string friendName = Steam3.SteamFriends.GetFriendPersonaName( sender ); string time = DateTime.Now.ToString( "h:mm tt" ); var friend = new Friend( sender ); var status = new StatusColor(settings); var statusColor = status.GetStatusColor(friend); switch ( type ) { case EChatEntryType.ChatMsg: this.AppendText( statusColor, string.Format( "{0} - {1}", time, friendName ) ); this.AppendText( Color.Black, ": " + msg ); if ( sender != Steam3.SteamClient.SteamID ) FlashWindow(); break; case EChatEntryType.Emote: this.AppendText( statusColor, string.Format( "{0} - {1}", time, friendName ) ); this.AppendText( statusColor, " " + msg ); if ( sender != Steam3.SteamClient.SteamID ) FlashWindow(); break; case EChatEntryType.InviteGame: this.AppendText( statusColor, string.Format( "{0} - {1}", time, friendName ) ); this.AppendText( statusColor, " has invited you to play a game." ); if ( sender != Steam3.SteamClient.SteamID ) FlashWindow(); break; default: return; } this.AppendText( Environment.NewLine ); this.ScrollLog(); }
public FriendControl( Friend steamid ) : this() { UpdateFriend( steamid ); }
Bitmap ComposeAvatar( Friend steamid, string path ) { Bitmap holder = GetHolder( steamid ); Bitmap avatar = GetAvatar( path ); Graphics gfx = null; try { gfx = Graphics.FromImage( holder ); gfx.DrawImage( avatar, new Rectangle( 4, 4, avatar.Width, avatar.Height ) ); } finally { gfx.Dispose(); } return holder; }
Bitmap GetHolder( Friend steamid ) { if ( steamid.IsInGame() ) return Resources.IconIngame; if ( steamid.IsOnline() ) return Resources.IconOnline; return Resources.IconOffline; }
public void UpdateFriend( Friend steamid ) { Friend = steamid; nameLbl.Text = steamid.GetName(); statusLbl.Text = steamid.GetStatus(); gameLbl.Text = steamid.GetGameName(); if ( steamid.IsRequestingFriendship() ) { btnAccept.Visible = true; btnDeny.Visible = true; } else { btnAccept.Visible = false; btnDeny.Visible = false; } nameLbl.ForeColor = statusLbl.ForeColor = gameLbl.ForeColor = Util.GetStatusColor( steamid ); byte[] avatarHash = Steam3.SteamFriends.GetFriendAvatar( steamid.SteamID ); bool validHash = avatarHash != null && !Util.IsZeros( avatarHash ); if ((AvatarHash == null && !validHash && avatarBox.Image != null) || (AvatarHash != null && AvatarHash.SequenceEqual(avatarHash))) { // avatar is already up to date, no operations necessary } else if ( validHash ) { AvatarHash = avatarHash; CDNCache.DownloadAvatar(steamid.SteamID, avatarHash, AvatarDownloaded); } else { AvatarHash = null; avatarBox.Image = ComposeAvatar( this.Friend, null ); } }
public FriendControl(Vapor.State.Settings settings, Friend steamid) : this(settings) { UpdateFriend(steamid); }
List<Friend> GetFriends() { List<Friend> friends = new List<Friend>(); int friendCount = Steam3.SteamFriends.GetFriendCount(); for ( int x = 0 ; x < friendCount ; ++x ) { SteamID friendId = Steam3.SteamFriends.GetFriendByIndex( x ); Friend friend = new Friend( friendId ); friends.Add( friend ); } return friends; }
private static int compareFriends(Friend a, Friend b) { if (a == b) return 0; int rankA = rankFriend(a); int rankB = rankFriend(b); if (rankA < rankB) return -1; else if (rankA > rankB) return 1; else return a.GetName().CompareTo(b.GetName()); }
private static int rankFriend(Friend x) { if (x.IsRequestingFriendship()) return 0; else if (x.IsAcceptingFriendship()) return 99; else if (x.IsInGame()) return 1; else if (x.IsOnline()) return 2; else if (x.GetState() == EPersonaState.Busy) return 3; else if (x.GetState() == EPersonaState.Away) return 4; else if (x.GetState() == EPersonaState.Snooze) return 5; return 10; }