/// <summary> /// Creates a new SkillTrackerBar object with this Tab's player and default skill, and subscribes to its BarClosing even. /// </summary> public void AddNewSkillBar(Player TrackedPlayer, Skills SkillName) { SkillTrackerBar newBar = new SkillTrackerBar(TrackingPlayer, SkillName); newBar.BarClosing += new BarClosingEventHandler(skillTrackerBar_Closing); newBar.BarUpdated += new ControlUpdatedEventHandler(skillTrackerBar_Updated); newBar.DragOver += new DragEventHandler(skillTrackerBar_DragOver); this.TrackingSkills.Add(newBar); this.Refresh(); }
private void SwapBars(SkillTrackerBar a, SkillTrackerBar b) { try { int a_index = TrackingSkills.IndexOf(a); int b_index = TrackingSkills.IndexOf(b); TrackingSkills[a_index] = b; TrackingSkills[b_index] = a; flowPanel.Controls.SetChildIndex(a, b_index); } catch (IndexOutOfRangeException e) { Console.WriteLine(e.Message); Console.WriteLine("One of the controls being swapped was not open."); } }
private void AltLoad() { // This (should) have the same result as this.Load(). // The only difference is AltLoad uses foreach loops instead of LINQ queries. if (!File.Exists(this.InterfaceXmlPath)) { return; // nothing to load } XDocument interfaceXML = XDocument.Load(this.InterfaceXmlPath); foreach (var tab in interfaceXML.Elements("InterfaceState").Elements("Tab")) { UserTrackerTab loadedTab = new UserTrackerTab(); loadedTab.TrackingPlayer = new Player(tab.Element("Username").Value); foreach (var skill in tab.Elements("Skill")) { // Build a new Skill object with data from the XElement Skill loadedSkill = new Skill( Skills.Parse(skill.Element("Skillname").Value), long.Parse(skill.Element("CurrentExperience").Value), int.Parse(skill.Element("Rank").Value), long.Parse(skill.Element("GoalExperience").Value)); // Create a new tracker bar SkillTrackerBar loadedSkillBar = new SkillTrackerBar(loadedTab.TrackingPlayer, loadedSkill.SkillsName); // Update the skill attached to the tracked player loadedTab.TrackingPlayer.UpdateSkill(loadedSkill, true, false); // Add the SkillTrackerBar to the new (loaded)Tab loadedTab.TrackingSkills.Add(loadedSkillBar); } // Add the new tab to the list of open tabs this.OpenTabs.Add(loadedTab); } }