private void OnTimeLineRepeated(object sender, EventArgs e) { if (sender is UIAnimationPlayer.TimeLine) { using (List <UIAnimationPlayer.Layer> .Enumerator enumerator = this.childLayers.GetEnumerator()) { while (enumerator.MoveNext()) { UIAnimationPlayer.Layer current = enumerator.Current; current.Start((sender as UIAnimationPlayer.TimeLine).CurrentTime); } } } }
public void Resume() { this.timeLineForChildren.Resume(); using (List <Effect> .Enumerator enumerator = this.motions.GetEnumerator()) { while (enumerator.MoveNext()) { Effect current = enumerator.Current; current.Resume(); } } using (List <UIAnimationPlayer.Layer> .Enumerator enumerator2 = this.childLayers.GetEnumerator()) { while (enumerator2.MoveNext()) { UIAnimationPlayer.Layer current2 = enumerator2.Current; current2.Resume(); } } }
public void Stop() { this.timeLineForChildren.Stop(); using (List <Effect> .Enumerator enumerator = this.motions.GetEnumerator()) { while (enumerator.MoveNext()) { Effect current = enumerator.Current; current.Stop(); } } using (List <UIAnimationPlayer.Layer> .Enumerator enumerator2 = this.childLayers.GetEnumerator()) { while (enumerator2.MoveNext()) { UIAnimationPlayer.Layer current2 = enumerator2.Current; current2.Stop(); } } this.startedMotions.Clear(); this.transformRoot.Transform3D = this.initialTransform3Dtroot; }
protected override void OnUpdate(float elapsedTime) { base.OnUpdate(elapsedTime); if (!this.Playing) { return; } this.timeLineForChildren.OnUpdate(elapsedTime); using (List <UIAnimationPlayer.Layer> .Enumerator enumerator = this.childLayers.GetEnumerator()) { while (enumerator.MoveNext()) { UIAnimationPlayer.Layer current = enumerator.Current; using (List <Effect> .Enumerator enumerator2 = current.motions.GetEnumerator()) { while (enumerator2.MoveNext()) { Effect current2 = enumerator2.Current; if (!current.startedMotions.Contains(current2)) { float num = current.motionStartTimes[current2]; if (num <= this.timeLineForChildren.CurrentTime) { current2.Start(); if (current.startedMotions.Count == 0) { current.timeLineForChildren.Start(this.timeLineForChildren.CurrentTime - num); } current.startedMotions.Add(current2); } } } } } } }
public bool ReplaceWidget(string name, Widget widget) { if (this.instanceName.Equals(name)) { float childrenLeft = this.GetChildrenLeft(); float childrenRight = this.GetChildrenRight(); float childrenTop = this.GetChildrenTop(); float childrenBottom = this.GetChildrenBottom(); widget.SetPosition(childrenLeft, childrenTop); widget.SetSize(childrenRight - childrenLeft, childrenBottom - childrenTop); using (List <UIAnimationPlayer.Layer> .Enumerator enumerator = this.childLayers.GetEnumerator()) { while (enumerator.MoveNext()) { UIAnimationPlayer.Layer current = enumerator.Current; this.transformRoot.RemoveChild(current); } } this.childLayers.Clear(); this.transformRoot.AddChildLast(widget); return(true); } using (List <UIAnimationPlayer.Layer> .Enumerator enumerator2 = this.childLayers.GetEnumerator()) { while (enumerator2.MoveNext()) { UIAnimationPlayer.Layer current2 = enumerator2.Current; bool flag = current2.ReplaceWidget(name, widget); if (flag) { return(true); } } } return(false); }
public UIAnimationPlayer(string filePath) { base.Clip = true; if (filePath != null) { UIAnimationPlayer.UIAnimationData uIAnimationData = new UIAnimationPlayer.UIAnimationData(); uIAnimationData.ReadFromFile(filePath); this.SetSize(uIAnimationData.header.width, uIAnimationData.header.height); this.BackgroundColor = new UIColor(uIAnimationData.header.backgroundColorR / 255f, uIAnimationData.header.backgroundColorG / 255f, uIAnimationData.header.backgroundColorB / 255f, 1f); if (uIAnimationData.rootSymbol != null && uIAnimationData.rootSymbol.timeLines != null && uIAnimationData.rootSymbol.timeLines[0] != null && uIAnimationData.rootSymbol.timeLines[0].layers != null) { this.rootLayer = new UIAnimationPlayer.Layer(); this.rootLayer.timeLineForChildren.FrameRate = uIAnimationData.header.frameRate; this.rootLayer.AnimationStopped += new EventHandler <EventArgs>(this.OnRootLayoutAnimationStoped); using (List <UIAnimationPlayer.UIAnimationData.Layer> .Enumerator enumerator = uIAnimationData.rootSymbol.timeLines[0].layers.GetEnumerator()) { while (enumerator.MoveNext()) { UIAnimationPlayer.UIAnimationData.Layer current = enumerator.Current; UIAnimationPlayer.Layer layer = new UIAnimationPlayer.Layer(); uint num = layer.InitLayer(this.rootLayer, current, 0f, 0f, uIAnimationData); this.rootLayer.transformRoot.AddChildLast(layer); this.rootLayer.childLayers.Add(layer); if (this.rootLayer.timeLineForChildren.Duration < num) { this.rootLayer.timeLineForChildren.Duration = num; } } } this.rootLayer.Repeating = uIAnimationData.header.repeating; this.Width = uIAnimationData.header.width; this.Height = uIAnimationData.header.height; this.AddChildLast(this.rootLayer); } } }
public uint InitLayer(UIAnimationPlayer.Layer parent, UIAnimationPlayer.UIAnimationData.Layer layerData, float x, float y, UIAnimationPlayer.UIAnimationData data) { uint num = 0u; List <uint> list = new List <uint>(); List <uint> list2 = new List <uint>(); UIMotion uIMotion = null; UIMotion uIMotion2 = null; this.timeLineForChildren.FrameRate = data.header.frameRate; this.SetPosition(x, y); using (List <UIAnimationPlayer.UIAnimationData.Frame> .Enumerator enumerator = layerData.frames.GetEnumerator()) { while (enumerator.MoveNext()) { UIAnimationPlayer.UIAnimationData.Frame current = enumerator.Current; if (current.instance != null) { UIAnimationPlayer.UIAnimationData.Instance instance = current.instance; if (instance.header.hasBitmap && !list.Contains(instance.header.bitmapId)) { this.SetPosition(x + instance.header.translationX + instance.header.matrix41, y + instance.header.translationY + instance.header.matrix42); Widget widget = this.CreateBitmap(data.bitmaps[(int)instance.header.bitmapId]); widget.SetSize(widget.Width * instance.header.scaleX, widget.Height * instance.header.scaleY); this.transformRoot.AddChildLast(widget); list.Add(instance.header.bitmapId); } if (instance.header.hasSymbol && !list2.Contains(instance.header.symbolId)) { this.transformRoot.SetPosition(instance.header.transPointX, instance.header.transPointY); this.SetPosition(x + instance.header.translationX + instance.header.matrix41, y + instance.header.translationY + instance.header.matrix42); UIAnimationPlayer.UIAnimationData.Symbol symbol = data.symbols[(int)instance.header.symbolId]; using (List <UIAnimationPlayer.UIAnimationData.Layer> .Enumerator enumerator2 = symbol.timeLines[0].layers.GetEnumerator()) { while (enumerator2.MoveNext()) { UIAnimationPlayer.UIAnimationData.Layer current2 = enumerator2.Current; UIAnimationPlayer.Layer layer = new UIAnimationPlayer.Layer(); uint num2 = layer.InitLayer(this, current2, -instance.header.transPointX, -instance.header.transPointY, data); this.transformRoot.AddChildLast(layer); this.childLayers.Add(layer); if (this.timeLineForChildren.Duration < num2) { this.timeLineForChildren.Duration = num2; } } } list2.Add(instance.header.symbolId); } if (current.header.hasMotion) { UIMotion uIMotion3 = new UIMotion(this.transformRoot, current.motion); this.motions.Add(uIMotion3); if (uIMotion != null) { uIMotion.EffectStopped -= new EventHandler <EventArgs>(this.OnEffectStopped); } uIMotion3.EffectStopped += new EventHandler <EventArgs>(this.OnEffectStopped); this.motionStartTimes.Add(uIMotion3, this.timeLineForChildren.GetTimeFromFrameIndex(current.header.index)); uIMotion2 = uIMotion3; uIMotion = uIMotion3; } else { uIMotion = null; } this.instanceName = instance.name; this.timeLineForChildren.Repeating = instance.header.repeating; uint num3 = current.header.index + current.header.duration; if (num < num3) { num = num3; } } } } if (uIMotion2 != null) { uIMotion2.EffectStopped -= new EventHandler <EventArgs>(this.OnEffectStopped); } this.initialTransform3Droot = this.Transform3D; this.initialTransform3Dtroot = this.transformRoot.Transform3D; return(num); }