Esempio n. 1
0
        static public TimelineEffect Clone(TimelineEffect copy)
        {
            TimelineEffect target = new TimelineEffect(copy.Type);

            target.Info         = copy.Info.Clone() as EffectInfoModel;
            target.DurationTime = copy.DurationTime;

            return(target);
        }
Esempio n. 2
0
        private void ParsingLayers(XmlNodeList layerNodes)
        {
            foreach (XmlNode node in layerNodes)
            {
                XmlElement element   = (XmlElement)node;
                string     layerName = element.GetAttribute("name");
                string     eye       = element.GetAttribute("Eye");
                LayerModel layer     = new LayerModel(layerName);
                layer.Eye = bool.Parse(eye);

                layer.TriggerAction = element.GetAttribute("trigger");

                // parsing effects
                XmlNode effectsNode = element.SelectSingleNode("effects");
                foreach (XmlNode effectNode in effectsNode.ChildNodes)
                {
                    XmlElement element2 = (XmlElement)effectNode;
                    int        type     = Int32.Parse(element2.SelectSingleNode("type").InnerText);

                    List <ColorPointModel> colorPoints = new List <ColorPointModel>();
                    XmlNode colorPointListNode         = element2.SelectSingleNode("colorPointList");
                    foreach (XmlNode colorpoint in colorPointListNode.ChildNodes)
                    {
                        ColorPointModel cp       = new ColorPointModel();
                        XmlElement      element3 = (XmlElement)colorpoint;
                        cp.Color = new Color
                        {
                            A = Byte.Parse(element3.SelectSingleNode("a").InnerText),
                            R = Byte.Parse(element3.SelectSingleNode("r").InnerText),
                            G = Byte.Parse(element3.SelectSingleNode("g").InnerText),
                            B = Byte.Parse(element3.SelectSingleNode("b").InnerText),
                        };
                        cp.Offset = double.Parse(element3.SelectSingleNode("offset").InnerText);
                        colorPoints.Add(cp);
                    }

                    EffectInfoModel info = new EffectInfoModel(type)
                    {
                        InitColor = new Color
                        {
                            A = Byte.Parse(element2.SelectSingleNode("a").InnerText),
                            R = Byte.Parse(element2.SelectSingleNode("r").InnerText),
                            G = Byte.Parse(element2.SelectSingleNode("g").InnerText),
                            B = Byte.Parse(element2.SelectSingleNode("b").InnerText),
                        },
                        DoubleColor1 = new Color
                        {
                            A = Byte.Parse(element2.SelectSingleNode("d1a").InnerText),
                            R = Byte.Parse(element2.SelectSingleNode("d1r").InnerText),
                            G = Byte.Parse(element2.SelectSingleNode("d1g").InnerText),
                            B = Byte.Parse(element2.SelectSingleNode("d1b").InnerText),
                        },
                        DoubleColor2 = new Color
                        {
                            A = Byte.Parse(element2.SelectSingleNode("d2a").InnerText),
                            R = Byte.Parse(element2.SelectSingleNode("d2r").InnerText),
                            G = Byte.Parse(element2.SelectSingleNode("d2g").InnerText),
                            B = Byte.Parse(element2.SelectSingleNode("d2b").InnerText),
                        },
                        Type               = type,
                        Speed              = Int32.Parse(element2.SelectSingleNode("speed").InnerText),
                        Angle              = Int32.Parse(element2.SelectSingleNode("angle").InnerText),
                        RandomRangeMax     = Int32.Parse(element2.SelectSingleNode("randomRangeMax").InnerText),
                        RandomRangeMin     = Int32.Parse(element2.SelectSingleNode("randomRangeMin").InnerText),
                        ColorModeSelection = Int32.Parse(element2.SelectSingleNode("colormodeselection").InnerText),
                        High               = Int32.Parse(element2.SelectSingleNode("high").InnerText),
                        Low                   = Int32.Parse(element2.SelectSingleNode("low").InnerText),
                        PatternSelect         = Int32.Parse(element2.SelectSingleNode("patternSelect").InnerText),
                        CustomizedPattern     = new List <ColorPointModel>(colorPoints),
                        ColorSegmentation     = bool.Parse(element2.SelectSingleNode("colorSegmentation").InnerText),
                        RainbowSpecialEffects = bool.Parse(element2.SelectSingleNode("rainbowRotation").InnerText),
                        RainbowSpecialMode    = Int32.Parse(element2.SelectSingleNode("rotationMode").InnerText),
                    };

                    if (!IsTriggerEffect(type))
                    {
                        TimelineEffect eff = new TimelineEffect(type);
                        eff.StartTime    = Int32.Parse(element2.SelectSingleNode("start").InnerText);
                        eff.DurationTime = Int32.Parse(element2.SelectSingleNode("duration").InnerText);
                        eff.Info         = info;
                        layer.AddTimelineEffect(new EffectLineViewModel(eff));
                    }
                    else
                    {
                        TriggerEffect eff = new TriggerEffect(type);
                        eff.StartTime    = Int32.Parse(element2.SelectSingleNode("start").InnerText);
                        eff.DurationTime = Int32.Parse(element2.SelectSingleNode("duration").InnerText);
                        eff.Info         = info;
                        layer.AddTriggerEffect(eff);
                        layer.IsTriggering = true;
                    }
                }

                // parsing zones
                XmlNode devicesNode = element.SelectSingleNode("devices");
                foreach (XmlNode deviceNode in devicesNode.ChildNodes)
                {
                    Dictionary <int, int[]> zoneDictionary = new Dictionary <int, int[]>();
                    List <int> zones    = new List <int>();
                    XmlElement element2 = (XmlElement)deviceNode;
                    string     typeName = element2.GetAttribute("type");
                    int        type     = GetTypeByTypeName(typeName);

                    XmlNodeList indexNodes = element2.ChildNodes;
                    foreach (XmlNode index in indexNodes)
                    {
                        zones.Add(Int32.Parse(index.InnerText));
                    }

                    zoneDictionary.Add(type, zones.ToArray());
                    layer.AddDeviceZones(zoneDictionary);
                }

                LayerPage.AddLayer(layer);
            }
        }