private void btn_Ok_Click(object sender, EventArgs e)
        {
            if (!ZeroFieldCheck())
            {
                return;
            }
            int height = Int32.Parse(txtBox_Height.Text);
            int width = Int32.Parse(txtBox_Width.Text);
            int rows = Int32.Parse(txtBox_Rows.Text);
            int columns = Int32.Parse(txtBox_Columns.Text);
            int startPositionX = Int32.Parse(txtBox_StartPositionX.Text);
            int startPositionY = Int32.Parse(txtBox_StartPositionY.Text);
            int widthSpacing = Int32.Parse(txtBox_WidthSpacing.Text);
            int heightSpacing = Int32.Parse(txtBox_HeightSpacing.Text);

            for (int r = 0; r < rows; r++)
            {
                for (int c = 0; c < columns; c++)
                {
                    int currentFrame = ReturnFrames.Count + 1;
                    int x = ((c * width) + (ReturnFrames.Count * widthSpacing) + startPositionX);
                    int y = ((r * height) + (ReturnFrames.Count * heightSpacing) + startPositionY);
                    Frame frame = new Frame(new GameRectangle(x,y, width, height));
                    ReturnFrames.Add(currentFrame, frame);
                }
            }
            DialogResult = DialogResult.OK;
            Close();
        }
示例#2
0
        public bool SetFrame(int frameNumber, Frame frame)
        {
            if (frameNumber > FrameCount || frameNumber < 0)
            {
                return false;
            }

            frames[frameNumber] = frame;
            return true;
        }
示例#3
0
 public void AddFrame(Frame frame)
 {
     frames.Add(FrameCount + 1, frame);
 }
        //Set textbox data to frame properties, then display new texture frame
        private void SetFrameData(bool saving)
        {
            DialogResult = DialogResult.OK;
            if (listBox_Frames.SelectedItem == null) return;
            int x = Int32.Parse(txtBox_FrameX.Text);
            int y = Int32.Parse(txtBox_FrameY.Text);
            int width = Int32.Parse(txtBox_FrameWidth.Text);
            int height = Int32.Parse(txtBox_FrameHeight.Text);
            int frame = Int32.Parse(lbl_FrameNumber.Text);
            Frame setFrame = new Frame(new GameRectangle(x, y, width, height));
            ReturnAnimation.SetFrame(frame, setFrame);
            if (saving) return;
            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))
            {
                Animation drawnAnimation = _frameGame.gameGraphics.GetDrawAnimation(ReturnAnimation.Name);
                drawnAnimation.SetFrame(frame, setFrame);
                _frameGame.gameGraphics.SetLoadedDrawn(drawnAnimation);
            }
            else
            {
                _frameGame.gameGraphics.AddToDrawList(new DrawParam(ReturnAnimation.Name, ReturnAnimation.Name, position, DrawnType.Animation));
                return;
            }
            _frameGame.gameGraphics.UpdateDrawPosition(new DrawParam(ReturnAnimation.Name, ReturnAnimation.Name, position, DrawnType.Animation));

            RectangleHeightAction rectangleHeightAction = new RectangleHeightAction
            {
                Name = FrameRectangleName,
                Drawable = FrameRectangleName,
                Value = height
            };
            RectangleWidthAction rectangleWidthAction = new RectangleWidthAction
            {
                Name = FrameRectangleName,
                Drawable = FrameRectangleName,
                Value = width
            };
            PositionXAction rectanglePositionXAction = new PositionXAction
            {
                Name = FrameRectangleName,
                Drawable = FrameRectangleName,
                Value = x
            };
            PositionYAction rectanglePositionYAction = new PositionYAction
            {
                Name = FrameRectangleName,
                Drawable = FrameRectangleName,
                Value = y
            };
            textureManager.ExecuteAction(rectanglePositionXAction);
            textureManager.ExecuteAction(rectanglePositionYAction);
            textureManager.ExecuteAction(rectangleWidthAction);
            textureManager.ExecuteAction(rectangleHeightAction);
            _textureGame.RunOneFrame();
        }
 //Set text boxes to frame properties
 private void SetFieldsFromFrame(Frame frame)
 {
     txtBox_FrameX.Text = frame.TextureSource.X.ToString();
     txtBox_FrameY.Text = frame.TextureSource.Y.ToString();
     txtBox_FrameWidth.Text = frame.TextureSource.Width.ToString();
     txtBox_FrameHeight.Text = frame.TextureSource.Height.ToString();
 }
 //Add frame to ReturnAnimation (aka, the current animaion). If FrameGame is started and has said animation, update it too.
 private void AddFrame(Frame frame)
 {
     ReturnAnimation.AddFrame(frame);
     if (_frameGame != null && _frameGame.gameGraphics.DoesDrawableExist(ReturnAnimation.Name))
     {
         Animation drawAnimation = _frameGame.gameGraphics.GetDrawAnimation(ReturnAnimation.Name);
         drawAnimation.AddFrame(frame);
         _frameGame.gameGraphics.SetLoadedDrawn(drawAnimation);
     }
     listBox_Frames.Items.Add(listBox_Frames.Items.Count + 1);
     lbl_CurrentFrameCount.Text = ReturnAnimation.FrameCount.ToString();
 }