WIP
DirectOutput framework for virtual pinball cabinets WIP
Go to:
Overview 
TableElementData.cs
Go to the documentation of this file.
1 using System;
2 
3 namespace DirectOutput.Table
4 {
8  public struct TableElementData
9  {
10 
15 
19  public int Number;
20 
24  public int Value;
25 
29  public string Name;
30 
31 
32 
39  public TableElementData(TableElementTypeEnum TableElementType, int Number, int Value)
40  {
41  this.TableElementType = TableElementType;
42  this.Number = Number;
43  this.Value = Value;
44  this.Name = null;
45  }
46 
47 
54  public TableElementData(Char TableElementTypeChar, int Number, int Value)
55  {
56 
57  if (!Enum.IsDefined(typeof(TableElementTypeEnum), (int)TableElementTypeChar))
58  {
59  Log.Warning("Undefined char \"{0}\" supplied for the TableElementTypeChar.".Build(TableElementTypeChar));
60  this.TableElementType = TableElementTypeEnum.Unknown;
61  }
62  else
63  {
64  this.TableElementType = (TableElementTypeEnum)TableElementTypeChar;
65  }
66  this.Number = Number;
67  this.Name = null;
68  this.Value = Value;
69  }
70 
76  {
77  this.Number = TableElement.Number;
78  this.TableElementType = TableElement.TableElementType;
79  this.Name = TableElement.Name;
80  this.Value = TableElement.Value;
81  }
82 
83  public TableElementData(string TableElementName, int Value)
84  {
85  if (TableElementName.Length > 1 && Enum.IsDefined(typeof(TableElementTypeEnum), (int)TableElementName[0]) && TableElementName[0]!=(char)TableElementTypeEnum.NamedElement && TableElementName.Substring(1).IsInteger())
86  {
87  //It is a normal table element.
88  this.TableElementType = (TableElementTypeEnum)TableElementName[0];
89  this.Number = TableElementName.Substring(1).ToInteger();
90  this.Name = null;
91  }
92  else
93  {
94  //Named table element
95  this.TableElementType = TableElementTypeEnum.NamedElement;
96  this.Name = (TableElementName[0] != (char)TableElementTypeEnum.NamedElement?TableElementName:TableElementName.Substring(1));
97  this.Number = int.MinValue;
98  }
99 
100 
101  this.Value = Value;
102  }
103 
104  }
105 }
TableElementTypeEnum TableElementType
The type of the table element.
int Number
Number of the TableElement.
Definition: TableElement.cs:43
TableElementData(Char TableElementTypeChar, int Number, int Value)
Initializes a new instance of the TableElementData class.
int Number
The number of the table element.
static void Warning(string Message)
Writes a warning message to the log.
Definition: Log.cs:134
TableElementTypeEnum
Enum for the different TableElement types.
A simple logger used to record important events and exceptions.
Definition: Log.cs:14
int Value
The value of the table element.
TableElementData(TableElementTypeEnum TableElementType, int Number, int Value)
Initializes a new instance of the TableElementData class.
string Name
Name of the TableElement. Triggers NameChanged if value is changed.
Definition: TableElement.cs:65
Data representing the state of a table emlement
TableElementData(TableElement TableElement)
Initializes a new instance of the TableElementData class from the data in a TableElement.
TableElementTypeEnum TableElementType
Type of the TableElement.
Definition: TableElement.cs:24
string Name
The name of the table element
Represents a element (e.g. Switch, Solenoid) of a pinball table
Definition: TableElement.cs:12
TableElementData(string TableElementName, int Value)
int Value
Value of the TableElement. Triggers ValueChanged if the value is changed.
Definition: TableElement.cs:94