private void Update() { var removed = new List <int>(avatars.Keys); if (Party != null) { foreach (var member in Party.Members.OrderBy(x => x.Id)) { if (member.Id == PlayerId || removed.Remove(member.Id)) { continue; } var avatar = new AvatarView(this); avatar.Resize(37, 37); avatar.BorderColor = member.Color; avatar.Click += OnAvatarClick; //avatar.Avatar = new Avatar(member.Id, gobCache); avatars.Add(member.Id, avatar); var gob = gobCache.Get(member.Id); if (gob != null) { avatar.Tooltip = (gob.KinInfo != null) ? new Tooltip(gob.KinInfo.Name) : null; } } } foreach (var memberId in removed) { var avatar = avatars[memberId]; avatar.Click -= OnAvatarClick; avatar.Dispose(); avatar.Remove(); avatars.Remove(memberId); } int i = 0; foreach (var avatar in avatars.Values) { avatar.Move((i % 2) * 43, (i / 2) * 43 + 24); i++; } Visible = avatars.Count > 0; }
protected override void OnDraw(DrawingContext dc) { base.OnDraw(dc); // offset contents dc.PushMatrix(); dc.Translate(Margin, Margin); dc.Draw(background, avatarPosition); if (gobId != -1) { var gob = gobCache.Get(gobId); if (gob != null && gob.Avatar != null) { dc.Draw(gob.Avatar, avatarPosition); } } dc.PopMatrix(); }