changeset 10:43d88f50c712

Continued work on Category Tab Up and Down buttons adjust category position.
author Tsudico
date Fri, 17 Dec 2010 22:02:04 -0600
parents 0dadaa315430
children 38f0ed348ca8
files FrmSystem.Designer.cs FrmSystem.cs
diffstat 2 files changed, 72 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/FrmSystem.Designer.cs	Thu Dec 16 18:52:30 2010 -0600
+++ b/FrmSystem.Designer.cs	Fri Dec 17 22:02:04 2010 -0600
@@ -520,6 +520,7 @@
 			this.btnCategoryUp.TabIndex = 17;
 			this.btnCategoryUp.Text = "Up";
 			this.btnCategoryUp.UseVisualStyleBackColor = true;
+			this.btnCategoryUp.Click += new System.EventHandler(this.btnCategoryUp_Click);
 			// 
 			// listCategories
 			// 
@@ -538,6 +539,7 @@
 			this.btnCategoryDown.TabIndex = 16;
 			this.btnCategoryDown.Text = "Down";
 			this.btnCategoryDown.UseVisualStyleBackColor = true;
+			this.btnCategoryDown.Click += new System.EventHandler(this.btnCategoryDown_Click);
 			// 
 			// btnCategoryAdd
 			// 
--- a/FrmSystem.cs	Thu Dec 16 18:52:30 2010 -0600
+++ b/FrmSystem.cs	Fri Dec 17 22:02:04 2010 -0600
@@ -211,6 +211,22 @@
 					break;
 				}
 			}
+			if(this.listCategories.SelectedIndex == 0)
+			{
+				this.btnCategoryUp.Enabled = false;
+			}
+			else
+			{
+				this.btnCategoryUp.Enabled = true;
+			}
+			if (this.listCategories.SelectedIndex == this.listCategories.Items.Count - 1)
+			{
+				this.btnCategoryDown.Enabled = false;
+			}
+			else
+			{
+				this.btnCategoryDown.Enabled = true;
+			}
 		}
 
 		private void btnCategoryAdd_Click(object sender, EventArgs e)
@@ -254,6 +270,60 @@
 			updateCategoryList();
 		}
 
+		private void btnCategoryUp_Click(object sender, EventArgs e)
+		{
+			int index = this.listCategories.SelectedIndex;
+			IBBoard.WarFoundry.API.Objects.Category[] catList = new IBBoard.WarFoundry.API.Objects.Category[this.listCategories.Items.Count];
+			
+			for(int i = 0; i < system.Categories.Length; i++)
+			{
+				catList[i] = system.Categories[i];
+			}
+			foreach(IBBoard.WarFoundry.API.Objects.Category cat in system.Categories)
+			{
+				system.RemoveCategory(cat.ID);
+			}
+			
+			IBBoard.WarFoundry.API.Objects.Category temp = catList[index];
+			catList[index] = catList[index - 1];
+			catList[index - 1] = temp;
+			
+			for(int i = catList.Length - 1; i >= 0; i--)
+			{
+				system.AddCategory(catList[i]);
+			}
+			
+			updateCategoryList();
+			this.listCategories.SelectedIndex = index - 1;
+		}
+
+		private void btnCategoryDown_Click(object sender, EventArgs e)
+		{
+			int index = this.listCategories.SelectedIndex;
+			IBBoard.WarFoundry.API.Objects.Category[] catList = new IBBoard.WarFoundry.API.Objects.Category[this.listCategories.Items.Count];
+
+			for (int i = 0; i < system.Categories.Length; i++)
+			{
+				catList[i] = system.Categories[i];
+			}
+			foreach (IBBoard.WarFoundry.API.Objects.Category cat in system.Categories)
+			{
+				system.RemoveCategory(cat.ID);
+			}
+
+			IBBoard.WarFoundry.API.Objects.Category temp = catList[index];
+			catList[index] = catList[index + 1];
+			catList[index + 1] = temp;
+
+			for (int i = catList.Length - 1; i >= 0; i--)
+			{
+				system.AddCategory(catList[i]);
+			}
+
+			updateCategoryList();
+			this.listCategories.SelectedIndex = index + 1;
+		}
+
 		private void txtCategoryName_TextChanged(object sender, EventArgs e)
 		{
 			if (this.UpdateCategory)