private Bitmap RenderItem(out int picH) { Bitmap tooltip = new Bitmap(290, DefaultPicHeight); Graphics g = Graphics.FromImage(tooltip); StringFormat format = (StringFormat)StringFormat.GenericDefault.Clone(); int value; picH = 10; //物品标题 StringResult sr; if (StringLinker == null || !StringLinker.StringItem.TryGetValue(item.ItemID, out sr)) { sr = new StringResult(); sr.Name = "(null)"; } SizeF titleSize = g.MeasureString(sr.Name, GearGraphics.ItemNameFont2, short.MaxValue, format); titleSize.Width += 12 * 2; if (titleSize.Width > 290) { //重构大小 g.Dispose(); tooltip.Dispose(); tooltip = new Bitmap((int)Math.Ceiling(titleSize.Width), DefaultPicHeight); g = Graphics.FromImage(tooltip); picH = 10; } //绘制标题 bool hasPart2 = false; format.Alignment = StringAlignment.Center; g.DrawString(sr.Name, GearGraphics.ItemNameFont2, Brushes.White, tooltip.Width / 2, picH, format); picH += 22; //额外特性 string attr = GetItemAttributeString(); if (!string.IsNullOrEmpty(attr)) { g.DrawString(attr, GearGraphics.ItemDetailFont, GearGraphics.GearNameBrushC, tooltip.Width / 2, picH, format); picH += 19; hasPart2 = true; } string expireTime = null; if (item.Props.TryGetValue(ItemPropType.permanent, out value) && value != 0) { expireTime = ItemStringHelper.GetItemPropString(ItemPropType.permanent, value); } else if (item.Props.TryGetValue(ItemPropType.life, out value) && value > 0) { DateTime time = DateTime.Now.AddDays(value); expireTime = time.ToString("USABLE UNTIL M-d-yyyy AT H:m"); } if (!string.IsNullOrEmpty(expireTime)) { g.DrawString(expireTime, GearGraphics.ItemDetailFont, Brushes.White, tooltip.Width / 2, picH, format); picH += 16; hasPart2 = true; } if (hasPart2) { picH += 1; } //装备限时 if (item.TimeLimited) { DateTime time = DateTime.Now.AddDays(7d); string expireStr = time.ToString("USABLE UNTIL M-d-yyyy AT H:m"); g.DrawString(expireStr, GearGraphics.ItemDetailFont, Brushes.White, tooltip.Width / 2, picH, format); picH += 21; } //绘制图标 int iconY = picH; int iconX = 14; g.DrawImage(Resource.UIToolTip_img_Item_ItemIcon_base, iconX, picH); if (item.Icon.Bitmap != null) { g.DrawImage(GearGraphics.EnlargeBitmap(item.Icon.Bitmap), iconX + 6 + (1 - item.Icon.Origin.X) * 2, picH + 6 + (33 - item.Icon.Origin.Y) * 2); } if (item.Cash) { Bitmap cashImg = null; if (item.Props.TryGetValue(ItemPropType.wonderGrade, out value) && value > 0) { string resKey = $"CashShop_img_CashItem_label_{value + 3}"; cashImg = Resource.ResourceManager.GetObject(resKey) as Bitmap; } if (cashImg == null) //default cashImg { cashImg = Resource.CashItem_0; } g.DrawImage(GearGraphics.EnlargeBitmap(cashImg), iconX + 6 + 68 - 26, picH + 6 + 68 - 26); } g.DrawImage(Resource.UIToolTip_img_Item_ItemIcon_cover, iconX + 4, picH + 4); //绘制左上角cover if (item.Props.TryGetValue(ItemPropType.reqLevel, out value)) { g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit; g.PixelOffsetMode = PixelOffsetMode.HighQuality; g.DrawString("REQ LEV :" + value, GearGraphics.ItemReqLevelFont, Brushes.White, 97, picH); picH += 15; g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SystemDefault; } else { picH += 3; } int right = tooltip.Width - 18; string desc = null; if (item.Level > 0) { desc += $"[LV.{item.Level}] "; } desc += sr.Desc; if (!string.IsNullOrEmpty(desc)) { GearGraphics.DrawString(g, desc, GearGraphics.ItemDetailFont2, 100, right, ref picH, 16); } if (!string.IsNullOrEmpty(sr.AutoDesc)) { GearGraphics.DrawString(g, sr.AutoDesc, GearGraphics.ItemDetailFont2, 100, right, ref picH, 16); } if (item.Props.TryGetValue(ItemPropType.tradeAvailable, out value) && value > 0) { attr = ItemStringHelper.GetItemPropString(ItemPropType.tradeAvailable, value); if (!string.IsNullOrEmpty(attr)) { GearGraphics.DrawString(g, "#c" + attr + "#", GearGraphics.ItemDetailFont2, 100, right, ref picH, 16); } } if (item.Specs.TryGetValue(ItemSpecType.recipeValidDay, out value) && value > 0) { GearGraphics.DrawString(g, "(Use Within " + value + " day(s))", GearGraphics.ItemDetailFont, 100, right, ref picH, 16); } if (item.Specs.TryGetValue(ItemSpecType.recipeUseCount, out value) && value > 0) { GearGraphics.DrawString(g, "(Craftable " + value + " time(s)", GearGraphics.ItemDetailFont, 100, right, ref picH, 16); } picH += 3; Wz_Node nickResNode = null; bool willDrawNickTag = this.ShowNickTag && this.Item.Props.TryGetValue(ItemPropType.nickTag, out value) && this.TryGetNickResource(value, out nickResNode); string descLeftAlign = sr["desc_leftalign"]; if (!string.IsNullOrEmpty(descLeftAlign) || item.Sample.Bitmap != null || willDrawNickTag) { if (picH < iconY + 84) { picH = iconY + 84; } if (!string.IsNullOrEmpty(descLeftAlign)) { picH += 12; GearGraphics.DrawString(g, descLeftAlign, GearGraphics.ItemDetailFont, 14, right, ref picH, 16); } if (item.Sample.Bitmap != null) { g.DrawImage(item.Sample.Bitmap, (tooltip.Width - item.Sample.Bitmap.Width) / 2, picH); picH += item.Sample.Bitmap.Height; picH += 2; } if (nickResNode != null) { //获取称号名称 string nickName; string nickWithQR = sr["nickWithQR"]; if (nickWithQR != null) { string qrDefault = sr["qrDefault"] ?? string.Empty; nickName = Regex.Replace(nickWithQR, "#qr.*?#", qrDefault); } else { nickName = sr.Name; } GearGraphics.DrawNameTag(g, nickResNode, nickName, tooltip.Width, ref picH); picH += 4; } } //绘制配方需求 if (item.Specs.TryGetValue(ItemSpecType.recipe, out value)) { int reqSkill, reqSkillLevel; if (!item.Specs.TryGetValue(ItemSpecType.reqSkill, out reqSkill)) { reqSkill = value / 10000 * 10000; } if (!item.Specs.TryGetValue(ItemSpecType.reqSkillLevel, out reqSkillLevel)) { reqSkillLevel = 1; } picH = Math.Max(picH, iconY + 107); g.DrawLine(Pens.White, 6, picH, 283, picH);//分割线 picH += 10; g.DrawString("<Requirements>", GearGraphics.ItemDetailFont, GearGraphics.SetItemNameBrush, 8, picH); picH += 17; //技能标题 if (StringLinker == null || !StringLinker.StringSkill.TryGetValue(reqSkill, out sr)) { sr = new StringResult(); sr.Name = "(null)"; } g.DrawString(string.Format("· {0} Lv. {1}", sr.Name, reqSkillLevel), GearGraphics.ItemDetailFont, GearGraphics.SetItemNameBrush, 13, picH); picH += 16; picH += 6; } picH = Math.Max(iconY + 94, picH + 6); return(tooltip); }