开发者

How do you determine the actual size on screen?

In a wpf control with zoom functionality I calculate from the MouseWheelEventArgs how to scale the drawing canvas to implemen开发者_如何学JAVAt the zoom effect.

Point mouse = e.GetPosition(myCanvas);
Matrix m = myCanvas.RenderTransform.Value;

if (e.Delta > 0)
{
    f = 1.1;
}
else
{
    f = 1.0 / 1.1;
}

m.ScaleAtPrepend(f, f, mouse.X, mouse.Y);
myCanvas.RenderTransform = new MatrixTransform(m);

I would like to know the actual size of one of the circles on the canvas. However Width, ActualWidth and such stay the same while zooming in and out (16.0). How would you determine (calculate?) the size of the circle that a user actually sees on his or her screen?


MatrixTransform has a method TransformBounds for this. You feed it with original bounding box of the image (I think in your case 0,0,width,height will do) and it will return you its resulting bounding box.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜