protected static void BaseSaveSequence(XmlDocument contextNode, EventSequence eventSequence, FormatChannelDelegate fc) { var programNode = Xml.GetEmptyNodeAlways(contextNode, "Program"); Xml.SetValue(programNode, "Time", eventSequence.Length.ToString(CultureInfo.InvariantCulture)); Xml.SetValue(programNode, "EventPeriodInMilliseconds", eventSequence.EventPeriod.ToString(CultureInfo.InvariantCulture)); Xml.SetValue(programNode, "MinimumLevel", eventSequence.MinimumLevel.ToString(CultureInfo.InvariantCulture)); Xml.SetValue(programNode, "MaximumLevel", eventSequence.MaximumLevel.ToString(CultureInfo.InvariantCulture)); Xml.SetValue(programNode, "AudioDevice", eventSequence.AudioDeviceIndex.ToString(CultureInfo.InvariantCulture)); Xml.SetValue(programNode, "AudioVolume", eventSequence.AudioDeviceVolume.ToString(CultureInfo.InvariantCulture)); if (eventSequence.Audio != null) { var node = Xml.SetNewValue(programNode, "Audio", eventSequence.Audio.Name); Xml.SetAttribute(node, "filename", eventSequence.Audio.FileName); Xml.SetAttribute(node, "duration", eventSequence.Audio.Duration.ToString(CultureInfo.InvariantCulture)); } var doc = contextNode.OwnerDocument ?? contextNode; if (eventSequence.Profile == null) { //Channels var channelNodes = Xml.GetEmptyNodeAlways(programNode, "Channels"); foreach (var channel in eventSequence.FullChannels) { channelNodes.AppendChild(fc(doc, channel)); } //Plugins if (programNode.OwnerDocument != null) { programNode.AppendChild(programNode.OwnerDocument.ImportNode(eventSequence.PlugInData.RootNode, true)); } BaseSaveNativeData(eventSequence.FileName, eventSequence.Groups); } else { Xml.SetValue(programNode, "Profile", eventSequence.Profile.Name); } var channelCount = eventSequence.FullChannels.Count; var totalEventPeriods = eventSequence.TotalEventPeriods; var inArray = new byte[channelCount * totalEventPeriods]; var eventIndex = 0; for (var row = 0; row < channelCount; row++) { for (var col = 0; col < totalEventPeriods; col++) { inArray[eventIndex++] = eventSequence.EventValues[row, col]; } } //todo GZIP inArray before encoding? Xml.GetNodeAlways(programNode, "EventValues").InnerText = Convert.ToBase64String(inArray); if (programNode.OwnerDocument != null && eventSequence.LoadableData != null) { programNode.AppendChild(programNode.OwnerDocument.ImportNode(eventSequence.LoadableData.RootNode, true)); } Xml.SetValue(programNode, "EngineType", eventSequence.EngineType.ToString()); if (programNode.OwnerDocument != null) { programNode.AppendChild(programNode.OwnerDocument.ImportNode(eventSequence.Extensions.RootNode, true)); } }
protected static void BaseSaveProfile(XmlDocument doc, Profile profileObject, FormatChannelDelegate fc) { profileObject.Freeze(); // fix VIX-53 XmlNode profileDoc = doc.DocumentElement; var channelObjectsNode = Xml.GetEmptyNodeAlways(profileDoc, "ChannelObjects"); foreach (var channel in profileObject.Channels) { channelObjectsNode.AppendChild(fc(doc, channel)); } var outputs = string.Join(",", (from c in profileObject.Channels select c.OutputChannel.ToString()).ToArray()); Xml.GetEmptyNodeAlways(profileDoc, "Outputs").InnerText = outputs; if (profileDoc != null) { profileDoc.AppendChild(doc.ImportNode(profileObject.PlugInData.RootNode, true)); } var disabledChannels = string.Join(",", (from c in profileObject.Channels where !c.Enabled select profileObject.Channels.FindIndex(i => i == c).ToString()).ToArray()); Xml.SetValue(profileDoc, "DisabledChannels", disabledChannels); }