freeso/TSOClient/FSO.IDE/EditorComponent/Commands/UpdateBoxPosCommand.cs
riperiperi b57ebbd141 Cleanup: Remove most unused usings and MPL per-file licenses
MPL per-file was used in older project files, but should apply to the whole project, so having it there was redundant.
2023-11-25 03:45:29 +00:00

45 lines
1.5 KiB
C#

using FSO.Files.Formats.IFF.Chunks;
using FSO.IDE.EditorComponent.UI;
using Microsoft.Xna.Framework;
namespace FSO.IDE.EditorComponent.Commands
{
public class UpdateBoxPosCommand : BHAVCommand
{
PrimitiveBox Box;
public Point BeforePos;
public Point BeforeSize;
public Point AfterPos;
public Point AfterSize;
public UpdateBoxPosCommand(PrimitiveBox box)
{
Box = box;
BeforePos = new Point(box.TreeBox.X, box.TreeBox.Y);
BeforeSize = new Point(box.TreeBox.Width, box.TreeBox.Height);
AfterPos = box.Position.ToPoint();
AfterSize = new Point(box.Width, box.Height);
}
public override void Execute(BHAV bhav, UIBHAVEditor editor)
{
var tree = editor.GetSavableTree();
Box.TreeBox.X = (short)AfterPos.X;
Box.TreeBox.Y = (short)AfterPos.Y;
Box.TreeBox.Width = (short)AfterSize.X;
Box.TreeBox.Height = (short)AfterSize.Y;
Content.Content.Get().Changes.ChunkChanged(tree);
}
public override void Undo(BHAV bhav, UIBHAVEditor editor)
{
var tree = editor.GetSavableTree();
Box.TreeBox.X = (short)BeforePos.X;
Box.TreeBox.Y = (short)BeforePos.Y;
Box.TreeBox.Width = (short)BeforeSize.X;
Box.TreeBox.Height = (short)BeforeSize.Y;
Box.ApplyBoxPositionCentered();
Content.Content.Get().Changes.ChunkChanged(tree);
}
}
}