I have several items, i want to calculate a minimum rectangle in which they can be fit, but items are rotated to some degree, or skewed or both. So how do i get the least rectangle which can contain all ?
5
votes
3 Answers
1
votes
1
votes
Here is an link to an implementation of a Dynamic Canvas. This control automatically sizes itself to fit its contents, so the answer to your problem can be found in this code. Look at the MeasureOverride function.
0
votes
Do a foreach on the list of items you want. In each iteration of the loop, get the item's Canvas position (upper left) and add ActualWidth/ActualHeight to get lower right point. Take the upper left and lower right points and call Transform.Transform to get the ACTUAL upper left and lower right points.
Keep track of min and max upper left and lower right to get your bounding box.