从当前方向旋转Web浏览器正在拉伸(缩放)Web浏览器内容Windows Phone [英] Rotating webbrowser from current orientation is stretching(zooming) the webbrowser contents Windows phone

查看:67
本文介绍了从当前方向旋转Web浏览器正在拉伸(缩放)Web浏览器内容Windows Phone的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个处于纵向模式的Web浏览器.我正在使用

I have a webbrowser which is in portrait mode. I am loading the webbrowser using

this.webBrowserControl.Source = new Uri("http://google.com");

加载内容后,视图如下所示:

When the content is loaded the view looks like this

提供了旋转按钮,因此,如果用户处于纵向模式并且用户按了旋转按钮,那么我将使用transform旋转webview并设置其高度和宽度,以使其可以占据整个屏幕

there is rotate button provided, so if user is in portrait mode and user presses rotate button then I am rotating the webview using transform and setting its height and width so that it can occupy the whole screen

pageWidth = 480;
pageHeight = 800;
RotateTransform transform = new RotateTransform();
transform.Angle = 90;
this.webbrowser.RenderTransform = transform;
webbrowser.Width = pageHeight;
webbrowser.Height = pageWidth;

网络浏览器已旋转,但是内容看起来像是缩放或拉伸,它可以这个

The webbrowser is rotated but the contents looks like zoomed or stretched, it looks like this

任何想法如何不缩放内容?

Any idea how not to zoom the content??

推荐答案

更改缩放百分比:

// figure out the ratio you want to reduce by
string zoom_js = "document.body.style.zoom=\"50%\";";

try
{
    this.myBrowser.IsScriptEnabled = true;
    this.myBrowser.InvokeScript("eval", zoom_js);
}
catch(Exception ex)
{
}


它没有缩放任何东西.只是旋转它然后拉伸(调整大小)容器即可.


It is not zooming anything. It just that you are rotating it then stretching (resizing) the container.

鉴于分辨率,如果您不希望进行任何拉伸,则必须保持宽高比.

Given your resolution, you have to have keep the aspect ratio if you don't want any stretching to be done.

<phone:WebBrowser x:Name="myBrowser" RenderTransformOrigin="0.5,0.5" Height="480" Width="480" Margin="0" Padding="0">
        <phone:WebBrowser.RenderTransform>
            <CompositeTransform Rotation="90"/>
        </phone:WebBrowser.RenderTransform>
    </phone:WebBrowser>
</Border>

现在不会拉伸,但也不会覆盖整个屏幕.现在,想象一下像您一样拉伸容器.结果将是您发布的图像.

Now that won't be stretched but it also not cover the entire screen. Now, imagine stretching the container like you did. The result will be your image you posted.

这篇关于从当前方向旋转Web浏览器正在拉伸(缩放)Web浏览器内容Windows Phone的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆