Mercurial > repos > WarFoundryForge
diff FrmSystem.cs @ 16:489d36b167a6
Added Up and Down buttons for Stat Lines tab
Fixed Category and Stat List from not removing the last one
author | Tsudico |
---|---|
date | Wed, 22 Dec 2010 19:58:51 -0600 |
parents | 3a347947ecea |
children |
line wrap: on
line diff
--- a/FrmSystem.cs Wed Dec 22 18:35:52 2010 -0600 +++ b/FrmSystem.cs Wed Dec 22 19:58:51 2010 -0600 @@ -183,9 +183,9 @@ private void updateCategoryList() { + this.listCategories.Items.Clear(); if (system.Categories.Length > 0) { - this.listCategories.Items.Clear(); for (int i = 0; i < system.Categories.Length; i++) { this.listCategories.Items.Add(system.Categories[i].Name); @@ -576,15 +576,14 @@ currentStats = null; foreach(IBBoard.WarFoundry.API.Objects.SystemStats stat in system.SystemStats) { - ListView.SelectedListViewItemCollection items = this.lviewStats.SelectedItems; - if(items.Count > 0) - { - this.btnStatsRemove.Enabled = true; - } - foreach(ListViewItem item in items) + foreach(ListViewItem item in this.lviewStats.SelectedItems) { if(stat.ID == item.Text) { + if(this.lviewStats.Items.Count > 0) + { + this.btnStatsRemove.Enabled = true; + } currentStats = new IBBoard.WarFoundry.API.Objects.SystemStats(stat.ID); foreach(IBBoard.WarFoundry.API.Objects.StatSlot slot in stat.StatSlots) { @@ -598,6 +597,22 @@ { this.btnStatsDefault.Enabled = true; } + if (item.Index == 0) + { + this.btnStatsUp.Enabled = false; + } + else + { + this.btnStatsUp.Enabled = true; + } + if (item.Index == this.lviewStats.Items.Count - 1) + { + this.btnStatsDown.Enabled = false; + } + else + { + this.btnStatsDown.Enabled = true; + } this.txtStatLineID.Text = currentStats.ID; this.txtStatName.Enabled = true; updateStatNames(currentStats); @@ -640,6 +655,60 @@ updateSystemStatsList(); } + private void btnStatsUp_Click(object sender, EventArgs e) + { + int index = this.lviewStats.SelectedIndices[0]; + IBBoard.WarFoundry.API.Objects.SystemStats[] statsList = new IBBoard.WarFoundry.API.Objects.SystemStats[this.lviewStats.Items.Count]; + + for (int i = 0; i < system.SystemStats.Length; i++) + { + statsList[i] = system.SystemStats[i]; + } + foreach (IBBoard.WarFoundry.API.Objects.SystemStats stat in system.SystemStats) + { + system.RemoveSystemStats(stat.ID); + } + + IBBoard.WarFoundry.API.Objects.SystemStats temp = statsList[index]; + statsList[index] = statsList[index - 1]; + statsList[index - 1] = temp; + + for (int i = statsList.Length - 1; i >= 0; i--) + { + system.AddSystemStats(statsList[i]); + } + + updateSystemStatsList(); + this.lviewStats.Items[index - 1].Selected = true; + } + + private void btnStatsDown_Click(object sender, EventArgs e) + { + int index = this.lviewStats.SelectedIndices[0]; + IBBoard.WarFoundry.API.Objects.SystemStats[] statsList = new IBBoard.WarFoundry.API.Objects.SystemStats[this.lviewStats.Items.Count]; + + for (int i = 0; i < system.SystemStats.Length; i++) + { + statsList[i] = system.SystemStats[i]; + } + foreach (IBBoard.WarFoundry.API.Objects.SystemStats stat in system.SystemStats) + { + system.RemoveSystemStats(stat.ID); + } + + IBBoard.WarFoundry.API.Objects.SystemStats temp = statsList[index]; + statsList[index] = statsList[index + 1]; + statsList[index + 1] = temp; + + for (int i = statsList.Length - 1; i >= 0; i--) + { + system.AddSystemStats(statsList[i]); + } + + updateSystemStatsList(); + this.lviewStats.Items[index + 1].Selected = true; + } + private void txtStatLineID_TextChanged(object sender, EventArgs e) { if(this.txtStatLineID.Text != string.Empty)