Browse Source

Added a TextBox and Image to animated controls.

Looks like in the TexbBox clipping rects aren't getting applied
correctly with rotation.
pull/16/head
Steven Kirk 12 years ago
parent
commit
60ad99c8c1
  1. 28
      TestApplication/Program.cs
  2. 2
      Windows/Perspex.Direct2D1/Renderer.cs

28
TestApplication/Program.cs

@ -465,7 +465,7 @@ namespace TestApplication
private static TabItem AnimationsTab() private static TabItem AnimationsTab()
{ {
Border border1; Border border1;
Rectangle rect2; Border border2;
RotateTransform rotate; RotateTransform rotate;
Button button1; Button button1;
@ -494,19 +494,27 @@ namespace TestApplication
VerticalAlignment = VerticalAlignment.Center, VerticalAlignment = VerticalAlignment.Center,
Background = Brushes.Crimson, Background = Brushes.Crimson,
RenderTransform = new RotateTransform(), RenderTransform = new RotateTransform(),
Content = new Border Content = new TextBox
{ {
Background = Brushes.Gainsboro, Background = Brushes.White,
Margin = new Thickness(25), Text = "Hello!",
} HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
},
}), }),
(rect2 = new Rectangle (border2 = new Border
{ {
Width = 100, Width = 100,
Height = 100, Height = 100,
HorizontalAlignment = HorizontalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center, VerticalAlignment = VerticalAlignment.Center,
Fill = Brushes.Coral, Background = Brushes.Coral,
Content = new Image
{
Source = new Bitmap("github_icon.png"),
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
},
RenderTransform = (rotate = new RotateTransform RenderTransform = (rotate = new RotateTransform
{ {
PropertyTransitions = new PropertyTransitions PropertyTransitions = new PropertyTransitions
@ -534,14 +542,14 @@ namespace TestApplication
button1.Click += (s, e) => button1.Click += (s, e) =>
{ {
if (rect2.Width == 100) if (border2.Width == 100)
{ {
rect2.Width = rect2.Height = 400; border2.Width = border2.Height = 400;
rotate.Angle = 180; rotate.Angle = 180;
} }
else else
{ {
rect2.Width = rect2.Height = 100; border2.Width = border2.Height = 100;
rotate.Angle = 0; rotate.Angle = 0;
} }
}; };

2
Windows/Perspex.Direct2D1/Renderer.cs

@ -134,7 +134,7 @@ namespace Perspex.Direct2D1
{ {
if (visual.IsVisible && visual.Opacity > 0) if (visual.IsVisible && visual.Opacity > 0)
{ {
// Translate an existing transform into this controls coordinate system. // Translate any existing transform into this controls coordinate system.
Matrix offset = Matrix.Translation(visual.Bounds.Position); Matrix offset = Matrix.Translation(visual.Bounds.Position);
transform = offset * transform * -offset; transform = offset * transform * -offset;

Loading…
Cancel
Save