Ejemplo n.º 1
0
 // Constructor
 public SpriteEdit(SpriteAction action, List <Sprites.Mold> molds, ListBox listbox,
                   Sprites.Mold moldA, Sprites.Mold moldB, int index, int indexB)
 {
     this.action  = action;
     this.molds   = molds;
     this.listbox = listbox;
     this.moldA   = moldA.Copy();
     this.moldB   = moldB.Copy();
     this.index   = index;
     this.indexB  = indexB;
 }
Ejemplo n.º 2
0
 // Execute
 public void Execute()
 {
     if (action == SpriteAction.Edit)
     {
         this.molds[index] = this.moldB.Copy();
         var temp = this.moldA.Copy();
         this.moldA = this.moldB.Copy();
         this.moldB = temp;
         this.listbox.SelectedIndex = this.index;
     }
     else if (action == SpriteAction.Create)
     {
         this.molds.RemoveAt(index);
         this.listbox.Items.RemoveAt(index);
         this.listbox.SelectedIndex = Math.Min(this.index, this.listbox.Items.Count - 1);
         this.action = SpriteAction.Delete;
     }
     else if (action == SpriteAction.Delete)
     {
         this.molds.Insert(index, moldB.Copy());
         this.listbox.Items.Insert(index, "Mold " + index);
         this.listbox.SelectedIndex = Math.Min(this.index, this.listbox.Items.Count - 1);
         this.action = SpriteAction.Create;
     }
     else if (action == SpriteAction.MoveDown)
     {
         this.molds.Reverse(index, 2);
         this.listbox.SelectedIndex = index;
         this.action = SpriteAction.MoveUp;
     }
     else if (action == SpriteAction.MoveUp)
     {
         this.molds.Reverse(index, 2);
         this.listbox.SelectedIndex = index + 1;
         this.action = SpriteAction.MoveDown;
     }
     else if (action == SpriteAction.IndexChange)
     {
         this.listbox.SelectedIndex = this.indexB;
         int index = this.index;
         this.index  = this.indexB;
         this.indexB = index;
     }
     //
 }