DirectOutputR1
DirectOutput framework R1 for virtual pinball cabinets.
Go to:
Overview 
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros Pages
MainMenu.cs
Go to the documentation of this file.
1 using System;
2 using System.Windows.Forms;
3 
4 
5 namespace DirectOutput.Frontend
6 {
7  public partial class MainMenu : Form
8  {
9  private Pinball Pinball { get; set; }
10 
11 
12  private MainMenu(Pinball Pinball)
13  {
14 
15 
16  this.Pinball = Pinball;
17  InitializeComponent();
18 
19  Version V = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
20  DateTime BuildDate = new DateTime(2000, 1, 1).AddDays(V.Build).AddSeconds(V.Revision * 2);
21 
22  Version.Text = "Version {0} as of {1}".Build(V.ToString(), BuildDate.ToString("yyyy.MM.dd HH:mm"));
23 
24  TableName.Text = (Pinball.Table.TableName.IsNullOrWhiteSpace() ? "<No table name set>" : Pinball.Table.TableName);
25  TableFilename.Text = (Pinball.Table.TableFilename.IsNullOrWhiteSpace() ? "<No table file name set>" : Pinball.Table.TableFilename);
26  TableRomname.Text = (Pinball.Table.RomName.IsNullOrWhiteSpace() ? "<No rom name set>" : Pinball.Table.RomName);
27 
28 
29  GlobalConfigFilename.Text = (Pinball.GlobalConfig.GlobalConfigFilename.IsNullOrWhiteSpace() ? "<no global config file set>" : (Pinball.GlobalConfig.GetGlobalConfigFile().Exists ? Pinball.GlobalConfig.GlobalConfigFilename : "<no global config file found>"));
30 
31 
32  switch (Pinball.Table.ConfigurationSource)
33  {
34  case DirectOutput.Table.TableConfigSourceEnum.TableConfigurationFile:
35  TableConfigFilename.Text = Pinball.Table.TableConfigurationFilename;
36  break;
37  case DirectOutput.Table.TableConfigSourceEnum.IniFile:
38  TableConfigFilename.Text = "Table config parsed from LedControl file.";
39  break;
40  default:
41  TableConfigFilename.Text = "<no config file loaded>";
42  break;
43  }
44 
45 
46  if (Pinball.Cabinet.CabinetConfigurationFilename.IsNullOrWhiteSpace())
47  {
48  CabinetConfigFilename.Text = "<no config file loaded>";
49  }
50  else
51  {
52  CabinetConfigFilename.Text = Pinball.Cabinet.CabinetConfigurationFilename;
53  }
54 
55  }
56 
57 
58  public static void Open(Pinball Pinball, Form Owner=null)
59  {
60 
61 
62  foreach (Form F in Application.OpenForms)
63  {
64  if (F.GetType() == typeof(MainMenu))
65  {
66  F.BringToFront();
67  F.Focus();
68  return;
69  }
70  }
71 
72  MainMenu M = new MainMenu(Pinball);
73 
74  if (Owner == null)
75  {
76  M.Show();
77  }
78  else
79  {
80  M.StartPosition = FormStartPosition.CenterParent;
81  M.Show(Owner);
82  }
83  }
84 
85  private void ShowCabinetConfiguration_Click(object sender, EventArgs e)
86  {
87  foreach (Form F in Application.OpenForms)
88  {
89  if (F.GetType() == typeof(CabinetInfo))
90  {
91  F.BringToFront();
92  F.Focus();
93  return;
94  }
95  }
96  CabinetInfo CI = new CabinetInfo(Pinball.Cabinet);
97  CI.StartPosition = FormStartPosition.CenterParent;
98  CI.Show(this);
99 
100  }
101 
102  private void ShowTableConfiguration_Click(object sender, EventArgs e)
103  {
104  foreach (Form F in Application.OpenForms)
105  {
106  if (F.GetType() == typeof(TableInfo))
107  {
108  F.BringToFront();
109  F.Focus();
110  return;
111  }
112  }
113  TableInfo CI = new TableInfo(Pinball);
114  CI.StartPosition = FormStartPosition.CenterParent;
115  CI.Show(this);
116  }
117 
118  private void EditGlobalConfiguration_Click(object sender, EventArgs e)
119  {
120  foreach (Form F in Application.OpenForms)
121  {
122  if (F.GetType() == typeof(GlobalConfigEdit))
123  {
124  F.BringToFront();
125  F.Focus();
126  return;
127  }
128  }
129  GlobalConfigEdit CI = new GlobalConfigEdit();
130  CI.StartPosition = FormStartPosition.CenterParent;
131  CI.Show(this);
132  }
133 
134  private void ShowLoadedScripts_Click(object sender, EventArgs e)
135  {
136  foreach (Form F in Application.OpenForms)
137  {
138  if (F.GetType() == typeof(ScriptInfo))
139  {
140  F.BringToFront();
141  F.Focus();
142  return;
143  }
144  }
145  ScriptInfo CI = new ScriptInfo(Pinball);
146  CI.StartPosition = FormStartPosition.CenterParent;
147  CI.Show(this);
148  }
149 
150  private void button1_Click(object sender, EventArgs e)
151  {
152  foreach (Form F in Application.OpenForms)
153  {
154  if (F.GetType() == typeof(AvailableToysInfo))
155  {
156  F.BringToFront();
157  F.Focus();
158  return;
159  }
160  }
161  AvailableToysInfo CI = new AvailableToysInfo();
162  CI.StartPosition = FormStartPosition.CenterParent;
163  CI.Show(this);
164  }
165 
166  private void button2_Click(object sender, EventArgs e)
167  {
168  foreach (Form F in Application.OpenForms)
169  {
170  if (F.GetType() == typeof(AvailableEffectsInfo))
171  {
172  F.BringToFront();
173  F.Focus();
174  return;
175  }
176  }
177  AvailableEffectsInfo CI = new AvailableEffectsInfo();
178  CI.StartPosition = FormStartPosition.CenterParent;
179  CI.Show(this);
180  }
181 
182  private void ShowSystemMonitor_Click(object sender, EventArgs e)
183  {
184  foreach (Form F in Application.OpenForms)
185  {
186  if (F.GetType() == typeof(SystemMonitor))
187  {
188  F.BringToFront();
189  F.Focus();
190  return;
191  }
192  }
193  SystemMonitor CI = new SystemMonitor(Pinball);
194  CI.StartPosition = FormStartPosition.CenterParent;
195  CI.Show(this);
196  }
197 
198 
199 
200 
201  }
202 }