private void MessageWindow_Load(object sender, EventArgs e) { RosterItem ri = null; if (!XmppGlobal.Roster.TryGetValue(foreign_jid, out ri)) { XmppGlobal.Roster.TryGetValue(new jabber.JID(foreign_jid.Bare), out ri); } if (ri == null) { this.Text = foreign_jid.Bare; this.Icon = PaintFunctions.ImageToIcon((Bitmap)XmppImages.DefaultAvatar); this.ChattingWith.Text = string.Format("Chatting with {0}", foreign_jid.ToString()); } else { this.Text = ri.GetDisplayName(); this.Icon = PaintFunctions.ImageToIcon((Bitmap)ri.BaseAvatar); this.ChattingWith.Text = string.Format("Chatting with {0}", ri.GetDisplayName()); ri.PresenceChanged += new EventHandler <PresenceItemEventArgs> (PresenceChanged); PresenceChanged(ri, new PresenceItemEventArgs(ri.GetPresence())); } StatusBarPanel1.Image = XmppImages.AwayOverlay; }
private void PresenceChanged(object sender, PresenceItemEventArgs e) { RosterItem ri = (RosterItem)sender; jabber.protocol.client.Presence pres = ri.GetPresence(); if (pres == null) { pres = e.Item; } ContactItem ci = null; if (pres != null) { ci = ContactListPanel.GetContactItem(ri.Jid.Bare); if (pres.Status != null) { ci.TextLineTwo = pres.Status; } else if (pres.Show != null) { ci.TextLineTwo = pres.Show; } else { ci.TextLineTwo = "Online"; } } switch (pres.Type) { case jabber.protocol.client.PresenceType.available: if (!(ci == null)) { ci.Enabled = true; ci.Visible = true; ci.Image = ri.Avatar; } break; case jabber.protocol.client.PresenceType.unavailable: if (ci != null) { ci.Enabled = false; ci.Visible = false; } break; } }
private void PresenceChanged(object sender, PresenceItemEventArgs e) { RosterItem ri = (RosterItem)sender; jabber.protocol.client.Presence pres = ri.GetPresence(); if (pres == null) { StatusBarPanel1.Text = string.Format("{0} is offline.", ri.GetDisplayName()); StatusBarPanel1.Visible = true; } else { switch (pres.Type) { case jabber.protocol.client.PresenceType.available: switch (pres.Show) { case "away": case "xa": case "dnd": if (pres.Status == null) { StatusBarPanel1.Text = string.Format("{0} is away.", ri.GetDisplayName()); } else { StatusBarPanel1.Text = string.Format("{0} is away. {1}", ri.GetDisplayName(), pres.Status.Trim().Length > 0 ? string.Format(" ({0})", pres.Status.Trim()) : string.Empty); } StatusBarPanel1.Visible = true; break; default: StatusBarPanel1.Visible = false; break; } break; case jabber.protocol.client.PresenceType.unavailable: StatusBarPanel1.Text = string.Format("{0} is offline.", ri.GetDisplayName()); StatusBarPanel1.Visible = true; break; } } UserAvatar.Image = ri.Avatar; }