Added: SelectionState; New Undoable Mods: AddAnimation, RemoveAnimation, AddFrame, RemoveFrame, RemoveSprite

This commit is contained in:
quinnvoker
2018-12-26 21:07:21 -08:00
parent 2e72c46b7b
commit aaa80bd654
16 changed files with 761 additions and 120 deletions
@@ -0,0 +1,82 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using QURO;
using QURO.Animation;
using System.Windows.Forms;
namespace AnimationEditor.Modifications
{
class RemoveSprite : IModification
{
private SelectionState preChangeSelection;
private SelectionState postChangeSelection;
private BindingList<Sprite> sprites;
private ListBox spriteListBox;
private int removeIndex;
private Sprite removedSprite;
public RemoveSprite(BindingList<Sprite> spriteList, ListBox spriteBox, int index)
{
sprites = spriteList;
spriteListBox = spriteBox;
removeIndex = index;
}
public void Do()
{
if(removeIndex > -1 && removeIndex < sprites.Count)
{
removedSprite = sprites[removeIndex];
if(sprites.Count == 1)
{
sprites.Clear();
}
else
sprites.RemoveAt(removeIndex);
if (sprites.Count > -1 && spriteListBox.SelectedIndex > sprites.Count - 1)
{
ModHelper.SetSingleSelection(spriteListBox, sprites.Count - 1);
}
}
}
public void Undo()
{
if(removedSprite != null)
{
sprites.Insert(removeIndex, removedSprite);
}
}
public SelectionState GetPreChangeSelection()
{
return preChangeSelection;
}
public void SetPreChangeSelection(SelectionState currentSelection)
{
preChangeSelection = currentSelection;
}
public SelectionState GetPostChangeSelection()
{
return postChangeSelection;
}
public void SetPostChangeSelection(SelectionState currentSelection)
{
postChangeSelection = currentSelection;
}
public override string ToString()
{
return "Remove Frame";
}
}
}