예제 #1
0
        public void Redo(int commandNumder)
        {
            string command = "";
            int    i       = 0;

            for (i = 0; i < commandNumder && redoElements.Count > 0; i++)
            {
                UndoRedoElement element = redoElements[redoElements.Count - 1];
                redoElements.RemoveAt(redoElements.Count - 1);
                if (element.Redo())
                {
                    OnRedoComplete(element.TypeString, element.Args);
                    if (undoElements.Count == stackCount)
                    {
                        undoElements.RemoveAt(0);
                    }
                    undoElements.Add(element);

                    if (element.TypeString == "RotateCW" || element.TypeString == "RotateCCW")
                    {
                        return;
                    }
                }
                else
                {
                    return;
                }
            }
            OnRedoEnd(command, i, 0);
        }
예제 #2
0
        public void Undo(int commandNumber)
        {
            string command = "";
            int    i       = 0;

            for (i = 0; i < commandNumber && undoElements.Count > 0; i++)
            {
                UndoRedoElement element = undoElements[undoElements.Count - 1];
                undoElements.RemoveAt(undoElements.Count - 1);
                command = element.TypeString;

                bool executed;
                if (element.Undo(out executed))
                {
                    OnUndoComplete(element.TypeString, element.Args);

                    if (element.TypeString == "AddImageToDoc" || element.TypeString == "AddImageCurrentDoc")
                    {
                        if (executed)
                        {
                            redoElements.Add(element);
                        }
                    }
                    else
                    {
                        redoElements.Add(element);
                    }

                    if (element.TypeString == "RotateCW" || element.TypeString == "RotateCCW")
                    {
                        return;
                    }
                }
                else
                {
                    return;
                }
            }
            OnUndoEnd(command, i, 0);
        }
예제 #3
0
        public bool Add(string type, string name, string undoString, string redoString, Func <object[], bool> command, object[] args, int empID)
        {
            UndoRedoElement undoelem;

            switch (type)
            {
            case "AddDoc":
                break;

            case "AddDocToWork":
                undoelem = new UndoRedoElement(name, undoString, redoString, new Func <object[], bool>(UndoRedoCommands.UndoAddToWork), new Func <object[], bool>(UndoRedoCommands.RedoAddToWork), args, type, empID);
                if (undoElements.Count == stackCount)
                {
                    undoElements.RemoveAt(0);
                }
                undoElements.Add(undoelem);
                break;

            case "RemoveDocFromWork":
                undoelem = new UndoRedoElement(name, undoString, redoString, new Func <object[], bool>(UndoRedoCommands.RedoAddToWork), new Func <object[], bool>(UndoRedoCommands.UndoAddToWork), args, type, empID);
                if (undoElements.Count == stackCount)
                {
                    undoElements.RemoveAt(0);
                }
                undoElements.Add(undoelem);
                break;

            case "EditDocProp":
                undoelem = new UndoRedoElement(name, undoString, redoString, new Func <object[], bool>(UndoRedoCommands.EditDocProp), new Func <object[], bool>(UndoRedoCommands.RedoEditDocProp), args, type, empID);
                if (undoElements.Count == stackCount)
                {
                    undoElements.RemoveAt(0);
                }
                undoElements.Add(undoelem);
                break;

            case "AddPerson":
                undoelem = new UndoRedoElement(name, undoString, redoString, new Func <object[], bool>(UndoRedoCommands.AddPerson), new Func <object[], bool>(UndoRedoCommands.RemovePerson), args, type, empID);
                if (undoElements.Count == stackCount)
                {
                    undoElements.RemoveAt(0);
                }
                undoElements.Add(undoelem);
                break;

            case "RemovePerson":
                undoelem = new UndoRedoElement(name, undoString, redoString, new Func <object[], bool>(UndoRedoCommands.RemovePerson), new Func <object[], bool>(UndoRedoCommands.AddPerson), args, type, empID);
                if (undoElements.Count == stackCount)
                {
                    undoElements.RemoveAt(0);
                }
                undoElements.Add(undoelem);
                break;

            case "AddLink":
                undoelem = new UndoRedoElement(name, undoString, redoString, new Func <object[], bool>(UndoRedoCommands.AddLink), new Func <object[], bool>(UndoRedoCommands.RemoveLink), args, type, empID);
                if (undoElements.Count == stackCount)
                {
                    undoElements.RemoveAt(0);
                }
                undoElements.Add(undoelem);
                break;

            case "RemoveLink":
                undoelem = new UndoRedoElement(name, undoString, redoString, new Func <object[], bool>(UndoRedoCommands.RemoveLink), new Func <object[], bool>(UndoRedoCommands.AddLink), args, type, empID);
                if (undoElements.Count == stackCount)
                {
                    undoElements.RemoveAt(0);
                }
                undoElements.Add(undoelem);
                break;

            case "RotateCW":
                undoelem = new UndoRedoElement(name, undoString, redoString, (Func <object[], bool>)args[1], (Func <object[], bool>)args[2], args, type, empID);
                if (undoElements.Count == stackCount)
                {
                    undoElements.RemoveAt(0);
                }
                undoElements.Add(undoelem);
                break;

            case "RotateCCW":
                undoelem = new UndoRedoElement(name, undoString, redoString, (Func <object[], bool>)args[1], (Func <object[], bool>)args[2], args, type, empID);
                if (undoElements.Count == stackCount)
                {
                    undoElements.RemoveAt(0);
                }
                undoElements.Add(undoelem);
                break;

            case "EditImageProperty":
                break;

            case "AddImageToDoc":
                undoelem = new UndoRedoElement(name, undoString, redoString, (Func <object[], bool>)args[1], (Func <object[], bool>)args[2], args, type, empID);
                if (undoElements.Count == stackCount)
                {
                    undoElements.RemoveAt(0);
                }
                undoElements.Add(undoelem);
                break;

            case "RemoveImageFromDoc":
                //undoelem = new UndoRedoElement(name, undoString, redoString, (Func<object[], bool>)args[1], (Func<object[], bool>)args[2], args, type, empID);
                //if (undoElements.Count == stackCount)
                //    undoElements.RemoveAt(0);
                //undoElements.Add(undoelem);
                break;

            case "AddImageCurrentDoc":
                undoelem = new UndoRedoElement(name, undoString, redoString, (Func <object[], bool>)args[0], (Func <object[], bool>)args[1], args, type, empID);
                if (undoElements.Count == stackCount)
                {
                    undoElements.RemoveAt(0);
                }
                undoElements.Add(undoelem);
                break;

            //  —войство изображени¤ документа. ”становка места хранени¤.
            case "SetDocImageArchive":
                undoelem = new UndoRedoElement(name, undoString, redoString, (Func <object[], bool>)args[1], (Func <object[], bool>)args[2], args, type, empID);
                if (undoElements.Count == stackCount)
                {
                    undoElements.RemoveAt(0);
                }
                undoElements.Add(undoelem);
                break;

            //  —войство изображени¤. —делать основным.
            case "SetMainImage":
                undoelem = new UndoRedoElement(name, undoString, redoString, (Func <object[], bool>)args[1], (Func <object[], bool>)args[2], args, type, empID);
                if (undoElements.Count == stackCount)
                {
                    undoElements.RemoveAt(0);
                }
                undoElements.Add(undoelem);
                break;

            case "Sign":
            case "RemoveSign":
                undoelem = new UndoRedoElement(name, undoString, redoString, (Func <object[], bool>)args[1], (Func <object[], bool>)args[2], args, type, empID);
                if (undoElements.Count == stackCount)
                {
                    undoElements.RemoveAt(0);
                }
                undoElements.Add(undoelem);
                break;

            case "MarkDocAsRead":
                undoelem = new UndoRedoElement(name, undoString, redoString, new Func <object[], bool>(UndoRedoCommands.MarkDocMessagesAsNotRead), new Func <object[], bool>(UndoRedoCommands.MarkDocMessagesAsRead), args, type, empID);
                if (undoElements.Contains(undoelem) || redoElements.Contains(undoelem))
                {
                    return(true);
                }
                if (undoElements.Count == stackCount)
                {
                    undoElements.RemoveAt(0);
                }
                undoElements.Add(undoelem);
                break;

            case "MarkDocAsNotRead":
                undoelem = new UndoRedoElement(name, undoString, redoString, new Func <object[], bool>(UndoRedoCommands.MarkDocMessagesAsRead), new Func <object[], bool>(UndoRedoCommands.MarkDocMessagesAsNotRead), args, type, empID);
                if (undoElements.Contains(undoelem) || redoElements.Contains(undoelem))
                {
                    return(true);
                }
                if (undoElements.Count == stackCount)
                {
                    undoElements.RemoveAt(0);
                }
                undoElements.Add(undoelem);
                break;
            }
            redoElements.Clear();
            return(true);
        }