Skip to content

Commit

Permalink
Finished Columns UI
Browse files Browse the repository at this point in the history
  • Loading branch information
krisdb2009 committed Dec 10, 2019
1 parent 7bbf773 commit bccd571
Show file tree
Hide file tree
Showing 3 changed files with 312 additions and 89 deletions.
258 changes: 176 additions & 82 deletions SuperGrate/Controls/ChangeColumns.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

104 changes: 97 additions & 7 deletions SuperGrate/Controls/ChangeColumns.cs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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();
}
}
}
Loading

0 comments on commit bccd571

Please sign in to comment.