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 diff
     1.1 --- a/FrmSystem.Designer.cs	Wed Dec 22 18:35:52 2010 -0600
     1.2 +++ b/FrmSystem.Designer.cs	Wed Dec 22 19:58:51 2010 -0600
     1.3 @@ -71,6 +71,8 @@
     1.4  			this.btnCategoryRemove = new System.Windows.Forms.Button();
     1.5  			this.btnCategoryApply = new System.Windows.Forms.Button();
     1.6  			this.tabStats = new System.Windows.Forms.TabPage();
     1.7 +			this.btnStatsUp = new System.Windows.Forms.Button();
     1.8 +			this.btnStatsDown = new System.Windows.Forms.Button();
     1.9  			this.btnStatListDown = new System.Windows.Forms.Button();
    1.10  			this.btnStatListUp = new System.Windows.Forms.Button();
    1.11  			this.btnStatListRemove = new System.Windows.Forms.Button();
    1.12 @@ -591,6 +593,8 @@
    1.13  			// 
    1.14  			// tabStats
    1.15  			// 
    1.16 +			this.tabStats.Controls.Add(this.btnStatsUp);
    1.17 +			this.tabStats.Controls.Add(this.btnStatsDown);
    1.18  			this.tabStats.Controls.Add(this.btnStatListDown);
    1.19  			this.tabStats.Controls.Add(this.btnStatListUp);
    1.20  			this.tabStats.Controls.Add(this.btnStatListRemove);
    1.21 @@ -615,6 +619,26 @@
    1.22  			this.tabStats.Text = "Stat Lines";
    1.23  			this.tabStats.UseVisualStyleBackColor = true;
    1.24  			// 
    1.25 +			// btnStatsUp
    1.26 +			// 
    1.27 +			this.btnStatsUp.Location = new System.Drawing.Point(203, 122);
    1.28 +			this.btnStatsUp.Name = "btnStatsUp";
    1.29 +			this.btnStatsUp.Size = new System.Drawing.Size(81, 23);
    1.30 +			this.btnStatsUp.TabIndex = 27;
    1.31 +			this.btnStatsUp.Text = "Up";
    1.32 +			this.btnStatsUp.UseVisualStyleBackColor = true;
    1.33 +			this.btnStatsUp.Click += new System.EventHandler(this.btnStatsUp_Click);
    1.34 +			// 
    1.35 +			// btnStatsDown
    1.36 +			// 
    1.37 +			this.btnStatsDown.Location = new System.Drawing.Point(203, 151);
    1.38 +			this.btnStatsDown.Name = "btnStatsDown";
    1.39 +			this.btnStatsDown.Size = new System.Drawing.Size(81, 23);
    1.40 +			this.btnStatsDown.TabIndex = 26;
    1.41 +			this.btnStatsDown.Text = "Down";
    1.42 +			this.btnStatsDown.UseVisualStyleBackColor = true;
    1.43 +			this.btnStatsDown.Click += new System.EventHandler(this.btnStatsDown_Click);
    1.44 +			// 
    1.45  			// btnStatListDown
    1.46  			// 
    1.47  			this.btnStatListDown.Enabled = false;
    1.48 @@ -902,6 +926,8 @@
    1.49  		private System.Windows.Forms.Button btnStatListDown;
    1.50  		private System.Windows.Forms.Button btnStatListUp;
    1.51  		private System.Windows.Forms.ListBox listStatNames;
    1.52 +		private System.Windows.Forms.Button btnStatsUp;
    1.53 +		private System.Windows.Forms.Button btnStatsDown;
    1.54  
    1.55  	}
    1.56  }
     2.1 --- a/FrmSystem.cs	Wed Dec 22 18:35:52 2010 -0600
     2.2 +++ b/FrmSystem.cs	Wed Dec 22 19:58:51 2010 -0600
     2.3 @@ -183,9 +183,9 @@
     2.4  		
     2.5  		private void updateCategoryList()
     2.6  		{
     2.7 +			this.listCategories.Items.Clear();
     2.8  			if (system.Categories.Length > 0)
     2.9  			{
    2.10 -				this.listCategories.Items.Clear();
    2.11  				for (int i = 0; i < system.Categories.Length; i++)
    2.12  				{
    2.13  					this.listCategories.Items.Add(system.Categories[i].Name);
    2.14 @@ -576,15 +576,14 @@
    2.15  			currentStats = null;
    2.16  			foreach(IBBoard.WarFoundry.API.Objects.SystemStats stat in system.SystemStats)
    2.17  			{
    2.18 -				ListView.SelectedListViewItemCollection items = this.lviewStats.SelectedItems;
    2.19 -				if(items.Count > 0)
    2.20 -				{
    2.21 -					this.btnStatsRemove.Enabled = true;
    2.22 -				}
    2.23 -				foreach(ListViewItem item in items)
    2.24 +				foreach(ListViewItem item in this.lviewStats.SelectedItems)
    2.25  				{
    2.26  					if(stat.ID == item.Text)
    2.27  					{
    2.28 +						if(this.lviewStats.Items.Count > 0)
    2.29 +						{
    2.30 +							this.btnStatsRemove.Enabled = true;
    2.31 +						}
    2.32  						currentStats = new IBBoard.WarFoundry.API.Objects.SystemStats(stat.ID);
    2.33  						foreach(IBBoard.WarFoundry.API.Objects.StatSlot slot in stat.StatSlots)
    2.34  						{
    2.35 @@ -598,6 +597,22 @@
    2.36  						{
    2.37  							this.btnStatsDefault.Enabled = true;
    2.38  						}
    2.39 +						if (item.Index == 0)
    2.40 +						{
    2.41 +							this.btnStatsUp.Enabled = false;
    2.42 +						}
    2.43 +						else
    2.44 +						{
    2.45 +							this.btnStatsUp.Enabled = true;
    2.46 +						}
    2.47 +						if (item.Index == this.lviewStats.Items.Count - 1)
    2.48 +						{
    2.49 +							this.btnStatsDown.Enabled = false;
    2.50 +						}
    2.51 +						else
    2.52 +						{
    2.53 +							this.btnStatsDown.Enabled = true;
    2.54 +						}
    2.55  						this.txtStatLineID.Text = currentStats.ID;
    2.56  						this.txtStatName.Enabled = true;
    2.57  						updateStatNames(currentStats);
    2.58 @@ -640,6 +655,60 @@
    2.59  			updateSystemStatsList();
    2.60  		}
    2.61  
    2.62 +		private void btnStatsUp_Click(object sender, EventArgs e)
    2.63 +		{
    2.64 +			int index = this.lviewStats.SelectedIndices[0];
    2.65 +			IBBoard.WarFoundry.API.Objects.SystemStats[] statsList = new IBBoard.WarFoundry.API.Objects.SystemStats[this.lviewStats.Items.Count];
    2.66 +
    2.67 +			for (int i = 0; i < system.SystemStats.Length; i++)
    2.68 +			{
    2.69 +				statsList[i] = system.SystemStats[i];
    2.70 +			}
    2.71 +			foreach (IBBoard.WarFoundry.API.Objects.SystemStats stat in system.SystemStats)
    2.72 +			{
    2.73 +				system.RemoveSystemStats(stat.ID);
    2.74 +			}
    2.75 +
    2.76 +			IBBoard.WarFoundry.API.Objects.SystemStats temp = statsList[index];
    2.77 +			statsList[index] = statsList[index - 1];
    2.78 +			statsList[index - 1] = temp;
    2.79 +
    2.80 +			for (int i = statsList.Length - 1; i >= 0; i--)
    2.81 +			{
    2.82 +				system.AddSystemStats(statsList[i]);
    2.83 +			}
    2.84 +
    2.85 +			updateSystemStatsList();
    2.86 +			this.lviewStats.Items[index - 1].Selected = true;
    2.87 +		}
    2.88 +
    2.89 +		private void btnStatsDown_Click(object sender, EventArgs e)
    2.90 +		{
    2.91 +			int index = this.lviewStats.SelectedIndices[0];
    2.92 +			IBBoard.WarFoundry.API.Objects.SystemStats[] statsList = new IBBoard.WarFoundry.API.Objects.SystemStats[this.lviewStats.Items.Count];
    2.93 +
    2.94 +			for (int i = 0; i < system.SystemStats.Length; i++)
    2.95 +			{
    2.96 +				statsList[i] = system.SystemStats[i];
    2.97 +			}
    2.98 +			foreach (IBBoard.WarFoundry.API.Objects.SystemStats stat in system.SystemStats)
    2.99 +			{
   2.100 +				system.RemoveSystemStats(stat.ID);
   2.101 +			}
   2.102 +
   2.103 +			IBBoard.WarFoundry.API.Objects.SystemStats temp = statsList[index];
   2.104 +			statsList[index] = statsList[index + 1];
   2.105 +			statsList[index + 1] = temp;
   2.106 +
   2.107 +			for (int i = statsList.Length - 1; i >= 0; i--)
   2.108 +			{
   2.109 +				system.AddSystemStats(statsList[i]);
   2.110 +			}
   2.111 +
   2.112 +			updateSystemStatsList();
   2.113 +			this.lviewStats.Items[index + 1].Selected = true;
   2.114 +		}
   2.115 +
   2.116  		private void txtStatLineID_TextChanged(object sender, EventArgs e)
   2.117  		{
   2.118  			if(this.txtStatLineID.Text != string.Empty)