2 using System.Collections.Generic;
22 get {
return _Pinball; }
30 private void UpdateAll()
35 UpdateTableElements();
36 UpdateTableAssignedStaticEffects();
39 private void UpdateTableGeneral()
41 DataTable DT =
new DataTable();
42 DT.Columns.Add(
"Property", typeof(
string));
43 DT.Columns.Add(
"Value", typeof(
string));
55 DT.Rows.Add(
"{0} count".Build(((
TableElementTypeEnum)TET).ToString()), Pinball.Table.TableElements.GetTableElementListForType(TET).Count);
58 DT.Rows.Add(
"Configured effects", Pinball.Table.Effects.Count);
59 DT.Rows.Add(
"Assigned startup effects", Pinball.Table.AssignedStaticEffects.Count);
61 TableGeneral.ClearSelection();
62 TableGeneral.Columns.Clear();
63 TableGeneral.AutoGenerateColumns =
true;
64 TableGeneral.DataSource = DT;
65 TableGeneral.Refresh();
66 TableGeneral.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
70 private void UpdateTableAssignedStaticEffects()
72 DataTable DT =
new DataTable();
73 DT.Columns.Add(
"Name", typeof(
string));
74 DT.Columns.Add(
"Type", typeof(
string));
75 DT.Columns.Add(
"Configured in", typeof(
string));
82 string Configured =
"<not configured>";
83 if (Pinball.Table.Effects.Contains(AE.
EffectName))
85 T = Pinball.Table.Effects[AE.
EffectName].GetType();
89 DT.Rows.Add(AE.
EffectName, T.Name, Configured);
92 TableAssignedStaticEffects.ClearSelection();
93 TableAssignedStaticEffects.Columns.Clear();
94 TableAssignedStaticEffects.AutoGenerateColumns =
true;
95 TableAssignedStaticEffects.DataSource = DT;
96 TableAssignedStaticEffects.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
97 TableAssignedStaticEffects.Refresh();
101 private void UpdateTableEffects()
103 DataTable DT =
new DataTable();
104 DT.Columns.Add(
"Name", typeof(
string));
105 DT.Columns.Add(
"Type", typeof(
string));
109 foreach (
IEffect E
in Pinball.Table.Effects)
111 DT.Rows.Add(E.
Name, E.GetType().
Name);
114 TableEffects.ClearSelection();
115 TableEffects.Columns.Clear();
116 TableEffects.AutoGenerateColumns =
true;
117 TableEffects.DataSource = DT;
118 TableEffects.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
120 TableEffects.Refresh();
125 private void UpdateTableElements()
127 DataTable DT =
new DataTable();
128 DT.Columns.Add(
"Type", typeof(
string));
129 DT.Columns.Add(
"Number", typeof(
int));
130 DT.Columns.Add(
"Name", typeof(
string));
131 DT.Columns.Add(
"Value", typeof(
int));
132 DT.Columns.Add(
"Assigned FX", typeof(
int));
142 DT.DefaultView.Sort =
"Type ASC, Number ASC";
143 TableElements.ClearSelection();
144 TableElements.Columns.Clear();
145 TableElements.AutoGenerateColumns =
true;
146 TableElements.DataSource = DT;
147 TableElements.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
152 private void UpdateTableElement()
154 if (TableElements.SelectedRows.Count > 0)
156 DataRow DR = ((DataRowView)TableElements.SelectedRows[0].DataBoundItem).Row;
163 UpdateTableElementAssignedEffects(null);
168 DataTable DT =
new DataTable();
169 DT.Columns.Add(
"Name", typeof(
string));
170 DT.Columns.Add(
"Type", typeof(
string));
171 DT.Columns.Add(
"Configured in", typeof(
string));
173 if (TableElement != null)
178 string Configured=
"<not configured>";
179 if(Pinball.Table.Effects.Contains(AE.
EffectName)) {
180 T= Pinball.Table.Effects[AE.
EffectName].GetType();
181 Configured =
"Table";
186 TableElementAssignedEffects.ClearSelection();
187 TableElementAssignedEffects.Columns.Clear();
188 TableElementAssignedEffects.AutoGenerateColumns =
true;
189 TableElementAssignedEffects.DataSource = DT;
190 TableElementAssignedEffects.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
191 TableElementAssignedEffects.Refresh();
195 private void UpdateEffect()
197 if (TableEffects.SelectedRows.Count > 0)
199 string N = (string)TableEffects.SelectedRows[0].Cells[0].Value;
200 if (Pinball.Table.Effects.Contains(N))
202 UpdateEffectProperties(Pinball.Table.Effects[N]);
206 UpdateEffectProperties(null);
209 private void UpdateEffectProperties(
IEffect Effect)
213 DataTable DT =
new DataTable();
214 DT.Columns.Add(
"Property", typeof(
string));
215 DT.Columns.Add(
"Value", typeof(
string));
218 DT.Rows.Add(
"Name", Effect.
Name);
220 Type T = Effect.GetType();
221 DT.Rows.Add(
"Type", T.Name);
223 foreach (PropertyInfo PI
in T.GetProperties(BindingFlags.Instance | BindingFlags.Public))
225 if (PI.Name !=
"Name" )
227 DT.Rows.Add(PI.Name, PI.GetValue(Effect,
new object[] { }).ToString());
231 TableEffectProperties.ClearSelection();
232 TableEffectProperties.Columns.Clear();
233 TableEffectProperties.AutoGenerateColumns =
true;
235 TableEffectProperties.DataSource = DT;
236 TableEffectProperties.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
237 TableEffectProperties.Refresh();
244 private void UpdateWindowTitle()
246 string S =
"Table Configuration";
247 if (!Pinball.Table.TableName.IsNullOrWhiteSpace())
249 S +=
" - {0}".Build(Pinball.Table.TableName);
252 if (!Pinball.Table.RomName.IsNullOrWhiteSpace())
254 S +=
" - {0}".Build(Pinball.Table.RomName);
263 InitializeComponent();
264 this.Pinball = Pinball;
267 private void TableEffects_SelectionChanged(
object sender, EventArgs e)
272 private void TableElements_SelectionChanged(
object sender, EventArgs e)
274 UpdateTableElement();
277 private void RefreshWindow_Click(
object sender, EventArgs e)
282 private void ExportTableConfiguration_Click(
object sender, EventArgs e)
284 if (!Pinball.Table.TableConfigurationFilename.IsNullOrWhiteSpace())
286 FileInfo FI =
new FileInfo(Pinball.Table.TableConfigurationFilename);
287 SaveTableConfigDialog.InitialDirectory = FI.Directory.FullName;
288 SaveTableConfigDialog.FileName = FI.FullName;
290 else if (!Pinball.Table.TableFilename.IsNullOrWhiteSpace())
292 FileInfo FI =
new FileInfo(Pinball.Table.TableFilename);
293 SaveTableConfigDialog.InitialDirectory = FI.Directory.FullName;
294 SaveTableConfigDialog.FileName = Path.Combine(FI.Directory.FullName,
"{0}.xml".Build(FI.GetNameWithoutExtension()));
298 SaveTableConfigDialog.InitialDirectory = Pinball.GlobalConfig.GetGlobalConfigDirectory().FullName;
300 if (SaveTableConfigDialog.ShowDialog() == DialogResult.OK)
302 Pinball.Table.TableConfigurationFilename = SaveTableConfigDialog.FileName;
305 Pinball.Table.SaveConfigXmlFile(SaveTableConfigDialog.FileName);
307 MessageBox.Show(
"Table configuration saved to\n{0}".Build(SaveTableConfigDialog.FileName),
"Table configuration saved", MessageBoxButtons.OK, MessageBoxIcon.Information);
311 MessageBox.Show(
"Could not save table config to\n{0}\n\nThe following error occured:\n{1}".Build(SaveTableConfigDialog.FileName, E.Message),
"File save error", MessageBoxButtons.OK, MessageBoxIcon.Error);
AssignedEffectList AssignedEffects
List of effects which are assigned to the table element.
int Number
Number of the TableElement.
string RomName
Name of the table rom. Triggers RomNameChanged if value is changed.
string TableName
Name of the Table. Triggers TableNameChanged if value is changed.
TableElementTypeEnum
Enum for the different TableElement types.
Pinball is the main object of the DirectOutput framework. It holds all objects required to process P...
TableConfigSourceEnum ConfigurationSource
Gets or sets the configuration source.
new string Name
Name of the effect.
Table.Table Table
Gets or sets the table object for the Pinball object.
TableConfigSourceEnum
Enum used to specify the source of a table configuration
Common interface for all effects. If a new effect is implemented it is best to inherit from the abst...
string Name
Name of the TableElement. Triggers NameChanged if value is changed.
string TableFilename
Gets or sets the filename of the table.
string TableConfigurationFilename
Gets or sets the table configuration filename.
string EffectName
Name of the AssignedEffect. Triggers EffectNameChanged if value is changed.
TableInfo(Pinball Pinball)
The Table namespace contains all table specific classes like the Table class itself, TableElement and effect assigment classes.
TableElementTypeEnum TableElementType
Type of the TableElement.
The namespace FX contains effect related classes. Effects can be assigned directly to a Table and wi...
Represents a element (e.g. Switch, Solenoid) of a pinball table
int Count
Number of items in the ExtList.
Handles the assignemt of a effect to a AssignedEffectList.
int Value
Value of the TableElement. Triggers ValueChanged if the value is changed.