2 using System.Collections.Generic;
3 using System.ComponentModel;
8 using System.Windows.Forms;
10 using DirectOutput.Table;
11 using System.Threading;
13 namespace DirectOutputConfigTester
19 private bool OutputActive =
false;
22 InitializeComponent();
33 if (OCD.ShowDialog() == DialogResult.OK)
59 Pinball.
Table.
TableElements.Sort((TE1, TE2) => (TE1.TableElementType == TE2.TableElementType ? TE1.Number.CompareTo(TE2.Number) : TE1.TableElementType.CompareTo(TE2.TableElementType)));
61 TableElements.Rows.Clear();
65 int RowIndex = TableElements.Rows.Add();
66 TableElements.Rows[RowIndex].Tag = TE;
68 TableElements[TEName.Name, RowIndex].Value = (TE.
Name.IsNullOrWhiteSpace() ?
"" : TE.
Name);
69 TableElements[TENumber.Name, RowIndex].Value = TE.
Number;
70 TableElements[TEValue.Name, RowIndex].Value = TE.
Value;
71 TableElements[TEActivate.Name, RowIndex].Value = (TE.
Value > 0 ?
"Deactivate" :
"Activate");
72 TableElements[TEPulse.Name, RowIndex].Value = (TE.
Value > 0 ?
@"Pulse ¯\_/¯" :
@"Pulse _/¯\_");
81 private void ConfigTester_FormClosed(
object sender, FormClosedEventArgs e)
86 private void ConfigTester_FormClosing(
object sender, FormClosingEventArgs e)
96 private void ConfigTester_Load(
object sender, EventArgs e)
104 private void TableElements_CellClick(
object sender, DataGridViewCellEventArgs e)
107 if (e.ColumnIndex >= 0 && e.ColumnIndex < TableElements.ColumnCount)
109 if (e.RowIndex >= 0 && e.RowIndex < TableElements.RowCount)
111 if (TableElements.Columns[e.ColumnIndex].Name == TEActivate.Name)
114 int.TryParse(TableElements[TEValue.Name, e.RowIndex].Value.ToString(), out OrgValue);
115 int NewValue = (OrgValue > 0 ? 0 : 1);
116 TableElements[TEValue.Name, e.RowIndex].Value = NewValue;
118 else if (TableElements.Columns[e.ColumnIndex].Name == TEPulse.Name)
121 int.TryParse(TableElements[TEValue.Name, e.RowIndex].Value.ToString(),out OrgValue);
122 int PulseValue = (OrgValue > 0 ? 0 : 1);
124 TableElements[TEValue.Name, e.RowIndex].Value = PulseValue;
126 TableElements[TEValue.Name, e.RowIndex].Value = OrgValue;
132 private void TableElements_CellValueChanged(
object sender, DataGridViewCellEventArgs e)
134 if (e.ColumnIndex >= 0 && e.ColumnIndex < TableElements.ColumnCount)
136 if (e.RowIndex >= 0 && e.RowIndex < TableElements.RowCount)
138 if (TableElements.Columns[e.ColumnIndex].Name == TEValue.Name)
140 object Value = TableElements[TEValue.Name, e.RowIndex].Value;
141 int NumericValue = 0;
142 if (!
int.TryParse(Value.ToString(), out NumericValue))
144 MessageBox.Show(
"The value entered is not a valid number.\nWill set the value to 0.",
"Invalid value entered", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
145 TableElements[TEValue.Name, e.RowIndex].Value = 0;
153 D.
Value = NumericValue;
157 TableElements[TEActivate.Name, e.RowIndex].Value = (NumericValue > 0 ?
"Deactivate" :
"Activate");
158 TableElements[TEPulse.Name, e.RowIndex].Value = (NumericValue > 0 ?
@"Pulse ¯\_/¯" :
@"Pulse _/¯\_");
165 private void PulseDurationInput_ValueChanged(
object sender, EventArgs e)
170 private void ActivateAllButton_Click(
object sender, EventArgs e)
172 for (
int RowIndex = 0; RowIndex < TableElements.Rows.Count; RowIndex++)
174 TableElements[TEValue.Name, RowIndex].Value = 1;
178 private void DeactivateAllButton_Click(
object sender, EventArgs e)
180 for (
int RowIndex = 0; RowIndex < TableElements.Rows.Count; RowIndex++)
182 TableElements[TEValue.Name, RowIndex].Value = 0;
186 private void LoadConfigButton_Click(
object sender, EventArgs e)
191 private void ShowFrontEndButton_Click(
object sender, EventArgs e)
193 DirectOutput.Frontend.MainMenu.Open(
Pinball);