public void Show(Role r) { IsActive = true; _mapping.Clear(); this.HotKeyPanel.Children.Clear(); this.SpecialSkillHotKeyPanel.Children.Clear(); int skillIndex = 0; int spIndex = 0; foreach (var s in r.GetAvaliableSkills()) { if (s.Instance != null || s.IsInternalUnique) { if (s.Status == SkillStatus.Ok && skillIndex < _hotKeys.Length - 1) { this.HotKeyPanel.Children.Add(SkillHotKeysItem.Create(s, _hotKeys[skillIndex], this)); _mapping[_hotKeys[skillIndex]] = s; } skillIndex++; } else if (s.SpecialSkill != null && spIndex < _specialHotKeys.Length - 1) { if (s.Status == SkillStatus.Ok) { this.SpecialSkillHotKeyPanel.Children.Add(SkillHotKeysItem.Create(s, _specialHotKeys[spIndex], this)); _mapping[_specialHotKeys[spIndex]] = s; } spIndex++; } } this.Visibility = System.Windows.Visibility.Visible; }
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); }