using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace FCC_Uber_MDX_Configurator { public partial class ThenDoForm : Form { public List _CurrentDoThenList; public ThenDoForm(List _input_List) { InitializeComponent(); _CurrentDoThenList = _input_List; UpdateFormWithCurentList(); } public void UpdateFormWithCurentList() { if (_CurrentDoThenList.Count > 0) { TSB_DELETE.Enabled = true; } else { TSB_DELETE.Enabled = false; } LIST_ThenDoList.Items.Clear(); foreach (GlobalStaticClass.Vote_VoteClass _voteClass in _CurrentDoThenList) { LIST_ThenDoList.Items.Add(_voteClass.FormatAsStringForListBox()); } LIST_ThenDoList.Update(); } private void TSB_ADD_Click(object sender, EventArgs e) { AddNewThenDo _tempAddNewThenDo = new AddNewThenDo(); if (_tempAddNewThenDo.ShowDialog() == DialogResult.OK) { this.DialogResult = DialogResult.None; _CurrentDoThenList.Add(_tempAddNewThenDo.MyVote); UpdateFormWithCurentList(); } this.DialogResult = DialogResult.None; } private void TSB_DELETE_Click(object sender, EventArgs e) { if (LIST_ThenDoList.SelectedItem != null && LIST_ThenDoList.SelectedIndex >= 0 && LIST_ThenDoList.SelectedIndex < _CurrentDoThenList.Count) { GlobalStaticClass.Vote_VoteClass _tempVC = _CurrentDoThenList[LIST_ThenDoList.SelectedIndex]; if ((new ConfirmDeleteForm(_tempVC.FormatAsStringForListBox())).ShowDialog() == DialogResult.OK) { _CurrentDoThenList.Remove(_tempVC); UpdateFormWithCurentList(); } } } private void LIST_ThenDoList_DoubleClick(object sender, EventArgs e) { EditThenDo(); } private void BTN_SAVE_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.OK; } private void TSB_Edit_Click(object sender, EventArgs e) { EditThenDo(); } private void EditThenDo() { if (LIST_ThenDoList.SelectedItem != null && LIST_ThenDoList.SelectedIndex >= 0 && LIST_ThenDoList.SelectedIndex < _CurrentDoThenList.Count) { GlobalStaticClass.Vote_VoteClass _tempVC = _CurrentDoThenList[LIST_ThenDoList.SelectedIndex]; if ((new AddNewThenDo(_tempVC)).ShowDialog() == DialogResult.OK) { UpdateFormWithCurentList(); } } } } }