//Send actions to make sure that the Texture continues displaying private void MakeTextureLoopFrame(string textureName) { FrameAction frameAction = new FrameAction { Name = textureName, Drawable = textureName, Value = 1 }; StatusAction statusAction = new StatusAction { Name = textureName, Drawable = textureName, Value = AnimationStatus.Paused }; LoopAction loopActon = new LoopAction { Name = textureName, Drawable = textureName, Value = true }; textureManager.ExecuteAction(statusAction); textureManager.ExecuteAction(frameAction); textureManager.ExecuteAction(loopActon); }
//When something is selected from the listbox, display it on the Current Frame screen private void listBox_Frames_SelectedIndexChanged(object sender, EventArgs e) { Action action = () => { if (listBox_Frames.SelectedItem == null) { DisableFrameButtons(); return; } EnableFrameButtons(); int selectedFrame = (int) listBox_Frames.SelectedItem; SetFieldsFromFrame(ReturnAnimation.Frames[selectedFrame]); lbl_FrameNumber.Text = selectedFrame.ToString(); float width = ReturnAnimation.Frames[selectedFrame].TextureSource.Width; float height = ReturnAnimation.Frames[selectedFrame].TextureSource.Height; _frameGame.gameGraphics.ClearDrawList(); Vector2 position = Vector2.Zero; if (width <= panel_FrameDisplay.Width && height <= panel_FrameDisplay.Height) { Vector2 center = StaticMethods.GetCenter(new Vector2(((width)*ReturnAnimation.Scale), (height)*ReturnAnimation.Scale)); position = StaticMethods.GetDrawPosition(new Vector2(panel_FrameDisplay.Width, panel_FrameDisplay.Height), center); } if (width > panel_FrameDisplay.Width || height > panel_FrameDisplay.Height) { panel_FrameDisplay.AutoScrollMinSize = new Size((int) width, (int) height); pictureBox_FrameDisplay.Location = new System.Drawing.Point(0, 0); } if (!_frameGame.gameGraphics.DoesDrawableExist(ReturnAnimation.Name)) { _frameGame.gameGraphics.AddToDrawList(new DrawParam(ReturnAnimation.Name, ReturnAnimation.Name, position, DrawnType.Animation)); } else { _frameGame.gameGraphics.UpdateDrawPosition(new DrawParam(ReturnAnimation.Name, ReturnAnimation.Name, position, DrawnType.Animation)); } Animation drawAnimation = _frameGame.gameGraphics.GetDrawAnimation(ReturnAnimation.Name); drawAnimation.Frame = selectedFrame; _frameGame.gameGraphics.SetLoadedDrawn(drawAnimation); SetFrameData(saving); FrameAction frameAction = new FrameAction { Name = ReturnAnimation.Name, Drawable = ReturnAnimation.Name, Value = selectedFrame }; StatusAction statusAction = new StatusAction { Name = ReturnAnimation.Name, Drawable = ReturnAnimation.Name, Value = AnimationStatus.Paused }; LoopAction loopActon = new LoopAction { Name = ReturnAnimation.Name, Drawable = ReturnAnimation.Name, Value = true }; animationManager.ExecuteAction(statusAction); animationManager.ExecuteAction(frameAction); animationManager.ExecuteAction(loopActon); }; if (!_frameGameLoaded) { LoadFrameGame(action); return; } action(); }