コード例 #1
0
        public void Redo(bool reference)
        {
            try {
                if (CanRedo())
                {
                    _index++;

                    UndoData data = _undoDataArray[_index];

                    restoreBehavior(data.Behavior, true);

                    if (ModifyNodeHandler != null)
                    {
                        ModifyNodeHandler(_behavior, reference);
                    }

                    if (!checkDirty(_index))
                    {
                        _behavior.TriggerWasSaved();
                    }

                    else
                    {
                        _behavior.TriggerWasModified(_behavior as Nodes.Node);
                    }
                }
                else
                {
                    _index = _undoDataArray.Count - 1;
                }
            } catch (Exception) {
            }
        }
コード例 #2
0
ファイル: Undo.cs プロジェクト: raptoravis/behaviac1
        public void Redo(bool reference)
        {
            try
            {
                if (CanRedo())
                {
                    _index++;

                    UndoData data = _undoDataArray[_index];
                    if (!checkBehaviorModification(data, false))
                    {
                        return;
                    }

                    int referCount = 0;

                    if (data.ReferencedBehavior1 != null && data.ReferencedBehavior1 != _behavior)
                    {
                        referCount++;
                        UndoManager.Redo(data.ReferencedBehavior1.Filename, true);
                    }

                    if (data.ReferencedBehavior2 != null && data.ReferencedBehavior2 != data.ReferencedBehavior1 && data.ReferencedBehavior2 != _behavior)
                    {
                        referCount++;
                        UndoManager.Redo(data.ReferencedBehavior2.Filename, true);
                    }

                    if (referCount < 2)
                    {
                        restoreBehavior(data.Behavior, referCount == 0);
                    }

                    if (ModifyNodeHandler != null)
                    {
                        ModifyNodeHandler(_behavior, reference);
                    }

                    if (!checkDirty(_index))
                    {
                        _behavior.TriggerWasSaved();
                    }
                    else
                    {
                        _behavior.IsModified = true;
                    }
                }
                else
                {
                    _index = _undoDataArray.Count - 1;
                }
            }
            catch (Exception)
            {
            }
        }
コード例 #3
0
ファイル: Undo.cs プロジェクト: raptoravis/behaviac1
        private bool checkBehaviorModification(UndoData data, bool undo)
        {
            bool check = true;

            if (data.ReferencedBehavior1 != null && data.ReferencedBehavior1 != _behavior)
            {
                check &= checkBehaviorModification(data.ReferencedBehavior1.Filename, undo);
            }

            if (data.ReferencedBehavior2 != null && data.ReferencedBehavior2 != data.ReferencedBehavior1 && data.ReferencedBehavior2 != _behavior)
            {
                check &= checkBehaviorModification(data.ReferencedBehavior2.Filename, undo);
            }

            return(check);
        }
コード例 #4
0
ファイル: Undo.cs プロジェクト: raptoravis/behaviac1
        private bool checkDirty(int currentIndex)
        {
            if (_lastSaveIndex > currentIndex)
            {
                return(true);
            }

            int startIndex = _lastSaveIndex > 0 ? _lastSaveIndex + 1 : 1;

            for (int i = startIndex; i <= currentIndex; ++i)
            {
                UndoData data = _undoDataArray[i];
                if ((data.ReferencedBehavior1 == null || data.ReferencedBehavior1 == _behavior) &&
                    (data.ReferencedBehavior2 == null || data.ReferencedBehavior2 == _behavior))
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #5
0
ファイル: Undo.cs プロジェクト: nusus/behaviac
        private bool checkBehaviorModification(UndoData data, bool undo)
        {
            bool check = true;

            if (data.ReferencedBehavior1 != null && data.ReferencedBehavior1 != _behavior)
                check &= checkBehaviorModification(data.ReferencedBehavior1.Filename, undo);

            if (data.ReferencedBehavior2 != null && data.ReferencedBehavior2 != data.ReferencedBehavior1 && data.ReferencedBehavior2 != _behavior)
                check &= checkBehaviorModification(data.ReferencedBehavior2.Filename, undo);

            return check;
        }