/// <summary> /// Save the toolbar state. /// </summary> public void Save() { StreamWriter fileStream = null; string toolbarFile = Path.Combine(CIX.HomeFolder, CIX.Username); toolbarFile = Path.ChangeExtension(toolbarFile, "toolbar.xml"); try { fileStream = new StreamWriter(toolbarFile, false); XmlWriterSettings settings = new XmlWriterSettings { Indent = true, OmitXmlDeclaration = true, NewLineOnAttributes = true }; using (XmlWriter writer = XmlWriter.Create(fileStream, settings)) { fileStream = null; XmlSerializer serializer = new XmlSerializer(typeof(toolbar)); toolbar newToolbar = new toolbar { Items = _buttons.Select(button => button.DataItem).ToArray() }; serializer.Serialize(writer, newToolbar); LogFile.WriteLine("Saved toolbar {0}", toolbarFile); } } catch (Exception e) { LogFile.WriteLine("Cannot save toolbar to {0} : {1}", toolbarFile, e.Message); } finally { if (fileStream != null) { fileStream.Dispose(); } } }
/// <summary> /// Save the toolbar state. /// </summary> public void Save() { StreamWriter fileStream = null; string toolbarFile = Path.Combine(CIX.HomeFolder, CIX.Username); toolbarFile = Path.ChangeExtension(toolbarFile, "toolbar.xml"); try { fileStream = new StreamWriter(toolbarFile, false); XmlWriterSettings settings = new XmlWriterSettings { Indent = true, OmitXmlDeclaration = true, NewLineOnAttributes = true }; using (XmlWriter writer = XmlWriter.Create(fileStream, settings)) { fileStream = null; XmlSerializer serializer = new XmlSerializer(typeof(toolbar)); toolbar newToolbar = new toolbar {Items = _buttons.Select(button => button.DataItem).ToArray()}; serializer.Serialize(writer, newToolbar); LogFile.WriteLine("Saved toolbar {0}", toolbarFile); } } catch (Exception e) { LogFile.WriteLine("Cannot save toolbar to {0} : {1}", toolbarFile, e.Message); } finally { if (fileStream != null) { fileStream.Dispose(); } } }