private void ImportSettings(object sender, RoutedEventArgs e) { // Prompt for a file to read. Microsoft.Win32.OpenFileDialog dialog = new Microsoft.Win32.OpenFileDialog(); dialog.FileName = "StepManiaX settings"; dialog.DefaultExt = ".smxcfg"; dialog.Filter = "StepManiaX settings (.smxcfg)|*.smxcfg"; bool?result = dialog.ShowDialog(); if (result == null || !(bool)result) { return; } string json = Helpers.ReadFile(dialog.FileName); // Apply settings from the file to all active pads. foreach (Tuple <int, SMX.SMXConfig> activePad in ActivePad.ActivePads()) { int pad = activePad.Item1; SMX.SMXConfig config = activePad.Item2; SMXHelpers.ImportSettingsFromJSON(json, ref config); SMX.SMX.SetConfig(pad, config); } CurrentSMXDevice.singleton.FireConfigurationChanged(null); }
private void ExportSettings(object sender, RoutedEventArgs e) { // Save the current thresholds on the first available pad as a preset. foreach (Tuple <int, SMX.SMXConfig> activePad in ActivePad.ActivePads()) { int pad = activePad.Item1; SMX.SMXConfig config = activePad.Item2; string json = SMXHelpers.ExportSettingsToJSON(config); Microsoft.Win32.SaveFileDialog dialog = new Microsoft.Win32.SaveFileDialog(); dialog.FileName = "StepManiaX settings"; dialog.DefaultExt = ".smxcfg"; dialog.Filter = "StepManiaX settings (.smxcfg)|*.smxcfg"; bool?result = dialog.ShowDialog(); if (result == null || !(bool)result) { return; } System.IO.File.WriteAllText(dialog.FileName, json); return; } }