本文整理汇总了C#中UndoManager.Undo方法的典型用法代码示例。如果您正苦于以下问题:C# UndoManager.Undo方法的具体用法?C# UndoManager.Undo怎么用?C# UndoManager.Undo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UndoManager
的用法示例。
在下文中一共展示了UndoManager.Undo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteXDocumentVariation
public void ExecuteXDocumentVariation(XNode toReplace, XNode newValue)
{
XDocument xDoc = new XDocument(toReplace);
XDocument xDocOriginal = new XDocument(xDoc);
using (UndoManager undo = new UndoManager(xDoc))
{
undo.Group();
using (EventsHelper docHelper = new EventsHelper(xDoc))
{
toReplace.ReplaceWith(newValue);
docHelper.Verify(new XObjectChange[] { XObjectChange.Remove, XObjectChange.Add }, new XObject[] { toReplace, newValue });
}
undo.Undo();
Assert.True(XNode.DeepEquals(xDoc, xDocOriginal), "Undo did not work!");
}
}
示例2: XProcessingInstructionPIVariation
public void XProcessingInstructionPIVariation()
{
XProcessingInstruction toChange = new XProcessingInstruction("target", "data");
XProcessingInstruction original = new XProcessingInstruction(toChange);
using (UndoManager undo = new UndoManager(toChange))
{
undo.Group();
using (EventsHelper eHelper = new EventsHelper(toChange))
{
toChange.Target = "newTarget";
Assert.True(toChange.Target.Equals("newTarget"), "Name did not change");
eHelper.Verify(XObjectChange.Name, toChange);
}
undo.Undo();
Assert.True(XNode.DeepEquals(toChange, original), "Undo did not work");
}
}
示例3: ExecuteXDocumentVariation
public void ExecuteXDocumentVariation(XNode[] content, int index)
{
XDocument xDoc = new XDocument(content);
XDocument xDocOriginal = new XDocument(xDoc);
XNode toRemove = xDoc.Nodes().ElementAt(index);
using (UndoManager undo = new UndoManager(xDoc))
{
undo.Group();
using (EventsHelper docHelper = new EventsHelper(xDoc))
{
toRemove.Remove();
docHelper.Verify(XObjectChange.Remove, toRemove);
}
undo.Undo();
Assert.True(XNode.DeepEquals(xDoc, xDocOriginal), "Undo did not work!");
}
}
示例4: ExecuteXElementVariation
public void ExecuteXElementVariation(XElement toChange, XName newName)
{
XElement original = new XElement(toChange);
using (UndoManager undo = new UndoManager(toChange))
{
undo.Group();
using (EventsHelper eHelper = new EventsHelper(toChange))
{
toChange.Name = newName;
Assert.True(newName.Namespace == toChange.Name.Namespace, "Namespace did not change");
Assert.True(newName.LocalName == toChange.Name.LocalName, "LocalName did not change");
eHelper.Verify(XObjectChange.Name, toChange);
}
undo.Undo();
Assert.True(XNode.DeepEquals(toChange, original), "Undo did not work");
}
}
示例5: ExecuteXElementVariation
public void ExecuteXElementVariation(XNode toReplace, XNode newValue)
{
XElement xElem = new XElement("root", toReplace);
XElement xElemOriginal = new XElement(xElem);
using (UndoManager undo = new UndoManager(xElem))
{
undo.Group();
using (EventsHelper eHelper = new EventsHelper(xElem))
{
toReplace.ReplaceWith(newValue);
xElem.Verify();
eHelper.Verify(new XObjectChange[] { XObjectChange.Remove, XObjectChange.Add }, new XObject[] { toReplace, newValue });
}
undo.Undo();
Assert.True(xElem.Nodes().SequenceEqual(xElemOriginal.Nodes(), XNode.EqualityComparer), "Undo did not work!");
Assert.True(xElem.Attributes().EqualsAllAttributes(xElemOriginal.Attributes(), Helpers.MyAttributeComparer), "Undo did not work!");
}
}
示例6: ExecuteXElementVariation
public void ExecuteXElementVariation(XNode[] content, int index)
{
XElement xElem = new XElement("root", content);
XNode toRemove = xElem.Nodes().ElementAt(index);
XElement xElemOriginal = new XElement(xElem);
using (UndoManager undo = new UndoManager(xElem))
{
undo.Group();
using (EventsHelper elemHelper = new EventsHelper(xElem))
{
toRemove.Remove();
xElem.Verify();
elemHelper.Verify(XObjectChange.Remove, toRemove);
}
undo.Undo();
Assert.True(xElem.Nodes().SequenceEqual(xElemOriginal.Nodes(), XNode.EqualityComparer), "Undo did not work!");
Assert.True(xElem.Attributes().EqualsAllAttributes(xElemOriginal.Attributes(), Helpers.MyAttributeComparer), "Undo did not work!");
}
}
示例7: ExecuteXDocumentVariation
public void ExecuteXDocumentVariation(XNode[] toAdd, XNode contextNode)
{
IEnumerable<XNode> toAddList = toAdd.OfType<XNode>();
XDocument xDoc = new XDocument(contextNode);
XDocument xDocOriginal = new XDocument(xDoc);
using (UndoManager undo = new UndoManager(xDoc))
{
undo.Group();
using (EventsHelper docHelper = new EventsHelper(xDoc))
{
using (EventsHelper nodeHelper = new EventsHelper(contextNode))
{
contextNode.AddBeforeSelf(toAdd);
Assert.True(toAddList.SequenceEqual(contextNode.NodesBeforeSelf(), XNode.EqualityComparer), "Nodes not added correctly!");
nodeHelper.Verify(0);
}
docHelper.Verify(XObjectChange.Add, toAdd);
}
undo.Undo();
Assert.True(XNode.DeepEquals(xDoc, xDocOriginal), "Undo did not work!");
}
}
示例8: ExecuteXElementVariation
public void ExecuteXElementVariation(XNode[] toAdd, XNode contextNode)
{
IEnumerable<XNode> toAddList = toAdd.OfType<XNode>();
XElement xElem = new XElement("root", contextNode);
XElement xElemOriginal = new XElement(xElem);
using (UndoManager undo = new UndoManager(xElem))
{
undo.Group();
using (EventsHelper elemHelper = new EventsHelper(xElem))
{
using (EventsHelper nodeHelper = new EventsHelper(contextNode))
{
contextNode.AddBeforeSelf(toAdd);
Assert.True(toAddList.SequenceEqual(contextNode.NodesBeforeSelf(), XNode.EqualityComparer), "Nodes not added correctly!");
nodeHelper.Verify(0);
}
elemHelper.Verify(XObjectChange.Add, toAdd);
}
undo.Undo();
Assert.True(xElem.Nodes().SequenceEqual(xElemOriginal.Nodes(), XNode.EqualityComparer), "Undo did not work!");
Assert.True(xElem.Attributes().EqualsAllAttributes(xElemOriginal.Attributes(), Helpers.MyAttributeComparer), "Undo did not work!");
}
}
示例9: XCDataChangeValue
public void XCDataChangeValue()
{
XCData toChange = new XCData("Original Value");
String newValue = "New Value";
XElement xElem = new XElement("root", toChange);
XElement xElemOriginal = new XElement(xElem);
using (UndoManager undo = new UndoManager(xElem))
{
undo.Group();
using (EventsHelper eHelper = new EventsHelper(xElem))
{
using (EventsHelper dataHelper = new EventsHelper(toChange))
{
toChange.Value = newValue;
Assert.True(toChange.Value.Equals(newValue), "Value did not change");
xElem.Verify();
dataHelper.Verify(XObjectChange.Value, toChange);
}
eHelper.Verify(XObjectChange.Value, toChange);
}
undo.Undo();
Assert.True(XNode.DeepEquals(xElem, xElemOriginal), "Undo did not work!");
}
}
示例10: ExecuteXAttributeVariation
public void ExecuteXAttributeVariation(XAttribute[] content)
{
XElement xElem = new XElement("root", content);
XElement xElemOriginal = new XElement(xElem);
using (UndoManager undo = new UndoManager(xElem))
{
undo.Group();
using (EventsHelper eHelper = new EventsHelper(xElem))
{
xElem.ReplaceAttributes(new XAttribute("a", "aa"));
Assert.True(XObject.ReferenceEquals(xElem.FirstAttribute, xElem.LastAttribute), "Did not replace attributes correctly");
xElem.Verify();
eHelper.Verify(content.Length + 1);
}
undo.Undo();
Assert.True(xElem.Nodes().SequenceEqual(xElemOriginal.Nodes(), XNode.EqualityComparer), "Undo did not work!");
Assert.True(xElem.Attributes().EqualsAllAttributes(xElemOriginal.Attributes(), Helpers.MyAttributeComparer), "Undo did not work!");
}
}
示例11: XElementRemoveSeq
public void XElementRemoveSeq()
{
XDocument xDoc = new XDocument(InputSpace.GetElement(100, 10));
XDocument xDocOriginal = new XDocument(xDoc);
using (UndoManager undo = new UndoManager(xDoc))
{
undo.Group();
using (EventsHelper docHelper = new EventsHelper(xDoc))
{
using (EventsHelper eHelper = new EventsHelper(xDoc.Root))
{
List<XElement> list = xDoc.Root.Elements().ToList();
xDoc.Root.Elements().Remove();
eHelper.Verify(XObjectChange.Remove, list.ToArray());
docHelper.Verify(XObjectChange.Remove, list.ToArray());
}
}
undo.Undo();
Assert.True(XNode.DeepEquals(xDoc, xDocOriginal), "Undo did not work!");
}
}
示例12: XElementWorkTextNodes
public void XElementWorkTextNodes()
{
XElement elem = new XElement("A", "text2");
XElement xElemOriginal = new XElement(elem);
using (UndoManager undo = new UndoManager(elem))
{
undo.Group();
using (EventsHelper eHelper = new EventsHelper(elem))
{
XNode x = elem.LastNode;
eHelper.Verify(0);
}
undo.Undo();
Assert.True(XNode.DeepEquals(elem, xElemOriginal), "Undo did not work!");
}
}
示例13: XElementXElementAddAtDeepLevel
public void XElementXElementAddAtDeepLevel()
{
XDocument xDoc = new XDocument(InputSpace.GetElement(100, 10));
XDocument xDocOriginal = new XDocument(xDoc);
using (UndoManager undo = new UndoManager(xDoc))
{
undo.Group();
using (EventsHelper docHelper = new EventsHelper(xDoc))
{
using (EventsHelper eHelper = new EventsHelper(xDoc.Root))
{
foreach (XElement x in xDoc.Root.Descendants())
{
x.Add(new XText("Add Me"));
eHelper.Verify(XObjectChange.Add);
}
docHelper.Verify(XObjectChange.Add, xDoc.Root.Descendants().Count());
}
}
undo.Undo();
Assert.True(XNode.DeepEquals(xDoc, xDocOriginal), "Undo did not work!");
}
}
示例14: ExecuteXAttributeVariation
public void ExecuteXAttributeVariation(XAttribute[] toAdd, XAttribute contextNode)
{
IEnumerable<XAttribute> allNodes, toAddList = toAdd.OfType<XAttribute>();
XElement xElem = contextNode == null ? new XElement("root") : new XElement("root", contextNode);
XElement xElemOriginal = new XElement(xElem);
using (UndoManager undo = new UndoManager(xElem))
{
undo.Group();
using (EventsHelper elemHelper = new EventsHelper(xElem))
{
xElem.Add(toAdd);
allNodes = contextNode == null ? xElem.Attributes() : xElem.Attributes().Skip(1);
Assert.True(toAddList.SequenceEqual(allNodes, Helpers.MyAttributeComparer), "Attributes not added correctly!");
elemHelper.Verify(XObjectChange.Add, toAdd);
}
undo.Undo();
Assert.True(xElem.Nodes().SequenceEqual(xElemOriginal.Nodes(), XNode.EqualityComparer), "Undo did not work!");
Assert.True(xElem.Attributes().EqualsAllAttributes(xElemOriginal.Attributes(), Helpers.MyAttributeComparer), "Undo did not work!");
}
}
示例15: XElementWorkOnTextNodes2
public void XElementWorkOnTextNodes2()
{
XElement elem = new XElement("A", "text2");
using (UndoManager undo = new UndoManager(elem))
{
undo.Group();
using (EventsHelper eHelper = new EventsHelper(elem))
{
elem.AddFirst("text0", "text1");
Assert.Equal("text0text1text2", elem.Value);
eHelper.Verify(XObjectChange.Add);
}
undo.Undo();
Assert.Equal("text2", elem.Value);
}
}