public override void reset(long time) { base.reset(time); TLayer layer = sequence.animation.layer; if (layer is TActor) { TActor target = (TActor)layer; if (type == ActionType.TO) { run_point0 = target.position; run_point1 = this.point1; run_point2 = this.point2; run_point3 = this.point3; } else if (type == ActionType.BY) { run_point0 = target.position; run_point1 = new PointF(target.position.X + this.point1.X, target.position.Y + this.point1.Y); run_point2 = new PointF(target.position.X + this.point2.X, target.position.Y + this.point2.Y); run_point3 = new PointF(target.position.X + this.point3.X, target.position.Y + this.point3.Y); } run_easingFunction = new TEasingFunction(); } }
public override bool parseXml(XElement xml, TLayer parentLayer) { if (xml == null || xml.Name != "TextActor") return false; if (!base.parseXml(xml, parentLayer)) return false; try { text = xml.Element("Text").Value; FontFamily family = Program.findFontFamily(xml.Element("FontFamilyName").Value); float fontSize = TUtil.parseFloatXElement(xml.Element("FontSize"), 12); FontStyle fontStyle = (FontStyle)TUtil.parseIntXElement(xml.Element("FontStyle"), 0); if (family != null) font = new Font(family, fontSize, fontStyle, GraphicsUnit.Point); else font = new Font("Arial", fontSize, fontStyle, GraphicsUnit.Point); color = Color.FromArgb(int.Parse(xml.Element("Color").Value)); BoxSize.Width = float.Parse(xml.Element("SizeWidth").Value); BoxSize.Height = float.Parse(xml.Element("SizeHeight").Value); refreshMatrix(); return true; } catch (Exception e) { Console.WriteLine(e.Message); return false; } }
public TAvatarActor pushAvatar(RectangleF region) { TAvatarActor actor = null; // new name string actorName = this.newLayerName("Actor_"); // selected layer if (document.haveSelection()) { TLayer selectedLayer = document.selectedItems[0]; PointF pt = selectedLayer.parent.screenToLogical(new PointF(region.X + region.Width / 2, region.Y + region.Height / 2)); PointF sz = selectedLayer.parent.screenVectorToLogical(new PointF(region.Width, region.Height)); actor = new TAvatarActor(document, pt.X, pt.Y, sz.X, sz.Y, selectedLayer.parent, actorName); } else { // create text actor PointF pt = this.screenToLogical(new PointF(region.X + region.Width / 2, region.Y + region.Height / 2)); PointF sz = this.screenVectorToLogical(new PointF(region.Width, region.Height)); actor = new TAvatarActor(document, pt.X, pt.Y, sz.X, sz.Y, this, actorName); } return(actor); }
public override void reset(long time) { base.reset(time); TLayer layer = sequence.animation.layer; switch (type) { case ActionType.TO: run_startAlpha = layer.alpha; run_endAlpha = this.endAlpha; break; case ActionType.FROMTO: run_startAlpha = this.startAlpha; run_endAlpha = this.endAlpha; break; case ActionType.IN: run_startAlpha = layer.alpha; run_endAlpha = 1; break; case ActionType.OUT: run_startAlpha = layer.alpha; run_endAlpha = 0; break; } run_easingFunction = new TEasingFunction(); }
protected virtual void clone(TLayer target) { target.document = this.document; target.parent = this.parent; target.name = this.name; target.locked = this.locked; target.backgroundColor = this.backgroundColor; target.alpha = this.alpha; this.childs.ForEach((item) => { TLayer newItem = item.clone(); newItem.parent = target; target.childs.Add(newItem); }); this.animations.ForEach((item) => { TAnimation newAnimation = item.clone(); newAnimation.layer = target; target.animations.Add(newAnimation); }); this.events.ForEach((item) => { target.events.Add(item); }); this.states.ForEach((item) => { target.states.Add(item); }); }
public DeleteAnimationAction(FrmMainContainer mainForm, TLayer layer, int index) { this.mainForm = mainForm; this.layer = layer; this.index = index; this.animation = layer.animations[index]; }
public ChangeAnimationAction(FrmMainContainer mainForm, TLayer layer, TAnimation oldAnimation, TAnimation newAnimation) { this.mainForm = mainForm; this.layer = layer; this.oldAnimation = oldAnimation; this.newAnimation = newAnimation; this.index = layer.animations.IndexOf(oldAnimation); }
public virtual TLayer clone() { TLayer layer = (TLayer)Activator.CreateInstance(this.GetType(), new Object[] { document }); this.clone(layer); return(layer); }
public virtual bool parseXml(XElement xml, TLayer parentLayer) { if (xml == null) { return(false); } try { name = xml.Element("Name").Value; parent = parentLayer; locked = TUtil.parseBoolXElement(xml.Element("Locked"), false); backgroundColor = Color.FromArgb(TUtil.parseIntXElement(xml.Element("BackgroundColor"), 0)); alpha = float.Parse(xml.Element("Alpha").Value); XElement xmlEvents = xml.Element("Events"); IEnumerable <XElement> xmlEventList = xmlEvents.Elements("Event"); foreach (XElement xmlEvent in xmlEventList) { events.Add(xmlEvent.Value); } XElement xmlStates = xml.Element("States"); IEnumerable <XElement> xmlStateList = xmlStates.Elements("State"); foreach (XElement xmlState in xmlStateList) { states.Add(xmlState.Value); } XElement xmlAnimations = xml.Element("Animations"); IEnumerable <XElement> xmlAnimationList = xmlAnimations.Elements("Animation"); foreach (XElement xmlAnimation in xmlAnimationList) { TAnimation animation = new TAnimation(this); if (!animation.parseXml(xmlAnimation)) { return(false); } animations.Add(animation); } XElement xmlChilds = xml.Element("Childs"); IEnumerable <XElement> xmlChildList = xmlChilds.Elements(); foreach (XElement xmlChild in xmlChildList) { TLayer layer = (TLayer)Activator.CreateInstance(Type.GetType(GetType().Namespace + ".T" + xmlChild.Name.ToString()), new Object[] { document }); if (!layer.parseXml(xmlChild, this)) { return(false); } childs.Add(layer); } return(true); } catch (Exception e) { Console.WriteLine(e.Message); return(false); } }
public TransferActorAction(TDocument doc, TActor actor, TLayer parent) { this.document = doc; this.actor = actor; this.oldData = new ActorMatrixData(); this.newData = new ActorMatrixData(); this.oldParent = actor.parent; this.newParent = parent; this.oldData.position = actor.position; this.oldData.scale = actor.scale; this.oldData.skew = actor.skew; this.oldData.rotation = actor.rotation; // actor's position based on new parent PointF pt = actor.parent.logicalToScreen(actor.position); pt = parent.screenToLogical(pt); // actor's rotation based on new parent float angle = actor.rotationOnScreen(); if (parent is TActor) { angle -= ((TActor)parent).rotationOnScreen(); } TUtil.normalizeDegreeAngle(angle); // for scale RectangleF bound = actor.bound(); PointF s = actor.logicalVectorToScreen(new PointF(bound.Width, bound.Height)); SizeF scale = new SizeF(1, 1); Matrix m2 = new Matrix(); m2.Translate(pt.X, pt.Y); m2.Rotate((float)(angle * 180 / Math.PI)); m2.Translate(-actor.anchor.X * actor.bound().Width, -actor.anchor.Y * actor.bound().Height); Matrix m = parent.matrixFromScreen(); m.Multiply(m2); if (m.IsInvertible) { PointF[] aPos = { s }; m.Invert(); m.TransformVectors(aPos); s = aPos[0]; scale = new SizeF(s.X / bound.Width, s.Y / bound.Height); } this.newData.position = pt; this.newData.scale = scale; this.newData.skew = actor.skew; this.newData.rotation = angle; oldIndex = actor.parent.childs.IndexOf(actor); }
protected override void clone(TLayer target) { base.clone(target); TAvatarActor targetLayer = (TAvatarActor)target; targetLayer.BoxSize = this.BoxSize; targetLayer.refreshMatrix(); }
protected override void clone(TLayer target) { base.clone(target); TImageActor targetLayer = (TImageActor)target; targetLayer.image = this.image; targetLayer.loadImage(); targetLayer.refreshMatrix(); }
protected override void clone(TLayer target) { base.clone(target); TTextActor targetLayer = (TTextActor)target; targetLayer.text = this.text; targetLayer.font = (Font)this.font.Clone(); targetLayer.color = this.color; targetLayer.BoxSize = this.boxSize; refreshMatrix(); }
public TAnimation(TLayer layer) { eventu = Program.DEFAULT_EVENT_UNDEFINED; state = Program.DEFAULT_STATE_DEFAULT; this.layer = layer; sequences = new List <TSequence>(); // for launch run_executing = false; }
public TImageActor(TDocument doc, Image texture, float x, float y, TLayer parent, string actorName) : base(doc, x, y, parent, actorName) { // save file path image = ""; // load image this.loadImage(texture); this.refreshMatrix(); }
protected override void clone(TLayer target) { base.clone(target); TScene targetLayer = (TScene)target; targetLayer.touchIndication = this.touchIndication; targetLayer.prevButtonVisible = this.prevButtonVisible; targetLayer.nextButtonVisible = this.nextButtonVisible; targetLayer.backgroundMusic = this.backgroundMusic; targetLayer.backgroundMusicVolume = this.backgroundMusicVolume; }
public static TAnimation newAnimation(TLayer layer, TAction action) { TAnimation animation = new TAnimation(layer); TSequence sequence = new TSequence(); animation.addSequence(sequence); action.sequence = sequence; sequence.addAction(action); return(animation); }
// execute action for every frame // if action is finished, return true; public override bool step(FrmEmulator emulator, long time) { float elapsed = time - run_startTime; if (elapsed > duration) { elapsed = duration; } TLayer layer = sequence.animation.layer; layer.alpha = run_easingFunction.ease(easingType, easingMode, duration, elapsed, run_startAlpha, run_endAlpha); return(base.step(emulator, time)); }
public TLayer(TDocument doc, TLayer parentLayer, string layerName) { document = doc; name = layerName; parent = parentLayer; locked = false; backgroundColor = Color.Transparent; alpha = 1; childs = new List <TLayer>(); animations = new List <TAnimation>(); run_state = Program.DEFAULT_STATE_DEFAULT; run_enabled = true; events = new List <string>(); states = new List <string>(); }
public override TLayer findLayer(string targetName) { if (run_extraActors != null) { foreach (TActor actor in run_extraActors) { TLayer ret = actor.findLayer(targetName); if (ret != null) { return(ret); } } } return(base.findLayer(targetName)); }
public override bool parseXml(XElement xml, TLayer parentLayer) { if (xml == null) { return(false); } if (!base.parseXml(xml, parentLayer)) { return(false); } try { Anchor.X = float.Parse(xml.Element("AnchorX").Value); Anchor.Y = float.Parse(xml.Element("AnchorY").Value); Position.X = float.Parse(xml.Element("PositionX").Value); Position.Y = float.Parse(xml.Element("PositionY").Value); Scale.Width = float.Parse(xml.Element("ScaleWidth").Value); Scale.Height = float.Parse(xml.Element("ScaleHeight").Value); Skew.Width = float.Parse(xml.Element("SkewWidth").Value); Skew.Height = float.Parse(xml.Element("SkewHeight").Value); Rotation = float.Parse(xml.Element("Rotation").Value); refreshMatrix(); zIndex = int.Parse(xml.Element("ZIndex").Value); draggable = bool.Parse(xml.Element("Draggable").Value); acceleratorSensibility = bool.Parse(xml.Element("AcceleratorSensibility").Value); autoInteractionBound = bool.Parse(xml.Element("AutoInteractionBound").Value); InteractionBound = new RectangleF(float.Parse(xml.Element("InteractionBoundX").Value), float.Parse(xml.Element("InteractionBoundY").Value), float.Parse(xml.Element("InteractionBoundWidth").Value), float.Parse(xml.Element("InteractionBoundHeight").Value)); puzzle = bool.Parse(xml.Element("Puzzle").Value); PuzzleArea = new RectangleF(TUtil.parseFloatXElement(xml.Element("PuzzleAreaX"), 0), TUtil.parseFloatXElement(xml.Element("PuzzleAreaY"), 0), TUtil.parseFloatXElement(xml.Element("PuzzleAreaWidth"), Program.BOOK_WIDTH), TUtil.parseFloatXElement(xml.Element("PuzzleAreaHeight"), Program.BOOK_HEIGHT)); return(true); } catch (Exception e) { Console.WriteLine(e.Message); return(false); } }
public virtual TLayer findLayer(string targetName) { if (this.name == targetName) { return(this); } foreach (TLayer layer in childs) { TLayer ret = layer.findLayer(targetName); if (ret != null) { return(ret); } } return(null); }
// execute action for every frame // if action is finished, return true; public override bool step(FrmEmulator emulator, long time) { float elapsed = time - run_startTime; if (elapsed > duration) { elapsed = duration; } TLayer layer = sequence.animation.layer; if (layer is TActor) { TActor target = (TActor)layer; target.rotation = TUtil.normalizeDegreeAngle(run_easingFunction.ease(easingType, easingMode, duration, elapsed, run_startAngle, run_endAngle)); } return(base.step(emulator, time)); }
// execute action for every frame // if action is finished, return true; public override bool step(FrmEmulator emulator, long time) { float elapsed = time - run_startTime; if (elapsed > duration) { elapsed = duration; } TLayer layer = sequence.animation.layer; if (layer is TActor) { TActor target = (TActor)layer; float t = run_easingFunction.ease(easingType, easingMode, duration, elapsed, 0, 1); target.position = bezier(t); } return(base.step(emulator, time)); }
public TActor(TDocument doc, float x, float y, TLayer parent, string actorName) : base(doc, parent, actorName) { Anchor = new PointF(0.5F, 0.5F); Position = new PointF(x, y); Scale = new SizeF(1, 1); Skew = new SizeF(0, 0); Rotation = 0; zIndex = 0; draggable = false; acceleratorSensibility = false; autoInteractionBound = true; InteractionBound = new RectangleF(); puzzle = false; PuzzleArea = new RectangleF(0, 0, Program.BOOK_WIDTH, Program.BOOK_HEIGHT); matrix = new Matrix(); _backupActor = null; run_xVelocity = 0; run_yVelocity = 0; }
// execute action for every frame // if action is finished, return true; public override bool step(FrmEmulator emulator, long time) { TLayer layer = sequence.animation.layer; if (frames.Count > 0 && layer is TImageActor) { float elapsed = time - run_startTime; if (elapsed > duration) { elapsed = duration; } long t = 0; int index = 0; while (t < elapsed && index < frames.Count) { t += frames[index++].duration; } if (index > 0) { index--; } if (index != run_currentFrame) { run_currentFrame = index; string image = frames[index].image; TImageActor target = (TImageActor)layer; TLibraryManager libraryManager = target.document.libraryManager; int libImageIndex = libraryManager.imageIndex(image); if (libImageIndex != -1) { target.loadImage(Image.FromFile(libraryManager.imageFilePath(libImageIndex))); } } } return(base.step(emulator, time)); }
public void transferLayer(TActor item, TLayer target) { // item's position based on new parent PointF pt = item.parent.logicalToScreen(item.position); pt = target.screenToLogical(pt); // item's rotation based on new parent float angle = item.rotationOnScreen(); if (target is TActor) { angle -= ((TActor)target).rotationOnScreen(); } TUtil.normalizeDegreeAngle(angle); // for scale RectangleF bound = item.bound(); PointF s = item.logicalVectorToScreen(new PointF(bound.Width, bound.Height)); // new properties item.position = pt; item.rotation = angle; item.scale = new Size(1, 1); Matrix m = target.matrixFromScreen(); m.Multiply(item.matrix); if (m.IsInvertible) { PointF[] aPos = { s }; m.Invert(); m.TransformVectors(aPos); s = aPos[0]; item.scale = new SizeF(s.X / bound.Width, s.Y / bound.Height); } item.parent.childs.Remove(item); target.childs.Add(item); item.parent = target; }
// execute action for every frame // if action is finished, return true; public override bool step(FrmEmulator emulator, long time) { float elapsed = time - run_startTime; if (elapsed > duration) { elapsed = duration; } TLayer layer = sequence.animation.layer; if (layer is TActor) { TActor target = (TActor)layer; float width = run_easingFunction.ease(easingType, easingMode, duration, elapsed, run_startScale.Width, run_endScale.Width); float height = run_easingFunction.ease(easingType, easingMode, duration, elapsed, run_startScale.Height, run_endScale.Height); target.scale = new SizeF(width, height); } return(base.step(emulator, time)); }
public override void reset(long time) { base.reset(time); TLayer layer = sequence.animation.layer; if (layer is TActor) { TActor target = (TActor)layer; run_startAngle = target.rotation; if (type == ActionType.TO) { run_endAngle = this.angle; } else if (type == ActionType.BY) { run_endAngle = target.rotation + this.angle; } run_easingFunction = new TEasingFunction(); } }
public override void reset(long time) { base.reset(time); TLayer layer = sequence.animation.layer; if (layer is TActor) { TActor target = (TActor)layer; run_startScale = target.scale; if (type == ActionType.TO) { run_endScale = this.scale; } else if (type == ActionType.BY) { run_endScale = new SizeF(target.scale.Width * this.scale.Width, target.scale.Height * this.scale.Height); } run_easingFunction = new TEasingFunction(); } }