public static Image GetIconForClient(string client) { switch (client.ToLower()) { case "d2dv": case "d2xp": case "star": case "sexp": case "w2bn": case "war3": case "w3xp": case "jstr": Image img = m_icons.GetImageFor(Product.GetByProductCode(client)); return(img); default: Image img2 = m_icons.GetImageFor(Product.ChatClient); return(img2); } }
public void DrawItem(CustomItemDrawData e) { e.DrawBackground(); if (e.State == System.Windows.Forms.DrawItemState.Selected) { e.DrawFocusRectangle(); } ChatUser user = e.Item as ChatUser; using (SolidBrush textBrush = new SolidBrush(e.ForeColor)) using (StringFormat nameFormat = new StringFormat() { Trimming = StringTrimming.EllipsisCharacter }) //using (StringFormat pingFormat = new StringFormat() { Trimming = StringTrimming.EllipsisCharacter, Alignment = StringAlignment.Center }) using (SolidBrush pingOutlineColor = new SolidBrush(Color.DarkRed)) using (Pen pingOutline = new Pen(pingOutlineColor)) { UserStats stats = user.Stats; PointF iconPosition = new PointF((float)e.Bounds.Left + 1.0f, (float)e.Bounds.Top + 1.0f); e.Graphics.DrawImage(m_provider.GetImageFor(user.Flags, stats), iconPosition); int userPing = user.Ping; if (userPing < 0) { userPing = int.MaxValue; } int pingWidth = (int)Math.Min(28.0f * ((float)userPing / 600.0f), 28.0f); Rectangle pingImgArea = new Rectangle(e.Bounds.Right - 33, e.Bounds.Y + (e.Bounds.Height - m_pingImg.Height) / 2, pingWidth, m_pingImg.Height); e.Graphics.DrawImageUnscaledAndClipped(m_pingImg, pingImgArea); //Rectangle pingOutlineBox = new Rectangle(pingImgArea.X, pingImgArea.Y, m_pingImg.Width - 1, m_pingImg.Height - 1); //e.Graphics.DrawRectangle(pingOutline, pingOutlineBox); //string userPingText = user.Ping.ToString(CultureInfo.CurrentCulture); //e.Graphics.DrawString(userPingText, e.Font, textBrush, pingOutlineBox, pingFormat); SizeF nameSize = e.Graphics.MeasureString(user.Username, e.Font); RectangleF nameArea = new RectangleF((float)e.Bounds.X + (float)m_provider.IconSize.Width + 1.0f + 4.0f, (float)e.Bounds.Y + (((float)e.Bounds.Height - nameSize.Height) / 2.0f), (float)e.Bounds.Width - 10.0f - 28.0f - (float)m_provider.IconSize.Width, (float)nameSize.Height); e.Graphics.DrawString(user.Username, e.Font, textBrush, nameArea, nameFormat); } }
public void DrawItem(CustomItemDrawData e) { e.DrawBackground(); if ((e.State & DrawItemState.Selected) == System.Windows.Forms.DrawItemState.Selected) { e.DrawFocusRectangle(); } FriendUser friend = e.Item as FriendUser; Color textColor = e.ForeColor; if (friend.LocationType == FriendLocation.Offline) { if ((e.State & DrawItemState.Selected) == System.Windows.Forms.DrawItemState.Selected) { textColor = Color.Black; } else { textColor = Color.SlateGray; } } using (SolidBrush textBrush = new SolidBrush(textColor)) using (StringFormat nameFormat = new StringFormat() { Trimming = StringTrimming.EllipsisCharacter }) { PointF iconPosition = new PointF((float)e.Bounds.Location.X + 1.0f, (float)e.Bounds.Location.Y + 1.0f); e.Graphics.DrawImage(m_provider.GetImageFor(friend.Product), (PointF)iconPosition); SizeF nameSize = e.Graphics.MeasureString(friend.AccountName, e.Font); RectangleF nameArea = new RectangleF((float)e.Bounds.X + (float)m_provider.IconSize.Width + 1.0f + 4.0f, (float)e.Bounds.Y + (((float)e.Bounds.Height - nameSize.Height) / 2.0f), (float)e.Bounds.Width - (float)m_provider.IconSize.Width - 2.0f - 4.0f, (float)nameSize.Height); e.Graphics.DrawString(friend.AccountName, e.Font, textBrush, nameArea, nameFormat); } }