WIP
DirectOutput framework for virtual pinball cabinets WIP
Go to:
Overview 
OpenConfigDialog.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
4 using System.Data;
5 using System.Drawing;
6 using System.Linq;
7 using System.Text;
8 using System.Windows.Forms;
9 
11 {
12  public partial class OpenConfigDialog : Form
13  {
14  private Settings Settings = new Settings();
15 
16  public OpenConfigDialog(Settings Settings = null)
17  {
18  if (Settings != null)
19  {
20  this.Settings = Settings;
21  }
22  InitializeComponent();
23 
24  LoadData();
25 
26  }
27 
28  private void LoadData()
29  {
32  RomName = Settings.LastRomName;
33  if (Settings.RomNames.Count > 0)
34  {
35  Settings.RomNames.Sort();
36  RomNameComboBox.Items.Clear();
37  RomNameComboBox.Items.AddRange(Settings.RomNames.ToArray());
38  }
39 
40  GlobalConfigFilenameComboBox.Items.Clear();
41  GlobalConfigFilenameComboBox.Items.AddRange(Settings.GlobalConfigFilenames.ToArray());
42 
43  TableFilenameComboBox.Items.Clear();
44  TableFilenameComboBox.Items.Add("");
45  TableFilenameComboBox.Items.AddRange(Settings.TableFilenames.ToArray());
46  }
47 
48  private void SaveData()
49  {
52  Settings.LastRomName = RomName;
53 
54  Settings.RomNames.Clear();
55  foreach (string Item in RomNameComboBox.Items)
56  {
57  Settings.RomNames.Add(Item);
58  }
59 
60  if (!Settings.RomNames.Contains(RomName))
61  {
62  Settings.RomNames.Add(RomName);
63  }
64 
66  Settings.GlobalConfigFilenames.Insert(0, GlobalConfigFilename);
67 
68  if (!TableFilename.IsNullOrWhiteSpace())
69  {
70  Settings.TableFilenames.Remove(TableFilename);
71  Settings.TableFilenames.Insert(0, TableFilename);
72  }
73  }
74 
75 
76  private void GlobalConfigFileSelectButton_Click(object sender, EventArgs e)
77  {
78  SelectGlobalConfigFile();
79  }
80 
81 
82 
83  private void TableFileSelectButton_Click(object sender, EventArgs e)
84  {
85  SelectTableFile();
86  }
87 
88 
89  private void SelectTableFile()
90  {
91  if (OpenTableFileDialog.ShowDialog(this) == DialogResult.OK)
92  {
93  TableFilename = OpenTableFileDialog.FileName;
94  }
95  }
96  private void SelectGlobalConfigFile()
97  {
98 
99  if (OpenGlobalConfigFileDialog.ShowDialog(this) == DialogResult.OK)
100  {
101  GlobalConfigFilename = OpenGlobalConfigFileDialog.FileName;
102  }
103  }
104 
105 
106 
107  public string RomName
108  {
109  get { return RomNameComboBox.Text; }
110  set { RomNameComboBox.Text = value; }
111  }
112 
113 
114 
115  public string GlobalConfigFilename
116  {
117  get { return GlobalConfigFilenameComboBox.Text; }
118  set { GlobalConfigFilenameComboBox.Text = value; }
119  }
120 
121 
122 
123  public string TableFilename
124  {
125  get { return TableFilenameComboBox.Text; }
126  set { TableFilenameComboBox.Text = value; }
127  }
128 
129  private void TableFileClearButton_Click(object sender, EventArgs e)
130  {
131  TableFilename = "";
132  }
133 
134  private void OKButton_Click(object sender, EventArgs e)
135  {
136 
137  SaveData();
138  }
139 
140 
141 
142  }
143 }
List< string > GlobalConfigFilenames
Definition: Settings.cs:56