From 354a5b5302f9045f608cd793e3d5d7f3ad998fe1 Mon Sep 17 00:00:00 2001 From: Peter Amrehn Date: Sat, 5 Oct 2019 12:05:10 +0200 Subject: [PATCH 1/3] Implement failing test: Test fails by exception This test should be extended later to check the correct output, but first step would be just not to crash. --- .../Tests/Designer/TransformTests.cs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 WpfDesign.Designer/Tests/Designer/TransformTests.cs diff --git a/WpfDesign.Designer/Tests/Designer/TransformTests.cs b/WpfDesign.Designer/Tests/Designer/TransformTests.cs new file mode 100644 index 0000000..48f562f --- /dev/null +++ b/WpfDesign.Designer/Tests/Designer/TransformTests.cs @@ -0,0 +1,28 @@ +using System.Windows; +using System.Windows.Media; +using ICSharpCode.WpfDesign.Designer; +using NUnit.Framework; + +namespace ICSharpCode.WpfDesign.Tests.Designer +{ + public class TransformTests : ModelTestHelper + { + internal static void Rotate(double angle, DesignItem item) + { + ModelTools.ApplyTransform(item, new RotateTransform(angle, 0.5, 0.5)); + } + + [Test] + public void RotateSkewedButton() + { + DesignItem button = CreateCanvasContext( + ""); + Rotate(30, button); + //AssertCanvasDesignerOutput(); + } + } +} \ No newline at end of file From 4bfc29b031858a52de40e59b495c20354489db8a Mon Sep 17 00:00:00 2001 From: Peter Amrehn Date: Sat, 5 Oct 2019 13:13:51 +0200 Subject: [PATCH 2/3] insertion after the last element is the same as AppendChild - but AppendChild works. --- WpfDesign.XamlDom/Project/XamlProperty.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WpfDesign.XamlDom/Project/XamlProperty.cs b/WpfDesign.XamlDom/Project/XamlProperty.cs index 5f228de..03c0ff3 100644 --- a/WpfDesign.XamlDom/Project/XamlProperty.cs +++ b/WpfDesign.XamlDom/Project/XamlProperty.cs @@ -510,7 +510,7 @@ internal void InsertNodeInCollection(XmlNode newChildNode, int index) collection.AppendChild(newChildNode); } else if (index == collectionElements.Count) { // insert after last element in collection - collection.InsertAfter(newChildNode, collectionElements[collectionElements.Count - 1].GetNodeForCollection()); + collection.AppendChild(newChildNode); } else { // insert before specified index collection.InsertBefore(newChildNode, collectionElements[index].GetNodeForCollection()); From 982500825d70d37a55ff866e486149e854b57210 Mon Sep 17 00:00:00 2001 From: Peter Amrehn Date: Sat, 5 Oct 2019 13:15:43 +0200 Subject: [PATCH 3/3] refactoring: merge cases with identical content --- WpfDesign.XamlDom/Project/XamlProperty.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/WpfDesign.XamlDom/Project/XamlProperty.cs b/WpfDesign.XamlDom/Project/XamlProperty.cs index 03c0ff3..d31f3aa 100644 --- a/WpfDesign.XamlDom/Project/XamlProperty.cs +++ b/WpfDesign.XamlDom/Project/XamlProperty.cs @@ -505,11 +505,9 @@ internal void InsertNodeInCollection(XmlNode newChildNode, int index) collection = parentObject.XmlElement; } } - if (collectionElements.Count == 0) { - // collection is empty -> we may insert anywhere - collection.AppendChild(newChildNode); - } else if (index == collectionElements.Count) { - // insert after last element in collection + if (collectionElements.Count == 0 || index == collectionElements.Count) { + // collection is empty -> we may insert anywhere, thus we choose the end + // or the index is the end of the list: collection.AppendChild(newChildNode); } else { // insert before specified index