public TabControl GenerateTabs(Character _Character) { HashSet<string> _ExistingTabs = new HashSet<string>(); //TabControl _Skills = new TabControl(); foreach (Skill _Skill in _Character.Skills) { /*if (_Character.Skills.IndexOf(_Skill) == _Character.Skills.Count - 1) break; if (_Skill.TabNumber != _Character.Skills[_Character.Skills.IndexOf(_Skill) + 1].TabNumber) { Font _Font = new Font(new FontFamily("Levenim MT"), 12.0f); TabPage _TabPage = new TabPage(_Skill.TabNumber); _TabPage.Font = _Font; TabPage _TabPage2 = new TabPage(_Character.Skills[_Character.Skills.IndexOf(_Skill) + 1].TabNumber); _TabPage2.Font = _Font; _SkillTabs.Controls.Add(_TabPage); _SkillTabs.Controls.Add(_TabPage2); }*/ _ExistingTabs.Add(_Skill.TabNumber); } foreach (string str in _ExistingTabs) _SkillTabs.Controls.Add(new TabPage(str)); //_SkillTabs = _Skills; return _SkillTabs; }
public void Initialize(Character _Character, TabControl _SkillTabs) { UpdateLabels(); int _Column, _Row; foreach (TabPage _TabPage in _SkillTabs.TabPages) { _Column = 0; _Row = 0; foreach (Skill _Skill in _Character.Skills) { if (_Skill.TabNumber == _TabPage.Text) { PictureBox _SkillBackground = new PictureBox(); PictureBox _SkillIcon = new PictureBox(); PictureBox _PlusIconOn = new PictureBox(); PictureBox _PlusIconOff = new PictureBox(); PictureBox _FirstNumber = new PictureBox(); PictureBox _SecondNumber = new PictureBox(); PictureBox _Slash = new PictureBox(); _SkillBackground.Image = (Image)_ResourceManager.GetObject("SkillBack".Replace(".png", "")); //Grey background to draw all the icons on; _SkillBackground.Location = new Point(_SkillBackground.Image.Width * _Column, (int)_SkillBackground.Image.Height * _Row); _SkillBackground.Size = _SkillBackground.Image.Size; //(Background.Width/Tab.Width) * height so it only drops when the tab is full, because that returns 0 unless background's width is same as tab width; _SkillIcon.Image = (Image)_ResourceManager.GetObject(_Skill.IconName.Replace(".png", "")); //The skill icon; _SkillIcon.Location = new Point(_SkillBackground.Location.X + 5, _SkillBackground.Location.Y + 5); _SkillIcon.Size = _SkillIcon.Image.Size; _PlusIconOn.Image = (Image)_ResourceManager.GetObject("SkillAddP_N".Replace(".png", "")); //Plus icon to indicate that SP is available and that skill is learnable; _PlusIconOn.Location = new Point(_SkillBackground.Location.X + 54, _SkillBackground.Location.Y + 23); _PlusIconOn.Size = _PlusIconOn.Image.Size; _PlusIconOff.Image = (Image)_ResourceManager.GetObject("SkillAddP_D".Replace(".png", "")); //Plus icon to indicate that SP is available and that skill is learnable; _PlusIconOff.Location = new Point(_SkillBackground.Location.X + 54, _SkillBackground.Location.Y + 23); _PlusIconOff.Size = _PlusIconOn.Image.Size; _PlusIconOn.MouseHover += (_Sender, _E) => //Event handler for hovering over the Plus icon; { _PlusIconOn.Image = (Image)_ResourceManager.GetObject("SkillAddP_H".Replace(".png", "")); }; _PlusIconOn.MouseClick += (_Sender, _E) => //Event handler for clicking the Plus icon; { _PlusIconOn.Image = (Image)_ResourceManager.GetObject("SkillAddP_C".Replace(".png", "")); _PlusIconOn.Update(); _Character.SkillPoints--; _Character.UsedSkillPoints++; UpdateLabels(); _Skill.CurrentLevel++; if (_Character.SkillPoints == 0) foreach (Skill _SkillToDisable in _Character.Skills) { _SkillToDisable.Assets.Find(PictureBox => PictureBox.Name == "_PlusIconOn").Enabled = false; _SkillToDisable.Assets.Find(PictureBox => PictureBox.Name == "_PlusIconOn").Visible = false; _SkillToDisable.Assets.Find(PictureBox => PictureBox.Name == "_PlusIconOff").BringToFront(); } else if (_Skill.CurrentLevel == _Skill.MaxLevel) { _FirstNumber.Image = (Image)_ResourceManager.GetObject("_" + _Skill.CurrentLevel.ToString().Replace(".png", "") + "_d"); _Slash.Image = (Image)_ResourceManager.GetObject("div_d".Replace(".png", "")); _SecondNumber.Image = (Image)_ResourceManager.GetObject("_" + _Skill.MaxLevel.ToString().Replace(".png", "") + "_d"); _PlusIconOn.Enabled = false; _PlusIconOn.Visible = false; _PlusIconOff.BringToFront(); } else if (_Skill.CurrentLevel > 9) { _FirstNumber.Image = (Image)_ResourceManager.GetObject("_" + _Skill.CurrentLevel.ToString().Replace(".png", "")); _FirstNumber.Location = new Point(_Slash.Location.X - 14, _Slash.Location.Y); _FirstNumber.Size = new Size(_FirstNumber.Image.Size.Width, _FirstNumber.Image.Size.Height); } else { _FirstNumber.Image = (Image)_ResourceManager.GetObject("_" + _Skill.CurrentLevel.ToString().Replace(".png", "")); System.Threading.Thread.Sleep(40); _PlusIconOn.Image = (Image)_ResourceManager.GetObject("SkillAddP_H".Replace(".png", "")); } }; _PlusIconOn.MouseLeave += (_Sender, _E) => //Event handler for leaving the perimeter of the Plus icon; { _PlusIconOn.Image = (Image)_ResourceManager.GetObject("SkillAddP_N".Replace(".png", "")); }; _Slash.Image = (Image)_ResourceManager.GetObject("div".Replace(".png", "")); //Slash icon to divide the currentLevel and maxLevel; _Slash.Location = new Point(_SkillBackground.Location.X + 67, _SkillBackground.Location.Y + 8); _Slash.Size = _Slash.Image.Size; _Skill.Assets.Add(_SkillBackground); _Skill.Assets.Add(_SkillIcon); _Skill.Assets.Add(_PlusIconOn); _Skill.Assets.Add(_Slash); _TabPage.Controls.Add(_SkillBackground); //Adding all the PictureBoxes to the TabControl; _TabPage.Controls.Add(_SkillIcon); _TabPage.Controls.Add(_PlusIconOn); //_TabPage.Controls.Add(_PlusIconHover); //_TabPage.Controls.Add(_PlusIconClick); _TabPage.Controls.Add(_Slash); _SkillIcon.BringToFront(); _PlusIconOn.BringToFront(); _Slash.BringToFront(); _FirstNumber.Image = (Image)_ResourceManager.GetObject("_" + _Skill.CurrentLevel.ToString().Replace(".png", "")); _FirstNumber.Location = new Point(_Slash.Location.X - 8, _Slash.Location.Y); _FirstNumber.Size = new Size(_FirstNumber.Image.Size.Width, _FirstNumber.Image.Size.Height); _SecondNumber.Image = (Image)_ResourceManager.GetObject("_" + _Skill.MaxLevel.ToString().Replace(".png", "")); _SecondNumber.Location = new Point(_Slash.Location.X + 8, _Slash.Location.Y); _SecondNumber.Size = new Size(_SecondNumber.Image.Size.Width, _SecondNumber.Image.Size.Height); _Skill.Assets.Add(_FirstNumber); _Skill.Assets.Add(_SecondNumber); _TabPage.Controls.Add(_FirstNumber); _TabPage.Controls.Add(_SecondNumber); _FirstNumber.BringToFront(); _SecondNumber.BringToFront(); if (_Column == 3) { _Column = 0; _Row++; } else _Column++; } } } }
private List<Skill> getAllElements(Character _Character) { string _TabName = "error"; string _Data = _FileReader.ReadLine(); while (!_Data.Contains("</CharacterName>")) { if (_Data.Contains("<CharacterName")) _Character.Name = getBetween(_Data, " value=\"", "\"/>"); if (_Data.Contains("<TabNumber")) _TabName = getBetween(_Data, " value=\"", "\">"); if (_Data.Contains("<SkillGroup")) { Skill _Skill = new Skill(); string _SkillGroup = getBetween(_Data, "<", " value="); string _SkillGroupValue = getBetween(_Data, " value=\"", "\">"); PropertyInfo _PropertyInfoSkillGroup = _Skill.GetType().GetProperty(_SkillGroup); _PropertyInfoSkillGroup.SetValue(_Skill, Convert.ChangeType(_SkillGroupValue, _PropertyInfoSkillGroup.PropertyType), null); _Data = _FileReader.ReadLine(); while (!_Data.Contains("</SkillGroup>")) { string _PropertyName = getBetween(_Data, "<", " value="); string _PropertyValue = getBetween(_Data, " value=\"", "\"/>"); PropertyInfo _PropertyInfo = _Skill.GetType().GetProperty(_PropertyName); if (_PropertyValue.Length == 1) _PropertyInfo.SetValue(_Skill, (int)Char.GetNumericValue(_PropertyValue[0])); else if (_PropertyValue.Contains(",")) _PropertyInfo.SetValue(_Skill, MakeList(_PropertyInfo, _PropertyValue)); else _PropertyInfo.SetValue(_Skill, Convert.ChangeType(_PropertyValue, _PropertyInfo.PropertyType), null); _Data = _FileReader.ReadLine(); } _Skill.IconNameOff = _Skill.IconName.Insert(_Skill.IconName.IndexOf('.'), "_d"); _Skill.TabNumber = _TabName; _Character.Skills.Add(_Skill); } _Data = _FileReader.ReadLine(); } return _Character.Skills; }