private static void MigrateFireworksFrom2To3(XElement content) { //This migration deals with changing the Fireworks effect to accomodate multiple gradients instead of miltiple colors //Get the standard namespaces that are needed in the sequence var namespaces = GetStandardNamespaces(); //Add in the ones for this effect XNamespace d2p1 = "http://schemas.datacontract.org/2004/07/VixenModules.Effect.Fireworks"; namespaces.AddNamespace("d2p1", d2p1.NamespaceName); //Find the Snowflakes effects. IEnumerable <XElement> fireworksElements = content.XPathSelectElements( "_dataModels/d1p1:anyType[@i:type = 'd2p1:FireworksData']", namespaces); var datamodel = content.XPathSelectElement("_dataModels", namespaces); foreach (var fireworkElement in fireworksElements.ToList()) { //Find all the data points we need to keep. XElement colors = fireworkElement.XPathSelectElement("d2p1:Colors", namespaces); XElement explosions = fireworkElement.XPathSelectElement("d2p1:Explosions", namespaces); XElement particleFade = fireworkElement.XPathSelectElement("d2p1:ParticleFade", namespaces); XElement level = fireworkElement.XPathSelectElement("d2p1:LevelCurve", namespaces); XElement particles = fireworkElement.XPathSelectElement("d2p1:Particles", namespaces); XElement velocity = fireworkElement.XPathSelectElement("d2p1:Velocity", namespaces); XElement moduleInstanceId = fireworkElement.XPathSelectElement("ModuleInstanceId", namespaces); XElement moduleTypeId = fireworkElement.XPathSelectElement("ModuleTypeId", namespaces); var colorList = DeSerializer <List <Color> >(colors); List <ColorGradient> colorGradients = colorList.Select(color => new ColorGradient(color)).ToList(); //Build up our new replacement model FireworksData data = new FireworksData() { ModuleInstanceId = DeSerializer <Guid>(moduleInstanceId), ModuleTypeId = DeSerializer <Guid>(moduleTypeId), Velocity = DeSerializer <int>(velocity), Explosions = DeSerializer <int>(explosions), ParticleFade = DeSerializer <int>(particleFade), Particles = DeSerializer <int>(particles), LevelCurve = DeSerializer <Curve>(level), ColorGradients = colorGradients, RandomParticles = false, RandomVelocity = false }; //Remove the old version fireworkElement.Remove(); //Build up a temporary container similar to the way sequences are stored to //make all the namespace prefixes line up. IModuleDataModel[] dm = { data }; DataContainer dc = new DataContainer { _dataModels = dm }; //Serialize the object into a xelement XElement glp = Serializer(dc, new[] { typeof(FireworksData), typeof(IModuleDataModel[]), typeof(DataContainer) }); //Extract the new data model that we want and insert it in the tree datamodel.Add(glp.XPathSelectElement("//*[local-name()='anyType']", namespaces)); } }
private static void MigrateSnowflakesFrom2To3(XElement content) { //This migration deals with changing the Snowflake effect to accomodate multiple gradients instead of single colors for inner and outer //Getthe standard namespaces that are needed in the sequence var namespaces = GetStandardNamespaces(); //Add in the ones for this effect XNamespace d2p1 = "http://schemas.datacontract.org/2004/07/VixenModules.Effect.Snowflakes"; namespaces.AddNamespace("d2p1", d2p1.NamespaceName); //Find the Snowflakes effects. IEnumerable <XElement> snowFlakeElements = content.XPathSelectElements( "_dataModels/d1p1:anyType[@i:type = 'd2p1:SnowflakesData']", namespaces); var datamodel = content.XPathSelectElement("_dataModels", namespaces); foreach (var snowflakeElement in snowFlakeElements.ToList()) { //Find all the data points we need to keep. XElement outerColor = snowflakeElement.XPathSelectElement("d2p1:OuterColor", namespaces); XElement centerColor = snowflakeElement.XPathSelectElement("d2p1:CenterColor", namespaces); XElement flakeCount = snowflakeElement.XPathSelectElement("d2p1:FlakeCount", namespaces); XElement level = snowflakeElement.XPathSelectElement("d2p1:LevelCurve", namespaces); XElement speed = snowflakeElement.XPathSelectElement("d2p1:Speed", namespaces); XElement snowFlakeType = snowflakeElement.XPathSelectElement("d2p1:SnowflakeType", namespaces); XElement moduleInstanceId = snowflakeElement.XPathSelectElement("ModuleInstanceId", namespaces); XElement moduleTypeId = snowflakeElement.XPathSelectElement("ModuleTypeId", namespaces); //Build up our new replacement model SnowflakesData snowflakesData = new SnowflakesData() { ModuleInstanceId = DeSerializer <Guid>(moduleInstanceId), ModuleTypeId = DeSerializer <Guid>(moduleTypeId), OutSideColor = new List <ColorGradient>(new[] { new ColorGradient(DeSerializer <Color>(outerColor)) }), InnerColor = new List <ColorGradient>(new[] { new ColorGradient(DeSerializer <Color>(centerColor)) }), FlakeCount = DeSerializer <int>(flakeCount), LevelCurve = DeSerializer <Curve>(level), Speed = DeSerializer <int>(speed), SnowflakeType = DeSerializer <SnowflakeType>(snowFlakeType), RandomSpeed = false, RandomBrightness = false, PointFlake45 = false }; //Remove the old version snowflakeElement.Remove(); //Build up a temporary container similar to the way sequences are stored to //make all the namespace prefixes line up. IModuleDataModel[] dm = { snowflakesData }; DataContainer dc = new DataContainer { _dataModels = dm }; //Serialize the object into a xelement XElement glp = Serializer(dc, new[] { typeof(SnowflakesData), typeof(IModuleDataModel[]), typeof(DataContainer) }); //Extract the new data model that we want and insert it in the tree datamodel.Add(glp.XPathSelectElement("//*[local-name()='anyType']", namespaces)); } }
private void MigrateWipeFrom6To7(XElement content) { // This migration deals with changing the Wipe Direction property to reduce the number of options in the Direction and add in reverse option. // Add Wipe movement and movement curve. // Get the standard namespaces that are needed in the sequence var namespaces = GetStandardNamespaces(); XNamespace d2p1 = "http://schemas.datacontract.org/2004/07/VixenModules.Effect.Wipe"; namespaces.AddNamespace("d2p1", d2p1.NamespaceName); //Find the Wipe effects. IEnumerable <XElement> wipeElements = content.XPathSelectElements( "_dataModels/d1p1:anyType[@i:type = 'd2p1:WipeData']", namespaces); var datamodel = content.XPathSelectElement("_dataModels", namespaces); foreach (var wipeElement in wipeElements.ToList()) { XElement direction = wipeElement.XPathSelectElement("d2p1:Direction", namespaces); XElement colorGradient = wipeElement.XPathSelectElement("d2p1:ColorGradient", namespaces); XElement colorHandling = wipeElement.XPathSelectElement("d2p1:ColorHandling", namespaces); XElement passCount = wipeElement.XPathSelectElement("d2p1:PassCount", namespaces); XElement pulsePercent = wipeElement.XPathSelectElement("d2p1:PulsePercent", namespaces); XElement pulseTime = wipeElement.XPathSelectElement("d2p1:PulseTime", namespaces); XElement wipeByCount = wipeElement.XPathSelectElement("d2p1:WipeByCount", namespaces); XElement wipeOn = wipeElement.XPathSelectElement("d2p1:WipeOn", namespaces); XElement wipeOff = wipeElement.XPathSelectElement("d2p1:WipeOff", namespaces); XElement curve = wipeElement.XPathSelectElement("d2p1:Curve", namespaces); XElement moduleInstanceId = wipeElement.XPathSelectElement("ModuleInstanceId", namespaces); XElement moduleTypeId = wipeElement.XPathSelectElement("ModuleTypeId", namespaces); WipeDirection dataDirection = WipeDirection.Burst; bool dataReverseDirection = false; switch (direction.Value) { case "Up": dataDirection = WipeDirection.Vertical; dataReverseDirection = true; break; case "Down": dataDirection = WipeDirection.Vertical; dataReverseDirection = false; break; case "Right": dataDirection = WipeDirection.Horizontal; dataReverseDirection = false; break; case "Left": dataDirection = WipeDirection.Horizontal; dataReverseDirection = true; break; case "In": dataDirection = WipeDirection.Burst; dataReverseDirection = true; break; case "Out": dataDirection = WipeDirection.Burst; dataReverseDirection = false; break; } WipeData data = new WipeData { ColorGradient = new ColorGradient(DeSerializer <ColorGradient>(colorGradient)), ColorHandling = DeSerializer <ColorHandling>(colorHandling), PassCount = DeSerializer <int>(passCount), PulsePercent = DeSerializer <double>(pulsePercent), PulseTime = DeSerializer <int>(pulseTime), WipeMovement = DeSerializer <bool>(wipeByCount) ? WipeMovement.Count : WipeMovement.PulseLength, WipeOn = DeSerializer <bool>(wipeOn), WipeOff = DeSerializer <bool>(wipeOff), ColorAcrossItemPerCount = true, ReverseColorDirection = true, Curve = DeSerializer <Curve>(curve), MovementCurve = new Curve(new PointPairList(new[] { 0.0, 100.0 }, new[] { 0.0, 100.0 })), Direction = dataDirection, ReverseDirection = dataReverseDirection, ModuleInstanceId = DeSerializer <Guid>(moduleInstanceId), ModuleTypeId = DeSerializer <Guid>(moduleTypeId) }; //Remove the old version wipeElement.Remove(); //Build up a temporary container similar to the way sequences are stored to //make all the namespace prefixes line up. IModuleDataModel[] dm = { data }; DataContainer dc = new DataContainer { _dataModels = dm }; //Serialize the object into a xelement XElement glp = Serializer(dc, new[] { typeof(WipeData), typeof(IModuleDataModel[]), typeof(DataContainer) }); //Extract the new data model that we want and insert it in the tree datamodel.Add(glp.XPathSelectElement("//*[local-name()='anyType']", namespaces)); } }
private XElement _Version_1_to_2(XElement content) { var messageBox = new MessageBoxForm(string.Format( "Migrating sequence from version 1 to version 2. Changes include upgrades to the Alternating effect to allow more than 2 colors.{0}{0}" + "These changes are not backward compatible.", Environment.NewLine), "Sequence Upgrade", MessageBoxButtons.OK, SystemIcons.Information); messageBox.ShowDialog(); //This migration deals with changing the Alternating effect to a Multi Alternating //Style that allows N number of colors. var namespaces = GetStandardNamespaces(); //Add in our specific ones XNamespace d2p1 = "http://schemas.datacontract.org/2004/07/VixenModules.Effect.Alternating"; namespaces.AddNamespace("d2p1", d2p1.NamespaceName); //Find the Alternating effects. IEnumerable <XElement> alternatingElements = content.XPathSelectElements( "_dataModels/d1p1:anyType[@i:type = 'd2p1:AlternatingData']", namespaces); var datamodel = content.XPathSelectElement("_dataModels", namespaces); foreach (var alternatingElement in alternatingElements.ToList()) { //Find all the data points. XElement isStaticColor1 = alternatingElement.XPathSelectElement("d2p1:StaticColor1", namespaces); XElement isStaticColor2 = alternatingElement.XPathSelectElement("d2p1:StaticColor2", namespaces); XElement color1 = alternatingElement.XPathSelectElement("d2p1:Color1", namespaces); XElement level1 = alternatingElement.XPathSelectElement("d2p1:Level1", namespaces); XElement colorGradient1 = alternatingElement.XPathSelectElement("d2p1:ColorGradient1", namespaces); XElement curve1 = alternatingElement.XPathSelectElement("d2p1:Curve1", namespaces); XElement color2 = alternatingElement.XPathSelectElement("d2p1:Color2", namespaces); XElement level2 = alternatingElement.XPathSelectElement("d2p1:Level2", namespaces); XElement colorGradient2 = alternatingElement.XPathSelectElement("d2p1:ColorGradient2", namespaces); XElement curve2 = alternatingElement.XPathSelectElement("d2p1:Curve2", namespaces); XElement enable = alternatingElement.XPathSelectElement("d2p1:Enable", namespaces); XElement groupEffect = alternatingElement.XPathSelectElement("d2p1:GroupEffect", namespaces); XElement interval = alternatingElement.XPathSelectElement("d2p1:Interval", namespaces); XElement moduleInstanceId = alternatingElement.XPathSelectElement("ModuleInstanceId", namespaces); XElement moduleTypeId = alternatingElement.XPathSelectElement("ModuleTypeId", namespaces); //Determine which of the old types were used, colors vs gradients //The new only uses gradients and levels so take the two and build up the new object var gradientLevelPairs = new List <GradientLevelPair>(); //Colors are used backwards in the old effect, so pick them off in reverse. if (isStaticColor2.Value.Equals("true")) { RGB c2 = DeSerializer <RGB>(color2); double l2 = DeSerializer <double>(level2); l2 *= 100; gradientLevelPairs.Add(new GradientLevelPair(c2, new Curve(new PointPairList(new[] { 0.0, 100.0 }, new[] { l2, l2 })))); } else { ColorGradient cg2 = DeSerializer <ColorGradient>(colorGradient2); Curve c2 = DeSerializer <Curve>(curve2); gradientLevelPairs.Add(new GradientLevelPair(cg2, c2)); } if (isStaticColor1.Value.Equals("true")) { RGB c1 = DeSerializer <RGB>(color1); double l1 = DeSerializer <double>(level1); l1 *= 100; gradientLevelPairs.Add(new GradientLevelPair(c1, new Curve(new PointPairList(new[] { 0.0, 100.0 }, new[] { l1, l1 })))); } else { ColorGradient cg1 = DeSerializer <ColorGradient>(colorGradient1); Curve c1 = DeSerializer <Curve>(curve1); gradientLevelPairs.Add(new GradientLevelPair(cg1, c1)); } //Build the new data model AlternatingData data = new AlternatingData { Colors = gradientLevelPairs, ModuleInstanceId = DeSerializer <Guid>(moduleInstanceId), ModuleTypeId = DeSerializer <Guid>(moduleTypeId), EnableStatic = !DeSerializer <bool>(enable), GroupLevel = DeSerializer <int>(groupEffect), Interval = DeSerializer <int>(interval), IntervalSkipCount = 1 }; //Remove the old data model from the xml alternatingElement.Remove(); //Build up a temporary container similar to the way sequences are stored to //make all the namespace prefixes line up. IModuleDataModel[] dm = { data }; DataContainer dc = new DataContainer { _dataModels = dm }; //Serialize the object into a xelement XElement glp = Serializer(dc, new[] { typeof(AlternatingData), typeof(IModuleDataModel[]), typeof(DataContainer) }); //Extract the new data model that we want and insert it in the tree datamodel.Add(glp.XPathSelectElement("//*[local-name()='anyType']", namespaces)); } return(content); }
private void MigrateLipSyncFrom4To5(XElement content) { //This migration deals with changing the LipSync matrix elements from version 4 to 5 //Get the standard namespaces that are needed in the sequence var namespaces = GetStandardNamespaces(); //Add in the ones for this effect XNamespace d2p1 = "http://schemas.datacontract.org/2004/07/VixenModules.Effect.LipSync"; namespaces.AddNamespace("d2p1", d2p1.NamespaceName); //Find the Chase effects. IEnumerable <XElement> lipSyncElements = content.XPathSelectElements( "_dataModels/d1p1:anyType[@i:type = 'd2p1:LipSyncData']", namespaces); var datamodel = content.XPathSelectElement("_dataModels", namespaces); LipSyncMapLibrary _library = ApplicationServices.Get <IAppModuleInstance>(LipSyncMapDescriptor.ModuleID) as LipSyncMapLibrary; foreach (var lipSyncElement in lipSyncElements.ToList()) { LipSyncMapData mapData = null; var lipSyncData = DeSerializer <LipSyncData>(lipSyncElement); if (_library.Library.TryGetValue(lipSyncData.PhonemeMapping, out mapData)) { if ((null != mapData) && (mapData.IsMatrix)) { if (lipSyncData.Level == 0) { lipSyncData.Level = 100; } if (lipSyncData.ScalePercent == 0) { lipSyncData.ScalePercent = 100; } lipSyncData.Orientation = (mapData.StringsAreRows) ? StringOrientation.Horizontal : StringOrientation.Vertical; lipSyncData.ScaleToGrid = true; mapData.UsingDefaults = false; } } //Remove the old version lipSyncElement.Remove(); //Build up a temporary container similar to the way sequences are stored to //make all the namespace prefixes line up. IModuleDataModel[] dm = { lipSyncData }; DataContainer dc = new DataContainer { _dataModels = dm }; //Serialize the object into a xelement XElement glp = Serializer(dc, new[] { typeof(LipSyncData), typeof(IModuleDataModel[]), typeof(DataContainer) }); //Extract the new data model that we want and insert it in the tree datamodel.Add(glp.XPathSelectElement("//*[local-name()='anyType']", namespaces)); } }