Example #1
0
 /// <summary>
 /// Ends the action associated with the cursor. If it had any effect, a CommandReady
 /// event is fired.
 /// </summary>
 public void EndEdit()
 {
     if (commandList.IsEmpty) return;
     OnCommand(new UndoEventArgs(commandList));
     commandList = new UndoCommandList(Name);
 }
Example #2
0
 public UndoEventArgs(UndoCommandList c)
 {
     this.Command = c;
 }
Example #3
0
 public void RemoveSprite(Sprite s)
 {
     var l = new UndoCommandList("Remove sprite " + s.Name);
     RemoveSprite(s, l);
     Undo.DoCommand(l);
 }
Example #4
0
 public Cursor()
 {
     commandList = new UndoCommandList(Name);
 }
Example #5
0
 public void RemoveSprite(Sprite s, UndoCommandList list)
 {
     foreach (var map in maps) {
         foreach (var l in map.Value.layerGroups) {
             if (!(l is SimpleLayerGroup)) continue;
             foreach (var o in l[0].objects) {
                 if (o != null && o.Sprite == s) {
                     throw new CannotRemoveException(o.ToString());
                 }
             }
         }
     }
     string name = s.Name;
     list.Add(new UndoCommand(
                  delegate() {
                      sprites.Remove(name);
                  },
                  delegate() {
                      sprites.Add(name, s);
                  }
              ));
 }
Example #6
0
 public void RemoveMusic(BigFile music)
 {
     var list = new UndoCommandList("Remove audio file");
     RemoveMusic(music, list);
     Undo.DoCommand(list);
 }
Example #7
0
 public void RemoveMusic(BigFile music, UndoCommandList list)
 {
     string name = null;
     foreach (var m in musics) {
         if (m.Value == music) {
             name = m.Key;
         }
     }
     if (name == null) throw new ArgumentException("Music is not in the list!");
     list.Add(new UndoCommand(
                  delegate() {
                      musics.Remove(name);
                  },
                  delegate() {
                      musics.Add(name, music);
                  }
              ));
 }
Example #8
0
 public void RemoveAnimation(Animation a)
 {
     var undoComm = new UndoCommandList("Remove animation " + a.Name);
     RemoveAnimation(a, undoComm);
     Undo.DoCommand(undoComm);
 }
Example #9
0
 public void RemoveAnimation(Animation a, UndoCommandList list)
 {
     foreach (var sprite in sprites.Values) {
         if (sprite.animation == a) {
             throw new CannotRemoveException("Sprite " + sprite.Name);
         }
     }
     string name = a.Name;
     list.Add(new UndoCommand(
                  delegate() {
                      animations.Remove(name);
                  },
                  delegate() {
                      animations.Add(name, a);
                  }
              ));
 }