Mercurial > repos > WarFoundryForge
changeset 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 | 0ea6ce3c6434 |
files | FrmSystem.Designer.cs FrmSystem.cs |
diffstat | 2 files changed, 102 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/FrmSystem.Designer.cs Wed Dec 22 18:35:52 2010 -0600 +++ b/FrmSystem.Designer.cs Wed Dec 22 19:58:51 2010 -0600 @@ -71,6 +71,8 @@ this.btnCategoryRemove = new System.Windows.Forms.Button(); this.btnCategoryApply = new System.Windows.Forms.Button(); this.tabStats = new System.Windows.Forms.TabPage(); + this.btnStatsUp = new System.Windows.Forms.Button(); + this.btnStatsDown = new System.Windows.Forms.Button(); this.btnStatListDown = new System.Windows.Forms.Button(); this.btnStatListUp = new System.Windows.Forms.Button(); this.btnStatListRemove = new System.Windows.Forms.Button(); @@ -591,6 +593,8 @@ // // tabStats // + this.tabStats.Controls.Add(this.btnStatsUp); + this.tabStats.Controls.Add(this.btnStatsDown); this.tabStats.Controls.Add(this.btnStatListDown); this.tabStats.Controls.Add(this.btnStatListUp); this.tabStats.Controls.Add(this.btnStatListRemove); @@ -615,6 +619,26 @@ this.tabStats.Text = "Stat Lines"; this.tabStats.UseVisualStyleBackColor = true; // + // btnStatsUp + // + this.btnStatsUp.Location = new System.Drawing.Point(203, 122); + this.btnStatsUp.Name = "btnStatsUp"; + this.btnStatsUp.Size = new System.Drawing.Size(81, 23); + this.btnStatsUp.TabIndex = 27; + this.btnStatsUp.Text = "Up"; + this.btnStatsUp.UseVisualStyleBackColor = true; + this.btnStatsUp.Click += new System.EventHandler(this.btnStatsUp_Click); + // + // btnStatsDown + // + this.btnStatsDown.Location = new System.Drawing.Point(203, 151); + this.btnStatsDown.Name = "btnStatsDown"; + this.btnStatsDown.Size = new System.Drawing.Size(81, 23); + this.btnStatsDown.TabIndex = 26; + this.btnStatsDown.Text = "Down"; + this.btnStatsDown.UseVisualStyleBackColor = true; + this.btnStatsDown.Click += new System.EventHandler(this.btnStatsDown_Click); + // // btnStatListDown // this.btnStatListDown.Enabled = false; @@ -902,6 +926,8 @@ private System.Windows.Forms.Button btnStatListDown; private System.Windows.Forms.Button btnStatListUp; private System.Windows.Forms.ListBox listStatNames; + private System.Windows.Forms.Button btnStatsUp; + private System.Windows.Forms.Button btnStatsDown; } }
--- 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)