B2S.Server Sample Plugin
Sample plugin implementation for the B2S.Server
Go to:
Overview 
 All Classes Namespaces Files Functions Properties Pages
SamplePluginCSharp.cs
Go to the documentation of this file.
1 /******************************************************
2  * Sample C# Plugin implementation for the B2S.Server *
3  *****************************************************/
4 
5 using System;
6 
7 //Makes the MEF functions available (dont forget the a reference to System.ComponentModel.Composition in your own projects)
8 using System.ComponentModel.Composition;
9 
10 //Makes the interfaces in the B2SServerPluginInterface.dll available (dont forget to set the reference to the DLL in your own projects).
11 using B2SServerPluginInterface;
12 
13 //Makes the forms namespace available. Used for the frontend call.
14 using System.Windows.Forms;
15 
20 namespace B2SServerSamplePluginCSharp
21 {
22 
32  [Export(typeof(IDirectPlugin))]
33  public class SamplePluginCSharp : IDirectPlugin, IDirectPluginFrontend, IDirectPluginPinMame
34  {
35 
36  #region IDirectPlugin Members
37 
47  public string Name
48  {
49  get
50  {
51  //Get the version of the assembly
52  Version V =System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
53  //Calculate the BuildDate based in the build and revsion number of the project.
54  DateTime BuildDate = new DateTime(2000, 1, 1).AddDays(V.Build).AddSeconds(V.Revision * 2);
55  //Format and return the name string.
56  return string.Format("Sample Plugin C# (V: {0} as of {1})",V.ToString(), BuildDate.ToString("yyyy.MM.dd hh:mm"));
57  }
58  }
59 
67  public void PluginInit(string TableFilename, string RomName)
68  {
69  //Initialize your plugin here
70  }
71 
78  public void PluginFinish()
79  {
80  //Do cleanup work here
81  }
82 
92  public void DataReceive(char TableElementTypeChar, int Number, int Value)
93  {
94  //Do something with the received data.
95  }
96 
97  #endregion
98 
99  #region IDirectPluginPinMame Members
100 
105  public void PinMameRun() {
106  }
107 
112  public void PinMamePause() {
113  }
114 
119  public void PinMameContinue() { }
120 
121 
126  public void PinMameStop() { }
127 
128  #endregion
129 
130  #region IDirectPluginFrontend Members
131 
137  public void PluginShowFrontend(Form Owner = null)
138  {
139  //Open the frontend in this method, e.g. as demonstrated below.
140 
141  //Check if the frontend window is already open
142  //If yes, bring it to the front and set focus
143  foreach (Form F in Application.OpenForms)
144  {
145  if (F.GetType() == typeof(Frontend))
146  {
147  F.BringToFront();
148  F.Focus();
149  return;
150  }
151  }
152 
153  //If the frontend is not yet open, create a new instance and show it
154  Frontend FE = new Frontend();
155  if (Owner == null)
156  {
157  //Owner para is not set.
158  FE.Show();
159  }
160  else
161  {
162  //Owner para set set. Show frontend and pass owner para.
163  FE.Show(Owner);
164  }
165  }
166 
167 
168  #endregion
169 
170  #region Constructor of the class
171 
172 
173 
174 
176  {
177  }
178  #endregion
179 
180  }
181 }