private void OnDeleteRecordButtonClick(object sender, EventArgs e) { int selected; if (DataDeleteWarning() == false) { return; } Model.Delete(); //repopulate the tome list selected = TomeListBox.SelectedIndex - 1; if (selected < 0) { selected = 0; } TomeListBox.Items.Clear(); TomeListNames = TomeModel.GetNames(); foreach (string name in TomeListNames) { TomeListBox.Items.Add(name); } TomeListBox.SelectedIndex = selected; }
private void SkillUpDownValueChanged(object sender, EventArgs e) { NumericUpDownWithBlank control; string controlName; List <string> SkillNames; CharacterSkillClass.Skills Skill; SkillNames = Enum.GetNames(typeof(CharacterSkillClass.Skills)).ToList(); control = (NumericUpDownWithBlank)sender; int tomeBonus; int minLevel = 0; if (AllowChange == true) { bool SkillFound = false; controlName = control.Name; //determine the ability changed Skill = CharacterSkillClass.Skills.Balance; for (int i = 0; i < SkillNames.Count; ++i) { if (controlName.Contains(SkillNames[i])) { Skill = (CharacterSkillClass.Skills)i; SkillFound = true; if (SkillFound) { break; } } } if (!SkillFound) { return; } //determine the level of the tome tomeBonus = (int)control.Value; Guid SkillID = SkillModel.GetIdFromName(Skill.ToString().Replace("_", " ")); int SkillMax = TomeModel.GetMaxBonus(SkillID); if (tomeBonus != 0) { minLevel = TomeModel.GetMinLevel(SkillID, tomeBonus); } if (control.Blank == true) { CharacterManagerClass.CharacterManager.CharacterSkill.SetPriorLifeTomeBonus(Skill, tomeBonus, 0); } else { CharacterManagerClass.CharacterManager.CharacterSkill.SetPriorLifeTomeBonus(Skill, tomeBonus, minLevel); } for (int i = tomeBonus + 1; i < SkillMax + 1; ++i) { CharacterManagerClass.CharacterManager.CharacterSkill.SetPriorLifeTomeBonus(Skill, i, 0); } //inform other screens UIManagerClass.UIManager.ScreenMessenger.NotifyChange(UIManagerClass.ChildScreen.PastLifeEditScreen, ScreenMessengerClass.ChangeList.SkillChange); } }
private void OnTomeListBoxSelectedIndexChanged(object sender, EventArgs e) { if (DataChangeWarning() == false) { return; } Model = new TomeModel(); if (TomeListBox.SelectedIndex != -1) { Model.Initialize(TomeListBox.SelectedItem.ToString()); } PopulateFields(Model.TomeLongName); }
/// <summary> /// Save the data from the model into the database /// </summary> private void SaveScreen() { SaveLabel.ForeColor = Color.Green; SaveLabel.Text = "Saving Record..."; SaveLabel.Refresh(); Model.Save(); SaveLabel.ForeColor = Color.Green; SaveLabel.Text = "Record Saved"; //populate the tome list box TomeListBox.Items.Clear(); TomeListNames = TomeModel.GetNames(); foreach (string Name in TomeListNames) { TomeListBox.Items.Add(Name); } }
private void OnDuplicateRecordButtonClick(object sender, System.EventArgs e) { TomeModel duplicateModel; int index, newIndex; SaveLabel.ForeColor = Color.Green; SaveLabel.Text = "Duplicating Record..."; SaveLabel.Refresh(); //save the current model (just in case the user has changed anything Model.Save(); duplicateModel = new TomeModel(); duplicateModel.MinLevel = Model.MinLevel; duplicateModel.ModifiedID = Model.ModifiedID; duplicateModel.TomeBonus = Model.TomeBonus; duplicateModel.TomeName = Model.TomeName; duplicateModel.TomeLongName = Model.TomeLongName; duplicateModel.TomeType = Model.TomeType; duplicateModel.Save(); SaveLabel.ForeColor = Color.Green; SaveLabel.Text = "Record Duplicated"; DataHasChanged = false; //populate the tome list box TomeListBox.Items.Clear(); TomeListNames = TomeModel.GetNames(); foreach (string Name in TomeListNames) { TomeListBox.Items.Add(Name); } //select the last instance of this name index = 0; newIndex = TomeListBox.FindStringExact(duplicateModel.TomeLongName); while (newIndex != ListBox.NoMatches && newIndex >= index) { index = newIndex; newIndex = TomeListBox.FindStringExact(duplicateModel.TomeLongName, index); } TomeListBox.SelectedIndex = index; }
public DataInputTomeScreenClass() { InitializeComponent(); Model = new TomeModel(); //populate the list of abilty and skill names AbilityNames = AbilityModel.GetNames(); SkillNames = SkillModel.GetNames(); foreach (string Name in AbilityNames) { ModifierListBox.Items.Add(Name); } //populate the tome list box TomeListNames = TomeModel.GetNames(); foreach (string Name in TomeListNames) { TomeListBox.Items.Add(Name); } }
public SkillTomePanel() { int posx = 10; int posy = 60; int MaxLevel; MaxLevel = DDOCharacterPlanner.Utility.Constant.MaxLevels; InitializeComponent(); SkillNames = Enum.GetNames(typeof(CharacterSkillClass.Skills)).ToList(); NumSkills = SkillNames.Count; List <Model.Tome.TomeModel> TomeList; TomeList = Model.Tome.TomeModel.GetAllByType("Skill"); TomeList.Sort((x, y) => x.TomeLongName.CompareTo(y.TomeLongName)); Dictionary <Guid, string> SkillbyID; SkillbyID = new Dictionary <Guid, string>(); SkillbyID = SkillModel.GetNamesByID(); //get max number of Tomes int TomeCount = TomeModel.GetCountByModifiedId(SkillbyID.Keys.First()); SkillTomePanelEntry = new SkillTomePanelEntryStruct(); SkillTomePanelEntry.SkillLabel = new Label[NumSkills]; SkillTomePanelEntry.PastLifeTome = new Label[NumSkills]; SkillTomePanelEntry.TomeUpDown = new NumericUpDownWithBlank[NumSkills, TomeCount]; //create Skill Labels for (int i = 0; i < NumSkills; ++i) { SkillTomePanelEntry.SkillLabel[i] = new Label(); SkillTomePanelEntry.SkillLabel[i].Name = SkillNames[i].ToString() + "Label"; SkillTomePanelEntry.SkillLabel[i].Text = SkillNames[i].ToString().Replace("_", " "); SkillTomePanelEntry.SkillLabel[i].Location = new Point(posx, posy + 27 * i); SkillTomePanelEntry.SkillLabel[i].Width = 100; SkillTomePanelEntry.SkillLabel[i].Font = new Font("Times New Roman", 9, FontStyle.Bold); SkillTomePanelEntry.SkillLabel[i].TextAlign = ContentAlignment.MiddleLeft; } //create past life Labels posx = 500; for (int i = 0; i < NumSkills; ++i) { SkillTomePanelEntry.PastLifeTome[i] = new Label(); SkillTomePanelEntry.PastLifeTome[i].Name = SkillNames[i].ToString() + "PastLifeLabel"; SkillTomePanelEntry.PastLifeTome[i].Text = "0"; SkillTomePanelEntry.PastLifeTome[i].Location = new Point(posx, posy + 27 * i); SkillTomePanelEntry.PastLifeTome[i].Width = 50; SkillTomePanelEntry.PastLifeTome[i].Font = new Font("Times New Roman", 9, FontStyle.Bold); SkillTomePanelEntry.PastLifeTome[i].TextAlign = ContentAlignment.MiddleCenter; } posx = 127; foreach (TomeModel Tome in TomeList) { int skillIndex; int skillBonus; skillIndex = SkillNames.IndexOf(SkillbyID[Tome.ModifiedID].Replace(" ", "_")); skillBonus = Tome.TomeBonus - 1; SkillTomePanelEntry.TomeUpDown[skillIndex, skillBonus] = new NumericUpDownWithBlank(); SkillTomePanelEntry.TomeUpDown[skillIndex, skillBonus].Name = SkillbyID[Tome.ModifiedID] + "UpDwn" + (skillBonus + 1); SkillTomePanelEntry.TomeUpDown[skillIndex, skillBonus].Location = new Point(posx + (skillBonus) * 70, posy + skillIndex * 27); SkillTomePanelEntry.TomeUpDown[skillIndex, skillBonus].Width = 40; SkillTomePanelEntry.TomeUpDown[skillIndex, skillBonus].Minimum = 1; SkillTomePanelEntry.TomeUpDown[skillIndex, skillBonus].Maximum = MaxLevel; if (CharacterManagerClass.CharacterManager.CharacterSkill.Tome[skillIndex, skillBonus] > 0) { SkillTomePanelEntry.TomeUpDown[skillIndex, skillBonus].Value = CharacterManagerClass.CharacterManager.CharacterSkill.Tome[skillIndex, skillBonus]; SkillTomePanelEntry.TomeUpDown[skillIndex, skillBonus].Blank = false; } else { SkillTomePanelEntry.TomeUpDown[skillIndex, skillBonus].Blank = true; } SkillTomePanelEntry.TomeUpDown[skillIndex, skillBonus].ValueChanged += TomeChanged; } foreach (Label newcontrol in SkillTomePanelEntry.SkillLabel) { if (newcontrol != null) { Skilltome.Controls.Add(newcontrol); } } foreach (Label newcontrol in SkillTomePanelEntry.PastLifeTome) { if (newcontrol != null) { Skilltome.Controls.Add(newcontrol); } } foreach (NumericUpDownWithBlank newcontrol in SkillTomePanelEntry.TomeUpDown) { if (newcontrol != null) { Skilltome.Controls.Add(newcontrol); } } //set Pastlife tomeValues handlePastlifeSkillTomeChange(); //apply Skin SkillTomePanelSkin(); // listen for events UIManagerClass.UIManager.ScreenMessenger.RegisterListen(UIManagerClass.ChildScreen.SkillTomeEditScreen, ScreenMessengerClass.ChangeList.SkillChange, handlePastlifeSkillTomeChange); }
private void OnNewTomeButtonClick(object sender, System.EventArgs e) { Model = new TomeModel(); ClearScreen(); }
public PastLifeEditScreen() { InitializeComponent(); NumClasses = ClassModel.GetNumClasses(); NumSkills = SkillModel.GetNumSkills(); NumIconic = RaceModel.GetNumIconic(); AllowChange = false; int xpos = 4; int ypos = 0; float iconposx = 4; float iconposy = 0; int currentrow = 0; int PanelHeight = PastLifeClassPanel.Height; int PanelWidth = PastLifeClassPanel.Width; int maxrow = (int)System.Math.Ceiling((decimal)NumClasses / 4); StringBuilder controlName; ClassPanelEntry.ClassIcon = new IconClass[NumClasses]; //ClassPanelEntry.ClassPastLifeValue = new Label[NumClasses]; ClassPanelEntry.ClassPastLifeUpDown = new NumericUpDownWithBlank[NumClasses]; ClassNames = ClassModel.GetNames(); int xposstart = 10; for (int i = 0; i < NumClasses; i++) { //create Icon ClassPanelEntry.ClassIcon[i] = new IconClass("Classes\\" + ClassNames[i]); //create updown data entry controlName = new StringBuilder(); controlName.Append("ClassUpDown"); controlName.Append(i); ClassPanelEntry.ClassPastLifeUpDown[i] = new NumericUpDownWithBlank(); ClassPanelEntry.ClassPastLifeUpDown[i].Name = controlName.ToString(); PastLifeClassPanel.Controls.Add(ClassPanelEntry.ClassPastLifeUpDown[i]); ClassPanelEntry.ClassPastLifeUpDown[i].Size = new Size(39, 20); ClassPanelEntry.ClassPastLifeUpDown[i].Blank = true; ClassPanelEntry.ClassPastLifeUpDown[i].ValueChanged += ClassUpDownValueChanged; ClassPanelEntry.ClassPastLifeUpDown[i].Minimum = 1; //TODO: Hardcoded value! Remove into the database ClassPanelEntry.ClassPastLifeUpDown[i].Maximum = 3; //create position start point currentrow = (int)i / 4; xpos = (i - (currentrow * 4)) * 100 + xposstart; iconposx = ((float)xpos / (float)PanelWidth); ypos = 30 + ((PastLifeClassPanel.Height - 30) / maxrow) * currentrow; iconposy = ((float)ypos / (float)PanelHeight); // Place Icon and control ClassPanelEntry.ClassIcon[i].SetLocation(PastLifeClassPanel.Width, PastLifeClassPanel.Height, new PointF(iconposx, iconposy)); ClassPanelEntry.ClassPastLifeUpDown[i].Location = new Point(xpos + 40, ypos + 5); } //populate the Iconic past life panel xpos = 4; ypos = 0; iconposx = 0; iconposy = 0; currentrow = 0; PanelHeight = PastLifeIconicPanel.Height; PanelWidth = PastLifeIconicPanel.Width; maxrow = (int)System.Math.Ceiling((decimal)NumIconic / 4); IconicPanelEntry.IconicIcon = new IconClass[NumIconic]; IconicPanelEntry.IconicPastLifeUpDown = new NumericUpDownWithBlank[NumIconic]; IconicNames = RaceModel.GetIconicNames(); for (int i = 0; i < NumIconic; i++) { //create Icon IconicPanelEntry.IconicIcon[i] = new IconClass("Races\\" + IconicNames[i] + " Icon"); //create updown data entry controlName = new StringBuilder(); controlName.Append("IconicUpDown"); controlName.Append(i); IconicPanelEntry.IconicPastLifeUpDown[i] = new NumericUpDownWithBlank(); IconicPanelEntry.IconicPastLifeUpDown[i].Name = controlName.ToString(); PastLifeIconicPanel.Controls.Add(IconicPanelEntry.IconicPastLifeUpDown[i]); IconicPanelEntry.IconicPastLifeUpDown[i].Size = new Size(39, 20); IconicPanelEntry.IconicPastLifeUpDown[i].Blank = true; IconicPanelEntry.IconicPastLifeUpDown[i].ValueChanged += IconiocUpDownValueChanged; IconicPanelEntry.IconicPastLifeUpDown[i].Minimum = 1; //TODO: Hardcoded value! Remove into the database IconicPanelEntry.IconicPastLifeUpDown[i].Maximum = 3; //create position start point currentrow = (int)i / 4; xpos = (i - (currentrow * 4)) * 100 + xposstart; iconposx = ((float)xpos / (float)PanelWidth); ypos = 30 + ((PastLifeClassPanel.Height - 30) / maxrow) * currentrow; iconposy = ((float)ypos / (float)PanelHeight); // Place Icon and control IconicPanelEntry.IconicIcon[i].SetLocation(PastLifeIconicPanel.Width, PastLifeIconicPanel.Height, new PointF(iconposx, iconposy)); IconicPanelEntry.IconicPastLifeUpDown[i].Location = new Point(xpos + 40, ypos + 10); } //populate the skills panel SkillNames = Enum.GetNames(typeof(CharacterSkillClass.Skills)).ToList(); SkillTomePanelEntry.SkillLabel = new Label[NumSkills]; SkillTomePanelEntry.SkillUpDown = new NumericUpDownWithBlank[NumSkills]; xpos = 20; ypos = 0; Control[] control; NumericUpDownWithBlank upDown; int rowsplit = (int)System.Math.Ceiling((decimal)NumSkills / 2); for (int i = 0; i < NumSkills; i++) { ypos = 30 * i; if (i >= rowsplit) { ypos -= 30 * rowsplit; } SkillTomePanelEntry.SkillLabel[i] = new Label(); SkillTomeSubPanel.Controls.Add(SkillTomePanelEntry.SkillLabel[i]); SkillTomePanelEntry.SkillLabel[i].Text = SkillNames[i].Replace("_", " "); SkillTomePanelEntry.SkillLabel[i].Location = new Point(xpos, ypos + 3); SkillTomePanelEntry.SkillLabel[i].AutoSize = true; SkillTomePanelEntry.SkillLabel[i].ForeColor = System.Drawing.Color.Gold; SkillTomePanelEntry.SkillLabel[i].Font = new Font("Times New Roman", 9, FontStyle.Bold); SkillTomePanelEntry.SkillLabel[i].Name = "SkillLabel" + i; SkillTomePanelEntry.SkillUpDown[i] = new NumericUpDownWithBlank(); SkillTomeSubPanel.Controls.Add(SkillTomePanelEntry.SkillUpDown[i]); SkillTomePanelEntry.SkillUpDown[i].Location = new Point(xpos + 120, ypos); SkillTomePanelEntry.SkillUpDown[i].Name = "SkillUpDown" + SkillNames[i]; SkillTomePanelEntry.SkillUpDown[i].Size = new Size(39, 20); SkillTomePanelEntry.SkillUpDown[i].Blank = true; SkillTomePanelEntry.SkillUpDown[i].Minimum = 1; SkillTomePanelEntry.SkillUpDown[i].ValueChanged += SkillUpDownValueChanged; System.Guid SkillID = SkillModel.GetIdFromName(SkillNames[i].Replace("_", " ")); int UpDownMax = TomeModel.GetMaxBonus(SkillID); SkillTomePanelEntry.SkillUpDown[i].Maximum = UpDownMax; if (i >= rowsplit - 1) { xpos = 200; } } AllowChange = true; for (int i = 0; i < NumSkills; ++i) { SetSkillUpDown(SkillTomePanelEntry.SkillUpDown[i]); } SetAbilityUpDown(StrUpDown); SetAbilityUpDown(DexUpDown); SetAbilityUpDown(ConUpDown); SetAbilityUpDown(IntUpDown); SetAbilityUpDown(WisUpDown); SetAbilityUpDown(ChaUpDown); for (int i = 0; i < NumClasses; ++i) { controlName = new StringBuilder(); controlName.Append("ClassUpDown"); controlName.Append(i); control = Controls.Find(controlName.ToString(), true); upDown = (NumericUpDownWithBlank)control[0]; if (upDown == null) { continue; } SetClassUpDown(upDown); } for (int i = 0; i < NumIconic; ++i) { controlName = new StringBuilder(); controlName.Append("IconicUpDown"); controlName.Append(i); control = Controls.Find(controlName.ToString(), true); upDown = (NumericUpDownWithBlank)control[0]; if (upDown == null) { continue; } SetIconicUpDown(upDown); } ClassTooltipDisplay = -1; IconicTooltipDisplay = -1; }
private void TomeUpDownValueChanged(object sender, EventArgs e) { NumericUpDownWithBlank control; string controlName; CharacterAbilityClass.Abilities ability; int tomeBonus; int minLevel = 0; if (AllowChange == true) { control = (NumericUpDownWithBlank)sender; controlName = control.Name; //determine the ability changed ability = CharacterAbilityClass.Abilities.Strength; if (controlName.Contains("Str")) { ability = CharacterAbilityClass.Abilities.Strength; } if (controlName.Contains("Dex")) { ability = CharacterAbilityClass.Abilities.Dexterity; } if (controlName.Contains("Con")) { ability = CharacterAbilityClass.Abilities.Constitution; } if (controlName.Contains("Int")) { ability = CharacterAbilityClass.Abilities.Intelligence; } if (controlName.Contains("Wis")) { ability = CharacterAbilityClass.Abilities.Wisdom; } if (controlName.Contains("Cha")) { ability = CharacterAbilityClass.Abilities.Charisma; } //determine the level of the tome tomeBonus = (int)control.Value; Guid AbilityID = AbilityModel.GetIdFromName(ability.ToString()); int AbilityMax = TomeModel.GetMaxBonus(AbilityID); if (tomeBonus != 0) { minLevel = TomeModel.GetMinLevel(AbilityID, tomeBonus); } if (control.Blank == true) { CharacterManagerClass.CharacterManager.CharacterAbility.SetPriorLifeTomeBonus(ability, tomeBonus, 0); } else { CharacterManagerClass.CharacterManager.CharacterAbility.SetPriorLifeTomeBonus(ability, tomeBonus, minLevel); } for (int i = tomeBonus + 1; i < AbilityMax + 1; ++i) { CharacterManagerClass.CharacterManager.CharacterAbility.SetPriorLifeTomeBonus(ability, i, 0); } //inform other screens UIManagerClass.UIManager.ScreenMessenger.NotifyChange(UIManagerClass.ChildScreen.PastLifeEditScreen, ScreenMessengerClass.ChangeList.AbilityChange); } }
public void SetSkillUpDown(NumericUpDownWithBlank control) { string controlName; List <string> SkillNames; CharacterSkillClass.Skills Skill; SkillNames = Enum.GetNames(typeof(CharacterSkillClass.Skills)).ToList(); if (AllowChange == true) { bool SkillFound = false; controlName = control.Name; //determine the ability changed Skill = CharacterSkillClass.Skills.Balance; for (int i = 0; i < SkillNames.Count; ++i) { if (controlName.Contains(SkillNames[i])) { Skill = (CharacterSkillClass.Skills)i; SkillFound = true; if (SkillFound) { break; } } } if (!SkillFound) { return; } int MaxSkill = TomeModel.GetMaxBonus(SkillModel.GetIdFromName(Skill.ToString().Replace("_", " "))); control.Maximum = MaxSkill; int maxValue; int CurrentValue; int CurrentBonus; CurrentValue = 0; maxValue = 0; CurrentBonus = 0; for (int i = 0; i < MaxSkill; ++i) { CurrentValue = CharacterManagerClass.CharacterManager.CharacterSkill.PriorLifeTome[(int)Skill, i]; if (CurrentValue > maxValue) { maxValue = CurrentValue; CurrentBonus = i + 1; } } if (maxValue != 0) { control.Blank = false; control.Value = CurrentBonus; } else { control.Blank = true; } } }
public void SetAbilityUpDown(NumericUpDownWithBlank control) { string controlName; CharacterAbilityClass.Abilities ability; if (AllowChange == true) { controlName = control.Name; //determine the ability changed ability = CharacterAbilityClass.Abilities.Strength; if (controlName.Contains("Str")) { ability = CharacterAbilityClass.Abilities.Strength; } if (controlName.Contains("Dex")) { ability = CharacterAbilityClass.Abilities.Dexterity; } if (controlName.Contains("Con")) { ability = CharacterAbilityClass.Abilities.Constitution; } if (controlName.Contains("Int")) { ability = CharacterAbilityClass.Abilities.Intelligence; } if (controlName.Contains("Wis")) { ability = CharacterAbilityClass.Abilities.Wisdom; } if (controlName.Contains("Cha")) { ability = CharacterAbilityClass.Abilities.Charisma; } int MaxAbility = TomeModel.GetMaxBonus(AbilityModel.GetIdFromName(ability.ToString())); control.Maximum = MaxAbility; int maxValue; int CurrentValue; int CurrentBonus; CurrentValue = 0; maxValue = 0; CurrentBonus = 0; for (int i = 0; i < MaxAbility; ++i) { CurrentValue = CharacterManagerClass.CharacterManager.CharacterAbility.PriorLifeTome[(int)ability, i]; if (CurrentValue > maxValue) { maxValue = CurrentValue; CurrentBonus = i + 1; } } if (maxValue != 0) { control.Blank = false; control.Value = CurrentBonus; } else { control.Blank = true; } } }