public ToolTipPropertySet(ToolTipPropertySet source) { this.m_img = new Bitmap(source.Image); this.m_text = source.Text; this.m_titleColor = source.TitleColor; this.m_titleText = source.Title; }
private void ttChannelTip_Draw(object sender, DrawToolTipEventArgs e) { ToolTipPropertySet ttps = FindTip(); if (ttps != null) { ttps.Draw(e.Graphics, e.Bounds, e.Font); } }
private void ttChannelTip_Popup(object sender, PopupEventArgs e) { ToolTipPropertySet ttps = FindTip(); if (ttps != null) { Size size = ttps.MeasureArrangement(listBox1.Font); e.ToolTipSize = size; } }
private ToolTipPropertySet FindTip() { ToolTipPropertySet ttps = null; int index = this.listBox1.IndexFromPoint(listBox1.PointToClient(Cursor.Position)); if (index < 65535 && index >= 0) { ChatUser user = listBox1.Items[index] as ChatUser; if (user != null) { if (!m_tips.ContainsKey(user)) { m_tips.Add(user, CreateTip(user)); } ttps = m_tips[user]; } } return(ttps); }
private ToolTipPropertySet CreateTip(ChatUser user) { // get the image to use Image icon = null; if (m_resourceProvider != null) { icon = m_resourceProvider.Icons.GetImageFor(user.Stats.Product); } // get the color to use. Color background = Color.Black; if (ProductTipColors.ContainsKey(user.Stats.Product)) background = ProductTipColors[user.Stats.Product]; // generate description StringBuilder description = new StringBuilder(); description.Append("Product: "); description.AppendLine(user.Stats.Product.Name); description.Append("Ping: "); description.AppendLine(user.Ping.ToString(CultureInfo.InvariantCulture)); description.Append("Flags: "); description.AppendLine(user.Flags.ToString()); description.AppendLine(); if (user.Stats is StarcraftStats) { StarcraftStats stats = user.Stats as StarcraftStats; description.Append("Wins: "); description.AppendLine(stats.Wins.ToString(CultureInfo.InvariantCulture)); description.Append("Rank: "); description.AppendLine(stats.LadderRank.ToString(CultureInfo.InvariantCulture)); description.Append("Rating: "); description.AppendLine(stats.LadderRating.ToString(CultureInfo.InvariantCulture)); } else if (user.Stats is Diablo2Stats) { Diablo2Stats stats = user.Stats as Diablo2Stats; description.AppendLine(stats.IsExpansionCharacter ? "Expansion character" : "Classic character"); if (stats.IsHardcoreCharacter) description.Append("Hardcore "); if (stats.IsLadderCharacter) description.Append("Ladder "); description.Append(stats.IsRealmCharacter ? "Realm " : "Open "); description.AppendLine("character"); if (stats.IsRealmCharacter) { description.AppendFormat(CultureInfo.InvariantCulture, "Level {0} {1}", stats.Level, stats.CharacterClass); description.AppendLine(); description.AppendLine(stats.CharacterName); description.AppendLine(stats.Difficulty.ToString()); } } else if (user.Stats is Warcraft3Stats) { Warcraft3Stats stats = user.Stats as Warcraft3Stats; description.Append("Clan: "); description.AppendLine(string.IsNullOrEmpty(stats.ClanTag) ? "(none)" : stats.ClanTag); description.AppendFormat(CultureInfo.InvariantCulture, "Level: {0}", stats.Level); description.AppendLine(); } ToolTipPropertySet ttps = new ToolTipPropertySet(user.Username, description.ToString(), background, icon, Color.White, background); return ttps; }
private ToolTipPropertySet CreateTip(ChatUser user) { // get the image to use Image icon = null; if (m_resourceProvider != null) { icon = m_resourceProvider.Icons.GetImageFor(user.Stats.Product); } // get the color to use. Color background = Color.Black; if (ProductTipColors.ContainsKey(user.Stats.Product)) { background = ProductTipColors[user.Stats.Product]; } // generate description StringBuilder description = new StringBuilder(); description.Append("Product: "); description.AppendLine(user.Stats.Product.Name); description.Append("Ping: "); description.AppendLine(user.Ping.ToString(CultureInfo.InvariantCulture)); description.Append("Flags: "); description.AppendLine(user.Flags.ToString()); description.AppendLine(); if (user.Stats is StarcraftStats) { StarcraftStats stats = user.Stats as StarcraftStats; description.Append("Wins: "); description.AppendLine(stats.Wins.ToString(CultureInfo.InvariantCulture)); description.Append("Rank: "); description.AppendLine(stats.LadderRank.ToString(CultureInfo.InvariantCulture)); description.Append("Rating: "); description.AppendLine(stats.LadderRating.ToString(CultureInfo.InvariantCulture)); } else if (user.Stats is Diablo2Stats) { Diablo2Stats stats = user.Stats as Diablo2Stats; description.AppendLine(stats.IsExpansionCharacter ? "Expansion character" : "Classic character"); if (stats.IsHardcoreCharacter) { description.Append("Hardcore "); } if (stats.IsLadderCharacter) { description.Append("Ladder "); } description.Append(stats.IsRealmCharacter ? "Realm " : "Open "); description.AppendLine("character"); if (stats.IsRealmCharacter) { description.AppendFormat(CultureInfo.InvariantCulture, "Level {0} {1}", stats.Level, stats.CharacterClass); description.AppendLine(); description.AppendLine(stats.CharacterName); description.AppendLine(stats.Difficulty.ToString()); } } else if (user.Stats is Warcraft3Stats) { Warcraft3Stats stats = user.Stats as Warcraft3Stats; description.Append("Clan: "); description.AppendLine(string.IsNullOrEmpty(stats.ClanTag) ? "(none)" : stats.ClanTag); description.AppendFormat(CultureInfo.InvariantCulture, "Level: {0}", stats.Level); description.AppendLine(); } ToolTipPropertySet ttps = new ToolTipPropertySet(user.Username, description.ToString(), background, icon, Color.White, background); return(ttps); }