示例#1
0
        public XmlNode Redo()
        {
            XmlNode   affectedNode  = null;
            ArrayList affectedNodes = new ArrayList();

            if (redoCommands.Count > 0)
            {
                DeregisterHandlers();

                IReversibleCommand command = (IReversibleCommand)redoCommands[redoCommands.Count - 1];
                do
                {
                    affectedNodes.Add(command.Redo());

                    redoCommands.Remove(command);
                    undoCommands.Add(command);

                    if (redoCommands.Count > 0)
                    {
                        command = (IReversibleCommand)redoCommands[redoCommands.Count - 1];
                    }
                } while (redoCommands.Count > 0 && command.BeginCommandRange == false);

                RegisterHandlers();
            }

            foreach (XmlNode node in affectedNodes)
            {
                if (node is XmlText)
                {
                    if (node.ParentNode is XmlAttribute)
                    {
                        XmlAttribute att = node.ParentNode as XmlAttribute;
                        if (att.OwnerElement != null)
                        {
                            affectedNode = att.OwnerElement;
                            break;
                        }
                    }
                }
                else if (node.ParentNode != null)
                {
                    affectedNode = node;
                    break;
                }
                else if (node is XmlAttribute)
                {
                    XmlAttribute att = node as XmlAttribute;
                    if (att.OwnerElement != null)
                    {
                        affectedNode = att.OwnerElement;
                        break;
                    }
                }
            }

            return(affectedNode);
        }