private void pnlWorkspace_DragDrop(object sender, DragEventArgs e) { if (this.document.currentScene() == null) { return; } if (e.Data.GetDataPresent(DataFormats.Serializable, true) == true) { // dragging item ListViewItem item = (ListViewItem)e.Data.GetData(DataFormats.Serializable); // convert screen coordinate to client coordinate Point pt = this.pnlWorkspace.PointToClient(new Point(e.X, e.Y)); // item to current scene TImageActor actor = this.document.currentScene().pushImage(this.document.libraryManager.imageFileName(item.Index), pt.X, pt.Y); this.document.actionManager.RecordAction(new AddActorAction(this.document, actor)); // set the document modified flag this.document.modified = true; // redraw scene this.pnlWorkspace.Refresh(); // update panels FrmMainContainer mainForm = (FrmMainContainer)this.MdiParent; mainForm.updateScenesPanel(this.document.sceneManager.currentSceneIndex); mainForm.updateOutlinePanel(); mainForm.updateHistoryPanel(); } }
public ChangeImageActorAction(TDocument doc, TImageActor actor, string image) { this.document = doc; this.actor = actor; this.oldImage = actor.image; this.newImage = image; }
protected override void clone(TLayer target) { base.clone(target); TImageActor targetLayer = (TImageActor)target; targetLayer.image = this.image; targetLayer.loadImage(); targetLayer.refreshMatrix(); }
// 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 TImageActor pushImage(string image, float x, float y) { TImageActor actor; // new name string actorName = this.newLayerName("Actor_"); // selected layer if (document.haveSelection()) { TLayer selectedLayer = document.selectedItems[0]; PointF pt = selectedLayer.parent.screenToLogical(new PointF(x, y)); actor = new TImageActor(document, image, pt.X, pt.Y, selectedLayer.parent, actorName); } else { // create image actor PointF pt = this.screenToLogical(new PointF(x, y)); actor = new TImageActor(document, image, pt.X, pt.Y, this, actorName); } return(actor); }
private List <TActor> extraActorsOfEmulator(TScene scene) { // result List <TActor> extras = new List <TActor>(); // back navigation button if (scene.prevButtonVisible && imgPrevButton != null) { TImageActor btnPrev = new TImageActor(document, imgPrevButton, 0, Program.BOOK_HEIGHT, scene, "[emulator_actor]:prev_button"); btnPrev.anchor = new PointF(0, 1); extras.Add(btnPrev); if (document.navigationLeftButtonRender) { TAnimation animation = new TAnimation(btnPrev); TSequence sequence = animation.addSequence(); sequence.addAction(new TActionIntervalDelay() { duration = document.navigationButtonDelayTime * 1000 }); sequence.addAction(new TActionInstantDispatchEvent() { actor = btnPrev.name, eventu = Program.DEFAULT_EVENT_UNDEFINED, recursive = false }); animation.eventu = Program.DEFAULT_EVENT_ENTER; animation.start(); btnPrev.animations.Add(animation); animation = new TAnimation(btnPrev); sequence = animation.addSequence(); sequence.addAction(new TActionIntervalDelay() { duration = 500 }); sequence.addAction(new TActionIntervalScale() { duration = 300, scale = new SizeF(1.4f, 1.4f) }); sequence.addAction(new TActionIntervalScale() { duration = 300, scale = new SizeF(1f, 1f) }); sequence.repeat = 100; animation.eventu = Program.DEFAULT_EVENT_UNDEFINED; btnPrev.animations.Add(animation); } else { TAnimation animation = TAnimation.newAnimation(btnPrev, new TActionInstantGoScene() { type = TActionInstantGoScene.ActionType.PREVIOUS }); animation.eventu = Program.DEFAULT_EVENT_TOUCH; btnPrev.animations.Add(animation); } } // next navigation button if (scene.nextButtonVisible && imgNextButton != null) { TImageActor btnNext = new TImageActor(document, imgNextButton, Program.BOOK_WIDTH, Program.BOOK_HEIGHT, scene, "[emulator_actor]:next_button"); btnNext.anchor = new PointF(1, 1); extras.Add(btnNext); if (document.navigationRightButtonRender) { TAnimation animation = new TAnimation(btnNext); TSequence sequence = animation.addSequence(); sequence.addAction(new TActionIntervalDelay() { duration = document.navigationButtonDelayTime * 1000 }); sequence.addAction(new TActionInstantDispatchEvent() { actor = btnNext.name, eventu = Program.DEFAULT_EVENT_UNDEFINED, recursive = false }); animation.eventu = Program.DEFAULT_EVENT_ENTER; animation.start(); btnNext.animations.Add(animation); animation = new TAnimation(btnNext); sequence = animation.addSequence(); sequence.addAction(new TActionIntervalDelay() { duration = 500 }); sequence.addAction(new TActionIntervalScale() { duration = 300, scale = new SizeF(1.4f, 1.4f) }); sequence.addAction(new TActionIntervalScale() { duration = 300, scale = new SizeF(1f, 1f) }); sequence.repeat = 100; animation.eventu = Program.DEFAULT_EVENT_UNDEFINED; btnNext.animations.Add(animation); } else { TAnimation animation = TAnimation.newAnimation(btnNext, new TActionInstantGoScene() { type = TActionInstantGoScene.ActionType.NEXT }); animation.eventu = Program.DEFAULT_EVENT_TOUCH; btnNext.animations.Add(animation); } } // menu button { TImageActor btnMenu = new TImageActor(document, Properties.Resources.emulator_img_menu_button, Program.BOOK_WIDTH, 0, scene, "[emulator_actor]:menu_button"); btnMenu.anchor = new PointF(1, 0); extras.Add(btnMenu); TAnimation animation = TAnimation.newAnimation(btnMenu, new TActionInstantDispatchEvent() { actor = "[emulator_actor]:menu_dialog", eventu = "[emulator_event]:show_dialog", recursive = true }); animation.eventu = Program.DEFAULT_EVENT_TOUCH; btnMenu.animations.Add(animation); } // menu popup { // background TImageActor dlgMenu = new TImageActor(document, Properties.Resources.emulator_img_menu_dialog_bg, 0, 0, scene, "[emulator_actor]:menu_dialog"); { dlgMenu.anchor = new PointF(0, 0); dlgMenu.alpha = 0; extras.Add(dlgMenu); // show dialog TAnimation animShow = new TAnimation(dlgMenu); TSequence seqShow = animShow.addSequence(); seqShow.addAction(new TActionIntervalFade() { duration = 100, type = TActionIntervalFade.ActionType.IN }); animShow.eventu = "[emulator_event]:show_dialog"; dlgMenu.animations.Add(animShow); // hide dialog TAnimation animHide = new TAnimation(dlgMenu); TSequence seqHide = animHide.addSequence(); seqHide.addAction(new TActionIntervalDelay() { duration = 200 }); seqHide.addAction(new TActionIntervalFade() { duration = 100, type = TActionIntervalFade.ActionType.OUT }); animHide.eventu = "[emulator_event]:hide_dialog"; dlgMenu.animations.Add(animHide); TAnimation animation = TAnimation.newAnimation(dlgMenu, new TActionInstantDispatchEvent() { actor = "[emulator_actor]:menu_dialog", eventu = "[emulator_event]:hide_dialog", recursive = true }); animation.eventu = Program.DEFAULT_EVENT_TOUCH; dlgMenu.animations.Add(animation); } TAnimation animShowBase = TAnimation.newAnimation(null, new TActionIntervalMove() { duration = 300, easingMode = TEasingFunction.EasingMode.Out, easingType = TEasingFunction.EasingType.Bounce }); animShowBase.eventu = "[emulator_event]:show_dialog"; TAnimation animHideBase = TAnimation.newAnimation(null, new TActionIntervalMove() { duration = 300, easingMode = TEasingFunction.EasingMode.In, easingType = TEasingFunction.EasingType.Back }); animHideBase.eventu = "[emulator_event]:hide_dialog"; TImageActor btnBGM = new TImageActor(document, Properties.Resources.emulator_img_bgm_off, -100, 290, dlgMenu, "[emulator_actor]:menu_bgm_button"); { btnBGM.anchor = new PointF(0.5f, 0.5f); dlgMenu.childs.Add(btnBGM); // show animation from base show animation TAnimation animShow = animShowBase.clone(); animShow.layer = btnBGM; ((TActionIntervalMove)animShow.actionAtIndex(0, 0)).position = new PointF(170, 290); btnBGM.animations.Add(animShow); // hide animation from base hide animation TAnimation animHide = animHideBase.clone(); animHide.layer = btnBGM; ((TActionIntervalMove)animHide.actionAtIndex(0, 0)).position = btnBGM.position; btnBGM.animations.Add(animHide); // initialize button status, when menu is popuped TAnimation animInit = TAnimation.newAnimation(btnBGM, new TActionRuntime(0, delegate(float percent) { if (bgmOn) { btnBGM.loadImage(Properties.Resources.emulator_img_bgm_on); } else { btnBGM.loadImage(Properties.Resources.emulator_img_bgm_off); } })); animInit.eventu = "[emulator_event]:show_dialog"; btnBGM.animations.Add(animInit); // perform action of button and change status when button is clicked TAnimation animToggle = TAnimation.newAnimation(btnBGM, new TActionRuntime(0, delegate(float percent) { toggleBGM(); if (bgmOn) { btnBGM.loadImage(Properties.Resources.emulator_img_bgm_on); } else { btnBGM.loadImage(Properties.Resources.emulator_img_bgm_off); } })); animToggle.eventu = Program.DEFAULT_EVENT_TOUCH; btnBGM.animations.Add(animToggle); } TImageActor btnEffect = new TImageActor(document, Properties.Resources.emulator_img_effect_off, -100, 480, dlgMenu, "[emulator_actor]:menu_effect_button"); { btnEffect.anchor = new PointF(0.5f, 0.5f); dlgMenu.childs.Add(btnEffect); // show animation from base show animation TAnimation animShow = animShowBase.clone(); animShow.layer = btnEffect; ((TActionIntervalMove)animShow.actionAtIndex(0, 0)).position = new PointF(170, 480); btnEffect.animations.Add(animShow); // hide animation from base hide animation TAnimation animHide = animHideBase.clone(); animHide.layer = btnEffect; ((TActionIntervalMove)animHide.actionAtIndex(0, 0)).position = btnEffect.position; btnEffect.animations.Add(animHide); // initialize button status, when menu is popuped TAnimation animInit = TAnimation.newAnimation(btnEffect, new TActionRuntime(0, delegate(float percent) { if (effectOn) { btnEffect.loadImage(Properties.Resources.emulator_img_effect_on); } else { btnEffect.loadImage(Properties.Resources.emulator_img_effect_off); } })); animInit.eventu = "[emulator_event]:show_dialog"; btnEffect.animations.Add(animInit); // perform action of button and change status when button is clicked TAnimation animToggle = TAnimation.newAnimation(btnEffect, new TActionRuntime(0, delegate(float percent) { toggleEffect(); if (effectOn) { btnEffect.loadImage(Properties.Resources.emulator_img_effect_on); } else { btnEffect.loadImage(Properties.Resources.emulator_img_effect_off); } })); animToggle.eventu = Program.DEFAULT_EVENT_TOUCH; btnEffect.animations.Add(animToggle); } TImageActor btnVoice = new TImageActor(document, Properties.Resources.emulator_img_voice_off, -100, 600, dlgMenu, "[emulator_actor]:menu_voice_button"); { btnVoice.anchor = new PointF(0.5f, 0.5f); dlgMenu.childs.Add(btnVoice); // show animation from base show animation TAnimation animShow = animShowBase.clone(); animShow.layer = btnVoice; ((TActionIntervalMove)animShow.actionAtIndex(0, 0)).position = new PointF(170, 670); btnVoice.animations.Add(animShow); // hide animation from base hide animation TAnimation animHide = animHideBase.clone(); animHide.layer = btnVoice; ((TActionIntervalMove)animHide.actionAtIndex(0, 0)).position = btnVoice.position; btnVoice.animations.Add(animHide); // initialize button status, when menu is popuped TAnimation animInit = TAnimation.newAnimation(btnVoice, new TActionRuntime(0, delegate(float percent) { if (voiceOn) { btnVoice.loadImage(Properties.Resources.emulator_img_voice_on); } else { btnVoice.loadImage(Properties.Resources.emulator_img_voice_off); } })); animInit.eventu = "[emulator_event]:show_dialog"; btnVoice.animations.Add(animInit); // perform action of button and change status when button is clicked TAnimation animToggle = TAnimation.newAnimation(btnVoice, new TActionRuntime(0, delegate(float percent) { toggleVoice(); if (voiceOn) { btnVoice.loadImage(Properties.Resources.emulator_img_voice_on); } else { btnVoice.loadImage(Properties.Resources.emulator_img_voice_off); } })); animToggle.eventu = Program.DEFAULT_EVENT_TOUCH; btnVoice.animations.Add(animToggle); } TImageActor btnText = new TImageActor(document, Properties.Resources.emulator_img_text_off, -100, 100, dlgMenu, "[emulator_actor]:menu_text_button"); { btnText.anchor = new PointF(0.5f, 0.5f); dlgMenu.childs.Add(btnText); // show animation from base show animation TAnimation animShow = animShowBase.clone(); animShow.layer = btnText; ((TActionIntervalMove)animShow.actionAtIndex(0, 0)).position = new PointF(170, 100); btnText.animations.Add(animShow); // hide animation from base hide animation TAnimation animHide = animHideBase.clone(); animHide.layer = btnText; ((TActionIntervalMove)animHide.actionAtIndex(0, 0)).position = btnText.position; btnText.animations.Add(animHide); // initialize button status, when menu is popuped TAnimation animInit = TAnimation.newAnimation(btnText, new TActionRuntime(0, delegate(float percent) { if (textOn) { btnText.loadImage(Properties.Resources.emulator_img_text_on); } else { btnText.loadImage(Properties.Resources.emulator_img_text_off); } })); animInit.eventu = "[emulator_event]:show_dialog"; btnText.animations.Add(animInit); // perform action of button and change status when button is clicked TAnimation animToggle = TAnimation.newAnimation(btnText, new TActionRuntime(0, delegate(float percent) { toggleText(); if (textOn) { btnText.loadImage(Properties.Resources.emulator_img_text_on); } else { btnText.loadImage(Properties.Resources.emulator_img_text_off); } })); animToggle.eventu = Program.DEFAULT_EVENT_TOUCH; btnText.animations.Add(animToggle); } /* * TImageActor btnBack = new TImageActor(document, Properties.Resources.emulator_img_menu_dialog_bg, 0, 0, dlgMenu, "[emulator_actor]:menu_back_button"); * { * btnBack.anchor = new PointF(1.0f, 0f); * dlgMenu.childs.Add(btnBack); * * // show animation from base show animation * TAnimation animShow = animShowBase.clone(); * animShow.layer = btnBack; * ((TActionIntervalMove)animShow.actionAtIndex(0, 0)).position = new PointF(900, 500); * btnBack.animations.Add(animShow); * * // hide animation from base hide animation * TAnimation animHide = animHideBase.clone(); * animHide.layer = btnBack; * ((TActionIntervalMove)animHide.actionAtIndex(0, 0)).position = btnBack.position; * btnBack.animations.Add(animHide); * * TAnimation animation = TAnimation.newAnimation(btnBack, new TActionInstantDispatchEvent() { actor = "[emulator_actor]:menu_dialog", eventu = "[emulator_event]:hide_dialog", recursive = true }); * animation.eventu = Program.DEFAULT_EVENT_TOUCH; * btnBack.animations.Add(animation); * } */ } return(extras); }