Пример #1
0
        /// <summary>
        /// Beendet den UndoStep und trägt ihn in die Undo-Liste ein.
        /// </summary>
        public void EndUndoStep()
        {
            if (!initialized)
            {
                return;
            }

            depth--;

            if (depth == 0)
            {
                if (currentUndoStep.undoEntry.Count > 0)
                {
                    if (undoInAction)
                    {
                        redoSteps.Push(currentUndoStep);
                    }
                    else
                    {
                        if (!redoInAction)           // Redo-Buffer löschen
                        {
                            redoSteps.Clear();
                        }

                        undoSteps.Push(currentUndoStep);
                    }
                }

                currentUndoStep = null;
            }
        }
Пример #2
0
        /// <summary>
        /// Führt die angegebene Anzahl von Redo-Steps aus.
        /// </summary>
        /// <param name="steps"></param>
        public void DoRedo(int steps)
        {
            if (!initialized)
            {
                return;
            }

            if (redoSteps.Count < 1)           // Nichts da
            {
                return;
            }

            redoInAction = true;

            for (int i = 0; i < steps; i++)
            {
                UndoStep redoStep = redoSteps.Pop();

                BeginUndoStep(redoStep.undoName);
                DoUndoStep(redoStep);
                EndUndoStep();
            }

            //TODO_WPF!!!!!!!!!!!!!!!mainWindowControl.UpdateSelection();

            redoInAction = false;
        }
Пример #3
0
        /// <summary>
        /// Startet einen neuen Undo-Step. Mehrere Änderungen (UndoEntrys) werden in einem
        /// Undo-Step zusammengefasst. Muss immer aufgerufen werden, bevor etwas in die Undo-Liste
        /// eingetragen wird.
        /// </summary>
        /// <param name="undoName"></param>
        public void BeginUndoStep(string undoName)
        {
            if (!initialized)
            {
                return;
            }

            depth++;

            if (currentUndoStep != null)
            {
                return;
            }

            currentUndoStep = new UndoStep(undoName);
        }
Пример #4
0
        /// <summary>
        /// Führt einen einzelnen Undo-Step aus.
        /// </summary>
        /// <param name="step"></param>
        private void DoUndoStep(UndoStep step)
        {
            while (step.undoEntry.Count > 0)
            {
                UndoEntry entry = step.undoEntry.Pop();

                switch (entry.undoAction)
                {
                case UndoAction.ChangeProperty:
                {
                    // Property-Änderung rückgängig machen.
                    HitbaseControl hlControl = mainWindowControl.FindHitbaseControlFromID(entry.controlID);

                    mainWindowControl.ChangeProperty(hlControl, entry.property, entry.value);

                    break;
                }

                case UndoAction.Delete:
                {
                    // Löschen eines Objektes rückgängig machen.
                    HitbaseControl newControl = mainWindowControl.AddControlFromStream(entry.parentControlID, entry.controlIndex, entry.serializedObject, true);
                    newControl.SetTabIndex(entry.tabIndex);
                    break;
                }

                case UndoAction.New:
                {
                    HitbaseControl ctl = mainWindowControl.FindHitbaseControlFromID(entry.controlID);
                    HitbaseControl parent;

                    if (entry.parentControlID != 0)
                    {
                        parent = mainWindowControl.FindHitbaseControlFromID(entry.controlID);
                    }
                    else
                    {
                        parent = null;
                    }

                    mainWindowControl.DeleteHitbaseControlWithChilds(parent, ctl);
                    break;
                }
                }
            }
        }