Beispiel #1
0
 private void ProjectManager_ProjectChanged(object sender, EventArgs e)
 {
     UndoHistory.Clear();
     RedoHistory.Clear();
     HistoryLimitExceeded = false;
     CurrentChangeID      = 0;
 }
Beispiel #2
0
 public void ClearHistory()
 {
     UndoHistory.Clear();
     RedoHistory.Clear();
     HistoryLimitExceeded = false;
     ProjectIsModified    = false;
     CurrentChangeID      = 0;
 }
Beispiel #3
0
 public override void DiscardChanges()
 {
     _directImage.Render();
     UndoHistory.Clear();
     RedoHistory.Clear();
     NotifyOfPropertyChange(() => CanUndo);
     NotifyOfPropertyChange(() => CanRedo);
 }
Beispiel #4
0
 /// <summary>
 /// Redos the last change made and pushes it to the undo stack,
 /// if possible.
 /// </summary>
 public void Redo()
 {
     if (CanRedo())
     {
         UndoHistory.Push(new AppPalUndo(Palette, RedoHistory.Peek().Name));
         var state = RedoHistory.Pop();
         SetPalette(state.Palette, false);
     }
 }
        public void Use(Entity.Player p, string[] args)
        {
            int  time = 30;
            long uid  = -1;

            Level where = null;
            if (args.Length == 1)
            {
                try { time = int.Parse(args[0]); }
                catch { p.SendMessage("The time was incorrect, using 30 seconds instead"); }
            }
            if (args.Length == 2)
            {
                uid = Player.GetUID(args[0]);
                if (uid == -1)
                {
                    p.SendMessage("Player not found");
                    return;
                }
                try { time = int.Parse(args[1]); }
                catch { p.SendMessage("The time was incorrect, using 30 seconds instead"); }
            }
            if (args.Length == 3)
            {
                uid = Player.GetUID(args[0]);
                if (uid == -1)
                {
                    p.SendMessage("Player not found");
                    return;
                }
                try { time = int.Parse(args[1]); }
                catch { p.SendMessage("The time was incorrect, using 30 seconds instead"); }
                where = Level.FindLevel(args[2]);
                if (where == null)
                {
                    p.SendMessage("Level " + args[2] + " does not exist or is not loaded");
                    return;
                }
            }
            if (uid == -1)
            {
                uid = p.UID;
            }
            if (where == null)
            {
                where = p.Level;
            }
            int count = 0;

            foreach (var ch in RedoHistory.Redo((uint)uid, where.Name, DateTime.Now.AddSeconds(-time).Ticks))
            {
                where.BlockChange(ch.Item1, ch.Item2, ch.Item3, ch.Item4, p);
                count++;
            }
            p.SendMessage("&e" + count + MCForge.Core.Server.DefaultColor + " Blocks changed");
        }
Beispiel #6
0
        /// <summary>
        /// Redos the last change made and pushes it to the undo stack,
        /// if possible.
        /// </summary>
        public void Redo()
        {
            if (CanRedo())
            {
                UndoHistory.Push(new AppState(HsvColor, SchemeType));
                AppState s = RedoHistory.Pop();
                SetColor(s.Color, false, false);
                SetSchemeType(s.SchemeType, false, false);

                // because we didn't use the setters to fire events
                // because we'd be wastefully firing two otherwise
                OnResultChanged(new EventArgs());
            }
        }
Beispiel #7
0
        private void AddAction(ChangeAction action)
        {
            RedoHistory.Clear();
            UndoHistory.Add(action);
            action.ChangeID = ++CurrentChangeID;

            if (UndoHistory.Count > MaxHistory)
            {
                HistoryLimitExceeded = true;
                UndoHistory.RemoveAt(0);
            }

            UndoHistoryChanged?.Invoke(this, EventArgs.Empty);
        }
        void Undo(long UID, int time, Level l, Player online)
        {
            long since = DateTime.Now.AddSeconds(-time).Ticks;
            int  count = 0;

            foreach (var ch in BlockChangeHistory.GetCurrentIfUID(l.Name, (uint)UID, since))
            {
                RedoHistory.Add((uint)UID, l.Name, ch.Item1, ch.Item2, ch.Item3, ch.Item4);
                count++;
            }
            foreach (var ch in BlockChangeHistory.Undo(l.Name, (uint)UID, since))
            {
                l.BlockChange(ch.Item1, ch.Item2, ch.Item3, ch.Item4);
            }
            online.SendMessage("&e" + count + Server.DefaultColor + " Blocks changed");
            return;
        }
Beispiel #9
0
        public void Redo()
        {
            if (RedoHistory.Any())
            {
                BeginUndoRedo?.Invoke(this, EventArgs.Empty);

                var lastAction = RedoHistory.Last();
                CurrentChangeID = lastAction.ChangeID;

                RedoHistory.Remove(lastAction);
                UndoHistory.Add(lastAction);

                ExecutingUndoRedo = true;
                lastAction.Redo();
                ExecutingUndoRedo = false;

                EndUndoRedo?.Invoke(this, EventArgs.Empty);
                UndoHistoryChanged?.Invoke(this, EventArgs.Empty);
            }
        }
Beispiel #10
0
    public override void SaveChanges()
    {
        try
        {
            _directImage.SaveImage();

            UndoHistory.Clear();
            RedoHistory.Clear();
            NotifyOfPropertyChange(() => CanUndo);
            NotifyOfPropertyChange(() => CanRedo);

            IsModified = false;
            var changeEvent = new ArrangerChangedEvent(_projectArranger, ArrangerChange.Pixels);
            _events.PublishOnUIThread(changeEvent);
        }
        catch (Exception ex)
        {
            _windowManager.ShowMessageBox($"Could not save the pixel arranger contents\n{ex.Message}\n{ex.StackTrace}", "Save Error");
        }
    }
Beispiel #11
0
 /// <summary>
 /// Pushes the current state of the application to the undo stack, and purges the redo stack.
 /// </summary>
 private void PushUndo()
 {
     UndoHistory.Push(new AppState(HsvColor, SchemeType));
     RedoHistory.Clear();
 }
Beispiel #12
0
 /// <summary>
 /// Pushes the current state of the application to the undo stack, and purges the redo stack.
 /// </summary>
 private void PushUndo(string action)
 {
     UndoHistory.Push(new AppPalUndo(Palette, action));
     RedoHistory.Clear();
 }