private static void Save(XsdTidyConfig config, string toFile) { XmlSerializer serializer = new XmlSerializer (typeof (XsdTidyConfig)); FileStream stream = null; try{ stream = new FileStream (toFile, FileMode.Create); serializer.Serialize (stream, config); stream.Flush (); } catch(IOException ex){ throw new ApplicationException("There was an error while attempting to save the configuration file '" + toFile + "'.", ex); } finally{ if (stream != null ) stream.Close (); } }
private bool LoadDefaultSettings(bool silent) { bool success = false; try { grid.SelectedObject = this.config = XsdTidyConfigManager.LoadDefault(); success = true; } catch (Exception ex) { if (!silent) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } return(success); }
private static void Save(XsdTidyConfig config, string toFile) { XmlSerializer serializer = new XmlSerializer(typeof(XsdTidyConfig)); FileStream stream = null; try{ stream = new FileStream(toFile, FileMode.Create); serializer.Serialize(stream, config); stream.Flush(); } catch (IOException ex) { throw new ApplicationException("There was an error while attempting to save the configuration file '" + toFile + "'.", ex); } finally{ if (stream != null) { stream.Close(); } } }
public XsdTidyForm() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // this.config = new XsdTidyConfig(); grid = new PropertyGrid(); grid.CommandsVisibleIfAvailable = true; grid.Dock = DockStyle.Fill; grid.SelectedObject = config; this.panel1.Controls.Add(grid); this.statusBar1.Text = string.Empty; InitSettings(); }
/// <summary> /// Save the config to disk as default settings. /// </summary> /// <param name="config">Configuration settings to be saved.</param> internal static void SaveAsDefault(XsdTidyConfig config) { Save(config, _DEFAULT); }
/// <summary> /// Save the config to disk as normal settings. /// </summary> /// <param name="config">Configuration settings to be saved.</param> internal static void Save(XsdTidyConfig config) { Save(config, _SAVED); }
private bool LoadSettings(bool silent) { bool success = false; try { grid.SelectedObject = this.config = XsdTidyConfigManager.Load(); success = true; } catch(Exception ex) { if (!silent) MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } return success; }