当前位置: 首页>>代码示例>>C#>>正文


C# UndoManager.Undo方法代码示例

本文整理汇总了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!");
     }
 }
开发者ID:ChuangYang,项目名称:corefx,代码行数:16,代码来源:EventsReplace.cs

示例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");
     }
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:17,代码来源:EventsName.cs

示例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!");
     }
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:17,代码来源:EventsRemove.cs

示例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");
     }
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:17,代码来源:EventsName.cs

示例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!");
     }
 }
开发者ID:ChuangYang,项目名称:corefx,代码行数:18,代码来源:EventsReplace.cs

示例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!");
     }
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:19,代码来源:EventsRemove.cs

示例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!");
     }
 }
开发者ID:ESgarbi,项目名称:corefx,代码行数:22,代码来源:EventsAdd.cs

示例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!");
     }
 }
开发者ID:ESgarbi,项目名称:corefx,代码行数:23,代码来源:EventsAdd.cs

示例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!");
     }
 }
开发者ID:ESgarbi,项目名称:corefx,代码行数:24,代码来源:EventsValue.cs

示例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!");
     }
 }
开发者ID:ChuangYang,项目名称:corefx,代码行数:19,代码来源:EventsReplace.cs

示例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!");
     }
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:21,代码来源:EventsRemove.cs

示例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!");
     }
 }
开发者ID:ESgarbi,项目名称:corefx,代码行数:16,代码来源:EventsAdd.cs

示例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!");
     }
 }
开发者ID:ESgarbi,项目名称:corefx,代码行数:23,代码来源:EventsAdd.cs

示例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!");
     }
 }
开发者ID:ESgarbi,项目名称:corefx,代码行数:20,代码来源:EventsAdd.cs

示例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);
     }
 }
开发者ID:ESgarbi,项目名称:corefx,代码行数:16,代码来源:EventsAdd.cs


注:本文中的UndoManager.Undo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。