4 using System.Xml.Serialization;
50 get {
return _Bitmaps; }
51 private set { _Bitmaps = value; }
65 get {
return _ShapeDefinitions; }
66 set { _ShapeDefinitions = value; }
76 private string _TableName;
81 public string TableName
83 get {
return _TableName; }
86 if (_TableName != value)
89 if (TableNameChanged != null)
91 TableNameChanged(
this,
new EventArgs());
103 private string _RomName;
109 public string RomName
111 get {
return _RomName; }
114 if (_RomName != value)
117 if (RomNameChanged != null)
119 RomNameChanged(
this,
new EventArgs());
137 public string TableFilename {
get; set; }
146 public string TableConfigurationFilename {
get; set; }
149 private bool _AddLedControlConfig =
false;
157 public bool AddLedControlConfig
159 get {
return _AddLedControlConfig; }
160 set { _AddLedControlConfig = value; }
175 get {
return _ConfigurationSource; }
176 set { _ConfigurationSource = value; }
188 get {
return _Effects; }
189 set { _Effects = value; }
204 return _AssignedStaticEffects;
208 _AssignedStaticEffects = value;
220 TableElements.UpdateState(Data);
238 this.Pinball = Pinball;
240 FileInfo ShapeDefinitionFile = Pinball.
GlobalConfig.GetShapeDefinitionFile();
241 if (ShapeDefinitionFile != null && ShapeDefinitionFile.Exists)
243 Log.
Write(
"Loading shape definition file: {0}".Build(ShapeDefinitionFile.FullName));
250 Log.
Exception(
"Loading shape definition file {0} failed.".Build(ShapeDefinitionFile.FullName), E);
252 ShapeDefinitions.
BitmapFilePattern =
new General.FilePattern(ShapeDefinitionFile.FullName.Substring(0, ShapeDefinitionFile.FullName.Length - ShapeDefinitionFile.Extension.Length) +
".png");
256 if (ShapeDefinitionFile == null)
258 Log.
Warning(
"Could not determin name of shape definition file");
262 Log.
Warning(
"Shape definition file {0} does not exist");
269 TableElements.InitAssignedEffects(
this);
270 AssignedStaticEffects.Init(
this);
278 AssignedStaticEffects.Finish();
279 TableElements.FinishAssignedEffects();
285 #region Serialization
294 using (MemoryStream ms =
new MemoryStream())
296 new XmlSerializer(typeof(
Table)).Serialize(ms,
this);
299 using (StreamReader sr =
new StreamReader(ms, Encoding.Default))
301 Xml = sr.ReadToEnd();
316 GetConfigXml().WriteToFile(FileName);
331 Xml = General.FileReader.ReadFileToString(FileName);
338 Log.
Exception(
"Could not read Table Config file {0}".Build(FileName), E);
339 throw new Exception(
"Could not read Table Config file {0}".Build(FileName), E);
341 return GetTableFromConfigXml(Xml);
351 return GetTableFromConfigXmlFile(TableConfigFile.FullName);
364 byte[] xmlBytes = Encoding.Default.GetBytes(ConfigXml);
365 using (MemoryStream ms =
new MemoryStream(xmlBytes))
375 Exception Ex =
new Exception(
"Could not deserialize Table config from XML Data", E);
376 Ex.Data.Add(
"XMLData", ConfigXml);
390 Effects =
new FX.EffectList();
FilePattern BitmapFilePattern
Gets or sets the file pattern which is used to load the bitmap file for the effect.
void Finish()
Finishes the table and the contained objects (Effects, TableElements)
EventHandler< EventArgs > RomNameChanged
Event is fired if the value of the property RomName is changed.
static Table GetTableFromConfigXmlFile(FileInfo TableConfigFile)
Instanciates a Table object from a Table configuration in a XML file.
static void Warning(string Message)
Writes a warning message to the log.
GlobalConfig GlobalConfig
Gets the global config for the Pinnball object.
void TriggerStaticEffects()
Triggers the static effects for the table.
TableElementTypeEnum
Enum for the different TableElement types.
Pinball is the main object of the DirectOutput framework. It holds all objects required to process P...
static void Write(string Message)
Writes the specified message to the logfile.
TableConfigSourceEnum ConfigurationSource
Gets or sets the configuration source.
A simple logger used to record important events and exceptions.
void Init(Pinball Pinball)
Initializes the table and the contained objects(Effects, TableElements).
TableConfigSourceEnum
Enum used to specify the source of a table configuration
static Table GetTableFromConfigXml(string ConfigXml)
Instanciates a Table object from a Table configuration in a XML string.
static ShapeDefinitions GetShapeDefinitionsFromShapeDefinitionsXmlFile(string FileName)
Instanciates a ShapeDefinitions object from a ShapeDefinitions ShapeDefinitionsuration in a XML file...
Data representing the state of a table emlement
List of TableElement objects.
string GetConfigXml()
Returns a serialized XML representation of the Table configuration.
EventHandler< EventArgs > TableNameChanged
Event is fired if the value of the property TableName is changed.
static Table GetTableFromConfigXmlFile(string FileName)
Instanciates a Table object from a Table configuration in a XML file.
Holds all table specific information and handles all TableElements
void SaveConfigXmlFile(string FileName)
Serializes the Table configuration to a XML file.
The namespace FX contains effect related classes. Effects can be assigned directly to a Table and wi...
Table()
Initializes a new instance of the Table class.
The namespace DirectOutput.General contains classes for general use.
Effects in this namespace are controlling toys which implement the IMatrix interface ...
List of effects which are assigned to some other object.
static void Exception(string Message, Exception E=null)
Writes a exception message to the log.
Collection of IEffect objects. Every object can only exist once in the list and every objects needs t...