private void cmdDelete_Click(object sender, EventArgs e) { if (!CommonFunctions.ConfirmDelete(LanguageManager.GetString("Message_DeleteKnowledgeSkill"))) { return; } _skill.UnbindSkill(); _skill.CharacterObject.SkillsSection.KnowledgeSkills.Remove(_skill); }
public KnowledgeSkillControl(KnowledgeSkill skill) { if (skill == null) { return; } _skill = skill; InitializeComponent(); LanguageManager.TranslateWinForm(GlobalOptions.Language, this); //Display lblModifiedRating.DoDatabinding("Text", skill, nameof(KnowledgeSkill.DisplayPool)); lblModifiedRating.DoDatabinding("ToolTipText", skill, nameof(KnowledgeSkill.PoolToolTip)); List <ListItem> lstTypes = KnowledgeSkill.KnowledgeTypes().ToList(); lstTypes.Sort(CompareListItems.CompareNames); cboType.BeginUpdate(); cboSkill.BeginUpdate(); cboSpec.BeginUpdate(); cboType.DataSource = lstTypes; cboType.DisplayMember = nameof(ListItem.Name); cboType.ValueMember = nameof(ListItem.Value); cboType.DataBindings.Add("SelectedValue", skill, nameof(KnowledgeSkill.Type), false, DataSourceUpdateMode.OnPropertyChanged); nudSkill.Visible = !skill.CharacterObject.Created && skill.CharacterObject.SkillsSection.HasKnowledgePoints; nudKarma.Visible = !skill.CharacterObject.Created; chkKarma.Visible = !skill.CharacterObject.Created; cboSpec.Visible = !skill.CharacterObject.Created; //cboType.Visible = !skill.CharacterObject.Created; btnCareerIncrease.Visible = skill.CharacterObject.Created; lblSpec.Visible = skill.CharacterObject.Created; btnAddSpec.Visible = skill.CharacterObject.Created; lblRating.Visible = skill.CharacterObject.Created; if (skill.CharacterObject.Created) { nudKarma.Visible = false; nudSkill.Visible = false; lblRating.Visible = true; lblRating.DataBindings.Add("Text", skill, nameof(Skill.Rating), false, DataSourceUpdateMode.OnPropertyChanged); //New knowledge skills start at 0. Leave the Type selector unlocked until they spend Karma on the skill. cboType.Enabled = (skill.Karma == 0 && skill.Base == 0 || string.IsNullOrWhiteSpace(_skill.Type)); lblName.Visible = true; lblName.DataBindings.Add("Text", skill, nameof(KnowledgeSkill.WriteableName), false, DataSourceUpdateMode.OnPropertyChanged); lblName.DataBindings.Add("ForeColor", skill, nameof(Skill.PreferredColor)); lblName.DataBindings.Add("ToolTipText", skill, nameof(Skill.HtmlSkillToolTip)); lblSpec.Visible = true; lblSpec.DataBindings.Add("Text", skill, nameof(Skill.CurrentDisplaySpecialization), false, DataSourceUpdateMode.OnPropertyChanged); cboSkill.Visible = false; chkKarma.Visible = false; cboSpec.Visible = false; lblModifiedRating.Location = new Point(294 - 30, 4); btnAddSpec.DataBindings.Add("Enabled", skill, nameof(Skill.CanAffordSpecialization), false, DataSourceUpdateMode.OnPropertyChanged); btnAddSpec.DataBindings.Add("Visible", skill, nameof(Skill.CanHaveSpecs), false, DataSourceUpdateMode.OnPropertyChanged); btnAddSpec.DataBindings.Add("ToolTipText", skill, nameof(Skill.AddSpecToolTip), false, DataSourceUpdateMode.OnPropertyChanged); btnCareerIncrease.DataBindings.Add("Enabled", skill, nameof(Skill.CanUpgradeCareer), false, DataSourceUpdateMode.OnPropertyChanged); btnCareerIncrease.DataBindings.Add("ToolTipText", skill, nameof(Skill.UpgradeToolTip), false, DataSourceUpdateMode.OnPropertyChanged); } else { //Up down boxes nudKarma.DataBindings.Add("Value", skill, nameof(Skill.Karma), false, DataSourceUpdateMode.OnPropertyChanged); nudKarma.DataBindings.Add("InterceptMouseWheel", skill.CharacterObject.Options, nameof(CharacterOptions.InterceptMode), false, DataSourceUpdateMode.OnPropertyChanged); nudSkill.DataBindings.Add("Value", skill, nameof(Skill.Base), false, DataSourceUpdateMode.OnPropertyChanged); nudSkill.DataBindings.Add("Enabled", skill.CharacterObject.SkillsSection, nameof(SkillsSection.HasKnowledgePoints), false, DataSourceUpdateMode.OnPropertyChanged); nudSkill.DataBindings.Add("InterceptMouseWheel", skill.CharacterObject.Options, nameof(CharacterOptions.InterceptMode), false, DataSourceUpdateMode.OnPropertyChanged); chkKarma.DataBindings.Add("Checked", skill, nameof(Skill.BuyWithKarma), false, DataSourceUpdateMode.OnPropertyChanged); List <ListItem> lstDefaultKnowledgeSkills = KnowledgeSkill.DefaultKnowledgeSkills().ToList(); lstDefaultKnowledgeSkills.Sort(CompareListItems.CompareNames); cboSkill.DataSource = lstDefaultKnowledgeSkills; cboSkill.DisplayMember = nameof(ListItem.Name); cboSkill.ValueMember = nameof(ListItem.Value); cboSkill.SelectedIndex = -1; cboSkill.DataBindings.Add("Text", skill, nameof(KnowledgeSkill.WriteableName), false, DataSourceUpdateMode.OnPropertyChanged); cboSkill.DataBindings.Add(new NegatableBinding("Enabled", skill, nameof(KnowledgeSkill.ForcedName), true)); //dropdown/spec cboSpec.DataSource = skill.CGLSpecializations; cboSpec.DisplayMember = nameof(ListItem.Name); cboSpec.ValueMember = nameof(ListItem.Value); cboSpec.SelectedIndex = -1; cboSpec.DataBindings.Add("Enabled", skill, nameof(Skill.CanHaveSpecs), false, DataSourceUpdateMode.OnPropertyChanged); cboSpec.DataBindings.Add("Text", skill, nameof(Skill.Specialization), false, DataSourceUpdateMode.OnPropertyChanged); skill.PropertyChanged += Skill_PropertyChanged; } cmdDelete.DataBindings.Add("Visible", skill, nameof(Skill.AllowDelete), false, DataSourceUpdateMode.OnPropertyChanged); cmdDelete.Click += (sender, args) => { if (!skill.CharacterObject.ConfirmDelete(LanguageManager.GetString("Message_DeleteKnowledgeSkill", GlobalOptions.Language))) { return; } skill.UnbindSkill(); skill.CharacterObject.SkillsSection.KnowledgeSkills.Remove(skill); }; if (skill.ForcedName) { DataBindings.Add("Enabled", skill, nameof(KnowledgeSkill.Enabled), false, DataSourceUpdateMode.OnPropertyChanged); if (!skill.CharacterObject.Created) { cboType.Enabled = string.IsNullOrEmpty(_skill.Type); } } if (!skill.AllowUpgrade) { nudKarma.Visible = false; nudSkill.Visible = false; cboSkill.Enabled = false; chkKarma.Visible = false; btnAddSpec.Enabled = false; btnCareerIncrease.Enabled = false; if (!skill.CharacterObject.Created) { lblRating.Visible = true; lblRating.DataBindings.Add("Text", skill, nameof(Skill.Rating), false, DataSourceUpdateMode.OnPropertyChanged); } } cboType.EndUpdate(); cboSkill.EndUpdate(); cboSpec.EndUpdate(); }
public KnowledgeSkillControl(KnowledgeSkill skill) { _skill = skill; InitializeComponent(); //Display lblModifiedRating.DataBindings.Add("Text", skill, nameof(KnowledgeSkill.DisplayPool), false, DataSourceUpdateMode.OnPropertyChanged); List <ListItem> lstTypes = KnowledgeSkill.KnowledgeTypes(GlobalOptions.Language).ToList(); lstTypes.Sort(CompareListItems.CompareNames); cboType.BeginUpdate(); cboSkill.BeginUpdate(); cboSpec.BeginUpdate(); cboType.DisplayMember = nameof(ListItem.Name); cboType.ValueMember = nameof(ListItem.Value); cboType.DataSource = lstTypes; cboType.DataBindings.Add("SelectedValue", skill, nameof(KnowledgeSkill.Type), false, DataSourceUpdateMode.OnPropertyChanged); if (skill.CharacterObject.Created) { nudKarma.Visible = false; nudSkill.Visible = false; lblRating.Visible = true; lblRating.DataBindings.Add("Text", skill, nameof(Skill.Rating), false, DataSourceUpdateMode.OnPropertyChanged); //New knowledge skills start at 0. Leave the Type selector unlocked until they spend Karma on the skill. cboType.Enabled = (skill.Karma == 0 && skill.Base == 0 || string.IsNullOrWhiteSpace(_skill.Type)); lblName.Visible = true; lblName.DataBindings.Add("Text", skill, nameof(KnowledgeSkill.WriteableName), false, DataSourceUpdateMode.OnPropertyChanged); lblSpec.Visible = true; lblSpec.DataBindings.Add("Text", skill, nameof(Skill.DisplaySpecialization), false, DataSourceUpdateMode.OnPropertyChanged); cboSkill.Visible = false; chkKarma.Visible = false; cboSpec.Visible = false; lblModifiedRating.Location = new Point(294 - 30, 4); btnAddSpec.Visible = true; btnAddSpec.DataBindings.Add("Enabled", skill, nameof(Skill.CanAffordSpecialization), false, DataSourceUpdateMode.OnPropertyChanged); btnCareerIncrease.Visible = true; btnCareerIncrease.DataBindings.Add("Enabled", skill, nameof(Skill.CanUpgradeCareer), false, DataSourceUpdateMode.OnPropertyChanged); } else { //Up down boxes nudKarma.DataBindings.Add("Value", skill, nameof(Skill.Karma), false, DataSourceUpdateMode.OnPropertyChanged); nudKarma.DataBindings.Add("InterceptMouseWheel", skill.CharacterObject.Options, nameof(CharacterOptions.InterceptMode), false, DataSourceUpdateMode.OnPropertyChanged); nudSkill.DataBindings.Add("Value", skill, nameof(Skill.Base), false, DataSourceUpdateMode.OnPropertyChanged); nudSkill.DataBindings.Add("Enabled", skill.CharacterObject.SkillsSection, nameof(SkillsSection.HasKnowledgePoints), false, DataSourceUpdateMode.OnPropertyChanged); nudSkill.DataBindings.Add("InterceptMouseWheel", skill.CharacterObject.Options, nameof(CharacterOptions.InterceptMode), false, DataSourceUpdateMode.OnPropertyChanged); chkKarma.DataBindings.Add("Checked", skill, nameof(Skill.BuyWithKarma), false, DataSourceUpdateMode.OnPropertyChanged); cboSkill.DisplayMember = nameof(ListItem.Name); cboSkill.ValueMember = nameof(ListItem.Value); List <ListItem> lstDefaultKnowledgeSkills = KnowledgeSkill.DefaultKnowledgeSkills(GlobalOptions.Language).ToList(); lstDefaultKnowledgeSkills.Sort(CompareListItems.CompareNames); cboSkill.DataSource = lstDefaultKnowledgeSkills; cboSkill.SelectedIndex = -1; cboSkill.DataBindings.Add("Text", skill, nameof(KnowledgeSkill.WriteableName), false, DataSourceUpdateMode.OnPropertyChanged); //dropdown/spec cboSpec.DisplayMember = nameof(ListItem.Name); cboSpec.ValueMember = nameof(ListItem.Value); cboSpec.DataSource = skill.CGLSpecializations; cboSpec.SelectedIndex = -1; cboSpec.DataBindings.Add("Enabled", skill, nameof(Skill.Leveled), false, DataSourceUpdateMode.OnPropertyChanged); cboSpec.DataBindings.Add("Text", skill, nameof(Skill.Specialization), false, DataSourceUpdateMode.OnPropertyChanged); skill.PropertyChanged += RefreshSpecializationComboBox; } if (skill.ForcedName) { DataBindings.Add("Enabled", skill, nameof(KnowledgeSkill.Enabled), false, DataSourceUpdateMode.OnPropertyChanged); nudKarma.Visible = false; nudSkill.Visible = false; cboSkill.Enabled = false; cboSpec.DataBindings.Clear(); cboSpec.Enabled = false; btnAddSpec.Enabled = false; btnCareerIncrease.Enabled = false; lblRating.Visible = true; lblRating.Text = skill.CyberwareRating.ToString(); cmdDelete.Visible = false; } else { cmdDelete.Click += (sender, args) => { skill.UnbindSkill(); skill.CharacterObject.SkillsSection.KnowledgeSkills.Remove(skill); }; } cboType.EndUpdate(); cboSkill.EndUpdate(); cboSpec.EndUpdate(); }