private void AddSkill(SkillBox box, bool isEnable = true) { TextBlock skillButton = new TextBlock() { Text = string.Format("{0}", box.Name), Foreground = null, FontSize = 12, FontFamily = new FontFamily("SimHei") }; if (box.StatusInfo != string.Empty) { ToolTipService.SetToolTip(skillButton, box.StatusInfo); } if (box.IsSwitchInternalSkill) { skillButton.Foreground = new SolidColorBrush(Colors.Purple); } else if (box.IsUnique) { skillButton.Foreground = new SolidColorBrush(Colors.Red); } else if (box.IsSpecial) { skillButton.Foreground = new SolidColorBrush(Colors.Cyan); } else { skillButton.Foreground = new SolidColorBrush(Colors.White); } if (box.Status == SkillStatus.Ok && isEnable) { skillButton.MouseLeftButtonUp += (s, e) => { Callback(box); }; } else { skillButton.Opacity = 0.35; } skillButton.MouseEnter += (s, e) => { skillButton.Foreground = new SolidColorBrush(Colors.Orange); skillinfo.Xaml = box.GenerateToolTip(false).Xaml.Replace("#FF000000", "#FFFFFFFF"); //将黑色的字变成白色的 //skillinfo.Blocks.Add(box.GenerateToolTip().Blocks[0]); }; skillButton.MouseLeave += (s, e) => { if (box.IsSwitchInternalSkill) { skillButton.Foreground = new SolidColorBrush(Colors.Purple); } else if (box.IsUnique) { skillButton.Foreground = new SolidColorBrush(Colors.Red); } else if (box.IsSpecial) { skillButton.Foreground = new SolidColorBrush(Colors.Cyan); } else { skillButton.Foreground = new SolidColorBrush(Colors.White); } skillinfo.Blocks.Clear(); }; SkillContainer.Children.Add(skillButton); }
public static SkillHotKeysItem Create(SkillBox box, char hotKey, SkillHotKeysPanel parent) { SkillHotKeysItem rst = new SkillHotKeysItem(); ToolTipService.SetToolTip(rst, box.GenerateToolTip()); if (box.Name.Length > 14) { rst.NameText.Text = box.Name.Substring(0, 3) + "..."; } else { rst.NameText.Text = box.Name; } rst.HotKeyText.Text = hotKey.ToString(); if (box.Instance != null && !box.IsUnique) //外功 { switch (box.Instance.Skill.Type) { case CommonSettings.SKILLTYPE_JIAN: rst.TypeImageJian.Visibility = Visibility.Visible; break; case CommonSettings.SKILLTYPE_DAO: rst.TypeImageDao.Visibility = Visibility.Visible; break; case CommonSettings.SKILLTYPE_QUAN: rst.TypeImageQuan.Visibility = Visibility.Visible; break; case CommonSettings.SKILLTYPE_QIMEN: rst.TypeImageQimen.Visibility = Visibility.Visible; break; default: break; } } else if (box.IsUnique) //绝技 { rst.NameText.Foreground = new SolidColorBrush(Colors.Red); switch (box.Type) { case CommonSettings.SKILLTYPE_JIAN: rst.TypeImageJian.Visibility = Visibility.Visible; break; case CommonSettings.SKILLTYPE_DAO: rst.TypeImageDao.Visibility = Visibility.Visible; break; case CommonSettings.SKILLTYPE_QUAN: rst.TypeImageQuan.Visibility = Visibility.Visible; break; case CommonSettings.SKILLTYPE_QIMEN: rst.TypeImageQimen.Visibility = Visibility.Visible; break; case CommonSettings.SKILLTYPE_NEIGONG: rst.TypeImageNeigong.Visibility = Visibility.Visible; break; default: break; } } else if (box.IsSpecial) { rst.NameText.Foreground = new SolidColorBrush(Colors.Cyan); rst.TypeImageSpecial.Visibility = Visibility.Visible; } rst.MouseLeftButtonDown += (ss, ee) => { parent.Callback(box); }; return(rst); }