private void importToolStripMenuItem_Click(object sender, EventArgs e) { using (var ofd = new OpenFileDialog()) { ofd.Title = "Import Preset"; ofd.Filter = "ETGUI Pad Settings Preset File|*.etguipp|Data Files|*.dat|All Files|*.*"; if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { using (var fs = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read)) { try { PadSettings ps = new PadSettings(); ps.Load(fs); load(ps, false); MessageBox.Show("Loaded Preset", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show("Could not load preset: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } }
void loadPreset(int i) { if (!File.Exists(presetDir + "\\" + i)) { load(null, false); } else { try { using (var fs = new FileStream(presetDir + "\\" + i, FileMode.Open)) { PadSettings ps = new PadSettings(); ps.Load(fs); load(ps, false); } } catch { load(null, false); } } }