public void SaveSettings() { new XDocument( new XElement(Tag_Root, new XElement(Tag_NamedPipeAddress, NamedPipeAddress), new XElement(Tag_AutoConnect, AutoConnect.ToString()), new XElement(Tag_TimePaddingForLoop, TimePaddingForLoop.ToString()), new XElement(Tag_LoopSelection, LoopSelection.ToString()), new XElement(Tag_LoopNumber, LoopNumber.ToString()), new XElement(Tag_PlayMode, PlayMode.ToString()), new XElement(Tag_Volume, new XElement(Tag_VolumeValue, VolumeValue.ToString()), new XElement(Tag_VolumeMute, VolumeMute.ToString())), new XElement(Tag_Documents, DocumentByDocumentGuid.Select(x => new XElement(Tag_Document, new XAttribute(Att_Document_Id, x.Key), new XElement(Tag_Document_Name, x.Value.Name), new XElement(Tag_Media, x.Value.Media)))), new XElement(Tag_MinimalSeverityToShowInLog, MinimalSeverityToShowInLog.ToString()), new XElement(Tag_Window, new XElement(Tag_Top, WindowTop.ToString()), new XElement(Tag_Left, WindowLeft.ToString()), new XElement(Tag_Width, WindowWidth.ToString()), new XElement(Tag_Height, WindowHeight.ToString()), new XElement(Tag_Maximized, WindowMaximized.ToString()), new XElement(Tag_AlwaysOnTop, AlwaysOnTop.ToString())), new XElement(Tag_VlcLibPath, VlcLibPath), new XElement(Tag_DoNotAskAgain, FontMissingWindowDoNotAskAgain.ToString())) ).Save(SettingsPath); }
public void Save() { XDocument Xml = XDocument.Load(ConfigurationFile); Xml.Element("Configs").Element("EnableHotkeys").Value = EnableHotkeys.ToString(); Xml.Element("Configs").Element("AlwaysOnTop").Value = AlwaysOnTop.ToString(); Xml.Element("Configs").Element("LastOpened").Element("Game").Value = LastOpen.Game; Xml.Element("Configs").Element("LastOpened").Element("Profile").Value = LastOpen.Profile; Xml.Element("Configs").Element("LastCommitID").Value = LastCommitID; Xml.Element("Configs").Element("Games").RemoveAll(); Xml.Element("Configs").Element("Hotkeys").RemoveAll(); foreach (Game xGame in Games) { Xml.Element("Configs").Element("Games").Add(new XElement("Game", new XElement("Name", xGame.Name), new XElement("Path", xGame.Path))); } foreach (Hotkey xHotkey in Hotkeys) { Xml.Element("Configs").Element("Hotkeys").Add(new XElement("Hotkey", new XElement("Name", xHotkey.Name), new XElement("Modifier", xHotkey.Modifier), new XElement("KeyCode", xHotkey.KeyCode), new XElement("Enabled", xHotkey.Enabled.ToString()))); } Xml.Save(ConfigurationFile); }
public XmlNode GenerateXML() { // Create XML Node and Attributes XmlDocument d = new XmlDocument(); XmlNode output = d.CreateNode("element", "UIpp", null); XmlAttribute alwaysOnTop = d.CreateAttribute("AlwaysOnTop"); XmlAttribute color = d.CreateAttribute("Color"); XmlAttribute dialogSidebar = d.CreateAttribute("DialogSidebar"); XmlAttribute flat = d.CreateAttribute("Flat"); XmlAttribute icon = d.CreateAttribute("Icon"); XmlAttribute title = d.CreateAttribute("Title"); XmlAttribute rootXMLPath = d.CreateAttribute("RootXMLPath"); // Assign attribute valutes alwaysOnTop.Value = AlwaysOnTop.ToString(); color.Value = Color; dialogSidebar.Value = DialogSidebar.ToString(); flat.Value = Flat.ToString(); icon.Value = Icon; title.Value = Title; rootXMLPath.Value = RootXMLPath; // Append attributes if (null != AlwaysOnTop) { output.Attributes.Append(alwaysOnTop); } if (!string.IsNullOrEmpty(Color)) { output.Attributes.Append(color); } if (null != DialogSidebar) { output.Attributes.Append(dialogSidebar); } if (null != Flat) { output.Attributes.Append(flat); } if (!string.IsNullOrEmpty(Icon)) { output.Attributes.Append(icon); } if (!string.IsNullOrEmpty(Title)) { output.Attributes.Append(title); } if (!string.IsNullOrEmpty(RootXMLPath)) { output.Attributes.Append(rootXMLPath); } // Append Software if (Software.Softwares.Count != 0) { XmlNode importNode = d.ImportNode(Software.GenerateXML(), true); output.AppendChild(importNode); } // Append Messages if (Messages.MessageCollection.Count != 0) { XmlNode importNode = d.ImportNode(Messages.GenerateXML(), true); output.AppendChild(importNode); } // Append Actions if (Actions.actions.Count != 0) { XmlNode importNode = d.ImportNode(Actions.GenerateXML(), true); output.AppendChild(importNode); } return(output); }
public static void SaveConfiguration() { string fullFileName = Path.Combine(Assembly.GetExecutingAssembly().Location, fileName); if (!LocalConfig) { fullFileName = Path.Combine(GetLocalStoragePath(), fileName); } if (File.Exists(fullFileName)) { FileInfo fileInfo = new FileInfo(fullFileName); fileInfo.Attributes = FileAttributes.Normal; } XmlWriterSettings xwSettings = new XmlWriterSettings(); xwSettings.Indent = true; MemoryStream ms = new MemoryStream(); using (XmlWriter xw = XmlWriter.Create(ms, xwSettings)) { xw.WriteStartDocument(); xw.WriteStartElement("config"); xw.WriteStartElement("integrators"); foreach (string url in FarmList) { xw.WriteStartElement("integrator"); xw.WriteAttributeString("url", url); xw.WriteEndElement(); } xw.WriteEndElement(); xw.WriteStartElement("buildNotifications"); foreach (BuildNotificationViewInfo bnvi in buildNotifications) { xw.WriteStartElement("notification"); xw.WriteRaw(SmartCCNetHelper.GetSerializeString(bnvi.Notification)); xw.WriteEndElement(); } xw.WriteEndElement(); xw.WriteStartElement("PowerShellScripts"); foreach (PSScript script in powerShellScripts) { xw.WriteStartElement("PowerShellScript"); xw.WriteRaw(SmartCCNetHelper.GetSerializeString(script)); xw.WriteEndElement(); } xw.WriteEndElement(); xw.WriteStartElement("lastProjectDurationDictionary"); byte[] lastBuildDurationData = ProjectInfo.GetLastBuildDurationDictSaveData(); xw.WriteBase64(lastBuildDurationData, 0, lastBuildDurationData.Length); xw.WriteEndElement(); xw.WriteStartElement("layoutXml"); xw.WriteRaw(layoutXml); xw.WriteEndElement(); xw.WriteStartElement("gridProjectXml"); xw.WriteRaw(gridProjectXml); xw.WriteEndElement(); xw.WriteStartElement("gridTestsXml"); xw.WriteRaw(gridTestsXml); xw.WriteEndElement(); xw.WriteStartElement("gridServersXml"); xw.WriteRaw(gridServersXml); xw.WriteEndElement(); xw.WriteStartElement("gridNotificationsXml"); xw.WriteRaw(gridNotificationsXml); xw.WriteEndElement(); xw.WriteElementString("volunteerColorString", VolunteerColorString); xw.WriteElementString("alwaysOnTop", AlwaysOnTop.ToString()); xw.WriteElementString("refreshTime", RefreshTime.ToString()); xw.WriteElementString("minimized", Minimized.ToString()); xw.WriteElementString("buildLogMaximized", BuildLogMaximized.ToString()); xw.WriteElementString("formWidth", FormWidth.ToString()); xw.WriteElementString("formHeight", FormHeight.ToString()); xw.WriteElementString("formLeft", FormLeft.ToString()); xw.WriteElementString("formTop", FormTop.ToString()); xw.WriteElementString("updateUrl", UpdateUrl); xw.WriteElementString("workUserName", WorkUserName); xw.WriteElementString("useSkin", UseSkin.ToString()); xw.WriteElementString("UsePowerShellScript", UsePowerShellScript.ToString()); xw.WriteElementString("needAskForStutup", NeedAskForStutup.ToString()); xw.WriteElementString("alreadyReloadGridTestsLayout", AlreadyReloadGridTestsLayout.ToString()); xw.WriteElementString("skinName", SkinName); xw.WriteElementString("popupHideTimeout", PopupHideTimeout.ToString()); xw.WriteStartElement("trackedProjects"); foreach (ProjectShortInfo info in TrackedProjects) { xw.WriteStartElement("trackedProject"); xw.WriteAttributeString("name", info.Name); xw.WriteAttributeString("status", info.BuildStatus); xw.WriteEndElement(); } xw.WriteEndElement(); xw.WriteEndElement(); xw.WriteEndDocument(); } File.WriteAllBytes(fullFileName, ms.ToArray()); }