示例#1
0
        public void Merge(CompoundCommand cmd)
        {
            // Replace the current command without upsetting rest of the redo stack
            // and insert the current command into this compound command.
            Command current = Peek();

            if (current != null)
            {
                _stack.Insert(_pos - 1, cmd);
                _stack.RemoveAt(_pos);
                cmd.Do();
                cmd.Insert(current);
            }
            else
            {
                Push(cmd);
            }
        }
 public CompoundCommand OpenCompoundAction(string name)
 {
     this.compound = new CompoundCommand(name);
     Add(this.compound);
     return this.compound;
 }
 public void Merge(CompoundCommand cmd)
 {
     // Replace the current command without upsetting rest of the redo stack
     // and insert the current command into this compound command.
     Command current = Peek();
     if (current != null) {
         stack.Insert(pos-1, cmd);
         stack.RemoveAt(pos);
         cmd.Do();
         cmd.Insert(current);
     } else {
         Push(cmd);
     }
 }
 public void CloseCompoundAction()
 {
     this.compound = null;
 }
示例#5
0
 public void CloseCompoundAction()
 {
     this._compound = null;
 }
示例#6
0
 public CompoundCommand OpenCompoundAction(string name)
 {
     this._compound = new CompoundCommand(name);
     Add(this._compound);
     return(this._compound);
 }
示例#7
0
        public ChangeNode(XmlTreeView view, XmlTreeNode node, XmlNodeType nt)
        {
            this.doc = view.Model.Document;
            this.nt = nt;
            this.view = view;
            this.node = node;
            XmlNode n = node.Node;
            if (n == null) return;

            init:
            this.oldnt = n.NodeType;
            string innerXml = (oldnt == XmlNodeType.Element) ? n.InnerXml : SpecialUnescape(oldnt, n.Value);
            string outerXml = n.OuterXml;
            string qname = n.Name;
            string localName = n.LocalName;
            string ns = n.NamespaceURI;
            bool noName = false;
            if (qname.StartsWith("#")) {
                qname = localName = "";
            }
            noName = string.IsNullOrEmpty(qname);

            if (noName && IsNamedNodeType(nt)) {
                // Try parsing the content of the node as markup! (but first check for special unescaping
                // that we do for nested comment/cdata blocks)
                PasteCommand paste = new PasteCommand(doc, view, InsertPosition.Before, new TreeData(innerXml));
                XmlTreeNode nte = paste.NewNode;
                if (nte != null && IsNamedNodeType(nte.NodeType)) {
                    // then it worked - we extracted a node with a name, so start over.
                    n = newNode = nte.Node;
                    goto init;
                }
            }
            if (newNode == null || newNode.NodeType != nt) {
                switch (nt) {
                    case XmlNodeType.Element:
                        if (noName) {
                            qname = "element";
                        }
                        newNode = doc.CreateElement(qname, ns);
                        newNode.InnerXml = innerXml;
                        break;
                    case XmlNodeType.Attribute:
                        if (noName) {
                            qname = "attribute";
                        }
                        newNode = doc.CreateAttribute(qname, ns);
                        newNode.Value = innerXml;
                        break;
                    case XmlNodeType.Comment:
                        newNode = doc.CreateComment(SpecialEscape(nt, noName ? innerXml : outerXml));
                        break;
                    case XmlNodeType.ProcessingInstruction:
                        if (noName) {
                            localName = "pi";
                        }
                        newNode = doc.CreateProcessingInstruction(localName, innerXml);
                        break;
                    case XmlNodeType.Text:
                        newNode = doc.CreateTextNode(noName ? innerXml : outerXml);
                        break;
                    case XmlNodeType.CDATA:
                        newNode = doc.CreateCDataSection(SpecialEscape(nt, noName ? innerXml : outerXml));
                        break;
                }
            }
            InsertNode icmd = new InsertNode(node, InsertPosition.Before, newNode, true, true);
            newTreeNode = icmd.NewNode;
            DeleteNode del = new DeleteNode(doc, node);
            group = new CompoundCommand(this.Name);
            group.Add(icmd);
            group.Add(del);
        }