public virtual bool AktionDelete(UndoSnapshotSetzenOptionen undoSnapshotSetzen) { if (!this.AktionenMoeglich) { return(false); } if (this.IstRootNodeSelektiert) { return(false); } if (undoSnapshotSetzen == UndoSnapshotSetzenOptionen.ja) { this._undoHandler.SnapshotSetzen(ResReader.Reader.GetString("AktionLoeschen"), this._cursor); } XMLCursor cursor = this._cursor; cursor.SelektionOptimieren(); XMLCursorPos xMLCursorPos = default(XMLCursorPos); if (cursor.SelektionLoeschen(out xMLCursorPos)) { this._cursor.BeideCursorPosSetzen(xMLCursorPos.AktNode, xMLCursorPos.PosAmNode, xMLCursorPos.PosImTextnode); this.ContentChanged(); return(true); } return(false); }
public virtual bool AktionCutToClipboard(UndoSnapshotSetzenOptionen undoSnapshotSetzen) { if (!this.AktionenMoeglich) { return(false); } if (this._cursor != this._cursor) { goto IL_0026; } goto IL_0026; IL_0026: if (this.CursorOptimiert.StartPos.AktNode == this._rootNode) { return(false); } if (this.AktionCopyToClipboard()) { if (this.AktionDelete(UndoSnapshotSetzenOptionen.ja)) { return(true); } return(false); } return(false); }
public virtual bool AktionTextAnCursorPosEinfuegen(string einfuegeText, UndoSnapshotSetzenOptionen undoSnapshotSetzen) { if (!this.AktionenMoeglich) { return(false); } if (undoSnapshotSetzen == UndoSnapshotSetzenOptionen.ja) { this._undoHandler.SnapshotSetzen(string.Format(ResReader.Reader.GetString("AktionSchreiben"), einfuegeText), this._cursor); } this._cursor.TextEinfuegen(einfuegeText, this.Regelwerk); this.ContentChanged(); return(true); }
private bool AktionRootNodeDurchClipboardInhaltErsetzen(UndoSnapshotSetzenOptionen undoSnapshotSetzen) { if (!this.AktionenMoeglich) { return(false); } string text = ""; try { text = Clipboard.GetText(TextDataFormat.Text); XmlTextReader xmlTextReader = new XmlTextReader(text, XmlNodeType.Element, null); xmlTextReader.MoveToContent(); XmlNode xmlNode = this._rootNode.OwnerDocument.ReadNode(xmlTextReader); if (xmlNode.Name != this._rootNode.Name) { return(false); } if (undoSnapshotSetzen == UndoSnapshotSetzenOptionen.ja) { this._undoHandler.SnapshotSetzen(ResReader.Reader.GetString("RootNodedurchZwischenablageersetzen"), this._cursor); } this._rootNode.RemoveAll(); while (xmlNode.Attributes.Count > 0) { XmlAttribute node = xmlNode.Attributes.Remove(xmlNode.Attributes[0]); this._rootNode.Attributes.Append(node); } XMLCursorPos xMLCursorPos = new XMLCursorPos(); xMLCursorPos.CursorSetzen(this._rootNode, XMLCursorPositionen.CursorInDemLeeremNode); XMLCursorPos xMLCursorPos2 = xMLCursorPos.Clone(); while (xmlNode.ChildNodes.Count > 0) { XmlNode newChild = xmlNode.RemoveChild(xmlNode.FirstChild); this._rootNode.AppendChild(newChild); } this.ContentChanged(); this._cursor.BeideCursorPosSetzen(this._rootNode, XMLCursorPositionen.CursorAufNodeSelbstVorderesTag); this._cursor.ErzwingeChanged(); return(true); } catch (Exception ex) { Debugger.GlobalDebugger.Protokolliere(string.Format("AktionRootNodeDurchClipboardInhaltErsetzen:Fehler für Einfügetext '{0}':{1}", text, ex.Message), Debugger.ProtokollTypen.Fehlermeldung); return(false); } }
public virtual XmlNode AktionNeuesElementAnAktCursorPosEinfuegen(string nodeName, UndoSnapshotSetzenOptionen undoSnapshotSetzen, bool neueCursorPosAufJedenFallHinterDenEingefuegtenNodeSetzen) { if (!this.AktionenMoeglich) { return(null); } if (nodeName == "") { throw new ApplicationException(ResReader.Reader.GetString("KeinNodeNameAngegeben")); } if (undoSnapshotSetzen == UndoSnapshotSetzenOptionen.ja) { this._undoHandler.SnapshotSetzen(string.Format(ResReader.Reader.GetString("AktionInsertNode"), nodeName), this._cursor); } XmlNode xmlNode = (!(nodeName == "#COMMENT")) ? this._rootNode.OwnerDocument.CreateNode(XmlNodeType.Element, nodeName, null) : this._rootNode.OwnerDocument.CreateComment("NEW COMMENT"); this._cursor.XMLNodeEinfuegen(xmlNode, this.Regelwerk, neueCursorPosAufJedenFallHinterDenEingefuegtenNodeSetzen); this.ContentChanged(); return(xmlNode); }
public bool AktionNodeOderZeichenHinterCursorPosLoeschen(XMLCursorPos position, UndoSnapshotSetzenOptionen undoSnapshotSetzen) { if (!this.AktionenMoeglich) { return(false); } if (undoSnapshotSetzen == UndoSnapshotSetzenOptionen.ja) { this._undoHandler.SnapshotSetzen(ResReader.Reader.GetString("AktionLoeschen"), this._cursor); } XMLCursor xMLCursor = new XMLCursor(); xMLCursor.StartPos.CursorSetzen(position.AktNode, position.PosAmNode, position.PosImTextnode); XMLCursorPos xMLCursorPos = xMLCursor.StartPos.Clone(); xMLCursorPos.MoveRight(this._rootNode, this.Regelwerk); xMLCursor.EndPos.CursorSetzen(xMLCursorPos.AktNode, xMLCursorPos.PosAmNode, xMLCursorPos.PosImTextnode); xMLCursor.SelektionOptimieren(); if (xMLCursor.StartPos.AktNode == this._rootNode) { return(false); } XMLCursorPos xMLCursorPos2 = default(XMLCursorPos); if (xMLCursor.SelektionLoeschen(out xMLCursorPos2)) { this._cursor.BeideCursorPosSetzen(xMLCursorPos2.AktNode, xMLCursorPos2.PosAmNode, xMLCursorPos2.PosImTextnode); this._cursor.ErzwingeChanged(); this.ContentChanged(); return(true); } return(false); }
public virtual bool AktionAttributWertInNodeSetzen(XmlNode node, string attributName, string wert, UndoSnapshotSetzenOptionen undoSnapshotSetzen) { if (!this.AktionenMoeglich) { return(false); } XmlAttribute xmlAttribute = node.Attributes[attributName]; if (wert == "") { if (xmlAttribute != null) { if (undoSnapshotSetzen == UndoSnapshotSetzenOptionen.ja) { this._undoHandler.SnapshotSetzen(string.Format(ResReader.Reader.GetString("AktionAttributGeloescht"), attributName, node.Name), this._cursor); } node.Attributes.Remove(xmlAttribute); } } else if (xmlAttribute == null) { if (undoSnapshotSetzen == UndoSnapshotSetzenOptionen.ja) { this._undoHandler.SnapshotSetzen(string.Format(ResReader.Reader.GetString("AktionAttributValueGeaendert"), attributName, node.Name, wert), this._cursor); } xmlAttribute = node.OwnerDocument.CreateAttribute(attributName); node.Attributes.Append(xmlAttribute); xmlAttribute.Value = wert; } else if (xmlAttribute.Value != wert) { if (undoSnapshotSetzen == UndoSnapshotSetzenOptionen.ja) { this._undoHandler.SnapshotSetzen(string.Format(ResReader.Reader.GetString("AktionAttributValueGeaendert"), attributName, node.Name, wert), this._cursor); } xmlAttribute.Value = wert; } this.ContentChanged(); return(true); }
public virtual bool AktionPasteFromClipboard(UndoSnapshotSetzenOptionen undoSnapshotSetzen) { if (!this.AktionenMoeglich) { return(false); } string text = ""; try { XMLCursorPos startPos; if (Clipboard.ContainsText(TextDataFormat.Text)) { if (this.IstRootNodeSelektiert) { return(this.AktionRootNodeDurchClipboardInhaltErsetzen(undoSnapshotSetzen)); } if (this.IstEtwasSelektiert) { if (this.AktionDelete(UndoSnapshotSetzenOptionen.nein)) { startPos = this._cursor.StartPos; goto IL_008a; } return(false); } startPos = this.CursorOptimiert.StartPos; goto IL_008a; } return(false); IL_008a: if (undoSnapshotSetzen == UndoSnapshotSetzenOptionen.ja) { this._undoHandler.SnapshotSetzen(ResReader.Reader.GetString("AktionEinfuegen"), this._cursor); } text = Clipboard.GetText(TextDataFormat.Text); text = text.Replace("\r\n", " "); text = text.Replace("\n\r", " "); text = text.Replace("\r", " "); text = text.Replace("\n", " "); text = text.Replace("\t", " "); string xmlFragment = string.Format("<paste>{0}</paste>", text); XmlTextReader xmlTextReader = new XmlTextReader(xmlFragment, XmlNodeType.Element, null); xmlTextReader.MoveToContent(); XmlNode xmlNode = this._rootNode.OwnerDocument.ReadNode(xmlTextReader); XMLCursorPos xMLCursorPos = startPos.Clone(); foreach (XmlNode childNode in xmlNode.ChildNodes) { if (childNode is XmlText) { XmlNode xmlNode3 = null; xMLCursorPos.TextEinfuegen(childNode.Clone().Value, this.Regelwerk, out xmlNode3); if (xmlNode3 != null) { xMLCursorPos.InsertXMLNode(xmlNode3.Clone(), this.Regelwerk, true); } } else { xMLCursorPos.InsertXMLNode(childNode.Clone(), this.Regelwerk, true); } } XMLCursorPositionen posAmNode = this._cursor.EndPos.PosAmNode; if (posAmNode == XMLCursorPositionen.CursorVorDemNode || posAmNode == XMLCursorPositionen.CursorInnerhalbDesTextNodes) { this._cursor.BeideCursorPosSetzen(xMLCursorPos.AktNode, xMLCursorPos.PosAmNode, xMLCursorPos.PosImTextnode); } else { this._cursor.BeideCursorPosSetzen(xMLCursorPos.AktNode, XMLCursorPositionen.CursorHinterDemNode); } return(true); } catch (Exception ex) { Debugger.GlobalDebugger.Protokolliere(string.Format("AktionPasteFromClipboard:Fehler für Einfügetext '{0}':{1}", text, ex.Message), Debugger.ProtokollTypen.Fehlermeldung); return(false); } }