Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix exception when rotating skewed item. #63

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions WpfDesign.Designer/Tests/Designer/TransformTests.cs
Original file line number Diff line number Diff line change
@@ -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(
"<Button Content='Button' Width='75' Height='23' RenderTransformOrigin='0.5,0.5'>"
+ "<Button.RenderTransform>"
+ "<SkewTransform AngleY='-45' />"
+ "</Button.RenderTransform>"
+ "</Button>");
Rotate(30, button);
//AssertCanvasDesignerOutput();
}
}
}
8 changes: 3 additions & 5 deletions WpfDesign.XamlDom/Project/XamlProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -505,12 +505,10 @@ internal void InsertNodeInCollection(XmlNode newChildNode, int index)
collection = parentObject.XmlElement;
}
}
if (collectionElements.Count == 0) {
// collection is empty -> we may insert anywhere
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 if (index == collectionElements.Count) {
// insert after last element in collection
collection.InsertAfter(newChildNode, collectionElements[collectionElements.Count - 1].GetNodeForCollection());
} else {
// insert before specified index
collection.InsertBefore(newChildNode, collectionElements[index].GetNodeForCollection());
Expand Down