2 using System.Collections.Generic;
14 private Dictionary<TableElementTypeEnum, Dictionary<int, TableElement>> _NumberedTableElementsDictionary;
15 private Dictionary<string, TableElement> _NamedTableElementsDictionary;
39 #region Direct access to TableElementType Dictionaries
59 return new List<TableElement>(_NamedTableElementsDictionary.Values);
63 return new List<TableElement>(_NumberedTableElementsDictionary[Type].Values);
70 public Dictionary<int, TableElement>
Switch
80 public Dictionary<int, TableElement>
Solenoid
90 public Dictionary<int, TableElement>
Lamp
100 public Dictionary<int, TableElement>
GIString
111 public Dictionary<int, TableElement>
Mech
133 throw new IndexOutOfRangeException(
"Table element type NamedElement cant be retrieved by number.");
135 return _NumberedTableElementsDictionary[TableElementType][Number];
155 return _NamedTableElementsDictionary[TableElementName];
162 #region UpdateState()
187 if (Contains(Data.
Name))
189 _NamedTableElementsDictionary[Data.
Name.ToUpperInvariant()].Value = Data.
Value;
193 Add(Data.
Name.ToUpperInvariant(), Data.
Value);
212 if (TableElement == null)
214 throw new Exception(
"Cant add null to the list of table elements.");
219 if (Contains(TableElement))
221 throw new Exception(
"The TableElement {0} {1} cant be added to the list. Another entry with the same type and number does already exist.".Build(TableElement.
TableElementType, TableElement.
Number));
230 if (TableElement.
Name.IsNullOrWhiteSpace())
232 throw new Exception(
"Named TableElements cant have a empty name when they are added to the list.");
235 if (Contains(TableElement))
237 throw new Exception(
"The TableElement named {0} cant be added to the list. Another entry with the same name does already exist.".Build(TableElement.
Name));
239 _NamedTableElementsDictionary.Add(TableElement.
Name, TableElement);
242 base.Add(TableElement);
262 public void Add(
string TableElementName,
int State)
283 return _NumberedTableElementsDictionary[TableElement.
TableElementType].ContainsKey(TableElement.
Number) || base.Contains(TableElement);
287 return _NamedTableElementsDictionary.ContainsKey(TableElement.
Name.ToUpperInvariant()) || base.Contains(TableElement); ;
299 return _NumberedTableElementsDictionary[TableElementType].ContainsKey(Number);
311 return _NamedTableElementsDictionary.ContainsKey(TableElementName.ToUpperInvariant());
327 if (TableElement == null)
return false;
329 if (!Contains(TableElement))
return false;
337 _NamedTableElementsDictionary.Remove(TableElement.
Name);
340 return base.Remove(TableElement);
352 if (!Contains(TableElementType, Number))
return false;
354 Remove(_NumberedTableElementsDictionary[TableElementType][Number]);
356 _NumberedTableElementsDictionary[TableElementType].Remove(Number);
368 public bool Remove(
string TableElementName)
370 if (!Contains(TableElementName))
return false;
372 Remove(_NamedTableElementsDictionary[TableElementName]);
374 _NamedTableElementsDictionary.Remove(TableElementName);
395 #region Events & Event handling
401 _NumberedTableElementsDictionary[e.
OldItem.TableElementType].Remove(e.
OldItem.Number);
402 e.
OldItem.ValueChanged -=
new EventHandler<TableElementValueChangedEventArgs>(Item_ValueChanged);
404 e.
NewItem.ValueChanged +=
new EventHandler<TableElementValueChangedEventArgs>(Item_ValueChanged);
417 throw new Exception(
"Another TableElement with type {0} and number {1} does already exist in the list.".Build(e.
NewItem.TableElementType, e.
NewItem.Number));
424 e.
Item.ValueChanged -=
new EventHandler<TableElementValueChangedEventArgs>(Item_ValueChanged);
429 e.
Item.ValueChanged +=
new EventHandler<TableElementValueChangedEventArgs>(Item_ValueChanged);
432 void Item_ValueChanged(
object sender, TableElementValueChangedEventArgs e)
434 OnTableElementValueChanged(e);
437 #region "TableElement Value Changed Event
440 private void OnTableElementValueChanged(TableElementValueChangedEventArgs e)
442 if (TableElementValueChanged != null)
444 TableElementValueChanged(
this, e);
475 _NumberedTableElementsDictionary =
new Dictionary<TableElementTypeEnum, Dictionary<int, TableElement>>();
480 _NumberedTableElementsDictionary.Add(T,
new Dictionary<int, TableElement>());
483 _NamedTableElementsDictionary =
new Dictionary<string, TableElement>();
484 this.AfterInsert +=
new EventHandler<InsertEventArgs<TableElement>>(TableElementList_AfterInsert);
485 this.AfterRemove +=
new EventHandler<RemoveEventArgs<TableElement>>(TableElementList_AfterRemove);
486 this.BeforeSet +=
new EventHandler<SetEventArgs<TableElement>>(TableElementList_BeforeSet);
487 this.AfterSet +=
new EventHandler<SetEventArgs<TableElement>>(TableElementList_AfterSet);
503 TE.
ValueChanged -=
new EventHandler<TableElementValueChangedEventArgs>(Item_ValueChanged);
string[] GetTableElementDescriptors()
Gets the table element descriptors. NamedElements are returned as $Name. Numbered elemenst are return...
new void Add(TableElement TableElement)
Adds a TableElement to the list.
Ty Item
The value of the Item to remove from index.
Event args for Set events.
TableElementTypeEnum TableElementType
The type of the table element.
void InitAssignedEffects(Table Table)
Initializes the AssignedEffects for all TableElements in this list.
AssignedEffectList AssignedEffects
List of effects which are assigned to the table element.
bool Contains(string TableElementName)
Determines whether a table element with the specified name is contained in the list.
bool Remove(TableElementTypeEnum TableElementType, int Number)
Removes the TableElement with the specified TableElementType and Number from the list.
int Number
Number of the TableElement.
EventHandler< TableElementValueChangedEventArgs > ValueChanged
Event is fired if the value of the property State is changed.
Ty NewItem
New item for the replacement.
int Number
The number of the table element.
Ty Item
The new value of the element at Index.
EventErgs for remove events
TableElementTypeEnum
Enum for the different TableElement types.
bool Remove(string TableElementName)
Removes the table element with the specified name.
TableElementValueChangedEventHandler TableElementValueChanged
Is fired on changes of the value of any TableElement in this collection
int Value
The value of the table element.
void FinishAssignedEffects()
Finishes the AssignedEffects for all TableElements in this list.
EventArgs object for TableElementValueChanged events.
string Name
Name of the TableElement. Triggers NameChanged if value is changed.
new bool Contains(TableElement TableElement)
Checks if a specified TableElement is contained in the list.
TableElementList()
Initializes a new instance of the TableElementList class.
Ty OldItem
Item to be replaced.
Data representing the state of a table emlement
List of TableElement objects.
List< TableElement > GetTableElementListForType(TableElementTypeEnum Type)
Returns a list of the TableElement objects with the specified type.
void UpdateState(TableElementData Data)
Method to update the state and/or add a entry to the list
void Add(string TableElementName, int State)
bool Contains(TableElementTypeEnum TableElementType, int Number)
Checks if a specified TableElement is contained in the list.
TableElementTypeEnum TableElementType
Type of the TableElement.
Holds all table specific information and handles all TableElements
Extended version of the generic List class supporting events for various actions on the list...
string Name
The name of the table element
Represents a element (e.g. Switch, Solenoid) of a pinball table
Eventargs of BeforeInsert and AfterInsert events.
void Add(TableElementTypeEnum TableElementType, int Number, int State)
Method for adding a entry to the list.
The namespace DirectOutput.General contains classes for general use.
new bool Remove(TableElement TableElement)
Removes the specified TableElement from the List.