I have a polygon, I rotate it 90 degrees, it shows up fine on the GUI, however the ActualHeight and ActualWidth are still the same as before. I have tried RenderTransform and LayoutTransform, but neither makes a difference.
How can I make it so the polygon's height and width get updated after the transform?
The following is in the constructor under InitializeComponent();
-------------------------------------------------
Polygon _currShape = new Polygon();
_currShape.Fill = System.Windows.Media.Brushes.Blue;
System.Windows.Media.PointCollection pointCollection = new System.Windows.Media.PointCollection();
pointCollection.Add(new Point(23, 0));
pointCollection.Add(new Point(115, 0));
pointCollection.Add(new Point(115, 23));
pointCollection.Add(new Point(23, 23));
_currShape.Points = pointCollection;
TetrisCanvas.Children.Add(_currShape);
Canvas.SetLeft(_currShape, 100);
Canvas.SetTop(_currShape, 100);
RotateTransform rt = new RotateTransform(90);
_currShape.RenderTransform = rt;
Loading
Jaganathan BantheswaranPosted Jul 12, 2011, 5:58 AM
Anyway, if you need to get the height and width of the rotated polygon with 90' then you can take the updated height as width and updated width as height.
like,
double updatedHeight =_currShape.Width;
double updatedWidth = _currShape.Height;
Dea SaddlerPosted Jul 12, 2011, 6:25 AM
You can take help from The below blog.
http://www.vbdotnetheaven.com/Blogs/5395/how-to-rotate-a-ployline-in-wpf.aspx
Which contains rotation of polyline, so you can also rotate polygon with this method.
Jaganathan BantheswaranPosted Jul 12, 2011, 6:19 AM
David KayPosted Jul 12, 2011, 6:03 AM
David KayPosted Jul 12, 2011, 5:49 AM
Jaganathan BantheswaranPosted Jul 12, 2011, 5:45 AM
You are changing the angle of the polygon right. then how will the height and width change.? i cant get you...
David KayPosted Jul 12, 2011, 2:30 AM
Sam HobbsPosted Jul 11, 2011, 8:50 PM
Jaganathan BantheswaranPosted Jul 11, 2011, 6:53 AM
Can you post the bit of code..