From bccd571602ce259dff0df2ef2488e13ff3f42ec9 Mon Sep 17 00:00:00 2001 From: Dylan Bickerstaff Date: Mon, 9 Dec 2019 22:19:47 -0500 Subject: [PATCH] Finished Columns UI --- SuperGrate/Controls/ChangeColumns.Designer.cs | 258 ++++++++++++------ SuperGrate/Controls/ChangeColumns.cs | 104 ++++++- SuperGrate/Controls/ChangeColumns.resx | 39 +++ 3 files changed, 312 insertions(+), 89 deletions(-) diff --git a/SuperGrate/Controls/ChangeColumns.Designer.cs b/SuperGrate/Controls/ChangeColumns.Designer.cs index 3c25243..0cf33f3 100644 --- a/SuperGrate/Controls/ChangeColumns.Designer.cs +++ b/SuperGrate/Controls/ChangeColumns.Designer.cs @@ -28,88 +28,176 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - this.button1 = new System.Windows.Forms.Button(); - this.button2 = new System.Windows.Forms.Button(); - this.listBox1 = new System.Windows.Forms.ListBox(); - this.listBox2 = new System.Windows.Forms.ListBox(); - this.button3 = new System.Windows.Forms.Button(); - this.button4 = new System.Windows.Forms.Button(); - this.button5 = new System.Windows.Forms.Button(); + this.btnAdd = new System.Windows.Forms.Button(); + this.btnRemove = new System.Windows.Forms.Button(); + this.lbAvailable = new System.Windows.Forms.ListBox(); + this.lbDisplayed = new System.Windows.Forms.ListBox(); + this.btnMoveUp = new System.Windows.Forms.Button(); + this.btnMoveDown = new System.Windows.Forms.Button(); + this.btnRestoreDefaults = new System.Windows.Forms.Button(); + this.lblAvail = new System.Windows.Forms.Label(); + this.lblDispl = new System.Windows.Forms.Label(); + this.lblLine = new System.Windows.Forms.Label(); + this.btnOk = new System.Windows.Forms.Button(); + this.btnCancel = new System.Windows.Forms.Button(); this.SuspendLayout(); // - // button1 - // - this.button1.Location = new System.Drawing.Point(138, 63); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(95, 23); - this.button1.TabIndex = 0; - this.button1.Text = "button1"; - this.button1.UseVisualStyleBackColor = true; - // - // button2 - // - this.button2.Location = new System.Drawing.Point(138, 92); - this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(95, 23); - this.button2.TabIndex = 1; - this.button2.Text = "button2"; - this.button2.UseVisualStyleBackColor = true; - // - // listBox1 - // - this.listBox1.FormattingEnabled = true; - this.listBox1.Location = new System.Drawing.Point(12, 32); - this.listBox1.Name = "listBox1"; - this.listBox1.Size = new System.Drawing.Size(135, 186); - this.listBox1.TabIndex = 2; - // - // listBox2 - // - this.listBox2.FormattingEnabled = true; - this.listBox2.Location = new System.Drawing.Point(239, 32); - this.listBox2.Name = "listBox2"; - this.listBox2.Size = new System.Drawing.Size(135, 186); - this.listBox2.TabIndex = 3; - // - // button3 - // - this.button3.Location = new System.Drawing.Point(365, 47); - this.button3.Name = "button3"; - this.button3.Size = new System.Drawing.Size(95, 23); - this.button3.TabIndex = 4; - this.button3.Text = "button3"; - this.button3.UseVisualStyleBackColor = true; - // - // button4 - // - this.button4.Location = new System.Drawing.Point(365, 76); - this.button4.Name = "button4"; - this.button4.Size = new System.Drawing.Size(95, 23); - this.button4.TabIndex = 5; - this.button4.Text = "button4"; - this.button4.UseVisualStyleBackColor = true; - // - // button5 - // - this.button5.Location = new System.Drawing.Point(365, 117); - this.button5.Name = "button5"; - this.button5.Size = new System.Drawing.Size(95, 23); - this.button5.TabIndex = 6; - this.button5.Text = "button5"; - this.button5.UseVisualStyleBackColor = true; + // btnAdd + // + this.btnAdd.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.btnAdd.Location = new System.Drawing.Point(153, 73); + this.btnAdd.Name = "btnAdd"; + this.btnAdd.Size = new System.Drawing.Size(88, 21); + this.btnAdd.TabIndex = 0; + this.btnAdd.Text = "A&dd ->"; + this.btnAdd.UseVisualStyleBackColor = true; + this.btnAdd.Click += new System.EventHandler(this.btnAddRemove_Click); + // + // btnRemove + // + this.btnRemove.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.btnRemove.Location = new System.Drawing.Point(153, 102); + this.btnRemove.Name = "btnRemove"; + this.btnRemove.Size = new System.Drawing.Size(88, 21); + this.btnRemove.TabIndex = 1; + this.btnRemove.Text = "<- &Remove"; + this.btnRemove.UseVisualStyleBackColor = true; + this.btnRemove.Click += new System.EventHandler(this.btnAddRemove_Click); + // + // lbAvailable + // + this.lbAvailable.FormattingEnabled = true; + this.lbAvailable.HorizontalScrollbar = true; + this.lbAvailable.IntegralHeight = false; + this.lbAvailable.Items.AddRange(new object[] { + "1111111111111111111111111111111111", + "2222222222222222222222222222222222", + "3333333333333333333333333333333333", + "4444444444444444444444444444444444", + "5555555555555555555555555555555555"}); + this.lbAvailable.Location = new System.Drawing.Point(11, 28); + this.lbAvailable.Name = "lbAvailable"; + this.lbAvailable.ScrollAlwaysVisible = true; + this.lbAvailable.Size = new System.Drawing.Size(135, 192); + this.lbAvailable.TabIndex = 2; + this.lbAvailable.SelectedIndexChanged += new System.EventHandler(this.ListBox_SelectedIndexChanged); + this.lbAvailable.DoubleClick += new System.EventHandler(this.btnAddRemove_Click); + // + // lbDisplayed + // + this.lbDisplayed.FormattingEnabled = true; + this.lbDisplayed.HorizontalScrollbar = true; + this.lbDisplayed.IntegralHeight = false; + this.lbDisplayed.Location = new System.Drawing.Point(248, 28); + this.lbDisplayed.Name = "lbDisplayed"; + this.lbDisplayed.ScrollAlwaysVisible = true; + this.lbDisplayed.Size = new System.Drawing.Size(135, 192); + this.lbDisplayed.TabIndex = 3; + this.lbDisplayed.SelectedIndexChanged += new System.EventHandler(this.ListBox_SelectedIndexChanged); + this.lbDisplayed.DoubleClick += new System.EventHandler(this.btnAddRemove_Click); + // + // btnMoveUp + // + this.btnMoveUp.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.btnMoveUp.Location = new System.Drawing.Point(392, 27); + this.btnMoveUp.Name = "btnMoveUp"; + this.btnMoveUp.Size = new System.Drawing.Size(118, 21); + this.btnMoveUp.TabIndex = 4; + this.btnMoveUp.Text = "M&ove Up"; + this.btnMoveUp.UseVisualStyleBackColor = true; + this.btnMoveUp.Click += new System.EventHandler(this.btnMoveUp_Click); + // + // btnMoveDown + // + this.btnMoveDown.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.btnMoveDown.Location = new System.Drawing.Point(392, 56); + this.btnMoveDown.Name = "btnMoveDown"; + this.btnMoveDown.Size = new System.Drawing.Size(118, 21); + this.btnMoveDown.TabIndex = 5; + this.btnMoveDown.Text = "Mo&ve Down"; + this.btnMoveDown.UseVisualStyleBackColor = true; + this.btnMoveDown.Click += new System.EventHandler(this.btnMoveDown_Click); + // + // btnRestoreDefaults + // + this.btnRestoreDefaults.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.btnRestoreDefaults.Location = new System.Drawing.Point(392, 95); + this.btnRestoreDefaults.Name = "btnRestoreDefaults"; + this.btnRestoreDefaults.Size = new System.Drawing.Size(118, 21); + this.btnRestoreDefaults.TabIndex = 6; + this.btnRestoreDefaults.Text = "Re&store Defaults"; + this.btnRestoreDefaults.UseVisualStyleBackColor = true; + this.btnRestoreDefaults.Click += new System.EventHandler(this.btnRestoreDefaults_Click); + // + // lblAvail + // + this.lblAvail.AutoSize = true; + this.lblAvail.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.lblAvail.Location = new System.Drawing.Point(12, 9); + this.lblAvail.Name = "lblAvail"; + this.lblAvail.Size = new System.Drawing.Size(102, 13); + this.lblAvail.TabIndex = 9; + this.lblAvail.Text = "&Available columns:"; + // + // lblDispl + // + this.lblDispl.AutoSize = true; + this.lblDispl.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.lblDispl.Location = new System.Drawing.Point(247, 9); + this.lblDispl.Name = "lblDispl"; + this.lblDispl.Size = new System.Drawing.Size(106, 13); + this.lblDispl.TabIndex = 10; + this.lblDispl.Text = "Display&ed columns:"; + // + // lblLine + // + this.lblLine.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + this.lblLine.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.lblLine.Location = new System.Drawing.Point(11, 236); + this.lblLine.Name = "lblLine"; + this.lblLine.Size = new System.Drawing.Size(499, 2); + this.lblLine.TabIndex = 11; + // + // btnOk + // + this.btnOk.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.btnOk.Location = new System.Drawing.Point(356, 250); + this.btnOk.Name = "btnOk"; + this.btnOk.Size = new System.Drawing.Size(73, 21); + this.btnOk.TabIndex = 7; + this.btnOk.Text = "OK"; + this.btnOk.UseVisualStyleBackColor = true; + this.btnOk.Click += new System.EventHandler(this.btnOk_Click); + // + // btnCancel + // + this.btnCancel.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.btnCancel.Location = new System.Drawing.Point(437, 250); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(73, 21); + this.btnCancel.TabIndex = 8; + this.btnCancel.Text = "Cancel"; + this.btnCancel.UseVisualStyleBackColor = true; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); // // ChangeColumns // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(528, 297); - this.Controls.Add(this.button5); - this.Controls.Add(this.button4); - this.Controls.Add(this.button3); - this.Controls.Add(this.listBox2); - this.Controls.Add(this.listBox1); - this.Controls.Add(this.button2); - this.Controls.Add(this.button1); + this.ClientSize = new System.Drawing.Size(519, 281); + this.Controls.Add(this.lblLine); + this.Controls.Add(this.lblDispl); + this.Controls.Add(this.lblAvail); + this.Controls.Add(this.btnCancel); + this.Controls.Add(this.btnOk); + this.Controls.Add(this.btnRestoreDefaults); + this.Controls.Add(this.btnMoveDown); + this.Controls.Add(this.btnMoveUp); + this.Controls.Add(this.lbDisplayed); + this.Controls.Add(this.lbAvailable); + this.Controls.Add(this.btnRemove); + this.Controls.Add(this.btnAdd); + this.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.HelpButton = true; this.MaximizeBox = false; @@ -120,17 +208,23 @@ private void InitializeComponent() this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Add/Remove Columns"; this.ResumeLayout(false); + this.PerformLayout(); } #endregion - private System.Windows.Forms.Button button1; - private System.Windows.Forms.Button button2; - private System.Windows.Forms.ListBox listBox1; - private System.Windows.Forms.ListBox listBox2; - private System.Windows.Forms.Button button3; - private System.Windows.Forms.Button button4; - private System.Windows.Forms.Button button5; + private System.Windows.Forms.Button btnAdd; + private System.Windows.Forms.Button btnRemove; + private System.Windows.Forms.ListBox lbAvailable; + private System.Windows.Forms.ListBox lbDisplayed; + private System.Windows.Forms.Button btnMoveUp; + private System.Windows.Forms.Button btnMoveDown; + private System.Windows.Forms.Button btnRestoreDefaults; + private System.Windows.Forms.Label lblAvail; + private System.Windows.Forms.Label lblDispl; + private System.Windows.Forms.Label lblLine; + private System.Windows.Forms.Button btnOk; + private System.Windows.Forms.Button btnCancel; } } \ No newline at end of file diff --git a/SuperGrate/Controls/ChangeColumns.cs b/SuperGrate/Controls/ChangeColumns.cs index 331d912..33185f5 100644 --- a/SuperGrate/Controls/ChangeColumns.cs +++ b/SuperGrate/Controls/ChangeColumns.cs @@ -1,11 +1,4 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Forms; namespace SuperGrate.Controls @@ -15,6 +8,103 @@ public partial class ChangeColumns : Form public ChangeColumns() { InitializeComponent(); + lbAvailable.SelectedIndex = lbAvailable.Items.Count - 1; + lbDisplayed.SelectedIndex = lbDisplayed.Items.Count - 1; + UpdateUI(); + } + private void UpdateUI() + { + if (lbAvailable.Items.Count == 0) + { + btnAdd.Enabled = false; + } + else + { + btnAdd.Enabled = true; + } + if (lbDisplayed.Items.Count == 0) + { + btnRemove.Enabled = false; + } + else + { + btnRemove.Enabled = true; + } + if (lbDisplayed.SelectedIndex == lbDisplayed.Items.Count - 1) + { + btnMoveDown.Enabled = false; + } + else + { + btnMoveDown.Enabled = true; + } + if (lbDisplayed.SelectedIndex <= 0) + { + btnMoveUp.Enabled = false; + } + else + { + btnMoveUp.Enabled = true; + } + } + private void btnCancel_Click(object sender, EventArgs e) + { + Close(); + } + private void btnOk_Click(object sender, EventArgs e) + { + Close(); + } + private void btnAddRemove_Click(object sender, EventArgs e) + { + ListBox lbFrom = null; + ListBox lbTo = null; + if (sender == btnAdd || sender == lbAvailable) + { + lbFrom = lbAvailable; + lbTo = lbDisplayed; + } + else if(sender == btnRemove || sender == lbDisplayed) + { + lbFrom = lbDisplayed; + lbTo = lbAvailable; + } + lbTo.SelectedIndex = lbTo.Items.Add(lbFrom.SelectedItem); + int index = lbFrom.SelectedIndex; + lbFrom.Items.Remove(lbFrom.SelectedItem); + if (lbFrom.Items.Count >= (index + 1)) + { + lbFrom.SelectedIndex = index; + } + else if(lbFrom.Items.Count != 0) + { + lbFrom.SelectedIndex = lbFrom.Items.Count - 1; + } + UpdateUI(); + } + private void btnMoveUp_Click(object sender, EventArgs e) + { + int index = lbDisplayed.SelectedIndex; + object item = lbDisplayed.Items[index]; + lbDisplayed.Items.Remove(item); + lbDisplayed.Items.Insert(--index, item); + lbDisplayed.SelectedIndex = index; + } + private void btnMoveDown_Click(object sender, EventArgs e) + { + int index = lbDisplayed.SelectedIndex; + object item = lbDisplayed.Items[index]; + lbDisplayed.Items.Remove(item); + lbDisplayed.Items.Insert(++index, item); + lbDisplayed.SelectedIndex = index; + } + private void btnRestoreDefaults_Click(object sender, EventArgs e) + { + + } + private void ListBox_SelectedIndexChanged(object sender, EventArgs e) + { + UpdateUI(); } } } diff --git a/SuperGrate/Controls/ChangeColumns.resx b/SuperGrate/Controls/ChangeColumns.resx index 1af7de1..cbd1438 100644 --- a/SuperGrate/Controls/ChangeColumns.resx +++ b/SuperGrate/Controls/ChangeColumns.resx @@ -117,4 +117,43 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + \ No newline at end of file