开发者

How do you determine the actual size on screen?

开发者 https://www.devze.com 2023-03-09 01:12 出处:网络
In a wpf control with zoomfunctionality I calculate from the MouseWheelEventArgs how to scale the drawing canvas to implemen开发者_如何学JAVAt the zoom effect.

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

精彩评论

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